Add source: govpl (gov.pl government press releases)

#9
by ppuzio - opened
CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
  # Changelog
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## v0.3.1-preview (2026-07-10)
4
 
5
  - Added a separate 810-document Europeana direct-ingestion preview parquet at
 
1
  # Changelog
2
 
3
+ ## v0.2.2 (2026-07-19)
4
+
5
+ - Added `govpl` — gov.pl Polish government press releases (CC-BY-SA-4.0),
6
+ 88,190 documents / 80.7M tokens, fetched directly from gov.pl across 133
7
+ ministry/agency subsites. New scripts: `src/discover_govpl.py` (discovers each
8
+ subsite's news-section path into the committed `src/govpl_subsites.json`
9
+ manifest) and `src/fetch_govpl.py` (pure-stdlib crawl of that manifest).
10
+ - Stable totals after adding govpl: 13 sources, 2,579,963 docs, 6.36B tokens
11
+ (tiktoken proxy).
12
+ - Article date range 2005-09-26 → 2026-07-19. Build dropped 24 non-Polish and
13
+ deduped 1,926 cross-posted articles (exact sha1).
14
+
15
  ## v0.3.1-preview (2026-07-10)
16
 
17
  - Added a separate 810-document Europeana direct-ingestion preview parquet at
README.md CHANGED
@@ -19,9 +19,9 @@ A continuously developed, **openly-licensed**, human-text Polish corpus — a Po
19
  edition in the [Dynaword](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword)
20
  family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271)).
21
 
22
- > **v0.2.1 stable** · 2,491,773 documents · **6.28B tokens**
23
- > (tiktoken proxy; canonical Llama-3 count at release) · 12 sources
24
- > Updated: **2026-07-02**
25
 
26
  > **v0.3.0-preview validation release** · live source-gate validation for
27
  > SpeakLeash shards and direct Europeana candidate data, plus the quality/diversity
@@ -38,7 +38,8 @@ family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271))
38
 
39
  | version | status | documents | tokens | notes |
40
  |---|---|---:|---:|---|
41
- | `v0.2.1` | stable release | 2,491,773 | 6.28B | 12-source stable corpus with `license` and `author` metadata columns; adds `1000_novels`. |
 
42
  | `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |
43
  | `v0.3.0-preview` | validation release, candidate-only | candidate-only | TBD | Live source gates validated; Biblioteka Nauki, Europeana, and HPLT/Common Corpus expansion remain subject to per-source QA, dedup, and legal review. |
44
  | `v0.3.1-preview` | reproducible Europeana shard | 810 | 140,042 | 1,000 direct API records sampled; 810 passed short/language/OCR gates, with per-record rights and author metadata. |
@@ -87,13 +88,14 @@ as the redistributing aggregator; this release does not claim ownership of them
87
  | [wikipedia](data/wikipedia/wikipedia.md) | Polish Wikipedia | `CC-BY-SA-3.0` | 1,171,897 | 707.2M |
88
  | [dziennik_ustaw](data/dziennik_ustaw/dziennik_ustaw.md) | Dziennik Ustaw + Monitor Polski (Polish primary legislation) | `public-domain (official documents)` | 35,442 | 486.1M |
89
  | [wolne_lektury](data/wolne_lektury/wolne_lektury.md) | Wolne Lektury (school readings) | `CC-BY-SA-4.0 / Wolna Sztuka 1.3` | 6,141 | 103.0M |
 
90
  | [1000_novels](data/1000_novels/1000_novels.md) | 1000 Novels Corpus (CLARIN-PL) | `CC-BY-4.0` | 1,000 | 60.5M |
91
  | [wikiquote](data/wikiquote/wikiquote.md) | Polish Wikiquote (quotations) | `CC-BY-SA-3.0` | 30,363 | 31.9M |
92
  | [eltec_pol](data/eltec_pol/eltec_pol.md) | ELTeC-pol (European Literary Text Collection, Polish) | `CC-BY-4.0` | 100 | 21.5M |
93
  | [wikivoyage](data/wikivoyage/wikivoyage.md) | Polish Wikivoyage (travel guides) | `CC-BY-SA-3.0` | 13,645 | 17.1M |
94
  | [wikibooks](data/wikibooks/wikibooks.md) | Polish Wikibooks (open textbooks) | `CC-BY-SA-3.0` | 9,112 | 15.6M |
95
  | [wikinews](data/wikinews/wikinews.md) | Polish Wikinews | `CC-BY-2.5` | 24,386 | 12.1M |
96
- | **total** | | | **2,491,773** | **6,281.9M** |
97
 
98
  ## Method
99
  Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed
@@ -214,19 +216,19 @@ python3 src/make_docs.py
214
 
215
  Raw counts and token-normalized shares are regenerated from the current parquet files with `src/pattern_frequency_report.py`.
216
 
217
- - Total token count (tiktoken proxy): **6,281,911,234**
218
 
219
  | Pattern | Count | Share of all tokens |
220
  |---|---:|---:|
221
- | `w roku` | 435,541 | 0.0069% |
222
- | `klasyfikacji` | 129,977 | 0.0021% |
223
- | `ustawa` | 587,459 | 0.0094% |
224
- | `artykuł` | 2,036,359 | 0.0324% |
225
- | `parlament` | 1,201,641 | 0.0191% |
226
- | `rozporządzenie` | 1,490,464 | 0.0237% |
227
- | `w pobliżu` | 78,823 | 0.0013% |
228
- | `mieszkańców` | 241,200 | 0.0038% |
229
- | `Dz.U.` | 939,966 | 0.0150% |
230
 
231
  ### Per-source shares
232
 
@@ -268,6 +270,15 @@ Raw counts and token-normalized shares are regenerated from the current parquet
268
  | `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
269
  | `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
270
  | `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
 
 
 
 
 
 
 
 
 
271
  | `parliamentary` | `w roku` | 198,192 | 0.01203% |
272
  | `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
273
  | `parliamentary` | `ustawa` | 459,179 | 0.02788% |
 
19
  edition in the [Dynaword](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword)
20
  family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271)).
21
 
22
+ > **v0.2.2 stable** · 2,579,963 documents · **6.36B tokens**
23
+ > (tiktoken proxy; canonical Llama-3 count at release) · 13 sources
24
+ > Updated: **2026-07-19**
25
 
26
  > **v0.3.0-preview validation release** · live source-gate validation for
27
  > SpeakLeash shards and direct Europeana candidate data, plus the quality/diversity
 
38
 
39
  | version | status | documents | tokens | notes |
40
  |---|---|---:|---:|---|
41
+ | `v0.2.2` | stable release | 2,579,963 | 6.36B | Adds `govpl` (gov.pl government press releases, CC-BY-SA-4.0): 88,190 docs / 80.7M tokens fetched directly across 133 ministry/agency subsites. |
42
+ | `v0.2.1` | previous stable | 2,491,773 | 6.28B | 12-source stable corpus with `license` and `author` metadata columns; adds `1000_novels`. |
43
  | `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |
44
  | `v0.3.0-preview` | validation release, candidate-only | candidate-only | TBD | Live source gates validated; Biblioteka Nauki, Europeana, and HPLT/Common Corpus expansion remain subject to per-source QA, dedup, and legal review. |
45
  | `v0.3.1-preview` | reproducible Europeana shard | 810 | 140,042 | 1,000 direct API records sampled; 810 passed short/language/OCR gates, with per-record rights and author metadata. |
 
88
  | [wikipedia](data/wikipedia/wikipedia.md) | Polish Wikipedia | `CC-BY-SA-3.0` | 1,171,897 | 707.2M |
89
  | [dziennik_ustaw](data/dziennik_ustaw/dziennik_ustaw.md) | Dziennik Ustaw + Monitor Polski (Polish primary legislation) | `public-domain (official documents)` | 35,442 | 486.1M |
90
  | [wolne_lektury](data/wolne_lektury/wolne_lektury.md) | Wolne Lektury (school readings) | `CC-BY-SA-4.0 / Wolna Sztuka 1.3` | 6,141 | 103.0M |
91
+ | [govpl](data/govpl/govpl.md) | gov.pl — Polish government press releases | `CC-BY-SA-4.0` | 88,190 | 80.7M |
92
  | [1000_novels](data/1000_novels/1000_novels.md) | 1000 Novels Corpus (CLARIN-PL) | `CC-BY-4.0` | 1,000 | 60.5M |
93
  | [wikiquote](data/wikiquote/wikiquote.md) | Polish Wikiquote (quotations) | `CC-BY-SA-3.0` | 30,363 | 31.9M |
94
  | [eltec_pol](data/eltec_pol/eltec_pol.md) | ELTeC-pol (European Literary Text Collection, Polish) | `CC-BY-4.0` | 100 | 21.5M |
95
  | [wikivoyage](data/wikivoyage/wikivoyage.md) | Polish Wikivoyage (travel guides) | `CC-BY-SA-3.0` | 13,645 | 17.1M |
96
  | [wikibooks](data/wikibooks/wikibooks.md) | Polish Wikibooks (open textbooks) | `CC-BY-SA-3.0` | 9,112 | 15.6M |
97
  | [wikinews](data/wikinews/wikinews.md) | Polish Wikinews | `CC-BY-2.5` | 24,386 | 12.1M |
98
+ | **total** | | | **2,579,963** | **6,362.6M** |
99
 
100
  ## Method
101
  Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed
 
216
 
217
  Raw counts and token-normalized shares are regenerated from the current parquet files with `src/pattern_frequency_report.py`.
