Restore 34 line breaks in 24 DE-SN law texts (<br> -> newline, joined words from the 2026-10-15 HTML cleanup); laws.parquet only, all other rows byte-identical; articles unchanged
Browse files- README.md +8 -1
- data/laws.parquet +2 -2
- manifests/fix_sn_lawtext_br_REPORT.json +38 -0
- manifests/fix_sn_lawtext_br_SHA256SUMS +28 -0
- manifests/fix_sn_lawtext_br_code.json +24 -0
- manifests/fix_sn_lawtext_br_ids.jsonl +24 -0
- scrapers/README.md +3 -0
- scrapers/code.json +5 -3
- scrapers/fix_lawtext_br.py +208 -0
- scrapers/pack_de.py +1 -1
- scrapers/tests/test_fix_lawtext_br.py +55 -0
README.md
CHANGED
|
@@ -37,7 +37,7 @@ Bremen (DE-HB) was collected but is **held back** pending a licence review (see
|
|
| 37 |
|
| 38 |
| Field | Value |
|
| 39 |
| --- | --- |
|
| 40 |
-
| Snapshot date | 2026-09-05 (federal); Landesrecht 2026-10-02; DE-SN densify 2026-10-15; DE-SN heading/HTML fix 2026-10-15; contents/titles fix 2026-10-15 |
|
| 41 |
| Coverage | full Bundesrecht via gesetze-im-internet.de TOC |
|
| 42 |
| Source | Bundesministerium der Justiz / gesetze-im-internet.de |
|
| 43 |
| Collector | `scrapers/collect_gii.py` |
|
|
@@ -60,6 +60,7 @@ Bremen (DE-HB) was collected but is **held back** pending a licence review (see
|
|
| 60 |
- `manifests/densify_sn_*` — per-batch record of the DE-SN densify: build report, code record (sha256 per scraper file), card section, pack SHA256SUMS.
|
| 61 |
- `manifests/fix_sn_headings_ids.jsonl` — every DE-SN law/article id changed by the 2026-10-15 heading/HTML fix, with the action taken; `manifests/fix_sn_headings_REPORT.json` — invariants and gate results.
|
| 62 |
- `manifests/fix_contents_titles_ids.jsonl` — every article row dropped and every title restored by the 2026-10-15 contents/titles fix, plus each law whose article_count changed; `manifests/fix_contents_titles_REPORT.json` — invariants and gate results.
|
|
|
|
| 63 |
- `MANIFEST.md`, `PACK_META.json` — records of the 2026-10-02 Landesrecht append (not updated for later densify batches).
|
| 64 |
|
| 65 |
## License / reuse
|
|
@@ -208,3 +209,9 @@ DE-SN totals after the heading fix: 2,600 laws / 33,551 articles.
|
|
| 208 |
- `article_count` recomputed for 967 laws (no other law field changed). No heading-only rows were folded in this fix; ids are not renumbered. Every dropped and retitled id is listed in `manifests/fix_contents_titles_ids.jsonl`.
|
| 209 |
|
| 210 |
Totals after the contents/titles fix: 10,953 laws / 209,481 articles.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
| Field | Value |
|
| 39 |
| --- | --- |
|
| 40 |
+
| Snapshot date | 2026-09-05 (federal); Landesrecht 2026-10-02; DE-SN densify 2026-10-15; DE-SN heading/HTML fix 2026-10-15; contents/titles fix 2026-10-15; SN law-text line breaks 2026-10-15 |
|
| 41 |
| Coverage | full Bundesrecht via gesetze-im-internet.de TOC |
|
| 42 |
| Source | Bundesministerium der Justiz / gesetze-im-internet.de |
|
| 43 |
| Collector | `scrapers/collect_gii.py` |
|
|
|
|
| 60 |
- `manifests/densify_sn_*` — per-batch record of the DE-SN densify: build report, code record (sha256 per scraper file), card section, pack SHA256SUMS.
|
| 61 |
- `manifests/fix_sn_headings_ids.jsonl` — every DE-SN law/article id changed by the 2026-10-15 heading/HTML fix, with the action taken; `manifests/fix_sn_headings_REPORT.json` — invariants and gate results.
|
| 62 |
- `manifests/fix_contents_titles_ids.jsonl` — every article row dropped and every title restored by the 2026-10-15 contents/titles fix, plus each law whose article_count changed; `manifests/fix_contents_titles_REPORT.json` — invariants and gate results.
|
| 63 |
+
- `manifests/fix_sn_lawtext_br_ids.jsonl` — the DE-SN law texts whose line breaks were restored on 2026-10-15, with offsets and before/after snippets; `manifests/fix_sn_lawtext_br_REPORT.json` — invariants and gate results.
|
| 64 |
- `MANIFEST.md`, `PACK_META.json` — records of the 2026-10-02 Landesrecht append (not updated for later densify batches).
|
| 65 |
|
| 66 |
## License / reuse
|
|
|
|
| 209 |
- `article_count` recomputed for 967 laws (no other law field changed). No heading-only rows were folded in this fix; ids are not renumbered. Every dropped and retitled id is listed in `manifests/fix_contents_titles_ids.jsonl`.
|
| 210 |
|
| 211 |
Totals after the contents/titles fix: 10,953 laws / 209,481 articles.
|
| 212 |
+
|
| 213 |
+
## DE-SN law-text line breaks — 2026-10-15 (in place, `laws.text` of DE-SN rows only)
|
| 214 |
+
|
| 215 |
+
- In 24 DE-SN law texts the 2026-10-15 heading/HTML fix had removed 34 line breaks (`<br>`) that sat directly between two words, joining them (e.g. `elektronischenInformations-`). Each is a line break again, at the exact position taken from the raw text before that fix; offsets and before/after snippets are in `manifests/fix_sn_lawtext_br_ids.jsonl`.
|
| 216 |
+
- No other field or row changed; law and article counts are unchanged.
|
| 217 |
+
- Note: the bundled `scrapers/de_lib.py` still has default `HUB_TIP` f9384361 (an earlier tip). Set `DE_HUB_TIP` to the current tip before building a new pack, as the scrapers README says.
|
data/laws.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f7e428a2a2d853935cf4e8bb1f6ae6d91ae212ea4e157d2a53d4b670ed4cca69
|
| 3 |
+
size 69196884
|
manifests/fix_sn_lawtext_br_REPORT.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"repo": "endomorphosis/ipfs_germany_laws",
|
| 3 |
+
"parent": "PENDING_LIVE_COMMIT_OF_fix_contents_titles",
|
| 4 |
+
"base_sha256": {
|
| 5 |
+
"laws": "b7a5ef06b9def91ebed135b92e361bdfbb58b15b274d4c14ec6b7d3aec951fc2",
|
| 6 |
+
"articles": "ca5e29490f1a2c335767df6125281a991903a55fbe909cefeb010c0a168bc82d"
|
| 7 |
+
},
|
| 8 |
+
"prev_laws_sha256": "3a2953d41a534521ea1932907cc88b53a041b23fa820f0548f6a21571859cf8c",
|
| 9 |
+
"laws_changed": 24,
|
| 10 |
+
"spots": 34,
|
| 11 |
+
"invariants": {
|
| 12 |
+
"law_ids_and_order_identical": true,
|
| 13 |
+
"untouched_laws_identical": true,
|
| 14 |
+
"law_fields_changed": [
|
| 15 |
+
"text"
|
| 16 |
+
],
|
| 17 |
+
"only_text_changed": true,
|
| 18 |
+
"changed_text_only_adds_newlines": true,
|
| 19 |
+
"ok": true
|
| 20 |
+
},
|
| 21 |
+
"gate": {
|
| 22 |
+
"contents_rows": 0,
|
| 23 |
+
"contents_row_ids": [],
|
| 24 |
+
"raw_html_article_rows": 0,
|
| 25 |
+
"raw_html_law_rows": 0,
|
| 26 |
+
"raw_html_ids": [],
|
| 27 |
+
"card_matches_data": true,
|
| 28 |
+
"card_vs_data_diff": {},
|
| 29 |
+
"heading_only_rows": 0,
|
| 30 |
+
"heading_only_allowed": 0,
|
| 31 |
+
"heading_only_ok": true,
|
| 32 |
+
"ok": true,
|
| 33 |
+
"sentinel_left": 0,
|
| 34 |
+
"raw_html_all_rows": 0,
|
| 35 |
+
"scope": "DE-SN rows + whole-dataset raw HTML + README counts"
|
| 36 |
+
},
|
| 37 |
+
"built_at": "2026-10-15T23:17:23-0700"
|
| 38 |
+
}
|
manifests/fix_sn_lawtext_br_SHA256SUMS
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
a50b87f6050b1467eca838774678b3518dd63bb63e1fb80a7227e1eee6068bd6 README.md
|
| 2 |
+
ca5e29490f1a2c335767df6125281a991903a55fbe909cefeb010c0a168bc82d data/articles.parquet
|
| 3 |
+
f7e428a2a2d853935cf4e8bb1f6ae6d91ae212ea4e157d2a53d4b670ed4cca69 data/laws.parquet
|
| 4 |
+
801f5aed9f738f7498571b4af3e8bcbb48107e94bcacb9947e3619a965ac0c28 manifests/fix_sn_lawtext_br_REPORT.json
|
| 5 |
+
9a0dc83c769ce4ca46a4272801d3e0ae8c202c8aac179bab55e284a93c45ddd7 manifests/fix_sn_lawtext_br_ids.jsonl
|
| 6 |
+
792bd097762ac6419bda46b832c8aa7846168c42732e7a45191666fd629eb7c3 scrapers/README.md
|
| 7 |
+
bd8be9170918d81981a1f6b7733a8517764a2b46adc2841aba7d62759750b1f6 scrapers/code.json
|
| 8 |
+
6d3295170bf67bf187bbf361e9e5c9a77fbe5d2fb5c7149bd4b9966e7e479faf scrapers/collect_de_laender.py
|
| 9 |
+
410a63b8b89f9cd870711ba76b3bf814e1a3e6d94236939344ef508a17610c90 scrapers/de_lib.py
|
| 10 |
+
4587e8d9e0b7ce55dffef23d874dae7a03b1093fdead26fd8313d5597c86a31f scrapers/de_queue.example.txt
|
| 11 |
+
026850a3461008942beb7f5299b3ee58daecf4e7e7e005dcf8baa4e47666a79d scrapers/de_waiter.sh
|
| 12 |
+
09a00eec60380b50e94ef57ec069add4835104bc34082c3981482054af1d12ad scrapers/finalize_gate.py
|
| 13 |
+
315a8fe0768c6d33bb8d3b388508461187959cef48bd4f5aa3630104e95b2f8b scrapers/fix_contents_titles.py
|
| 14 |
+
2dcc695bebf6ea306c045b13e483097353be8f402e90a8fd3984fa21b3260d1c scrapers/fix_lawtext_br.py
|
| 15 |
+
048fdd4e5f999ebb49db7491fe9f98c2792a5236cf57f5c7798c260ee927b117 scrapers/fix_sn.py
|
| 16 |
+
fbfbe563bf0b7ceebb8478f8600654dd0f9014c0f3f1a6d467a16230b24a883d scrapers/gate_profile.sh
|
| 17 |
+
a386a7b235b3bf4f1eb0e3df86ef73ef9e3c8688ff7182015df9d730cee79b99 scrapers/pack_de.py
|
| 18 |
+
7420dd98db2604b7f2ef9ccbf8679d5aceb9bdd8f769bfca587ae19e15e5be00 scrapers/requirements.txt
|
| 19 |
+
87915efb8db8d5863f7a2d209b27ae4c64bfde7126dd5bf388242b5ed8c3c96b scrapers/resume_loop_de.sh
|
| 20 |
+
1c9f28bcf6851eaff85180c90bdf8054a3500edca773c5c5a84701e6053f0990 scrapers/robots_guard.py
|
| 21 |
+
9b7e5d48f8803a9e6f83e630f03e7110b96f5ea8971adaec771b4c7db50d9798 scrapers/run_de_short.sh
|
| 22 |
+
129c7f34bcacb6ba9bfdd856c68d9b5e33e547107689bde17afa9f61de9e8e09 scrapers/short_turn.sh
|
| 23 |
+
788bd4924861d35f5317b48682712d582190bcfcff3fe9410033b9f8ef5b7418 scrapers/tests/test_de_laender.py
|
| 24 |
+
9aec8bddfd4f9f65250e3def710f63097e9e5a2e85fcb4ca1304d0f2e10f8401 scrapers/tests/test_finalize_gate.py
|
| 25 |
+
9811842a3c165c0671d8e150359bba808931088fdf880b43b93adb6b25fb67f6 scrapers/tests/test_fix_contents_titles.py
|
| 26 |
+
994e6a99b74f47d3dc283977cc7021a37c6ff0153da61623d61dd9a96d0817ea scrapers/tests/test_fix_lawtext_br.py
|
| 27 |
+
6870695e1c3c224c82b1110bb36bcdb0f52be134b98da726456b5e2b483a5264 scrapers/tests/test_fix_sn.py
|
| 28 |
+
6f6681d63f90858cf01924133e07a26d9c56e1f783b7ed35017e513ceb5ce7b7 scrapers/tests/test_short_turn.py
|
manifests/fix_sn_lawtext_br_code.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"de_lib.py": "410a63b8b89f9cd870711ba76b3bf814e1a3e6d94236939344ef508a17610c90",
|
| 3 |
+
"collect_de_laender.py": "6d3295170bf67bf187bbf361e9e5c9a77fbe5d2fb5c7149bd4b9966e7e479faf",
|
| 4 |
+
"pack_de.py": "a386a7b235b3bf4f1eb0e3df86ef73ef9e3c8688ff7182015df9d730cee79b99",
|
| 5 |
+
"robots_guard.py": "1c9f28bcf6851eaff85180c90bdf8054a3500edca773c5c5a84701e6053f0990",
|
| 6 |
+
"run_de_short.sh": "9b7e5d48f8803a9e6f83e630f03e7110b96f5ea8971adaec771b4c7db50d9798",
|
| 7 |
+
"resume_loop_de.sh": "87915efb8db8d5863f7a2d209b27ae4c64bfde7126dd5bf388242b5ed8c3c96b",
|
| 8 |
+
"de_waiter.sh": "026850a3461008942beb7f5299b3ee58daecf4e7e7e005dcf8baa4e47666a79d",
|
| 9 |
+
"gate_profile.sh": "fbfbe563bf0b7ceebb8478f8600654dd0f9014c0f3f1a6d467a16230b24a883d",
|
| 10 |
+
"de_queue.example.txt": "4587e8d9e0b7ce55dffef23d874dae7a03b1093fdead26fd8313d5597c86a31f",
|
| 11 |
+
"requirements.txt": "7420dd98db2604b7f2ef9ccbf8679d5aceb9bdd8f769bfca587ae19e15e5be00",
|
| 12 |
+
"README.md": "792bd097762ac6419bda46b832c8aa7846168c42732e7a45191666fd629eb7c3",
|
| 13 |
+
"tests/test_de_laender.py": "788bd4924861d35f5317b48682712d582190bcfcff3fe9410033b9f8ef5b7418",
|
| 14 |
+
"short_turn.sh": "129c7f34bcacb6ba9bfdd856c68d9b5e33e547107689bde17afa9f61de9e8e09",
|
| 15 |
+
"tests/test_short_turn.py": "6f6681d63f90858cf01924133e07a26d9c56e1f783b7ed35017e513ceb5ce7b7",
|
| 16 |
+
"finalize_gate.py": "09a00eec60380b50e94ef57ec069add4835104bc34082c3981482054af1d12ad",
|
| 17 |
+
"tests/test_finalize_gate.py": "9aec8bddfd4f9f65250e3def710f63097e9e5a2e85fcb4ca1304d0f2e10f8401",
|
| 18 |
+
"fix_sn.py": "048fdd4e5f999ebb49db7491fe9f98c2792a5236cf57f5c7798c260ee927b117",
|
| 19 |
+
"tests/test_fix_sn.py": "6870695e1c3c224c82b1110bb36bcdb0f52be134b98da726456b5e2b483a5264",
|
| 20 |
+
"fix_contents_titles.py": "315a8fe0768c6d33bb8d3b388508461187959cef48bd4f5aa3630104e95b2f8b",
|
| 21 |
+
"tests/test_fix_contents_titles.py": "9811842a3c165c0671d8e150359bba808931088fdf880b43b93adb6b25fb67f6",
|
| 22 |
+
"fix_lawtext_br.py": "2dcc695bebf6ea306c045b13e483097353be8f402e90a8fd3984fa21b3260d1c",
|
| 23 |
+
"tests/test_fix_lawtext_br.py": "994e6a99b74f47d3dc283977cc7021a37c6ff0153da61623d61dd9a96d0817ea"
|
| 24 |
+
}
|
manifests/fix_sn_lawtext_br_ids.jsonl
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"table": "laws", "id": "de-sn-11436", "action": "lawtext_br_restored", "field": "text", "offsets": [37562], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 37562, "before_offset": 37562, "before": " Bestimmung des elektronischenInformations- und Kommunikatio", "after": " Bestimmung des elektronischen\nInformations- und Kommunikatio"}]}
|
| 2 |
+
{"table": "laws", "id": "de-sn-14024", "action": "lawtext_br_restored", "field": "text", "offsets": [36485], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 36485, "before_offset": 36485, "before": " Fassung.\n\n§ 9 Zuständigkeitendes Staatsbetriebes für Mess- ", "after": " Fassung.\n\n§ 9 Zuständigkeiten\ndes Staatsbetriebes für Mess- "}]}
|
| 3 |
+
{"table": "laws", "id": "de-sn-3264", "action": "lawtext_br_restored", "field": "text", "offsets": [38943], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 38943, "before_offset": 38943, "before": "32a Durchführung von Sitzungenohne persönliche Anwesenheit i", "after": "32a Durchführung von Sitzungen\nohne persönliche Anwesenheit i"}]}
|
| 4 |
+
{"table": "laws", "id": "de-sn-9184", "action": "lawtext_br_restored", "field": "text", "offsets": [34200, 49207], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 34200, "before_offset": 34200, "before": "d 2 entsprechend.\n\nAbschnitt 2Geschäftsführung\n\n§ 33 Vorstan", "after": "d 2 entsprechend.\n\nAbschnitt 2\nGeschäftsführung\n\n§ 33 Vorstan"}, {"offset": 49207, "before_offset": 49206, "before": "ben und annehmen.\n\nAbschnitt 3Rechtsstellung\n\n§ 46 Freistell", "after": "ben und annehmen.\n\nAbschnitt 3\nRechtsstellung\n\n§ 46 Freistell"}]}
|
| 5 |
+
{"table": "laws", "id": "de-sn-18419", "action": "lawtext_br_restored", "field": "text", "offsets": [7276], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 7276, "before_offset": 7276, "before": "er Landesdirektion Sachsen unddes Sächsischen Oberbergamts\n(", "after": "er Landesdirektion Sachsen und\ndes Sächsischen Oberbergamts\n("}]}
|
| 6 |
+
{"table": "laws", "id": "de-sn-18734", "action": "lawtext_br_restored", "field": "text", "offsets": [32466], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 32466, "before_offset": 32466, "before": "zende Vorschriften zur Auswahlim Auswahlverfahren der Hochsc", "after": "zende Vorschriften zur Auswahl\nim Auswahlverfahren der Hochsc"}]}
|
| 7 |
+
{"table": "laws", "id": "de-sn-18758", "action": "lawtext_br_restored", "field": "text", "offsets": [12762], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 12762, "before_offset": 12762, "before": "\n§ 14 Entschädigung von Zeugenund Vergütung von Sachverständ", "after": "\n§ 14 Entschädigung von Zeugen\nund Vergütung von Sachverständ"}]}
|
| 8 |
+
{"table": "laws", "id": "de-sn-18947", "action": "lawtext_br_restored", "field": "text", "offsets": [531], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 531, "before_offset": 531, "before": "ale Zuweisungen zum Ersatz vonGewerbesteuermindereinnahmen d", "after": "ale Zuweisungen zum Ersatz von\nGewerbesteuermindereinnahmen d"}]}
|
| 9 |
+
{"table": "laws", "id": "de-sn-18987", "action": "lawtext_br_restored", "field": "text", "offsets": [13648], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 13648, "before_offset": 13648, "before": "uslagenersatz für Inhaberinnenund Inhaber von Abstimmungsämt", "after": "uslagenersatz für Inhaberinnen\nund Inhaber von Abstimmungsämt"}]}
|
| 10 |
+
{"table": "laws", "id": "de-sn-19346", "action": "lawtext_br_restored", "field": "text", "offsets": [13213], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 13213, "before_offset": 13213, "before": "\n§ 9 Zulassungsvoraussetzungenfür die Abschluss- und Umschul", "after": "\n§ 9 Zulassungsvoraussetzungen\nfür die Abschluss- und Umschul"}]}
|
| 11 |
+
{"table": "laws", "id": "de-sn-19338", "action": "lawtext_br_restored", "field": "text", "offsets": [39888], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 39888, "before_offset": 39888, "before": "nis der schriftlichen Prüfung;Zulassung zur mündlichen Prüfu", "after": "nis der schriftlichen Prüfung;\nZulassung zur mündlichen Prüfu"}]}
|
| 12 |
+
{"table": "laws", "id": "de-sn-19454", "action": "lawtext_br_restored", "field": "text", "offsets": [8399, 24521], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 8399, "before_offset": 8399, "before": "ennung von Betreuungsangebotenund kombinierten Angeboten zur", "after": "ennung von Betreuungsangeboten\nund kombinierten Angeboten zur"}, {"offset": 24521, "before_offset": 24520, "before": "usammenarbeit der Pflegekassenund des Kommunalen Sozialverba", "after": "usammenarbeit der Pflegekassen\nund des Kommunalen Sozialverba"}]}
|
| 13 |
+
{"table": "laws", "id": "de-sn-19746", "action": "lawtext_br_restored", "field": "text", "offsets": [48900], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 48900, "before_offset": 48900, "before": "chen Befähigungsnachweisen undBerufsqualifikationen\n(1) Für ", "after": "chen Befähigungsnachweisen und\nBerufsqualifikationen\n(1) Für "}]}
|
| 14 |
+
{"table": "laws", "id": "de-sn-19947", "action": "lawtext_br_restored", "field": "text", "offsets": [658, 27133, 43347, 57371], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 658, "before_offset": 658, "before": "leiterin oder Landeswahlleitersowie Kreiswahlleiterinnen und", "after": "leiterin oder Landeswahlleiter\nsowie Kreiswahlleiterinnen und"}, {"offset": 27133, "before_offset": 27132, "before": "aussetzungen und Zuständigkeitfür die Erteilung von Wahlsche", "after": "aussetzungen und Zuständigkeit\nfür die Erteilung von Wahlsche"}, {"offset": 43347, "before_offset": 43345, "before": "ach § 20 Absatz 2 Satz 2 und 3des Sächsischen Wahlgesetzes\n(", "after": "ach § 20 Absatz 2 Satz 2 und 3\ndes Sächsischen Wahlgesetzes\n("}, {"offset": 57371, "before_offset": 57368, "before": "36 Vorprüfung der Landeslistendurch die Landeswahlleiterin o", "after": "36 Vorprüfung der Landeslisten\ndurch die Landeswahlleiterin o"}]}
|
| 15 |
+
{"table": "laws", "id": "de-sn-19986", "action": "lawtext_br_restored", "field": "text", "offsets": [147342], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 147342, "before_offset": 147342, "before": " und Ernennungsvoraussetzungenfür Juniorprofessorinnen und J", "after": " und Ernennungsvoraussetzungen\nfür Juniorprofessorinnen und J"}]}
|
| 16 |
+
{"table": "laws", "id": "de-sn-20186", "action": "lawtext_br_restored", "field": "text", "offsets": [57172], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 57172, "before_offset": 57172, "before": " Bestehen der Abschlussprüfungund Wiederholung der Schulfrem", "after": " Bestehen der Abschlussprüfung\nund Wiederholung der Schulfrem"}]}
|
| 17 |
+
{"table": "laws", "id": "de-sn-5209", "action": "lawtext_br_restored", "field": "text", "offsets": [61160], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 61160, "before_offset": 61160, "before": "ge zu verrechnen.\n\nAbschnitt 4Vorschriften für den Bereich d", "after": "ge zu verrechnen.\n\nAbschnitt 4\nVorschriften für den Bereich d"}]}
|
| 18 |
+
{"table": "laws", "id": "de-sn-20766", "action": "lawtext_br_restored", "field": "text", "offsets": [10829, 10866, 22216], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 10829, "before_offset": 10829, "before": "nforderungen an Einrichtungen,ambulant betreute Wohngemeinsc", "after": "nforderungen an Einrichtungen,\nambulant betreute Wohngemeinsc"}, {"offset": 10866, "before_offset": 10865, "before": "nt betreute Wohngemeinschaftenund Intensivpflege-Wohngemeins", "after": "nt betreute Wohngemeinschaften\nund Intensivpflege-Wohngemeins"}, {"offset": 22216, "before_offset": 22214, "before": "eld- oder geldwerte Leistungenan Träger, Leistungsanbieter, ", "after": "eld- oder geldwerte Leistungen\nan Träger, Leistungsanbieter, "}]}
|
| 19 |
+
{"table": "laws", "id": "de-sn-20787", "action": "lawtext_br_restored", "field": "text", "offsets": [69566, 73556], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 69566, "before_offset": 69566, "before": "schnitt 3 Disziplinarverfahrenvor dem Sächsischen Oberverwal", "after": "schnitt 3 Disziplinarverfahren\nvor dem Sächsischen Oberverwal"}, {"offset": 73556, "before_offset": 73555, "before": "sgerichtsordnung.\n\nAbschnitt 5Wiederaufnahme des gerichtlich", "after": "sgerichtsordnung.\n\nAbschnitt 5\nWiederaufnahme des gerichtlich"}]}
|
| 20 |
+
{"table": "laws", "id": "de-sn-3834", "action": "lawtext_br_restored", "field": "text", "offsets": [21648], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 21648, "before_offset": 21648, "before": "slagen anordnen.\n\nDritter TeilBesondere Verfahrensvorschrift", "after": "slagen anordnen.\n\nDritter Teil\nBesondere Verfahrensvorschrift"}]}
|
| 21 |
+
{"table": "laws", "id": "de-sn-21127", "action": "lawtext_br_restored", "field": "text", "offsets": [35083], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 35083, "before_offset": 35083, "before": "nitt 3 Besondere Anforderungenan anbieterverantwortete ambul", "after": "nitt 3 Besondere Anforderungen\nan anbieterverantwortete ambul"}]}
|
| 22 |
+
{"table": "laws", "id": "de-sn-11659", "action": "lawtext_br_restored", "field": "text", "offsets": [1043, 5824, 28190], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 1043, "before_offset": 1043, "before": "nitt 1 Gemeinsame Vorschriftenüber Vorbereitung und Durchfüh", "after": "nitt 1 Gemeinsame Vorschriften\nüber Vorbereitung und Durchfüh"}, {"offset": 5824, "before_offset": 5823, "before": "lenden Personalratsmitglieder,Verteilung der Sitze auf die G", "after": "lenden Personalratsmitglieder,\nVerteilung der Sitze auf die G"}, {"offset": 28190, "before_offset": 28188, "before": "ewählten Gruppenvertreterinnenund Gruppenvertreter bei Grupp", "after": "ewählten Gruppenvertreterinnen\nund Gruppenvertreter bei Grupp"}]}
|
| 23 |
+
{"table": "laws", "id": "de-sn-14136", "action": "lawtext_br_restored", "field": "text", "offsets": [6106], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 6106, "before_offset": 6106, "before": "en zugunsten schwerbehinderterund diesen gleichgestellter Me", "after": "en zugunsten schwerbehinderter\nund diesen gleichgestellter Me"}]}
|
| 24 |
+
{"table": "laws", "id": "de-sn-4721", "action": "lawtext_br_restored", "field": "text", "offsets": [16622], "offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text", "snippets": [{"offset": 16622, "before_offset": 16622, "before": ".\n\n§ 13 Ausnahme bei Erklärungder Beamtin oder des Beamten\n(", "after": ".\n\n§ 13 Ausnahme bei Erklärung\nder Beamtin oder des Beamten\n("}]}
|
scrapers/README.md
CHANGED
|
@@ -97,3 +97,6 @@ leaked into a title after the `Vom <date>` line is cut, and article_count is rec
|
|
| 97 |
- 2026-10-15 23:15 PT: `<br>` now becomes a line break (a space in titles) in `finalize_gate.strip_html_footnotes`, so words are never
|
| 98 |
glued. `fix_contents_titles.py` drops contents-list rows in contents-only mode (federal DE except a CoS keep list, DE-BB, DE-NW)
|
| 99 |
and restores the `<br>` spaces in DE-SN titles from the pre-fix tip; tests `tests/test_fix_contents_titles.py`.
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
- 2026-10-15 23:15 PT: `<br>` now becomes a line break (a space in titles) in `finalize_gate.strip_html_footnotes`, so words are never
|
| 98 |
glued. `fix_contents_titles.py` drops contents-list rows in contents-only mode (federal DE except a CoS keep list, DE-BB, DE-NW)
|
| 99 |
and restores the `<br>` spaces in DE-SN titles from the pre-fix tip; tests `tests/test_fix_contents_titles.py`.
|
| 100 |
+
- 2026-10-15 23:20 PT: `fix_lawtext_br.py` restores, as line breaks, the `<br>` spots the headings fix had glued in DE-SN law texts
|
| 101 |
+
(exact positions from the pre-fix raw text; re-runs the legacy cleaning and requires a byte-exact match). Its `stage` refuses READY
|
| 102 |
+
until `<out>/HUB_PARENT` holds the live commit of the base pack and the live data shas equal the staged base. Tests `tests/test_fix_lawtext_br.py`.
|
scrapers/code.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"de_lib.py": "410a63b8b89f9cd870711ba76b3bf814e1a3e6d94236939344ef508a17610c90",
|
| 3 |
"collect_de_laender.py": "6d3295170bf67bf187bbf361e9e5c9a77fbe5d2fb5c7149bd4b9966e7e479faf",
|
| 4 |
-
"pack_de.py": "
|
| 5 |
"robots_guard.py": "1c9f28bcf6851eaff85180c90bdf8054a3500edca773c5c5a84701e6053f0990",
|
| 6 |
"run_de_short.sh": "9b7e5d48f8803a9e6f83e630f03e7110b96f5ea8971adaec771b4c7db50d9798",
|
| 7 |
"resume_loop_de.sh": "87915efb8db8d5863f7a2d209b27ae4c64bfde7126dd5bf388242b5ed8c3c96b",
|
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"gate_profile.sh": "fbfbe563bf0b7ceebb8478f8600654dd0f9014c0f3f1a6d467a16230b24a883d",
|
| 10 |
"de_queue.example.txt": "4587e8d9e0b7ce55dffef23d874dae7a03b1093fdead26fd8313d5597c86a31f",
|
| 11 |
"requirements.txt": "7420dd98db2604b7f2ef9ccbf8679d5aceb9bdd8f769bfca587ae19e15e5be00",
|
| 12 |
-
"README.md": "
|
| 13 |
"tests/test_de_laender.py": "788bd4924861d35f5317b48682712d582190bcfcff3fe9410033b9f8ef5b7418",
|
| 14 |
"short_turn.sh": "129c7f34bcacb6ba9bfdd856c68d9b5e33e547107689bde17afa9f61de9e8e09",
|
| 15 |
"tests/test_short_turn.py": "6f6681d63f90858cf01924133e07a26d9c56e1f783b7ed35017e513ceb5ce7b7",
|
|
@@ -18,5 +18,7 @@
|
|
| 18 |
"fix_sn.py": "048fdd4e5f999ebb49db7491fe9f98c2792a5236cf57f5c7798c260ee927b117",
|
| 19 |
"tests/test_fix_sn.py": "6870695e1c3c224c82b1110bb36bcdb0f52be134b98da726456b5e2b483a5264",
|
| 20 |
"fix_contents_titles.py": "315a8fe0768c6d33bb8d3b388508461187959cef48bd4f5aa3630104e95b2f8b",
|
| 21 |
-
"tests/test_fix_contents_titles.py": "9811842a3c165c0671d8e150359bba808931088fdf880b43b93adb6b25fb67f6"
|
|
|
|
|
|
|
| 22 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"de_lib.py": "410a63b8b89f9cd870711ba76b3bf814e1a3e6d94236939344ef508a17610c90",
|
| 3 |
"collect_de_laender.py": "6d3295170bf67bf187bbf361e9e5c9a77fbe5d2fb5c7149bd4b9966e7e479faf",
|
| 4 |
+
"pack_de.py": "a386a7b235b3bf4f1eb0e3df86ef73ef9e3c8688ff7182015df9d730cee79b99",
|
| 5 |
"robots_guard.py": "1c9f28bcf6851eaff85180c90bdf8054a3500edca773c5c5a84701e6053f0990",
|
| 6 |
"run_de_short.sh": "9b7e5d48f8803a9e6f83e630f03e7110b96f5ea8971adaec771b4c7db50d9798",
|
| 7 |
"resume_loop_de.sh": "87915efb8db8d5863f7a2d209b27ae4c64bfde7126dd5bf388242b5ed8c3c96b",
|
|
|
|
| 9 |
"gate_profile.sh": "fbfbe563bf0b7ceebb8478f8600654dd0f9014c0f3f1a6d467a16230b24a883d",
|
| 10 |
"de_queue.example.txt": "4587e8d9e0b7ce55dffef23d874dae7a03b1093fdead26fd8313d5597c86a31f",
|
| 11 |
"requirements.txt": "7420dd98db2604b7f2ef9ccbf8679d5aceb9bdd8f769bfca587ae19e15e5be00",
|
| 12 |
+
"README.md": "792bd097762ac6419bda46b832c8aa7846168c42732e7a45191666fd629eb7c3",
|
| 13 |
"tests/test_de_laender.py": "788bd4924861d35f5317b48682712d582190bcfcff3fe9410033b9f8ef5b7418",
|
| 14 |
"short_turn.sh": "129c7f34bcacb6ba9bfdd856c68d9b5e33e547107689bde17afa9f61de9e8e09",
|
| 15 |
"tests/test_short_turn.py": "6f6681d63f90858cf01924133e07a26d9c56e1f783b7ed35017e513ceb5ce7b7",
|
|
|
|
| 18 |
"fix_sn.py": "048fdd4e5f999ebb49db7491fe9f98c2792a5236cf57f5c7798c260ee927b117",
|
| 19 |
"tests/test_fix_sn.py": "6870695e1c3c224c82b1110bb36bcdb0f52be134b98da726456b5e2b483a5264",
|
| 20 |
"fix_contents_titles.py": "315a8fe0768c6d33bb8d3b388508461187959cef48bd4f5aa3630104e95b2f8b",
|
| 21 |
+
"tests/test_fix_contents_titles.py": "9811842a3c165c0671d8e150359bba808931088fdf880b43b93adb6b25fb67f6",
|
| 22 |
+
"fix_lawtext_br.py": "2dcc695bebf6ea306c045b13e483097353be8f402e90a8fd3984fa21b3260d1c",
|
| 23 |
+
"tests/test_fix_lawtext_br.py": "994e6a99b74f47d3dc283977cc7021a37c6ff0153da61623d61dd9a96d0817ea"
|
| 24 |
}
|
scrapers/fix_lawtext_br.py
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Follow-up in-place fix (CoS, 2026-10-15 23:15 PT): the DE-SN headings fix removed '<br>' without a separator in some SN
|
| 3 |
+
law texts ('...ZuständigkeitenDes...'). Each '<br>' that sat between two non-space characters in the raw text before that fix
|
| 4 |
+
(--prev-laws, tip e5474984) becomes a line break again, at exactly that spot; nothing else changes.
|
| 5 |
+
|
| 6 |
+
Method: in the raw text each glued '<br>' is replaced by a sentinel, the original (pre-2026-10-15-23:15) cleaning is re-run, and
|
| 7 |
+
the result minus the sentinels must equal the current text byte for byte; only then do the sentinels become '\\n'.
|
| 8 |
+
|
| 9 |
+
fix_lawtext_br.py build --base-laws L --base-articles A --prev-laws L_prev --prev-manifest fix_sn_headings_ids.jsonl --readme README.md
|
| 10 |
+
fix_lawtext_br.py stage # needs <out>/HUB_PARENT = live commit of the base pack; live tip == parent and live data shas == base
|
| 11 |
+
Exit: 0 ok, 5 tip/base mismatch, 7 credential scan hit, 8 bundle file missing, 9 invariant failed, 10 parent placeholder, 11 gate failed.
|
| 12 |
+
"""
|
| 13 |
+
import argparse, json, os, re, shutil, sys, time
|
| 14 |
+
from pathlib import Path
|
| 15 |
+
|
| 16 |
+
HERE = Path(__file__).resolve().parent
|
| 17 |
+
sys.path.insert(0, str(HERE))
|
| 18 |
+
import de_lib as L # noqa: E402
|
| 19 |
+
import finalize_gate as G # noqa: E402
|
| 20 |
+
from fix_sn import rowset_sha, sha256 # noqa: E402
|
| 21 |
+
|
| 22 |
+
TAG = "fix_sn_lawtext_br"
|
| 23 |
+
API = f"https://huggingface.co/api/datasets/{L.HUB_REPO}"
|
| 24 |
+
OUT = Path(os.environ.get("DE_FIX_STAGE", f"/workspace/hf-staging/germany_laws_{TAG}"))
|
| 25 |
+
PLACEHOLDER = "PENDING_LIVE_COMMIT_OF_fix_contents_titles"
|
| 26 |
+
SENT = "\ue000"
|
| 27 |
+
GLUED = re.compile(r"(?i)(?<=\S)<br\s*/?>(?=\S)")
|
| 28 |
+
EXTRA_BUNDLE = ["fix_sn.py", "tests/test_fix_sn.py", "fix_contents_titles.py", "tests/test_fix_contents_titles.py",
|
| 29 |
+
"fix_lawtext_br.py", "tests/test_fix_lawtext_br.py"]
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def legacy_clean(raw):
|
| 33 |
+
"""The cleaning used by the 2026-10-15 headings fix: '<br>' removed with the other tags (no separator)."""
|
| 34 |
+
keep = G._BR
|
| 35 |
+
G._BR = re.compile(r"(?!x)x")
|
| 36 |
+
try:
|
| 37 |
+
return G.strip_html_footnotes(raw)[0]
|
| 38 |
+
finally:
|
| 39 |
+
G._BR = keep
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def restore(raw, current):
|
| 43 |
+
"""-> (new_text, [offsets in new_text of the inserted '\\n']) or None if raw has no glued <br>. Raises if not exact."""
|
| 44 |
+
if not GLUED.search(raw or ""):
|
| 45 |
+
return None
|
| 46 |
+
marked = legacy_clean(GLUED.sub(SENT, raw))
|
| 47 |
+
if SENT in (raw or "") or marked.replace(SENT, "") != current:
|
| 48 |
+
raise ValueError("legacy cleaning does not reproduce the live text")
|
| 49 |
+
offs = [m.start() for m in re.finditer(SENT, marked)]
|
| 50 |
+
return marked.replace(SENT, "\n"), offs
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def fix_rows(laws, prev_laws, prev_manifest, jur="DE-SN"):
|
| 54 |
+
cleaned = {m["id"] for m in prev_manifest if m["table"] == "laws" and m["action"] == "html_cleaned"}
|
| 55 |
+
prev = {r["id"]: r["text"] for r in prev_laws if r["id"] in cleaned}
|
| 56 |
+
out, man = [], []
|
| 57 |
+
for r in laws:
|
| 58 |
+
if r["id"] in prev and r["jurisdiction"] == jur:
|
| 59 |
+
res = restore(prev[r["id"]], r["text"])
|
| 60 |
+
if res:
|
| 61 |
+
new, offs = res
|
| 62 |
+
man.append({"table": "laws", "id": r["id"], "action": "lawtext_br_restored", "field": "text", "offsets": offs,
|
| 63 |
+
"offsets_note": "offset = index of the inserted '\\n' in the new text; before_offset = the join point in the old text",
|
| 64 |
+
"snippets": [{"offset": o, "before_offset": o - k, "before": r["text"][max(0, o - k - 30):o - k + 30],
|
| 65 |
+
"after": new[max(0, o - 30):o + 31]} for k, o in enumerate(offs)]})
|
| 66 |
+
r = dict(r, text=new)
|
| 67 |
+
out.append(r)
|
| 68 |
+
return out, man
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def invariants(ol, nl, man):
|
| 72 |
+
ch = {m["id"] for m in man}
|
| 73 |
+
diffs = set()
|
| 74 |
+
for a, b in zip(ol, nl):
|
| 75 |
+
diffs |= {f for f in a if a[f] != b[f]}
|
| 76 |
+
return {"law_ids_and_order_identical": [r["id"] for r in ol] == [r["id"] for r in nl],
|
| 77 |
+
"untouched_laws_identical": rowset_sha([r for r in ol if r["id"] not in ch]) == rowset_sha([r for r in nl if r["id"] not in ch]),
|
| 78 |
+
"law_fields_changed": sorted(diffs), "only_text_changed": diffs <= {"text"},
|
| 79 |
+
"changed_text_only_adds_newlines": all(b["text"].replace("\n", "") == a["text"].replace("\n", "") and
|
| 80 |
+
len(b["text"]) - len(a["text"]) == len(next(m for m in man if m["id"] == a["id"])["offsets"])
|
| 81 |
+
for a, b in zip(ol, nl) if a["id"] in ch)}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def update_readme(text, man):
|
| 85 |
+
s = re.sub(r"(\| Snapshot date \| [^|\n]*?)( \|)", lambda m: m.group(1) + ("; SN law-text line breaks 2026-10-15" if "law-text line breaks" not in m.group(1) else "") + m.group(2), text, count=1)
|
| 86 |
+
anchor = re.search(r"^- `manifests/fix_contents_titles_ids\.jsonl`.*$", s, re.M)
|
| 87 |
+
line = (f"- `manifests/{TAG}_ids.jsonl` — the DE-SN law texts whose line breaks were restored on 2026-10-15, with offsets and "
|
| 88 |
+
f"before/after snippets; `manifests/{TAG}_REPORT.json` — invariants and gate results.")
|
| 89 |
+
s = s[:anchor.end()] + "\n" + line + s[anchor.end():] if anchor else s.rstrip("\n") + "\n\n" + line + "\n"
|
| 90 |
+
n = sum(len(m["offsets"]) for m in man)
|
| 91 |
+
s = s.rstrip("\n") + "\n\n" + (
|
| 92 |
+
"## DE-SN law-text line breaks — 2026-10-15 (in place, `laws.text` of DE-SN rows only)\n\n"
|
| 93 |
+
f"- In {len(man)} DE-SN law texts the 2026-10-15 heading/HTML fix had removed {n} line breaks (`<br>`) that sat directly between two "
|
| 94 |
+
"words, joining them (e.g. `elektronischenInformations-`). Each is a line break again, at the exact position taken from the raw "
|
| 95 |
+
"text before that fix; offsets and before/after snippets are in "
|
| 96 |
+
f"`manifests/{TAG}_ids.jsonl`.\n- No other field or row changed; law and article counts are unchanged.\n")
|
| 97 |
+
return s
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def readme_counts(text):
|
| 101 |
+
m1 = re.search(r"\| Laws / instruments \| (\d+) \(federal (\d+) \+ Landesrecht (\d+)\)", text)
|
| 102 |
+
m2 = re.search(r"\| Articles \| (\d+) \(federal (\d+) \+ Landesrecht (\d+)\)", text)
|
| 103 |
+
return {"laws_total": int(m1.group(1)) if m1 else None, "laws_federal": int(m1.group(2)) if m1 else None,
|
| 104 |
+
"articles_total": int(m2.group(1)) if m2 else None, "articles_federal": int(m2.group(2)) if m2 else None}
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def gate_report(laws, arts, readme, jur="DE-SN"):
|
| 108 |
+
j = {r["id"]: r["jurisdiction"] for r in laws}
|
| 109 |
+
data = {"laws_total": len(laws), "laws_federal": sum(r["jurisdiction"] == "DE" for r in laws),
|
| 110 |
+
"articles_total": len(arts), "articles_federal": sum(j[a["law_id"]] == "DE" for a in arts)}
|
| 111 |
+
g = G.gate([r for r in laws if r["jurisdiction"] == jur], [a for a in arts if j[a["law_id"]] == jur], readme_counts(readme), data)
|
| 112 |
+
glued = [r["id"] for r in laws if r["jurisdiction"] == jur and SENT in (r["text"] or "")]
|
| 113 |
+
g["sentinel_left"] = len(glued)
|
| 114 |
+
g["raw_html_all_rows"] = sum(1 for r in laws if G.RAW_HTML.search((r["text"] or "") + (r["title"] or ""))) + \
|
| 115 |
+
sum(1 for a in arts if G.RAW_HTML.search((a["text"] or "") + (a["title"] or "")))
|
| 116 |
+
g["ok"] = g["ok"] and not glued and g["raw_html_all_rows"] == 0
|
| 117 |
+
g["scope"] = f"{jur} rows + whole-dataset raw HTML + README counts"
|
| 118 |
+
return g
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def cmd_build(a):
|
| 122 |
+
import pyarrow as pa, pyarrow.parquet as pq
|
| 123 |
+
import pack_de as P
|
| 124 |
+
lt = pq.read_table(a.base_laws)
|
| 125 |
+
ol = lt.to_pylist()
|
| 126 |
+
nl, man = fix_rows(ol, pq.read_table(a.prev_laws, columns=["id", "text"]).to_pylist(),
|
| 127 |
+
[json.loads(x) for x in open(a.prev_manifest, encoding="utf-8")])
|
| 128 |
+
inv = invariants(ol, nl, man)
|
| 129 |
+
out = Path(a.out); pack = out / "pack"
|
| 130 |
+
if pack.exists():
|
| 131 |
+
shutil.rmtree(pack)
|
| 132 |
+
(pack / "data").mkdir(parents=True); (pack / "manifests").mkdir(); (pack / "scrapers" / "tests").mkdir(parents=True)
|
| 133 |
+
pq.write_table(pa.Table.from_pylist(nl, schema=lt.schema), pack / "data" / "laws.parquet", compression="zstd")
|
| 134 |
+
shutil.copy2(a.base_articles, pack / "data" / "articles.parquet") # unchanged file, byte-identical
|
| 135 |
+
readme = update_readme(Path(a.readme).read_text(encoding="utf-8"), man)
|
| 136 |
+
(pack / "README.md").write_text(readme, encoding="utf-8")
|
| 137 |
+
with open(pack / "manifests" / f"{TAG}_ids.jsonl", "w", encoding="utf-8") as f:
|
| 138 |
+
for m in man:
|
| 139 |
+
f.write(json.dumps(m, ensure_ascii=False) + "\n")
|
| 140 |
+
for fn in dict.fromkeys(P.BUNDLE + EXTRA_BUNDLE):
|
| 141 |
+
if not (HERE / fn).exists():
|
| 142 |
+
print("bundle file missing", fn); return 8
|
| 143 |
+
shutil.copy2(HERE / fn, pack / "scrapers" / fn)
|
| 144 |
+
g = gate_report(pq.read_table(pack / "data" / "laws.parquet").to_pylist(), pq.read_table(pack / "data" / "articles.parquet").to_pylist(), readme)
|
| 145 |
+
inv["ok"] = inv["law_ids_and_order_identical"] and inv["untouched_laws_identical"] and inv["only_text_changed"] and inv["changed_text_only_adds_newlines"] \
|
| 146 |
+
and sha256(pack / "data" / "articles.parquet") == sha256(a.base_articles)
|
| 147 |
+
rep = {"repo": L.HUB_REPO, "parent": PLACEHOLDER, "base_sha256": {"laws": sha256(a.base_laws), "articles": sha256(a.base_articles)},
|
| 148 |
+
"prev_laws_sha256": sha256(a.prev_laws), "laws_changed": len(man), "spots": sum(len(m["offsets"]) for m in man),
|
| 149 |
+
"invariants": inv, "gate": g, "built_at": time.strftime("%Y-%m-%dT%H:%M:%S%z")}
|
| 150 |
+
(pack / "manifests" / f"{TAG}_REPORT.json").write_text(json.dumps(rep, ensure_ascii=False, indent=1))
|
| 151 |
+
hits = P.scan_tree(pack)
|
| 152 |
+
if hits:
|
| 153 |
+
print("credential scan hits", hits[:5]); return 7
|
| 154 |
+
(pack / "scrapers" / "code.json").write_text(json.dumps({fn: sha256(pack / "scrapers" / fn) for fn in dict.fromkeys(P.BUNDLE + EXTRA_BUNDLE)}, indent=1))
|
| 155 |
+
(pack / "SHA256SUMS").write_text("\n".join(f"{sha256(p)} {p.relative_to(pack)}" for p in sorted(pack.rglob("*")) if p.is_file()) + "\n")
|
| 156 |
+
par = out / "HUB_PARENT"
|
| 157 |
+
if not par.exists():
|
| 158 |
+
par.write_text(PLACEHOLDER + "\n")
|
| 159 |
+
(out / "BASE_SHAS.json").write_text(json.dumps(rep["base_sha256"], indent=1) + "\n")
|
| 160 |
+
print(json.dumps(rep, ensure_ascii=False))
|
| 161 |
+
if not inv["ok"]:
|
| 162 |
+
return 9
|
| 163 |
+
return 0 if g["ok"] else 11
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def cmd_stage(a):
|
| 167 |
+
import requests, pyarrow.parquet as pq
|
| 168 |
+
out = Path(a.out); pack = out / "pack"
|
| 169 |
+
parent = (out / "HUB_PARENT").read_text().strip() if (out / "HUB_PARENT").exists() else ""
|
| 170 |
+
if not re.fullmatch(r"[0-9a-f]{40}", parent):
|
| 171 |
+
print(f"HUB_PARENT not set ({parent or 'missing'}); no READY"); return 10
|
| 172 |
+
rep = json.loads((pack / "manifests" / f"{TAG}_REPORT.json").read_text())
|
| 173 |
+
g = gate_report(pq.read_table(pack / "data" / "laws.parquet").to_pylist(), pq.read_table(pack / "data" / "articles.parquet").to_pylist(),
|
| 174 |
+
(pack / "README.md").read_text(encoding="utf-8"))
|
| 175 |
+
if not (rep["invariants"]["ok"] and g["ok"]):
|
| 176 |
+
print("invariants / gate failed; no READY"); return 11
|
| 177 |
+
bad = [ln for ln in (pack / "SHA256SUMS").read_text().splitlines() if sha256(pack / ln.split(" ", 1)[1]) != ln.split(" ", 1)[0]]
|
| 178 |
+
if bad:
|
| 179 |
+
print("SHA256SUMS mismatch", bad[:3]); return 9
|
| 180 |
+
sha = requests.get(API, timeout=60).json().get("sha")
|
| 181 |
+
if sha != parent:
|
| 182 |
+
print(f"live tip {sha} != HUB_PARENT {parent}; no READY"); return 5
|
| 183 |
+
tree = {x["path"]: (x.get("lfs") or {}).get("oid") for x in requests.get(f"{API}/tree/{parent}/data", timeout=60).json()}
|
| 184 |
+
base = json.loads((out / "BASE_SHAS.json").read_text())
|
| 185 |
+
if tree.get("data/laws.parquet") != base["laws"] or tree.get("data/articles.parquet") != base["articles"]:
|
| 186 |
+
print("live data at parent != staged base", tree, base); return 5
|
| 187 |
+
ready = out.parent / f"READY_germany_laws_{TAG}"
|
| 188 |
+
ready.write_text(json.dumps({"repo": L.HUB_REPO, "expected_parent": parent, "live_tip_checked": sha, "live_data_matches_base": True,
|
| 189 |
+
"pack": str(pack), "replaces": ["data/laws.parquet", "README.md"], "unchanged": ["data/articles.parquet"],
|
| 190 |
+
"adds": [f"manifests/{TAG}_ids.jsonl", f"manifests/{TAG}_REPORT.json", "scrapers/fix_lawtext_br.py",
|
| 191 |
+
"scrapers/tests/test_fix_lawtext_br.py"],
|
| 192 |
+
"sums_sha256": sha256(pack / "SHA256SUMS"), "at": time.strftime("%Y-%m-%dT%H:%M:%S%z")}, indent=1) + "\n")
|
| 193 |
+
print("READY", ready); return 0
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def main(argv=None):
|
| 197 |
+
ap = argparse.ArgumentParser(); sp = ap.add_subparsers(dest="cmd", required=True)
|
| 198 |
+
p = sp.add_parser("build")
|
| 199 |
+
for k in ("--base-laws", "--base-articles", "--prev-laws", "--prev-manifest", "--readme"):
|
| 200 |
+
p.add_argument(k, required=True)
|
| 201 |
+
p.add_argument("--out", default=str(OUT))
|
| 202 |
+
p = sp.add_parser("stage"); p.add_argument("--out", default=str(OUT))
|
| 203 |
+
a = ap.parse_args(argv)
|
| 204 |
+
return cmd_build(a) if a.cmd == "build" else cmd_stage(a)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
if __name__ == "__main__":
|
| 208 |
+
sys.exit(main())
|
scrapers/pack_de.py
CHANGED
|
@@ -22,7 +22,7 @@ API = f"https://huggingface.co/api/datasets/{L.HUB_REPO}"
|
|
| 22 |
RESOLVE = f"https://huggingface.co/datasets/{L.HUB_REPO}/resolve/{L.HUB_TIP}"
|
| 23 |
BUNDLE = ["de_lib.py", "collect_de_laender.py", "pack_de.py", "robots_guard.py", "run_de_short.sh", "resume_loop_de.sh",
|
| 24 |
"de_waiter.sh", "gate_profile.sh", "de_queue.example.txt", "requirements.txt", "README.md", "tests/test_de_laender.py",
|
| 25 |
-
"short_turn.sh", "tests/test_short_turn.py", "finalize_gate.py", "tests/test_finalize_gate.py", "fix_sn.py", "tests/test_fix_sn.py", "fix_contents_titles.py", "tests/test_fix_contents_titles.py"]
|
| 26 |
SECRET = re.compile(r"hf_[A-Za-z0-9]{30,}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY|xox[abps]-[A-Za-z0-9-]{10,}")
|
| 27 |
|
| 28 |
|
|
|
|
| 22 |
RESOLVE = f"https://huggingface.co/datasets/{L.HUB_REPO}/resolve/{L.HUB_TIP}"
|
| 23 |
BUNDLE = ["de_lib.py", "collect_de_laender.py", "pack_de.py", "robots_guard.py", "run_de_short.sh", "resume_loop_de.sh",
|
| 24 |
"de_waiter.sh", "gate_profile.sh", "de_queue.example.txt", "requirements.txt", "README.md", "tests/test_de_laender.py",
|
| 25 |
+
"short_turn.sh", "tests/test_short_turn.py", "finalize_gate.py", "tests/test_finalize_gate.py", "fix_sn.py", "tests/test_fix_sn.py", "fix_contents_titles.py", "tests/test_fix_contents_titles.py", "fix_lawtext_br.py", "tests/test_fix_lawtext_br.py"]
|
| 26 |
SECRET = re.compile(r"hf_[A-Za-z0-9]{30,}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|AKIA[0-9A-Z]{16}|-----BEGIN [A-Z ]*PRIVATE KEY|xox[abps]-[A-Za-z0-9-]{10,}")
|
| 27 |
|
| 28 |
|
scrapers/tests/test_fix_lawtext_br.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Offline tests for fix_lawtext_br.py (restore glued <br> line breaks in DE-SN law texts). Synthetic rows only."""
|
| 3 |
+
import sys, unittest
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
CODE = Path(__file__).resolve().parent.parent
|
| 7 |
+
sys.path.insert(0, str(CODE))
|
| 8 |
+
import fix_lawtext_br as F # noqa: E402
|
| 9 |
+
|
| 10 |
+
RAW = ('§ 9 Zuständigkeiten<br>des Staatsbetriebes\n§ 10 Prüfung;<br/>Zulassung\n§ 11 Text <br> mit Leerzeichen.'
|
| 11 |
+
'<a title="Fußnote\nzwei" class="fussnote_link" href="#FNID_1"> 1</a> Ende<b></b>')
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class Fix(unittest.TestCase):
|
| 15 |
+
def setUp(self):
|
| 16 |
+
self.cur = F.legacy_clean(RAW) # what the headings fix wrote
|
| 17 |
+
|
| 18 |
+
def test_legacy_reproduces_glue(self):
|
| 19 |
+
self.assertIn("Zuständigkeitendes", self.cur); self.assertIn("Prüfung;Zulassung", self.cur)
|
| 20 |
+
|
| 21 |
+
def test_restore_exact_spots_only(self):
|
| 22 |
+
new, offs = F.restore(RAW, self.cur)
|
| 23 |
+
self.assertIn("Zuständigkeiten\ndes", new); self.assertIn("Prüfung;\nZulassung", new)
|
| 24 |
+
self.assertEqual(len(offs), 2); self.assertEqual(len(new), len(self.cur) + 2)
|
| 25 |
+
self.assertEqual(new.replace("\n", ""), self.cur.replace("\n", ""))
|
| 26 |
+
self.assertIn("Text mit Leerzeichen", new) # spaced <br> untouched, as live
|
| 27 |
+
self.assertEqual([new[o] for o in offs], ["\n", "\n"])
|
| 28 |
+
|
| 29 |
+
def test_mismatch_raises_and_no_glue_is_none(self):
|
| 30 |
+
with self.assertRaises(ValueError):
|
| 31 |
+
F.restore(RAW, self.cur + "x")
|
| 32 |
+
self.assertIsNone(F.restore("a <br> b", "a b"))
|
| 33 |
+
|
| 34 |
+
def test_rows_and_invariants(self):
|
| 35 |
+
laws = [{"id": "de-sn-1", "jurisdiction": "DE-SN", "title": "G", "text": self.cur, "article_count": 1},
|
| 36 |
+
{"id": "de-sn-2", "jurisdiction": "DE-SN", "title": "G2", "text": "x", "article_count": 1},
|
| 37 |
+
{"id": "bund", "jurisdiction": "DE", "title": "B", "text": "y", "article_count": 1}]
|
| 38 |
+
prev = [{"id": "de-sn-1", "text": RAW}, {"id": "de-sn-2", "text": "x"}]
|
| 39 |
+
pm = [{"table": "laws", "id": "de-sn-1", "action": "html_cleaned"}, {"table": "laws", "id": "de-sn-2", "action": "html_cleaned"}]
|
| 40 |
+
nl, man = F.fix_rows(laws, prev, pm)
|
| 41 |
+
self.assertEqual([m["id"] for m in man], ["de-sn-1"]); self.assertEqual(nl[1:], laws[1:])
|
| 42 |
+
sn = man[0]["snippets"]
|
| 43 |
+
self.assertIn("Zuständigkeitendes", sn[0]["before"]); self.assertIn("Zuständigkeiten\ndes", sn[0]["after"])
|
| 44 |
+
self.assertIn("Prüfung;Zulassung", sn[1]["before"])
|
| 45 |
+
inv = F.invariants(laws, nl, man)
|
| 46 |
+
self.assertTrue(inv["only_text_changed"] and inv["untouched_laws_identical"] and inv["changed_text_only_adds_newlines"], inv)
|
| 47 |
+
|
| 48 |
+
def test_stage_blocks_on_placeholder(self):
|
| 49 |
+
import tempfile
|
| 50 |
+
d = Path(tempfile.mkdtemp(prefix="lbr_")); (d / "HUB_PARENT").write_text(F.PLACEHOLDER + "\n")
|
| 51 |
+
self.assertEqual(F.main(["stage", "--out", str(d)]), 10)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
unittest.main()
|