218
 
219
+ - Total token count (tiktoken proxy): **6,362,577,363**
220
 
221
  | Pattern | Count | Share of all tokens |
222
  |---|---:|---:|
223
+ | `w roku` | 438,913 | 0.0069% |
224
+ | `klasyfikacji` | 130,503 | 0.0021% |
225
+ | `ustawa` | 592,186 | 0.0093% |
226
+ | `artykuł` | 2,038,776 | 0.0320% |
227
+ | `parlament` | 1,205,608 | 0.0189% |
228
+ | `rozporządzenie` | 1,494,566 | 0.0235% |
229
+ | `w pobliżu` | 79,715 | 0.0013% |
230
+ | `mieszkańców` | 254,305 | 0.0040% |
231
+ | `Dz.U.` | 943,080 | 0.0148% |
232
 
233
  ### Per-source shares
234
 
 
270
  | `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
271
  | `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
272
  | `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
273
+ | `govpl` | `w roku` | 3,372 | 0.00418% |
274
+ | `govpl` | `klasyfikacji` | 526 | 0.00065% |
275
+ | `govpl` | `ustawa` | 4,727 | 0.00586% |
276
+ | `govpl` | `artykuł` | 2,417 | 0.00300% |
277
+ | `govpl` | `parlament` | 3,967 | 0.00492% |
278
+ | `govpl` | `rozporządzenie` | 4,102 | 0.00509% |
279
+ | `govpl` | `w pobliżu` | 892 | 0.00111% |
280
+ | `govpl` | `mieszkańców` | 13,105 | 0.01625% |
281
+ | `govpl` | `Dz.U.` | 3,114 | 0.00386% |
282
  | `parliamentary` | `w roku` | 198,192 | 0.01203% |
283
  | `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
284
  | `parliamentary` | `ustawa` | 459,179 | 0.02788% |
artifacts/pattern_frequency_artykul.png CHANGED

Git LFS Details

  • SHA256: 3449a103b1d166d01662ebe064c986eee9512730c14a1659dc65b59bfce76c65
  • Pointer size: 130 Bytes
  • Size of remote file: 52.5 kB

Git LFS Details

  • SHA256: f980030ed6ceeebcd54a7a5054df5e72ed3221e6080ccf82dc268d6d4fee4149
  • Pointer size: 130 Bytes
  • Size of remote file: 53.5 kB
artifacts/pattern_frequency_dzu.png CHANGED

Git LFS Details

  • SHA256: 2818db834f27681d87214668da8e8cf8b4c3d60ac4515e592ef55d598d100bc4
  • Pointer size: 130 Bytes
  • Size of remote file: 54.8 kB

Git LFS Details

  • SHA256: fb55b01d95a4bff496bb8fa665f2a8866f59aa72584f10f840ad41ee84e25b0c
  • Pointer size: 130 Bytes
  • Size of remote file: 56 kB
artifacts/pattern_frequency_hf_snippet.md CHANGED
@@ -1,18 +1,18 @@
1
  ## Phrase frequency in corpus (token-normalized)
2
 
3
- - Total token count (tiktoken proxy): **6,281,911,234**
4
 
5
  | Pattern | Count | Share of all tokens |
6
  |---|---:|---:|
7
- | `w roku` | 435,541 | 0.0069% |
8
- | `klasyfikacji` | 129,977 | 0.0021% |
9
- | `ustawa` | 587,459 | 0.0094% |
10
- | `artykuł` | 2,036,359 | 0.0324% |
11
- | `parlament` | 1,201,641 | 0.0191% |
12
- | `rozporządzenie` | 1,490,464 | 0.0237% |
13
- | `w pobliżu` | 78,823 | 0.0013% |
14
- | `mieszkańców` | 241,200 | 0.0038% |
15
- | `Dz.U.` | 939,966 | 0.0150% |
16
 
17
  ### Per-source shares
18
 
@@ -54,6 +54,15 @@
54
  | `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
55
  | `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
56
  | `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
 
 
 
 
 
 
 
 
 
57
  | `parliamentary` | `w roku` | 198,192 | 0.01203% |
58
  | `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
59
  | `parliamentary` | `ustawa` | 459,179 | 0.02788% |
 
1
  ## Phrase frequency in corpus (token-normalized)
2
 
3
+ - Total token count (tiktoken proxy): **6,362,577,363**
4
 
5
  | Pattern | Count | Share of all tokens |
6
  |---|---:|---:|
7
+ | `w roku` | 438,913 | 0.0069% |
8
+ | `klasyfikacji` | 130,503 | 0.0021% |
9
+ | `ustawa` | 592,186 | 0.0093% |
10
+ | `artykuł` | 2,038,776 | 0.0320% |
11
+ | `parlament` | 1,205,608 | 0.0189% |
12
+ | `rozporządzenie` | 1,494,566 | 0.0235% |
13
+ | `w pobliżu` | 79,715 | 0.0013% |
14
+ | `mieszkańców` | 254,305 | 0.0040% |
15
+ | `Dz.U.` | 943,080 | 0.0148% |
16
 
17
  ### Per-source shares
18
 
 
54
  | `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
55
  | `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
56
  | `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
57
+ | `govpl` | `w roku` | 3,372 | 0.00418% |
58
+ | `govpl` | `klasyfikacji` | 526 | 0.00065% |
59
+ | `govpl` | `ustawa` | 4,727 | 0.00586% |
60
+ | `govpl` | `artykuł` | 2,417 | 0.00300% |
61
+ | `govpl` | `parlament` | 3,967 | 0.00492% |
62
+ | `govpl` | `rozporządzenie` | 4,102 | 0.00509% |
63
+ | `govpl` | `w pobliżu` | 892 | 0.00111% |
64
+ | `govpl` | `mieszkańców` | 13,105 | 0.01625% |
65
+ | `govpl` | `Dz.U.` | 3,114 | 0.00386% |
66
  | `parliamentary` | `w roku` | 198,192 | 0.01203% |
67
  | `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
68
  | `parliamentary` | `ustawa` | 459,179 | 0.02788% |
artifacts/pattern_frequency_klasyfikacji.png CHANGED

Git LFS Details

  • SHA256: b351d8f562d98cdb9b1a66fac29abb8668a13ec5ef2a2a72dcdb74035bd477b0
  • Pointer size: 130 Bytes
  • Size of remote file: 53.5 kB

Git LFS Details

  • SHA256: df83d98e08ef8b6e5a90e953bc6c0d3719925236a2120183b9ea9fa5f8f45261
  • Pointer size: 130 Bytes
  • Size of remote file: 54.7 kB
artifacts/pattern_frequency_mieszkańców.png CHANGED

Git LFS Details

  • SHA256: 2d80ba18cf966b50d04078a6e7037f936f3fca7b6ad94af284d4c1ff77de67e8
  • Pointer size: 130 Bytes
  • Size of remote file: 52.2 kB

Git LFS Details

  • SHA256: 9719b64ff1588c0c7ea3abf74d636939fef2d97ce241e7802d0bdbec22ab6cf1
  • Pointer size: 130 Bytes
  • Size of remote file: 53.3 kB
artifacts/pattern_frequency_overall.png CHANGED

Git LFS Details

  • SHA256: 82f0a7cf259c63d6002ed9112e10cb1f09fb7a8e57f52951dc30656cae347281
  • Pointer size: 130 Bytes
  • Size of remote file: 42.2 kB

Git LFS Details

  • SHA256: afeb4d10d132b3656739502dc1ab5cc9a548b38fcd966821d9f7a645b18fdf2e
  • Pointer size: 130 Bytes
  • Size of remote file: 42.2 kB
artifacts/pattern_frequency_parlament.png CHANGED

Git LFS Details

  • SHA256: 65ef092f3f52fc9e47e75e907b4f66897838731551c30575386adee804b147b6
  • Pointer size: 130 Bytes
  • Size of remote file: 53 kB

Git LFS Details

  • SHA256: 7182ca813e5e34540a33ce35cdc7e7150028fd36ad00a75e80058a1cd53619b7
  • Pointer size: 130 Bytes
  • Size of remote file: 54.1 kB
artifacts/pattern_frequency_rozporządzenie.png CHANGED

Git LFS Details

  • SHA256: 89e05870fc5461cf05a9107e7063fbc1c232956e73978fb00f1f9ee4d634e979
  • Pointer size: 130 Bytes
  • Size of remote file: 51.1 kB

Git LFS Details

  • SHA256: dfa81f8a1e0f277ea334bd0ccf9cfedd303965f339f01f56c8c1332f7eaccd05
  • Pointer size: 130 Bytes
  • Size of remote file: 52.1 kB
artifacts/pattern_frequency_ustawa.png CHANGED

Git LFS Details

  • SHA256: fd37c46dbb0797739dde7ff15fcc84324a024246d4d4f3627b8fff0cbda0467e
  • Pointer size: 130 Bytes
  • Size of remote file: 51.7 kB

Git LFS Details

  • SHA256: 3847ae1472bf8f57e2158aee907017a8c783cd1aff7009bab074cf5eaef9b6b2
  • Pointer size: 130 Bytes
  • Size of remote file: 52.8 kB
artifacts/pattern_frequency_w_pobliżu.png CHANGED

Git LFS Details

  • SHA256: 996f880cbee3ed67170921a9a0734b49854fe9c85101806d80a7350bac7c59fb
  • Pointer size: 130 Bytes
  • Size of remote file: 54.2 kB

Git LFS Details

  • SHA256: a3e1daedbd3fc84a33ce8165bcbb4894e01dc5feb227194f05440b4ee1454b1a
  • Pointer size: 130 Bytes
  • Size of remote file: 55.4 kB
artifacts/pattern_frequency_w_roku.png CHANGED

Git LFS Details

  • SHA256: 0dbee575a4aa9a74a34afec885758cac62bd57a96097a1f3bd5925910b3e942d
  • Pointer size: 130 Bytes
  • Size of remote file: 56.4 kB

Git LFS Details

  • SHA256: df33a8fc14f059c83f546a295e0a7aa048600cf4844d4791e7dc786039d674f4
  • Pointer size: 130 Bytes
  • Size of remote file: 57.5 kB
data/govpl/govpl.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # govpl
2
+
3
+ gov.pl — Polish government press releases
4
+
5
+ ## Dataset description
6
+ - **Source (upstream):** https://www.gov.pl/
7
+ - **Domain:** government
8
+ - **Language:** Polish (pl)
9
+ - **License:** `CC-BY-SA-4.0`
10
+ - **Created (range):** 2005-09-26, 2026-07-19
11
+ - **Added:** 2026-07-19
12
+
13
+ ## Licensing — traceable basis
14
+ All textual content on gov.pl is published under CC-BY-SA 4.0 (site footer: "Treści tekstowe publikowane w serwisie … są udostępniane na licencji CC BY-SA 4.0"). Authored and hosted by the Polish government, which holds the right to license it — same open family as Polish Wikipedia.
15
+
16
+ ## Provenance
17
+ Ministry/agency press releases fetched directly from gov.pl (editor-content per article, HTML stripped) by src/fetch_govpl.py. Subsites + their non-uniform news-section paths are enumerated by src/discover_govpl.py into the committed manifest src/govpl_subsites.json (gov.pl has no sitemap/API). Each record's meta.url resolves on gov.pl.
18
+
19
+ ## Statistics
20
+ | documents | characters | tokens (tiktoken proxy) |
21
+ |---:|---:|---:|
22
+ | 88,190 | 218,099,000 | 80,666,129 |
23
+
24
+
25
+ ## Per-document license metadata
26
+ | license | documents |
27
+ |---|---:|
28
+ | `CC-BY-SA-4.0` | 88,190 |
29
+
30
+ Author metadata present for **0** documents. Empty values mean the upstream record did not expose a machine-readable author field.
31
+
32
+ ## Filters applied (build_dynaword.py)
33
+ Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
34
+ - drop documents < 200 chars: **0**
35
+ - drop non-Polish (diacritic ratio): **24**
36
+ - exact cross-source dedup (sha1): **1,926**
37
+ - OCR alpha-ratio < 0.70 (OCR sources only): **0**
38
+ - read 90,140 → kept 88,190
39
+
40
+ Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
41
+ Llama-3 count is computed at release.
data/govpl/govpl.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c0310fcdf45804e6547bd197cba55f58f12df618cd3d8b92b8e9077a3720b9f
3
+ size 82940575
data/govpl/govpl.stats.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "read": 90140,
3
+ "kept": 88190,
4
+ "drop_short": 0,
5
+ "drop_lang": 24,
6
+ "drop_dup": 1926,
7
+ "drop_ocr": 0,
8
+ "chars": 218099000,
9
+ "tokens": 80666129,
10
+ "licenses": {
11
+ "CC-BY-SA-4.0": 88190
12
+ },
13
+ "authors_with_value": 0,
14
+ "secs": 2.9,
15
+ "license": "CC-BY-SA-4.0"
16
+ }
pattern_frequency_report.md CHANGED
@@ -1,18 +1,18 @@
1
  ## Pattern frequency on corpus
2
 
3
- - total tokens (tiktoken proxy): `6,281,911,234`
4
 
5
  | pattern | count | share of all tokens |
6
  |---|---:|---:|
7
- | `w roku` | 435,541 | 0.0069% |
8
- | `klasyfikacji` | 129,977 | 0.0021% |
9
- | `ustawa` | 587,459 | 0.0094% |
10
- | `artykuł` | 2,036,359 | 0.0324% |
11
- | `parlament` | 1,201,641 | 0.0191% |
12
- | `rozporządzenie` | 1,490,464 | 0.0237% |
13
- | `w pobliżu` | 78,823 | 0.0013% |
14
- | `mieszkańców` | 241,200 | 0.0038% |
15
- | `Dz.U.` | 939,966 | 0.0150% |
16
 
17
  | source | pattern | count | per-token share |
18
  |---|---|---:|---:|
@@ -52,6 +52,15 @@
52
  | eurlex | `w pobliżu` | 6,088 | 0.00026% |
53
  | eurlex | `mieszkańców` | 9,441 | 0.00040% |
54
  | eurlex | `Dz.U.` | 915,707 | 0.03851% |
 
 
 
 
 
 
 
 
 
55
  | parliamentary | `w roku` | 198,192 | 0.01203% |
56
  | parliamentary | `klasyfikacji` | 12,637 | 0.00077% |
57
  | parliamentary | `ustawa` | 459,179 | 0.02788% |
 
1
  ## Pattern frequency on corpus
2
 
3
+ - total tokens (tiktoken proxy): `6,362,577,363`
4
 
5
  | pattern | count | share of all tokens |
6
  |---|---:|---:|
7
+ | `w roku` | 438,913 | 0.0069% |
8
+ | `klasyfikacji` | 130,503 | 0.0021% |
9
+ | `ustawa` | 592,186 | 0.0093% |
10
+ | `artykuł` | 2,038,776 | 0.0320% |
11
+ | `parlament` | 1,205,608 | 0.0189% |
12
+ | `rozporządzenie` | 1,494,566 | 0.0235% |
13
+ | `w pobliżu` | 79,715 | 0.0013% |
14
+ | `mieszkańców` | 254,305 | 0.0040% |
15
+ | `Dz.U.` | 943,080 | 0.0148% |
16
 
17
  | source | pattern | count | per-token share |
18
  |---|---|---:|---:|
 
52
  | eurlex | `w pobliżu` | 6,088 | 0.00026% |
53
  | eurlex | `mieszkańców` | 9,441 | 0.00040% |
54
  | eurlex | `Dz.U.` | 915,707 | 0.03851% |
55
+ | govpl | `w roku` | 3,372 | 0.00418% |
56
+ | govpl | `klasyfikacji` | 526 | 0.00065% |
57
+ | govpl | `ustawa` | 4,727 | 0.00586% |
58
+ | govpl | `artykuł` | 2,417 | 0.00300% |
59
+ | govpl | `parlament` | 3,967 | 0.00492% |
60
+ | govpl | `rozporządzenie` | 4,102 | 0.00509% |
61
+ | govpl | `w pobliżu` | 892 | 0.00111% |
62
+ | govpl | `mieszkańców` | 13,105 | 0.01625% |
63
+ | govpl | `Dz.U.` | 3,114 | 0.00386% |
64
  | parliamentary | `w roku` | 198,192 | 0.01203% |
65
  | parliamentary | `klasyfikacji` | 12,637 | 0.00077% |
66
  | parliamentary | `ustawa` | 459,179 | 0.02788% |
src/discover_govpl.py ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Discover gov.pl subsites + their news-section paths and write a committed
3
+ manifest (govpl_subsites.json) that fetch_govpl.py consumes.
4
+
5
+ gov.pl offers no sitemap or API for enumeration, and news-section slugs are
6
+ non-uniform: ministries use `/aktualnosci`, but voivodeship/agency subsites use
7
+ `/wiadomosci2`, `/aktualnosci10`, `/wszystkie-aktualnosci`, etc. (gov.pl appends
8
+ numeric suffixes to disambiguate repeated slugs). So discovery is a separate,
9
+ auditable step — freeze the JS-rendered subsite list, then probe each landing
10
+ page for its deepest-paginating news section. fetch_govpl.py then reads the
11
+ manifest with plain stdlib (no browser), keeping the fetch reproducible.
12
+
13
+ SEED_SLUGS was captured from the rendered catalog at
14
+ https://www.gov.pl/web/gov/katalog-jednostek on 2026-07-18 (a client-side list,
15
+ NOT fetchable over plain HTTP). To refresh, open that page in a browser console
16
+ and run:
17
+ [...new Set([...document.querySelectorAll('a[href*="/web/"]')]
18
+ .map(a => (a.getAttribute('href').match(/\\/web\\/([a-z0-9-]+)/i)||[])[1])
19
+ .filter(Boolean))].filter(s => s !== 'gov')
20
+ then paste the array into SEED_SLUGS below.
21
+
22
+ All gov.pl text is CC-BY-SA 4.0 (site footer), government-authored/hosted.
23
+
24
+ Usage:
25
+ python3 src/discover_govpl.py --out src/govpl_subsites.json
26
+ """
27
+ from __future__ import annotations
28
+ import argparse, http.client, json, re, time
29
+ from datetime import date
30
+ from html import unescape
31
+ from urllib.request import urlopen, Request
32
+ from urllib.error import URLError, HTTPError
33
+
34
+ BASE = "https://www.gov.pl"
35
+ UA = {"User-Agent": "polish-dynaword/0.1 (+research; openly-licensed corpus)",
36
+ "Accept": "text/html"}
37
+
38
+ # Frozen JS-rendered catalog (see module docstring for refresh recipe).
39
+ SEED_SLUGS = [
40
+ "premier", "aktywa-panstwowe", "cyfryzacja", "edukacja", "energia",
41
+ "finanse", "fundusze-regiony", "infrastruktura", "klimat", "kultura",
42
+ "nauka", "obrona-narodowa", "rodzina", "rolnictwo", "rozwoj-technologia",
43
+ "sport", "sprawiedliwosc", "mswia", "dyplomacja", "zdrowie", "zermswia",
44
+ "arimr", "chemikalia", "rpp", "gdos", "gif", "piorin", "gios", "gis",
45
+ "gitd", "gugik", "krus", "paa", "rcb", "udsc", "prokuratoria", "urpl",
46
+ "uzp", "uw-kujawsko-pomorski", "uw-lubelski", "uw-lubuski", "uw-lodzki",
47
+ "uw-mazowiecki", "uw-opolski", "uw-podkarpacki", "uw-podlaski",
48
+ "uw-warminsko-mazurski", "uw-zachodniopomorski", "gddkia-bialystok",
49
+ "gddkia-bydgoszcz", "gddkia-gdansk", "gddkia-katowice", "gddkia-kielce",
50
+ "gddkia-krakow", "gddkia-lublin", "gddkia-lodz", "gddkia-olsztyn",
51
+ "gddkia-opole", "gddkia-poznan", "gddkia-rzeszow", "gddkia-szczecin",
52
+ "gddkia-warszawa", "gddkia-wroclaw", "gddkia-zielona-gora", "wsse-bialystok",
53
+ "wsse-bydgoszcz", "wsse-gdansk", "wsse-gorzowwlkp", "wsse-katowice",
54
+ "wsse-kielce", "wsse-krakow", "wsse-lublin", "wsse-lodz", "wsse-olsztyn",
55
+ "wsse-opole", "wsse-poznan", "wsse-rzeszow", "wsse-szczecin",
56
+ "wsse-warszawa", "wsse-wroclaw", "prokuratura-krajowa", "po-bialystok",
57
+ "po-bielsko-biala", "po-bydgoszcz", "po-elblag", "po-gdansk", "po-gliwice",
58
+ "po-gorzow-wielkopolski", "po-katowice", "po-kielce", "po-krakow",
59
+ "po-legnica", "po-lublin", "po-lodz", "po-lomza", "po-nowy-sacz",
60
+ "po-olsztyn", "po-opole", "po-ostroleka", "po-ostrow-wielkopolski",
61
+ "po-piotrkow-trybunalski", "po-plock", "po-poznan", "po-rzeszow",
62
+ "po-siedlce", "po-sieradz", "po-slupsk", "po-sosnowiec", "po-swidnica",
63
+ "po-tarnobrzeg", "po-tarnow", "po-torun", "po-warszawa", "po-warszawa-praga",
64
+ "po-wloclawek", "po-wroclaw", "po-zielona-gora", "pr-gdansk", "pr-katowice",
65
+ "pr-krakow", "pr-lublin", "pr-lodz", "pr-poznan", "pr-rzeszow",
66
+ "pr-szczecin", "pr-warszawa", "pr-wroclaw", "kgpsp", "kwpsp-gdansk",
67
+ "kwpsp-opole", "kwpsp-poznan", "cskmswia", "spzoz-mswia-katowice",
68
+ "spzoz-mswia-lublin", "spzoz-mswia-opole", "spzoz-mswia-szczecin",
69
+ "spzoz-mswia-zielona-gora", "spzoz-mswia-glucholazy", "krrit", "kowr",
70
+ "kzn", "nck", "wody-polskie",
71
+ ]
72
+
73
+ # A landing-page sub-page counts as a news section if its slug starts with one
74
+ # of these (gov.pl appends -suffix / digits, e.g. aktualnosci10, wiadomosci2).
75
+ _NEWS_PREFIX = re.compile(r"^(wszystkie-aktualnosci|aktualnosci|wiadomosci|"
76
+ r"serwis-prasowy|komunikaty)", re.I)
77
+ # On a listing page each article preview is an <span class="date"> ... </span>
78
+ # (inside a class="event" block) followed by <div class="title"><a href=...>.
79
+ # Binding the two in one match keeps date/title/url aligned per article.
80
+ _ARTICLE = re.compile(
81
+ r'<span class="date">\s*([\d.]+)\s*</span>.*?'
82
+ r'<div class="title">\s*<a href="([^"]+)"[^>]*>\s*(.*?)\s*</a>',
83
+ re.I | re.S)
84
+ _PAGE = re.compile(r'[?&]page=(\d+)')
85
+
86
+
87
+ def http_get_url(url: str, tries: int = 4) -> tuple[str | None, str]:
88
+ """GET, returning (text, final_url_after_redirects). text is None on 404 or
89
+ exhausted retries. Needed because gov.pl news aliases (e.g. /aktualnosci)
90
+ 302-redirect to a canonical feed (/wydarzenia) and DROP the ?page= param —
91
+ so pagination must run against the resolved canonical URL, not the alias."""
92
+ for i in range(tries):
93
+ try:
94
+ with urlopen(Request(url, headers=UA), timeout=60) as r:
95
+ return r.read().decode("utf-8", "replace"), r.geturl()
96
+ # OSError covers URLError/TimeoutError/socket/ssl/ConnectionReset;
97
+ # HTTPException covers IncompleteRead (truncated body) — all transient, retry.
98
+ except (HTTPError, OSError, http.client.HTTPException) as e:
99
+ if isinstance(e, HTTPError) and e.code == 404:
100
+ return None, url
101
+ time.sleep(1.5 * (i + 1))
102
+ return None, url
103
+
104
+
105
+ def http_get(url: str, tries: int = 4) -> str | None:
106
+ """GET text, retrying transient errors; None on 404 or exhausted retries."""
107
+ return http_get_url(url, tries)[0]
108
+
109
+
110
+ def listing_articles(html: str, slug: str) -> list[dict]:
111
+ """{url,title,date} for real articles on a listing page of subsite `slug`."""
112
+ out = []
113
+ prefix = f"/web/{slug}/"
114
+ for date_str, href, title in _ARTICLE.findall(html):
115
+ if href.startswith(prefix):
116
+ out.append({
117
+ "url": href,
118
+ "title": unescape(re.sub(r"\s+", " ", title)).strip(),
119
+ "date": date_str,
120
+ })
121
+ return out
122
+
123
+
124
+ def max_page(html: str) -> int:
125
+ nums = [int(n) for n in _PAGE.findall(html)]
126
+ return max(nums) if nums else 1
127
+
128
+
129
+ def news_candidates(landing_html: str, slug: str) -> list[str]:
130
+ """Distinct same-subsite sub-slugs that look like a news section."""
131
+ seen = {}
132
+ for sub in re.findall(rf'href="/web/{re.escape(slug)}/([a-z0-9-]+)"', landing_html):
133
+ if _NEWS_PREFIX.match(sub):
134
+ seen[sub] = True
135
+ return list(seen)
136
+
137
+
138
+ def probe_subsite(slug: str) -> dict | None:
139
+ """Resolve a subsite's best news section -> {slug, news_path, pages} or None."""
140
+ landing = http_get(f"{BASE}/web/{slug}")
141
+ if not landing:
142
+ return None
143
+ best = None
144
+ for sub in news_candidates(landing, slug):
145
+ html = http_get(f"{BASE}/web/{slug}/{sub}")
146
+ if not html:
147
+ continue
148
+ n_art = len(listing_articles(html, slug))
149
+ if n_art == 0:
150
+ continue
151
+ pages = max_page(html)
152
+ # Prefer the deepest-paginating feed; tie-break the shorter (more general) slug.
153
+ key = (pages, -len(sub))
154
+ if best is None or key > best[0]:
155
+ best = (key, sub, pages)
156
+ time.sleep(0.2)
157
+ if best is None:
158
+ return None
159
+ return {"slug": slug, "news_path": best[1], "pages": best[2]}
160
+
161
+
162
+ def main():
163
+ ap = argparse.ArgumentParser()
164
+ ap.add_argument("--out", default="src/govpl_subsites.json")
165
+ ap.add_argument("--slugs", nargs="*", help="override SEED_SLUGS (for testing)")
166
+ args = ap.parse_args()
167
+
168
+ slugs = args.slugs or SEED_SLUGS
169
+ manifest, skipped = [], []
170
+ for i, slug in enumerate(slugs, 1):
171
+ rec = probe_subsite(slug)
172
+ if rec:
173
+ manifest.append(rec)
174
+ print(f"[{i}/{len(slugs)}] {slug} -> {rec['news_path']} ({rec['pages']}p)", flush=True)
175
+ else:
176
+ skipped.append(slug)
177
+ print(f"[{i}/{len(slugs)}] {slug} -> NO NEWS SECTION (skipped)", flush=True)
178
+
179
+ total_pages = sum(r["pages"] for r in manifest)
180
+ out = {
181
+ "generated": date.today().isoformat(),
182
+ "source": f"{BASE}/web/gov/katalog-jednostek",
183
+ "subsites": manifest,
184
+ "skipped": skipped, # logged, not silently dropped
185
+ "total_pages": total_pages,
186
+ }
187
+ with open(args.out, "w", encoding="utf-8") as f:
188
+ json.dump(out, f, ensure_ascii=False, indent=2)
189
+ print(f"\nwrote {args.out}: {len(manifest)} subsites, {total_pages} listing pages, "
190
+ f"{len(skipped)} skipped")
191
+
192
+
193
+ if __name__ == "__main__":
194
+ main()
src/fetch_govpl.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Fetch gov.pl ministry/agency press releases into a SpeakLeash-style
3
+ .jsonl.zst, so build_dynaword.py consumes it unchanged (native source, not via
4
+ SpeakLeash). All textual content on gov.pl is published under CC-BY-SA 4.0 (site
5
+ footer: "Treści tekstowe publikowane w serwisie … CC BY-SA 4.0"), authored and
6
+ hosted by the Polish government — so the redistributor genuinely holds the right
7
+ to license it.
8
+
9
+ Enumeration is driven by the committed manifest src/govpl_subsites.json (built
10
+ by discover_govpl.py): {slug, news_path, pages} per subsite. This keeps the
11
+ fetch pure-stdlib and reproducible — no headless browser at fetch time.
12
+
13
+ Resumable: appends to <out>/govpl.jsonl, skips article URLs already present,
14
+ then compresses to govpl.jsonl.zst at the end of a run. Per-request failures are
15
+ retried then logged and skipped (never silently truncating the crawl).
16
+
17
+ Usage:
18
+ python3 src/discover_govpl.py --out src/govpl_subsites.json # once / to refresh
19
+ python3 src/fetch_govpl.py --out ~/speakleash --manifest src/govpl_subsites.json
20
+ """
21
+ from __future__ import annotations
22
+ import argparse, json, re, subprocess, sys, threading, time
23
+ from concurrent.futures import ThreadPoolExecutor
24
+ from html import unescape
25
+ from pathlib import Path
26
+
27
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
28
+ from discover_govpl import BASE, http_get, http_get_url, listing_articles # shared, DRY
29
+
30
+ KEY = "govpl" # build_dynaword reads <KEY>.jsonl.zst
31
+ MIN_CHARS = 200 # same floor as build_dynaword; skip stubs early
32
+
33
+ _SCRIPT = re.compile(r"(?is)<(script|style)[^>]*>.*?</\1>")
34
+ _BLOCK_END = re.compile(r"(?i)</(p|div|h[1-6]|li|tr|table|ul|ol|blockquote)\s*>|<br\s*/?>")
35
+ _TAG = re.compile(r"<[^>]+>")
36
+ # Body ends where the editor-content region gives way to gallery/attachments/tags.
37
+ _END_MARKER = re.compile(
38
+ r'<[^>]+class="[^"]*(?:attachments|art-tags|tags|social|share|gallery|files)[^"]*"'
39
+ r'|data-group="gallery"|</article', re.I)
40
+ _EDITOR = re.compile(r'<div class="editor-content"[^>]*>', re.I)
41
+
42
+
43
+ def html_to_text(html: str) -> str:
44
+ html = _SCRIPT.sub("", html)
45
+ html = _BLOCK_END.sub("\n", html)
46
+ html = _TAG.sub("", html)
47
+ text = unescape(html)
48
+ text = re.sub(r"[ \t]+", " ", text)
49
+ text = re.sub(r" *\n *", "\n", text)
50
+ text = re.sub(r"\n{3,}", "\n\n", text)
51
+ return text.strip()
52
+
53
+
54
+ def article_body(html: str) -> str:
55
+ """Text of the article body. gov.pl pages carry the class twice; pick the
56
+ richest editor-content region and cut at the trailing gallery/attachments.
57
+ ponytail: regex slice, not a DOM parse — end-markers drop gallery captions;
58
+ upgrade to an HTML parser only if boilerplate leakage shows up in stats."""
59
+ best = ""
60
+ for m in _EDITOR.finditer(html):
61
+ start = m.end()
62
+ end = _END_MARKER.search(html, start)
63
+ chunk = html[start:end.start()] if end else html[start:]
64
+ text = html_to_text(chunk)
65
+ if len(text) > len(best):
66
+ best = text
67
+ return best
68
+
69
+
70
+ def normalize(art: dict, html: str, slug: str) -> dict | None:
71
+ """Listing entry {url,title,date} + article HTML -> record, or None if thin."""
72
+ body = article_body(html)
73
+ if len(body) < MIN_CHARS:
74
+ return None
75
+ title = art.get("title") or ""
76
+ text = f"{title}\n\n{body}" if title else body
77
+ return {
78
+ "text": text,
79
+ "meta": {
80
+ "url": BASE + art["url"],
81
+ "subsite": slug,
82
+ "title": title,
83
+ "date": art.get("date") or "",
84
+ },
85
+ }
86
+
87
+
88
+ def iter_listing(slug: str, news_path: str, pages: int):
89
+ """Yield {url,title,date} article entries across a subsite's listing pages.
90
+
91
+ Resolves the news section's canonical URL first: gov.pl aliases (e.g.
92
+ /aktualnosci) redirect to a canonical feed (/wydarzenia) and drop ?page=,
93
+ so paginating the alias returns page 1 forever. We paginate the resolved
94
+ base with ?page=N&size=10 (the exact form gov.pl's own pager emits)."""
95
+ first_html, canonical = http_get_url(f"{BASE}/web/{slug}/{news_path}")
96
+ if first_html is None:
97
+ print(f" WARN news section failed, skipped: {slug}/{news_path}",
98
+ file=sys.stderr, flush=True)
99
+ return
100
+ base = canonical.split("?", 1)[0] # canonical path, no query
101
+ for page in range(1, pages + 1):
102
+ html = http_get(f"{base}?page={page}&size=10")
103
+ if html is None:
104
+ print(f" WARN listing failed, skipped: {base}?page={page}",
105
+ file=sys.stderr, flush=True)
106
+ continue
107
+ yield from listing_articles(html, slug)
108
+
109
+
110
+ def fetch_subsite(si: int, n_sub: int, sub: dict, done: set, lock: threading.Lock,
111
+ fo, st: dict) -> None:
112
+ """Crawl one subsite. Runs in a worker thread: the slow article GET stays
113
+ outside the lock so workers actually overlap; only shared state (done set,
114
+ file, counters) is lock-guarded."""
115
+ slug, news_path, pages = sub["slug"], sub["news_path"], sub["pages"]
116
+ print(f"[{si}/{n_sub}] {slug}/{news_path} ({pages}p)", flush=True)
117
+ try:
118
+ for art in iter_listing(slug, news_path, pages):
119
+ url = BASE + art["url"]
120
+ with lock:
121
+ if url in done:
122
+ continue
123
+ done.add(url)
124
+ st["seen"] += 1
125
+ seen = st["seen"]
126
+ html = http_get(url) # network — deliberately outside the lock
127
+ if html is None:
128
+ with lock: st["skipped"] += 1
129
+ print(f" WARN article failed, skipped: {url}", file=sys.stderr, flush=True)
130
+ continue
131
+ rec = normalize(art, html, slug)
132
+ line = json.dumps(rec, ensure_ascii=False) + "\n" if rec else None
133
+ with lock:
134
+ if line:
135
+ fo.write(line); st["kept"] += 1
136
+ if seen % 500 == 0:
137
+ print(f" seen {st['seen']:,} | kept {st['kept']:,} | skipped {st['skipped']:,} "
138
+ f"| {st['seen']/(time.time()-st['t0']):.1f}/s", flush=True)
139
+ except Exception as e:
140
+ # A subsite that dies must not abort the whole crawl (ex.map would
141
+ # propagate and kill every worker). Log, skip the rest, keep going.
142
+ print(f" WARN subsite crashed, skipped rest: {slug}: {e!r}",
143
+ file=sys.stderr, flush=True)
144
+
145
+
146
+ def main():
147
+ ap = argparse.ArgumentParser()
148
+ ap.add_argument("--out", default="~/speakleash")
149
+ ap.add_argument("--manifest", default="src/govpl_subsites.json")
150
+ ap.add_argument("--workers", type=int, default=2,
151
+ help="concurrent subsite crawlers (be polite to gov.pl)")
152
+ args = ap.parse_args()
153
+
154
+ manifest = json.loads(Path(args.manifest).read_text(encoding="utf-8"))
155
+ subsites = manifest["subsites"]
156
+
157
+ out_dir = Path(args.out).expanduser(); out_dir.mkdir(parents=True, exist_ok=True)
158
+ jsonl = out_dir / f"{KEY}.jsonl"
159
+ done = set()
160
+ if jsonl.exists():
161
+ for ln in jsonl.open(encoding="utf-8"):
162
+ try: done.add(json.loads(ln)["meta"]["url"])
163
+ except Exception: pass
164
+ print(f"resume: {len(done):,} already fetched")
165
+
166
+ st = {"seen": 0, "kept": 0, "skipped": 0, "t0": time.time()}
167
+ lock = threading.Lock()
168
+ with jsonl.open("a", encoding="utf-8") as fo:
169
+ with ThreadPoolExecutor(max_workers=args.workers) as ex:
170
+ # list() drains the map so any worker exception surfaces here.
171
+ list(ex.map(
172
+ lambda item: fetch_subsite(item[0], len(subsites), item[1],
173
+ done, lock, fo, st),
174
+ enumerate(subsites, 1)))
175
+
176
+ print(f"fetched {st['kept']:,} articles ({st['skipped']:,} skipped); compressing...", flush=True)
177
+ subprocess.run(["zstd", "-19", "-f", "--rm", str(jsonl), "-o",
178
+ str(out_dir / f"{KEY}.jsonl.zst")], check=True)
179
+ print(f"wrote {out_dir / (KEY + '.jsonl.zst')} in {round(time.time()-st['t0'])}s")
180
+
181
+
182
+ if __name__ == "__main__":
183
+ main()
src/govpl_subsites.json ADDED
@@ -0,0 +1,684 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generated": "2026-07-18",
3
+ "source": "https://www.gov.pl/web/gov/katalog-jednostek",
4
+ "subsites": [
5
+ {
6
+ "slug": "premier",
7
+ "news_path": "aktualnosci",
8
+ "pages": 294
9
+ },
10
+ {
11
+ "slug": "aktywa-panstwowe",
12
+ "news_path": "wiadomosci",
13
+ "pages": 87
14
+ },
15
+ {
16
+ "slug": "cyfryzacja",
17
+ "news_path": "wiadomosci",
18
+ "pages": 353
19
+ },
20
+ {
21
+ "slug": "edukacja",
22
+ "news_path": "wiadomosci",
23
+ "pages": 104
24
+ },
25
+ {
26
+ "slug": "energia",
27
+ "news_path": "wiadomosci",
28
+ "pages": 36
29
+ },
30
+ {
31
+ "slug": "finanse",
32
+ "news_path": "wiadomosci",
33
+ "pages": 266
34
+ },
35
+ {
36
+ "slug": "fundusze-regiony",
37
+ "news_path": "aktualnosci1",
38
+ "pages": 378
39
+ },
40
+ {
41
+ "slug": "infrastruktura",
42
+ "news_path": "aktualnosci",
43
+ "pages": 325
44
+ },
45
+ {
46
+ "slug": "klimat",
47
+ "news_path": "wiadomosci",
48
+ "pages": 289
49
+ },
50
+ {
51
+ "slug": "kultura",
52
+ "news_path": "aktualnosci",
53
+ "pages": 481
54
+ },
55
+ {
56
+ "slug": "nauka",
57
+ "news_path": "wiadomosci",
58
+ "pages": 78
59
+ },
60
+ {
61
+ "slug": "obrona-narodowa",
62
+ "news_path": "aktualnosci5",
63
+ "pages": 186
64
+ },
65
+ {
66
+ "slug": "rodzina",
67
+ "news_path": "wiadomosci-polityka-rodzinna",
68
+ "pages": 111
69
+ },
70
+ {
71
+ "slug": "rolnictwo",
72
+ "news_path": "wiadomosci",
73
+ "pages": 5
74
+ },
75
+ {
76
+ "slug": "rozwoj-technologia",
77
+ "news_path": "wiadomosci",
78
+ "pages": 52
79
+ },
80
+ {
81
+ "slug": "sport",
82
+ "news_path": "wiadomosci",
83
+ "pages": 219
84
+ },
85
+ {
86
+ "slug": "sprawiedliwosc",
87
+ "news_path": "aktualnosci-ogloszenia-i-informacje",
88
+ "pages": 285
89
+ },
90
+ {
91
+ "slug": "mswia",
92
+ "news_path": "aktualnosci",
93
+ "pages": 216
94
+ },
95
+ {
96
+ "slug": "dyplomacja",
97
+ "news_path": "aktualnosci",
98
+ "pages": 302
99
+ },
100
+ {
101
+ "slug": "zdrowie",
102
+ "news_path": "wiadomosci",
103
+ "pages": 145
104
+ },
105
+ {
106
+ "slug": "zermswia",
107
+ "news_path": "aktualnosci",
108
+ "pages": 12
109
+ },
110
+ {
111
+ "slug": "arimr",
112
+ "news_path": "aktualnosci10",
113
+ "pages": 6
114
+ },
115
+ {
116
+ "slug": "rpp",
117
+ "news_path": "aktualnosci",
118
+ "pages": 93
119
+ },
120
+ {
121
+ "slug": "gdos",
122
+ "news_path": "aktualnosci",
123
+ "pages": 57
124
+ },
125
+ {
126
+ "slug": "gif",
127
+ "news_path": "wiadomosci",
128
+ "pages": 37
129
+ },
130
+ {
131
+ "slug": "gios",
132
+ "news_path": "wiadomosci",
133
+ "pages": 53
134
+ },
135
+ {
136
+ "slug": "gis",
137
+ "news_path": "wiadomosci",
138
+ "pages": 49
139
+ },
140
+ {
141
+ "slug": "gitd",
142
+ "news_path": "komunikaty-btm2",
143
+ "pages": 27
144
+ },
145
+ {
146
+ "slug": "gugik",
147
+ "news_path": "wiadomosci",
148
+ "pages": 183
149
+ },
150
+ {
151
+ "slug": "krus",
152
+ "news_path": "aktualnosci",
153
+ "pages": 18
154
+ },
155
+ {
156
+ "slug": "paa",
157
+ "news_path": "aktualnosci",
158
+ "pages": 49
159
+ },
160
+ {
161
+ "slug": "rcb",
162
+ "news_path": "komunikaty",
163
+ "pages": 90
164
+ },
165
+ {
166
+ "slug": "udsc",
167
+ "news_path": "aktualnosci",
168
+ "pages": 23
169
+ },
170
+ {
171
+ "slug": "prokuratoria",
172
+ "news_path": "aktualnosci",
173
+ "pages": 9
174
+ },
175
+ {
176
+ "slug": "urpl",
177
+ "news_path": "aktualnosci",
178
+ "pages": 14
179
+ },
180
+ {
181
+ "slug": "uzp",
182
+ "news_path": "aktualnosci",
183
+ "pages": 18
184
+ },
185
+ {
186
+ "slug": "uw-kujawsko-pomorski",
187
+ "news_path": "aktualnosci",
188
+ "pages": 216
189
+ },
190
+ {
191
+ "slug": "uw-lubelski",
192
+ "news_path": "wiadomosci",
193
+ "pages": 95
194
+ },
195
+ {
196
+ "slug": "uw-lubuski",
197
+ "news_path": "wiadomosci",
198
+ "pages": 138
199
+ },
200
+ {
201
+ "slug": "uw-lodzki",
202
+ "news_path": "wiadomosci",
203
+ "pages": 161
204
+ },
205
+ {
206
+ "slug": "uw-mazowiecki",
207
+ "news_path": "wiadomosci2",
208
+ "pages": 132
209
+ },
210
+ {
211
+ "slug": "uw-opolski",
212
+ "news_path": "aktualnosci",
213
+ "pages": 138
214
+ },
215
+ {
216
+ "slug": "uw-podkarpacki",
217
+ "news_path": "wiadomosci",
218
+ "pages": 149
219
+ },
220
+ {
221
+ "slug": "uw-podlaski",
222
+ "news_path": "wiadomosci",
223
+ "pages": 310
224
+ },
225
+ {
226
+ "slug": "uw-warminsko-mazurski",
227
+ "news_path": "aktualnosci",
228
+ "pages": 377
229
+ },
230
+ {
231
+ "slug": "uw-zachodniopomorski",
232
+ "news_path": "wiadomosci",
233
+ "pages": 4
234
+ },
235
+ {
236
+ "slug": "gddkia-bialystok",
237
+ "news_path": "aktualnosci",
238
+ "pages": 2
239
+ },
240
+ {
241
+ "slug": "gddkia-bydgoszcz",
242
+ "news_path": "aktualnosci",
243
+ "pages": 3
244
+ },
245
+ {
246
+ "slug": "gddkia-gdansk",
247
+ "news_path": "aktualnosci",
248
+ "pages": 5
249
+ },
250
+ {
251
+ "slug": "gddkia-katowice",
252
+ "news_path": "aktualnosci",
253
+ "pages": 5
254
+ },
255
+ {
256
+ "slug": "gddkia-kielce",
257
+ "news_path": "aktualnosci",
258
+ "pages": 6
259
+ },
260
+ {
261
+ "slug": "gddkia-krakow",
262
+ "news_path": "aktualnosci",
263
+ "pages": 7
264
+ },
265
+ {
266
+ "slug": "gddkia-lublin",
267
+ "news_path": "aktualnosci",
268
+ "pages": 5
269
+ },
270
+ {
271
+ "slug": "gddkia-lodz",
272
+ "news_path": "aktualnosci",
273
+ "pages": 4
274
+ },
275
+ {
276
+ "slug": "gddkia-olsztyn",
277
+ "news_path": "aktualnosci",
278
+ "pages": 1
279
+ },
280
+ {
281
+ "slug": "gddkia-opole",
282
+ "news_path": "aktualnosci",
283
+ "pages": 5
284
+ },
285
+ {
286
+ "slug": "gddkia-poznan",
287
+ "news_path": "aktualnosci",
288
+ "pages": 5
289
+ },
290
+ {
291
+ "slug": "gddkia-rzeszow",
292
+ "news_path": "aktualnosci",
293
+ "pages": 6
294
+ },
295
+ {
296
+ "slug": "gddkia-szczecin",
297
+ "news_path": "aktualnosci",
298
+ "pages": 3
299
+ },
300
+ {
301
+ "slug": "gddkia-warszawa",
302
+ "news_path": "aktualnosci",
303
+ "pages": 4
304
+ },
305
+ {
306
+ "slug": "gddkia-wroclaw",
307
+ "news_path": "aktualnosci",
308
+ "pages": 7
309
+ },
310
+ {
311
+ "slug": "gddkia-zielona-gora",
312
+ "news_path": "aktualnosci",
313
+ "pages": 2
314
+ },
315
+ {
316
+ "slug": "wsse-bialystok",
317
+ "news_path": "wiadomosci",
318
+ "pages": 20
319
+ },
320
+ {
321
+ "slug": "wsse-bydgoszcz",
322
+ "news_path": "aktualnosci",
323
+ "pages": 71
324
+ },
325
+ {
326
+ "slug": "wsse-gdansk",
327
+ "news_path": "wiadomosci",
328
+ "pages": 48
329
+ },
330
+ {
331
+ "slug": "wsse-katowice",
332
+ "news_path": "wiadomosci",
333
+ "pages": 35
334
+ },
335
+ {
336
+ "slug": "wsse-kielce",
337
+ "news_path": "wiadomosci",
338
+ "pages": 28
339
+ },
340
+ {
341
+ "slug": "wsse-lublin",
342
+ "news_path": "komunikaty-i-meldunki",
343
+ "pages": 53
344
+ },
345
+ {
346
+ "slug": "wsse-lodz",
347
+ "news_path": "komunikaty-o-wodzie-do-spozycia2",
348
+ "pages": 104
349
+ },
350
+ {
351
+ "slug": "wsse-olsztyn",
352
+ "news_path": "komunikaty-i-meldunki",
353
+ "pages": 52
354
+ },
355
+ {
356
+ "slug": "wsse-opole",
357
+ "news_path": "wiadomosci",
358
+ "pages": 17
359
+ },
360
+ {
361
+ "slug": "wsse-poznan",
362
+ "news_path": "wiadomosci",
363
+ "pages": 31
364
+ },
365
+ {
366
+ "slug": "wsse-rzeszow",
367
+ "news_path": "wiadomosci",
368
+ "pages": 24
369
+ },
370
+ {
371
+ "slug": "wsse-szczecin",
372
+ "news_path": "wiadomosci",
373
+ "pages": 44
374
+ },
375
+ {
376
+ "slug": "wsse-warszawa",
377
+ "news_path": "wiadomosci",
378
+ "pages": 36
379
+ },
380
+ {
381
+ "slug": "wsse-wroclaw",
382
+ "news_path": "komunikaty-i-meldunki",
383
+ "pages": 25
384
+ },
385
+ {
386
+ "slug": "prokuratura-krajowa",
387
+ "news_path": "aktualnosci",
388
+ "pages": 541
389
+ },
390
+ {
391
+ "slug": "po-bialystok",
392
+ "news_path": "aktualnosci",
393
+ "pages": 25
394
+ },
395
+ {
396
+ "slug": "po-bielsko-biala",
397
+ "news_path": "komunikaty",
398
+ "pages": 1
399
+ },
400
+ {
401
+ "slug": "po-bydgoszcz",
402
+ "news_path": "aktualnosci1",
403
+ "pages": 17
404
+ },
405
+ {
406
+ "slug": "po-elblag",
407
+ "news_path": "komunikaty",
408
+ "pages": 8
409
+ },
410
+ {
411
+ "slug": "po-gdansk",
412
+ "news_path": "aktualnosci",
413
+ "pages": 1
414
+ },
415
+ {
416
+ "slug": "po-gliwice",
417
+ "news_path": "komunikaty",
418
+ "pages": 32
419
+ },
420
+ {
421
+ "slug": "po-gorzow-wielkopolski",
422
+ "news_path": "aktualnosci1",
423
+ "pages": 17
424
+ },
425
+ {
426
+ "slug": "po-katowice",
427
+ "news_path": "komunikaty-rzecznika-prasowego",
428
+ "pages": 8
429
+ },
430
+ {
431
+ "slug": "po-kielce",
432
+ "news_path": "aktualnosci1",
433
+ "pages": 25
434
+ },
435
+ {
436
+ "slug": "po-krakow",
437
+ "news_path": "komunikaty-rzecznika2",
438
+ "pages": 11
439
+ },
440
+ {
441
+ "slug": "po-legnica",
442
+ "news_path": "aktualnosci1",
443
+ "pages": 36
444
+ },
445
+ {
446
+ "slug": "po-lublin",
447
+ "news_path": "aktualnosci",
448
+ "pages": 9
449
+ },
450
+ {
451
+ "slug": "po-lodz",
452
+ "news_path": "aktualnosci1",
453
+ "pages": 26
454
+ },
455
+ {
456
+ "slug": "po-lomza",
457
+ "news_path": "komunikaty-rzecznika-prasowego---archiwalne",
458
+ "pages": 13
459
+ },
460
+ {
461
+ "slug": "po-nowy-sacz",
462
+ "news_path": "aktualnosci",
463
+ "pages": 25
464
+ },
465
+ {
466
+ "slug": "po-olsztyn",
467
+ "news_path": "aktualnosci1",
468
+ "pages": 16
469
+ },
470
+ {
471
+ "slug": "po-opole",
472
+ "news_path": "aktualnosci",
473
+ "pages": 21
474
+ },
475
+ {
476
+ "slug": "po-ostroleka",
477
+ "news_path": "komunikaty-prasowe",
478
+ "pages": 6
479
+ },
480
+ {
481
+ "slug": "po-ostrow-wielkopolski",
482
+ "news_path": "aktualnosci1",
483
+ "pages": 18
484
+ },
485
+ {
486
+ "slug": "po-piotrkow-trybunalski",
487
+ "news_path": "aktualnosci",
488
+ "pages": 17
489
+ },
490
+ {
491
+ "slug": "po-plock",
492
+ "news_path": "aktualnosci",
493
+ "pages": 13
494
+ },
495
+ {
496
+ "slug": "po-poznan",
497
+ "news_path": "aktualnosci1",
498
+ "pages": 51
499
+ },
500
+ {
501
+ "slug": "po-rzeszow",
502
+ "news_path": "komunikaty-prasowe",
503
+ "pages": 38
504
+ },
505
+ {
506
+ "slug": "po-siedlce",
507
+ "news_path": "aktualnosci1",
508
+ "pages": 15
509
+ },
510
+ {
511
+ "slug": "po-sieradz",
512
+ "news_path": "aktualnosci",
513
+ "pages": 15
514
+ },
515
+ {
516
+ "slug": "po-sosnowiec",
517
+ "news_path": "aktualnosci",
518
+ "pages": 28
519
+ },
520
+ {
521
+ "slug": "po-swidnica",
522
+ "news_path": "aktualnosci",
523
+ "pages": 23
524
+ },
525
+ {
526
+ "slug": "po-tarnow",
527
+ "news_path": "aktualnosci1",
528
+ "pages": 14
529
+ },
530
+ {
531
+ "slug": "po-torun",
532
+ "news_path": "aktualnosci1",
533
+ "pages": 19
534
+ },
535
+ {
536
+ "slug": "po-warszawa",
537
+ "news_path": "komunikaty-rzecznika-prasowego",
538
+ "pages": 28
539
+ },
540
+ {
541
+ "slug": "po-warszawa-praga",
542
+ "news_path": "aktualnosci",
543
+ "pages": 31
544
+ },
545
+ {
546
+ "slug": "po-wloclawek",
547
+ "news_path": "aktualnosci1",
548
+ "pages": 18
549
+ },
550
+ {
551
+ "slug": "po-wroclaw",
552
+ "news_path": "aktualnosci",
553
+ "pages": 23
554
+ },
555
+ {
556
+ "slug": "po-zielona-gora",
557
+ "news_path": "aktualnosci1",
558
+ "pages": 35
559
+ },
560
+ {
561
+ "slug": "pr-gdansk",
562
+ "news_path": "aktualnosci",
563
+ "pages": 23
564
+ },
565
+ {
566
+ "slug": "pr-katowice",
567
+ "news_path": "aktualnosci-prokuratury-regionalnej",
568
+ "pages": 14
569
+ },
570
+ {
571
+ "slug": "pr-krakow",
572
+ "news_path": "komunikaty",
573
+ "pages": 6
574
+ },
575
+ {
576
+ "slug": "pr-lublin",
577
+ "news_path": "aktualnosci1",
578
+ "pages": 8
579
+ },
580
+ {
581
+ "slug": "pr-lodz",
582
+ "news_path": "aktualnosci",
583
+ "pages": 15
584
+ },
585
+ {
586
+ "slug": "pr-poznan",
587
+ "news_path": "wiadomosci",
588
+ "pages": 17
589
+ },
590
+ {
591
+ "slug": "pr-rzeszow",
592
+ "news_path": "aktualnosci",
593
+ "pages": 11
594
+ },
595
+ {
596
+ "slug": "pr-szczecin",
597
+ "news_path": "aktualnosci",
598
+ "pages": 13
599
+ },
600
+ {
601
+ "slug": "pr-warszawa",
602
+ "news_path": "aktualnosci1",
603
+ "pages": 19
604
+ },
605
+ {
606
+ "slug": "pr-wroclaw",
607
+ "news_path": "aktualnosci1",
608
+ "pages": 32
609
+ },
610
+ {
611
+ "slug": "kgpsp",
612
+ "news_path": "aktualnosci",
613
+ "pages": 130
614
+ },
615
+ {
616
+ "slug": "kwpsp-gdansk",
617
+ "news_path": "aktualnosci",
618
+ "pages": 103
619
+ },
620
+ {
621
+ "slug": "kwpsp-opole",
622
+ "news_path": "aktualnosci",
623
+ "pages": 6
624
+ },
625
+ {
626
+ "slug": "kwpsp-poznan",
627
+ "news_path": "wiadomosci2021",
628
+ "pages": 24
629
+ },
630
+ {
631
+ "slug": "spzoz-mswia-opole",
632
+ "news_path": "wiadomosci",
633
+ "pages": 3
634
+ },
635
+ {
636
+ "slug": "spzoz-mswia-szczecin",
637
+ "news_path": "aktualnosci",
638
+ "pages": 62
639
+ },
640
+ {
641
+ "slug": "spzoz-mswia-zielona-gora",
642
+ "news_path": "aktualnosci",
643
+ "pages": 2
644
+ },
645
+ {
646
+ "slug": "krrit",
647
+ "news_path": "aktualnosci",
648
+ "pages": 61
649
+ },
650
+ {
651
+ "slug": "kowr",
652
+ "news_path": "aktualnosci",
653
+ "pages": 5
654
+ },
655
+ {
656
+ "slug": "kzn",
657
+ "news_path": "aktualnosci",
658
+ "pages": 24
659
+ },
660
+ {
661
+ "slug": "nck",
662
+ "news_path": "aktualnosci",
663
+ "pages": 55
664
+ },
665
+ {
666
+ "slug": "wody-polskie",
667
+ "news_path": "aktualnosci",
668
+ "pages": 62
669
+ }
670
+ ],
671
+ "skipped": [
672
+ "chemikalia",
673
+ "piorin",
674
+ "wsse-gorzowwlkp",
675
+ "wsse-krakow",
676
+ "po-slupsk",
677
+ "po-tarnobrzeg",
678
+ "cskmswia",
679
+ "spzoz-mswia-katowice",
680
+ "spzoz-mswia-lublin",
681
+ "spzoz-mswia-glucholazy"
682
+ ],
683
+ "total_pages": 9247
684
+ }
src/make_docs.py CHANGED
@@ -13,7 +13,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
13
  from sources import SOURCES, EXCLUDED, ADDED
14
 
15
  ROOT = Path(__file__).resolve().parent.parent
16
- VERSION = "0.2.1"
17
  CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests
18
 
19
  # Dupochron: documented good-faith provenance + no-warranty + takedown + PII.
 
13
  from sources import SOURCES, EXCLUDED, ADDED
14
 
15
  ROOT = Path(__file__).resolve().parent.parent
16
+ VERSION = "0.2.2"
17
  CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests
18
 
19
  # Dupochron: documented good-faith provenance + no-warranty + takedown + PII.
src/sources.py CHANGED
@@ -186,6 +186,28 @@ SOURCES = {
186
  "created": "1918-01-01, 2025-12-31",
187
  "is_ocr": False,
188
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  "biblioteka_nauki": {
190
  "file_key": "biblioteka_nauki_pl_corpus",
191
  "pretty": "Biblioteka Nauki",
@@ -231,7 +253,7 @@ SOURCES = {
231
  },
232
  }
233
 
234
- ADDED = "2026-06-15"
235
  EXCLUDED = {
236
  "open_subtitles_corpus": "Derivative of copyrighted film/TV dialogue; "
237
  "OpenSubtitles uploads largely unlicensed. Same copyright lesson as "
 
186
  "created": "1918-01-01, 2025-12-31",
187
  "is_ocr": False,
188
  },
189
+ "govpl": {
190
+ "file_key": "govpl", # fetched directly from gov.pl, NOT via SpeakLeash
191
+ "pretty": "gov.pl — Polish government press releases",
192
+ "license": "CC-BY-SA-4.0",
193
+ "license_spdx": "CC-BY-SA-4.0",
194
+ "traceable": "All textual content on gov.pl is published under CC-BY-SA "
195
+ "4.0 (site footer: \"Treści tekstowe publikowane w serwisie "
196
+ "… są udostępniane na licencji CC BY-SA 4.0\"). Authored and "
197
+ "hosted by the Polish government, which holds the right to "
198
+ "license it — same open family as Polish Wikipedia.",
199
+ "upstream": "https://www.gov.pl/",
200
+ "provenance": "Ministry/agency press releases fetched directly from gov.pl "
201
+ "(editor-content per article, HTML stripped) by "
202
+ "src/fetch_govpl.py. Subsites + their non-uniform news-section "
203
+ "paths are enumerated by src/discover_govpl.py into the "
204
+ "committed manifest src/govpl_subsites.json (gov.pl has no "
205
+ "sitemap/API). Each record's meta.url resolves on gov.pl.",
206
+ "domain": "government",
207
+ # actual min/max of article dates in the fetched corpus (90,124 dated).
208
+ "created": "2005-09-26, 2026-07-19",
209
+ "is_ocr": False,
210
+ },
211
  "biblioteka_nauki": {
212
  "file_key": "biblioteka_nauki_pl_corpus",
213
  "pretty": "Biblioteka Nauki",
 
253
  },
254
  }
255
 
256
+ ADDED = "2026-07-19"
257
  EXCLUDED = {
258
  "open_subtitles_corpus": "Derivative of copyrighted film/TV dialogue; "
259
  "OpenSubtitles uploads largely unlicensed. Same copyright lesson as "
src/test_govpl_contract.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """TDD contract for the direct gov.pl (press releases) ingestion path."""
2
+ import sys
3
+ import unittest
4
+ from pathlib import Path
5
+
6
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
7
+
8
+ from discover_govpl import listing_articles, news_candidates, max_page
9
+ from fetch_govpl import article_body, normalize, BASE
10
+
11
+ LISTING = """
12
+ <div class="art-prev">
13
+ <div class="event"><span class="date">14.07.2026</span><span class="location">Paryż</span></div>
14
+ <div class="title"><a href="/web/premier/polska-gospodarzem-cwiczen">
15
+ Polska gospodarzem &#263;wicze&#324;</a></div>
16
+ <div class="intro">Lead...</div>
17
+ </div>
18
+ <div class="art-prev">
19
+ <div class="event"><span class="date">13.07.2026</span></div>
20
+ <div class="title"><a href="/web/premier/druga-wiadomosc">Druga wiadomo&#347;&#263;</a></div>
21
+ </div>
22
+ <!-- foreign link that must be ignored -->
23
+ <div class="title"><a href="/web/gov/menu-link">nav</a></div>
24
+ """
25
+
26
+ ARTICLE = """
27
+ <article>
28
+ <h1>Tytu&#322;</h1>
29
+ <div class="editor-content"></div>
30
+ <div class="editor-content">
31
+ <p>Rada Ministr&oacute;w przyj&#281;&#322;a rozporz&#261;dzenie. """ + ("Tre&#347;&#263; komunikatu. " * 20) + """</p>
32
+ <div class="attachments"><a href="/x">Za&#322;&#261;cznik do pobrania</a></div>
33
+ </div>
34
+ <div class="gallery"><a href="/photo/1"><span class="sr-only">Poka&#380; zdj&#281;cie 1 z galerii</span></a></div>
35
+ </article>
36
+ """
37
+
38
+
39
+ class GovplContractTest(unittest.TestCase):
40
+ def test_listing_binds_date_title_url_and_filters_foreign(self):
41
+ arts = listing_articles(LISTING, "premier")
42
+ self.assertEqual(len(arts), 2) # nav link (foreign slug) dropped
43
+ self.assertEqual(arts[0]["url"], "/web/premier/polska-gospodarzem-cwiczen")
44
+ self.assertEqual(arts[0]["date"], "14.07.2026")
45
+ self.assertIn("ćwiczeń", arts[0]["title"]) # entities decoded
46
+ self.assertEqual(arts[1]["date"], "13.07.2026")
47
+
48
+ def test_article_body_picks_richest_region_and_drops_gallery(self):
49
+ body = article_body(ARTICLE)
50
+ self.assertIn("Rada Ministrów", body)
51
+ self.assertNotIn("<", body) # tags stripped
52
+ self.assertNotIn("Pokaż zdjęcie", body) # gallery caption cut
53
+ self.assertNotIn("Załącznik do pobrania", body) # attachments cut
54
+
55
+ def test_normalize_schema_prepends_title_and_prefixes_url(self):
56
+ art = {"url": "/web/premier/x", "title": "Nagłówek", "date": "14.07.2026"}
57
+ row = normalize(art, ARTICLE, "premier")
58
+ self.assertEqual(set(row), {"text", "meta"})
59
+ self.assertEqual(set(row["meta"]), {"url", "subsite", "title", "date"})
60
+ self.assertTrue(row["text"].startswith("Nagłówek"))
61
+ self.assertEqual(row["meta"]["url"], BASE + "/web/premier/x")
62
+ self.assertEqual(row["meta"]["subsite"], "premier")
63
+
64
+ def test_thin_body_is_rejected(self):
65
+ thin = '<div class="editor-content"><p>Kr&#243;tko.</p></div>'
66
+ self.assertIsNone(normalize({"url": "/web/premier/x", "title": "T"}, thin, "premier"))
67
+ self.assertIsNone(normalize({"url": "/web/premier/x", "title": "T"}, "", "premier"))
68
+
69
+ def test_news_candidate_detection(self):
70
+ landing = ('<a href="/web/arimr/aktualnosci10">n</a>'
71
+ '<a href="/web/arimr/wszystkie-aktualnosci">n</a>'
72
+ '<a href="/web/arimr/serwis-prasowy-arimr2">n</a>'
73
+ '<a href="/web/arimr/kontakt">x</a>'
74
+ '<a href="/web/arimr/informacje-o-arimr">x</a>')
75
+ cands = set(news_candidates(landing, "arimr"))
76
+ self.assertEqual(cands, {"aktualnosci10", "wszystkie-aktualnosci", "serwis-prasowy-arimr2"})
77
+
78
+ def test_max_page(self):
79
+ self.assertEqual(max_page('<a href="?page=2">2</a><a href="?page=294">294</a>'), 294)
80
+ self.assertEqual(max_page("<html>no pager</html>"), 1) # single-page listing
81
+
82
+
83
+ if __name__ == "__main__":
84
+ unittest.main()