Datasets:
Add source: sejm_interpellations (10th-term written Q&A)
Browse filesShip the current-term interpellations and HTML ministry replies as a
written-register complement to sejm_api speeches. Term 9 was empty on
the API; 7–8 were skipped because PPC already covers them.
Co-authored-by: Cursor <cursoragent@cursor.com>
- CHANGELOG.md +15 -0
- README.md +21 -8
- artifacts/source_findings.md +5 -5
- data/sejm_interpellations/sejm_interpellations.md +108 -0
- data/sejm_interpellations/sejm_interpellations.parquet +3 -0
- data/sejm_interpellations/sejm_interpellations.stats.json +16 -0
- src/build_dynaword.py +6 -0
- src/fetch_sejm_interpellations.py +81 -31
- src/make_docs.py +2 -2
- src/sources.py +5 -4
- src/test_sejm_interpellations_contract.py +49 -0
CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
| 1 |
# Changelog
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## v0.2.5 (2026-08-14)
|
| 4 |
|
| 5 |
- Added the community contribution `samorzad_gov_pl` by Dawid Majewski
|
|
|
|
| 1 |
# Changelog
|
| 2 |
|
| 3 |
+
## v0.2.6 (2026-09-05)
|
| 4 |
+
|
| 5 |
+
- Added `sejm_interpellations` (Paweł Puzio / `ppuzio`): 25,950 documents /
|
| 6 |
+
28,180,895 cl100k-proxy tokens of 10th-term Sejm interpellations, written
|
| 7 |
+
questions, and HTML ministry replies (2023-11-15 – 2026-09-03). Same legal
|
| 8 |
+
basis as `sejm_api` (art. 4 pkt 2 pr. aut. + Open Data Act). Spoken floor
|
| 9 |
+
speeches are not included.
|
| 10 |
+
- Fetch: `src/fetch_sejm_interpellations.py` (HTML `/body` only; header chrome
|
| 11 |
+
stripped into meta; PDF-only and keyless replies skipped; `scrub_pii` from
|
| 12 |
+
#20). Term 9 listed empty on the API. Build dropped 553 exact-duplicate
|
| 13 |
+
texts (26,503 → 25,950). Every row has a signatory/minister `author`.
|
| 14 |
+
- README source table now also lists already-merged `sejm_api` and
|
| 15 |
+
`wiktionary_examples` so the card totals match the per-source `stats.json`
|
| 16 |
+
files: 4,392,601 documents / 9,704,694,875 tokens across 21 sources.
|
| 17 |
+
|
| 18 |
## v0.2.5 (2026-08-14)
|
| 19 |
|
| 20 |
- Added the community contribution `samorzad_gov_pl` by Dawid Majewski
|
README.md
CHANGED
|
@@ -19,13 +19,13 @@ 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.
|
| 23 |
-
> (tiktoken proxy; canonical Llama-3 count at release) ·
|
| 24 |
-
> Updated: **2026-
|
| 25 |
|
| 26 |
> **v0.3-dev experimental track** · quality/diversity workflow, source-gate
|
| 27 |
> validation and candidate-data audits. This is development work, not a released
|
| 28 |
-
> corpus version, and it does not replace the v0.2.
|
| 29 |
|
| 30 |
> **Europeana validation artifact (2026-07-10)** · a separate reproducible
|
| 31 |
> 810-document direct-ingestion sample stored under the legacy path
|
|
@@ -37,7 +37,8 @@ family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271))
|
|
| 37 |
|
| 38 |
| version | status | documents | tokens | notes |
|
| 39 |
|---|---|---:|---:|---|
|
| 40 |
-
| `v0.2.
|
|
|
|
| 41 |
| `v0.2.4` | previous stable | 4,246,429 | 9.60B | Expanded `european_hplt_v3_pl` to WDS bins 10-5 (+1.49M docs / 2.04B tok); phone PII-scrub hardening (independent dual-lens) + cross-source dedup (zero-overlap). |
|
| 42 |
| `v0.2.3` | previous stable | 2,710,974 | 6.88B | Adds community-contributed `european_hplt_v3_pl`, `global_voices` and `nkjp1m`. |
|
| 43 |
| `v0.2.2` | previous stable | 2,579,963 | 6.36B | Added community-contributed `govpl`: 88,190 docs / 80.7M tokens. |
|
|
@@ -55,7 +56,16 @@ family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271))
|
|
| 55 |
|
| 56 |
### Version details
|
| 57 |
|
| 58 |
-
#### v0.2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
Added `samorzad_gov_pl`: **72,771 documents / 41,154,506 cl100k-proxy
|
| 61 |
tokens** from 246 Polish local public institutions and one central platform
|
|
@@ -145,7 +155,7 @@ as the redistributing aggregator; this release does not claim ownership of them
|
|
| 145 |
|---|---|---|
|
| 146 |
| [Kacper Wikieł](https://huggingface.co/kacperwikiel) | Project maintainer; corpus curation, source and license review, release engineering, documentation, validation and reproducible build workflow. | all releases |
|
| 147 |
| [Bart Kobyliński](https://huggingface.co/bartoszkobylinski1) | Added `1000_novels`; expanded Biblioteka Nauki and Europeana ingestion with per-document license and author metadata. | `v0.2.1`, [PR #1](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/1) |
|
| 148 |
-
| [Paweł Puzio](https://huggingface.co/ppuzio) | Built `govpl`
|
| 149 |
| [Arkadiusz Słota](https://huggingface.co/Maggio33) | Built & expanded `european_hplt_v3_pl`: HPLT v3 WDS 10+9 (PR #5) then WDS 10-5 expansion (+1,493,384 docs / 2.04B tok), modular cleaning pipeline, phone-recall PII-scrub (v12b, independent dual-lens), cross-source dedup-vs-base (zero-overlap), validation and documentation. | `v0.2.3` (PR #5), `v0.2.4` |
|
| 150 |
| [Dawid Majewski](https://huggingface.co/dawidmajewski) | Added the reviewed Global Voices Polish corpus; built `samorzad_gov_pl` with direct acquisition, institution attribution, licensing evidence, release artifact and reproducible conversion. | `v0.2.3`, [PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7); `v0.2.5` |
|
| 151 |
| [1am](https://huggingface.co/1am) | Added `nkjp1m`: the manually annotated 1-million-word NKJP subcorpus, direct fetch/build pipeline, source documentation and release artifact. | `v0.2.3`, [PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8) |
|
|
@@ -175,14 +185,17 @@ files is not listed as a data contribution.
|
|
| 175 |
| [govpl](data/govpl/govpl.md) | gov.pl — Polish government press releases | `CC-BY-SA-4.0` | 88,190 | 80.7M |
|
| 176 |
| [1000_novels](data/1000_novels/1000_novels.md) | 1000 Novels Corpus (CLARIN-PL) | `CC-BY-4.0` | 1,000 | 60.5M |
|
| 177 |
| [samorzad_gov_pl](data/samorzad_gov_pl/samorzad_gov_pl.md) | samorzad.gov.pl — Polish public-sector institutions | `CC-BY-SA-4.0` | 72,771 | 41.2M |
|
|
|
|
| 178 |
| [wikiquote](data/wikiquote/wikiquote.md) | Polish Wikiquote (quotations) | `CC-BY-SA-3.0` | 30,363 | 31.9M |
|
|
|
|
| 179 |
| [eltec_pol](data/eltec_pol/eltec_pol.md) | ELTeC-pol (European Literary Text Collection, Polish) | `CC-BY-4.0` | 100 | 21.5M |
|
| 180 |
| [wikivoyage](data/wikivoyage/wikivoyage.md) | Polish Wikivoyage (travel guides) | `CC-BY-SA-3.0` | 13,645 | 17.1M |
|
| 181 |
| [wikibooks](data/wikibooks/wikibooks.md) | Polish Wikibooks (open textbooks) | `CC-BY-SA-3.0` | 9,112 | 15.6M |
|
| 182 |
| [wikinews](data/wikinews/wikinews.md) | Polish Wikinews | `CC-BY-2.5` | 24,386 | 12.1M |
|
| 183 |
| [global_voices](data/global_voices/global_voices.md) | Global Voices Polish | `CC-BY-3.0` | 2,040 | 3.7M |
|
| 184 |
| [nkjp1m](data/nkjp1m/nkjp1m.md) | The manually annotated 1-million word subcorpus of the National Corpus of Polish | `CC-BY` | 18,381 | 2.6M |
|
| 185 |
-
|
|
|
|
|
| 186 |
|
| 187 |
## Method
|
| 188 |
Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed
|
|
|
|
| 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.6 stable** · 4,392,601 documents · **9.70B tokens**
|
| 23 |
+
> (tiktoken proxy; canonical Llama-3 count at release) · 21 sources
|
| 24 |
+
> Updated: **2026-09-05**
|
| 25 |
|
| 26 |
> **v0.3-dev experimental track** · quality/diversity workflow, source-gate
|
| 27 |
> validation and candidate-data audits. This is development work, not a released
|
| 28 |
+
> corpus version, and it does not replace the v0.2.6 stable parquets.
|
| 29 |
|
| 30 |
> **Europeana validation artifact (2026-07-10)** · a separate reproducible
|
| 31 |
> 810-document direct-ingestion sample stored under the legacy path
|
|
|
|
| 37 |
|
| 38 |
| version | status | documents | tokens | notes |
|
| 39 |
|---|---|---:|---:|---|
|
| 40 |
+
| `v0.2.6` | stable release | 4,392,601 | 9.70B | Adds `sejm_interpellations` (10th-term written Q&A). README source table now also lists already-merged `sejm_api` and `wiktionary_examples` so totals match `stats.json`. |
|
| 41 |
+
| `v0.2.5` | previous stable | 4,319,200 | 9.64B | Adds community-contributed `samorzad_gov_pl` with institution-level author attribution and a URL-bearing attribution sidecar. |
|
| 42 |
| `v0.2.4` | previous stable | 4,246,429 | 9.60B | Expanded `european_hplt_v3_pl` to WDS bins 10-5 (+1.49M docs / 2.04B tok); phone PII-scrub hardening (independent dual-lens) + cross-source dedup (zero-overlap). |
|
| 43 |
| `v0.2.3` | previous stable | 2,710,974 | 6.88B | Adds community-contributed `european_hplt_v3_pl`, `global_voices` and `nkjp1m`. |
|
| 44 |
| `v0.2.2` | previous stable | 2,579,963 | 6.36B | Added community-contributed `govpl`: 88,190 docs / 80.7M tokens. |
|
|
|
|
| 56 |
|
| 57 |
### Version details
|
| 58 |
|
| 59 |
+
#### v0.2.6 — current stable
|
| 60 |
+
|
| 61 |
+
Added `sejm_interpellations`: **25,950 documents / 28,180,895 cl100k-proxy
|
| 62 |
+
tokens** of 10th-term Sejm interpellations, written questions, and HTML
|
| 63 |
+
ministry replies. Same API and kadencja as `sejm_api`, written register
|
| 64 |
+
rather than floor speeches. PDF-only replies skipped; term 9 listed empty on
|
| 65 |
+
the API at fetch time. Header chrome stripped at fetch; `scrub_pii` already
|
| 66 |
+
on `main` (#20) ran before jsonl write.
|
| 67 |
+
|
| 68 |
+
#### v0.2.5 — previous stable
|
| 69 |
|
| 70 |
Added `samorzad_gov_pl`: **72,771 documents / 41,154,506 cl100k-proxy
|
| 71 |
tokens** from 246 Polish local public institutions and one central platform
|
|
|
|
| 155 |
|---|---|---|
|
| 156 |
| [Kacper Wikieł](https://huggingface.co/kacperwikiel) | Project maintainer; corpus curation, source and license review, release engineering, documentation, validation and reproducible build workflow. | all releases |
|
| 157 |
| [Bart Kobyliński](https://huggingface.co/bartoszkobylinski1) | Added `1000_novels`; expanded Biblioteka Nauki and Europeana ingestion with per-document license and author metadata. | `v0.2.1`, [PR #1](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/1) |
|
| 158 |
+
| [Paweł Puzio](https://huggingface.co/ppuzio) | Built `govpl`; built `sejm_interpellations` (10th-term written Q&A + HTML replies). | `v0.2.2`, [PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9); `v0.2.6` |
|
| 159 |
| [Arkadiusz Słota](https://huggingface.co/Maggio33) | Built & expanded `european_hplt_v3_pl`: HPLT v3 WDS 10+9 (PR #5) then WDS 10-5 expansion (+1,493,384 docs / 2.04B tok), modular cleaning pipeline, phone-recall PII-scrub (v12b, independent dual-lens), cross-source dedup-vs-base (zero-overlap), validation and documentation. | `v0.2.3` (PR #5), `v0.2.4` |
|
| 160 |
| [Dawid Majewski](https://huggingface.co/dawidmajewski) | Added the reviewed Global Voices Polish corpus; built `samorzad_gov_pl` with direct acquisition, institution attribution, licensing evidence, release artifact and reproducible conversion. | `v0.2.3`, [PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7); `v0.2.5` |
|
| 161 |
| [1am](https://huggingface.co/1am) | Added `nkjp1m`: the manually annotated 1-million-word NKJP subcorpus, direct fetch/build pipeline, source documentation and release artifact. | `v0.2.3`, [PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8) |
|
|
|
|
| 185 |
| [govpl](data/govpl/govpl.md) | gov.pl — Polish government press releases | `CC-BY-SA-4.0` | 88,190 | 80.7M |
|
| 186 |
| [1000_novels](data/1000_novels/1000_novels.md) | 1000 Novels Corpus (CLARIN-PL) | `CC-BY-4.0` | 1,000 | 60.5M |
|
| 187 |
| [samorzad_gov_pl](data/samorzad_gov_pl/samorzad_gov_pl.md) | samorzad.gov.pl — Polish public-sector institutions | `CC-BY-SA-4.0` | 72,771 | 41.2M |
|
| 188 |
+
| [sejm_api](data/sejm_api/sejm_api.md) | Sejm API parliamentary speeches (2023 onward) | `public-domain (official documents)` | 38,812 | 36.3M |
|
| 189 |
| [wikiquote](data/wikiquote/wikiquote.md) | Polish Wikiquote (quotations) | `CC-BY-SA-3.0` | 30,363 | 31.9M |
|
| 190 |
+
| [sejm_interpellations](data/sejm_interpellations/sejm_interpellations.md) | Sejm interpellations and written questions (10th term) | `public-domain (official documents)` | 25,950 | 28.2M |
|
| 191 |
| [eltec_pol](data/eltec_pol/eltec_pol.md) | ELTeC-pol (European Literary Text Collection, Polish) | `CC-BY-4.0` | 100 | 21.5M |
|
| 192 |
| [wikivoyage](data/wikivoyage/wikivoyage.md) | Polish Wikivoyage (travel guides) | `CC-BY-SA-3.0` | 13,645 | 17.1M |
|
| 193 |
| [wikibooks](data/wikibooks/wikibooks.md) | Polish Wikibooks (open textbooks) | `CC-BY-SA-3.0` | 9,112 | 15.6M |
|
| 194 |
| [wikinews](data/wikinews/wikinews.md) | Polish Wikinews | `CC-BY-2.5` | 24,386 | 12.1M |
|
| 195 |
| [global_voices](data/global_voices/global_voices.md) | Global Voices Polish | `CC-BY-3.0` | 2,040 | 3.7M |
|
| 196 |
| [nkjp1m](data/nkjp1m/nkjp1m.md) | The manually annotated 1-million word subcorpus of the National Corpus of Polish | `CC-BY` | 18,381 | 2.6M |
|
| 197 |
+
| [wiktionary_examples](data/wiktionary_examples/wiktionary_examples.md) | Polish Wiktionary usage examples | `CC-BY-SA-3.0` | 8,639 | 1.1M |
|
| 198 |
+
| **total** | | | **4,392,601** | **9,704.7M** |
|
| 199 |
|
| 200 |
## Method
|
| 201 |
Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed
|
artifacts/source_findings.md
CHANGED
|
@@ -680,11 +680,11 @@ designing a gate on one — two of the four were empty in every row sampled.
|
|
| 680 |
|
| 681 |
## Sejm API — interpelacje i zapytania poselskie (recheck)
|
| 682 |
|
| 683 |
-
**Investigated:** 2026-08-31
|
| 684 |
-
**Verdict:** `
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
|
| 689 |
### Enumeration — solved
|
| 690 |
|
|
|
|
| 680 |
|
| 681 |
## Sejm API — interpelacje i zapytania poselskie (recheck)
|
| 682 |
|
| 683 |
+
**Investigated:** 2026-08-31; built 2026-09-05
|
| 684 |
+
**Verdict:** `added` (term 10 only, this PR) — supersedes the 2026-08-27
|
| 685 |
+
`hold — recheck` above. The 305M estimate was terms 7–10 HTML. Term 9 listed
|
| 686 |
+
`X-Total-Count: 0` at fetch time; 7–8 were not fetched (PPC already has
|
| 687 |
+
interpellations through 2019). Shipped shard: **25,950 docs / 28,180,895 tok**.
|
| 688 |
|
| 689 |
### Enumeration — solved
|
| 690 |
|
data/sejm_interpellations/sejm_interpellations.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# sejm_interpellations
|
| 2 |
+
|
| 3 |
+
Interpelacje i zapytania pisemne z 10. kadencji Sejmu, wraz z odpowiedziami
|
| 4 |
+
ministerstw dostępnymi jako HTML.
|
| 5 |
+
|
| 6 |
+
## Dataset description
|
| 7 |
+
|
| 8 |
+
- **Source (upstream):** https://api.sejm.gov.pl/
|
| 9 |
+
- **Source documentation:** https://api.sejm.gov.pl/sejm.html
|
| 10 |
+
- **Domain:** political/written
|
| 11 |
+
- **Language:** Polish (`pl`)
|
| 12 |
+
- **License:** `public-domain (official documents)`
|
| 13 |
+
- **Created (range):** 2023-11-15, 2026-09-03
|
| 14 |
+
- **Added:** 2026-09-05
|
| 15 |
+
- **OCR:** no
|
| 16 |
+
|
| 17 |
+
## Licensing — traceable basis
|
| 18 |
+
|
| 19 |
+
Official parliamentary materials are excluded from copyright under Polish
|
| 20 |
+
Copyright Act art. 4 pkt 2
|
| 21 |
+
(https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf). Reuse of
|
| 22 |
+
public-sector information is governed by the Polish Open Data Act arts. 2(12),
|
| 23 |
+
5, 14 and 17 (https://eli.gov.pl/api/acts/DU/2023/1524/text.html). Same basis
|
| 24 |
+
as the shipped `sejm_api` shard. No Creative Commons grant is asserted.
|
| 25 |
+
|
| 26 |
+
## What the texts are
|
| 27 |
+
|
| 28 |
+
Written questions from MPs to ministers (`interpellations`,
|
| 29 |
+
`writtenQuestions`) and the ministry replies that the API serves as HTML.
|
| 30 |
+
Spoken floor speeches are **not** included — those are `sejm_api` (2023–) and
|
| 31 |
+
[#18](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/18)
|
| 32 |
+
(2011–2022). Same kadencja, different genre.
|
| 33 |
+
|
| 34 |
+
PDF-only replies (`onlyAttachment: true`) and keyless prolongation stubs are
|
| 35 |
+
skipped. Term 9 listed `X-Total-Count: 0` on both collections at fetch time
|
| 36 |
+
and is not in this shard. Terms 7–8 were not fetched (PPC already covers
|
| 37 |
+
interpellations through 2019).
|
| 38 |
+
|
| 39 |
+
## Provenance and reproducibility
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
python3 src/fetch_sejm_interpellations.py --out ~/speakleash --terms 9,10 --workers 4
|
| 43 |
+
python3 src/build_dynaword.py --sources sejm_interpellations --speakleash-dir ~/speakleash --out .
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
`src/fetch_sejm_interpellations.py` pulls HTML `/body` endpoints, strips
|
| 47 |
+
header chrome (nr / recipient / title / signatory / date) into `meta`, then
|
| 48 |
+
runs `src/scrub_pii.py` (phones → `[Telefon]`; email / PESEL / NIP / REGON /
|
| 49 |
+
IBAN → `[PII]`). Names of public officials stay. `build_dynaword.py` applies
|
| 50 |
+
the usual gates (strip, `< 200` chars, Polish diacritic ratio, exact sha1).
|
| 51 |
+
|
| 52 |
+
## Why include it
|
| 53 |
+
|
| 54 |
+
The corpus already has spoken Sejm (`parliamentary`, `sejm_api`). This adds
|
| 55 |
+
the written Q&A register for the current term: longer, formal, ministry-voiced
|
| 56 |
+
replies that do not appear in the speech shards.
|
| 57 |
+
|
| 58 |
+
## Statistics
|
| 59 |
+
|
| 60 |
+
| Measure | Value |
|
| 61 |
+
|---|---:|
|
| 62 |
+
| JSONL rows read | 26,503 |
|
| 63 |
+
| Exact duplicate texts removed | 553 |
|
| 64 |
+
| Documents published | 25,950 |
|
| 65 |
+
| Characters | 78,607,831 |
|
| 66 |
+
| Tokens (`cl100k_base` proxy) | 28,180,895 |
|
| 67 |
+
| Documents with author attribution | 25,950 |
|
| 68 |
+
|
| 69 |
+
JSONL mix before dedup: 19,413 interpellations, 3,889 written questions,
|
| 70 |
+
2,730 interpellation replies, 471 written-question replies. All term 10.
|
| 71 |
+
|
| 72 |
+
## Filters applied (build_dynaword.py)
|
| 73 |
+
|
| 74 |
+
- drop documents < 200 chars: **0**
|
| 75 |
+
- drop non-Polish (diacritic ratio): **0**
|
| 76 |
+
- exact sha1 dedup: **553**
|
| 77 |
+
- OCR alpha-ratio: **0**
|
| 78 |
+
- read 26,503 → kept 25,950
|
| 79 |
+
|
| 80 |
+
## Sample
|
| 81 |
+
|
| 82 |
+
Question (author `Daniel Milewski`):
|
| 83 |
+
|
| 84 |
+
```
|
| 85 |
+
Szanowny Panie Ministrze,
|
| 86 |
+
|
| 87 |
+
latem 2022 roku na podlaskiej części granicy z Białorusią ukończono zaporę
|
| 88 |
+
fizyczną, czyli 5,5-metrowy płot ze stalowych przęseł zwieńczony drutem
|
| 89 |
+
żyletkowym. Ogrodzenie stoi na 186 kilometrach. […]
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
Reply (author `sekretarz stanu w Ministerstwie Spraw Zagranicznych
|
| 93 |
+
Władysław Teofil Bartoszewski`):
|
| 94 |
+
|
| 95 |
+
```
|
| 96 |
+
Szanowny Panie Marszałku,
|
| 97 |
+
|
| 98 |
+
w odpowiedzi na zapytanie poselskie nr 3472 pana posła Bronisława Foltyna
|
| 99 |
+
w sprawie Instytutu Polskiego w Szwajcarii, uprzejmie informuję, co
|
| 100 |
+
następuje. […]
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
## Privacy and limitations
|
| 104 |
+
|
| 105 |
+
Regex PII scrub at fetch time is not a guarantee of zero personal data.
|
| 106 |
+
Constituency casework in interpellations can name private persons; those
|
| 107 |
+
names are left in (officials acting in capacity are not treated as PII).
|
| 108 |
+
Downstream users must review applicable privacy and source terms.
|
data/sejm_interpellations/sejm_interpellations.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a309b9300933ee772d3c8fcda7546461cbf072807ea37939b6101fc2eb33bead
|
| 3 |
+
size 27168758
|
data/sejm_interpellations/sejm_interpellations.stats.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"read": 26503,
|
| 3 |
+
"kept": 25950,
|
| 4 |
+
"drop_short": 0,
|
| 5 |
+
"drop_lang": 0,
|
| 6 |
+
"drop_dup": 553,
|
| 7 |
+
"drop_ocr": 0,
|
| 8 |
+
"chars": 78607831,
|
| 9 |
+
"tokens": 28180895,
|
| 10 |
+
"licenses": {
|
| 11 |
+
"public-domain (official documents)": 25950
|
| 12 |
+
},
|
| 13 |
+
"authors_with_value": 25950,
|
| 14 |
+
"secs": 1.8,
|
| 15 |
+
"license": "public-domain (official documents)"
|
| 16 |
+
}
|
src/build_dynaword.py
CHANGED
|
@@ -65,6 +65,12 @@ def _meta_value(row: dict, keys: tuple[str, ...], default: str = "") -> str:
|
|
| 65 |
value = _first_text(row.get(key))
|
| 66 |
if value:
|
| 67 |
return value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
return default
|
| 69 |
|
| 70 |
|
|
|
|
| 65 |
value = _first_text(row.get(key))
|
| 66 |
if value:
|
| 67 |
return value
|
| 68 |
+
nested = row.get("meta")
|
| 69 |
+
if isinstance(nested, dict):
|
| 70 |
+
for key in keys:
|
| 71 |
+
value = _first_text(nested.get(key))
|
| 72 |
+
if value:
|
| 73 |
+
return value
|
| 74 |
return default
|
| 75 |
|
| 76 |
|
src/fetch_sejm_interpellations.py
CHANGED
|
@@ -11,10 +11,12 @@ lives in meta, not text. PII regex-scrub runs before the line is written.
|
|
| 11 |
|
| 12 |
Usage:
|
| 13 |
python3 src/fetch_sejm_interpellations.py --out ~/speakleash
|
|
|
|
| 14 |
python3 src/fetch_sejm_interpellations.py --out ~/speakleash --terms 10 --max-docs 30
|
| 15 |
"""
|
| 16 |
from __future__ import annotations
|
| 17 |
import argparse, json, re, subprocess, sys, time
|
|
|
|
| 18 |
from pathlib import Path
|
| 19 |
from urllib.error import HTTPError, URLError
|
| 20 |
from urllib.request import Request, urlopen
|
|
@@ -153,6 +155,24 @@ def iter_listing(term, collection, page_size):
|
|
| 153 |
return
|
| 154 |
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
def main(argv=None) -> int:
|
| 157 |
ap = argparse.ArgumentParser()
|
| 158 |
ap.add_argument("--out", default="~/speakleash")
|
|
@@ -160,8 +180,11 @@ def main(argv=None) -> int:
|
|
| 160 |
help="comma-separated Sejm terms (default 7-10)")
|
| 161 |
ap.add_argument("--collections", default="interpellations,writtenQuestions")
|
| 162 |
ap.add_argument("--page-size", type=int, default=50)
|
|
|
|
|
|
|
| 163 |
ap.add_argument("--max-docs", type=int, default=0, help="stop after N kept rows")
|
| 164 |
args = ap.parse_args(argv)
|
|
|
|
| 165 |
|
| 166 |
terms = [int(t) for t in args.terms.split(",") if t.strip()]
|
| 167 |
collections = [c.strip() for c in args.collections.split(",") if c.strip()]
|
|
@@ -178,49 +201,76 @@ def main(argv=None) -> int:
|
|
| 178 |
pass
|
| 179 |
print(f"resume: {len(done):,} already fetched")
|
| 180 |
|
| 181 |
-
kept = seen = skipped = 0
|
| 182 |
t0 = time.time()
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
for term in terms:
|
|
|
|
|
|
|
| 185 |
for collection in collections:
|
|
|
|
|
|
|
| 186 |
print(f"term {term} {collection}", flush=True)
|
| 187 |
for item in iter_listing(term, collection, args.page_size):
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
jobs.append((True, reply))
|
| 192 |
-
for is_reply, reply in jobs:
|
| 193 |
url = body_url(term, collection, item.get("num"), reply)
|
| 194 |
seen += 1
|
| 195 |
if url in done:
|
| 196 |
continue
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
continue
|
| 203 |
-
kind = _KIND[(collection, is_reply)]
|
| 204 |
-
rec = normalize_document(
|
| 205 |
-
kind, item, raw.decode("utf-8", "replace"), reply
|
| 206 |
-
)
|
| 207 |
-
done.add(url)
|
| 208 |
-
if rec:
|
| 209 |
-
fo.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
| 210 |
-
kept += 1
|
| 211 |
-
else:
|
| 212 |
-
skipped += 1
|
| 213 |
-
if seen % 200 == 0:
|
| 214 |
-
print(f" seen {seen:,} kept {kept:,} skip {skipped:,} "
|
| 215 |
-
f"{seen / max(time.time() - t0, 1):.1f}/s", flush=True)
|
| 216 |
if args.max_docs and kept >= args.max_docs:
|
|
|
|
| 217 |
break
|
| 218 |
-
if
|
| 219 |
break
|
| 220 |
-
|
| 221 |
-
break
|
| 222 |
-
if args.max_docs and kept >= args.max_docs:
|
| 223 |
-
break
|
| 224 |
|
| 225 |
print(f"fetched {kept:,} new docs ({skipped:,} skipped); compressing...", flush=True)
|
| 226 |
subprocess.run(
|
|
|
|
| 11 |
|
| 12 |
Usage:
|
| 13 |
python3 src/fetch_sejm_interpellations.py --out ~/speakleash
|
| 14 |
+
python3 src/fetch_sejm_interpellations.py --out ~/speakleash --terms 10 --workers 4
|
| 15 |
python3 src/fetch_sejm_interpellations.py --out ~/speakleash --terms 10 --max-docs 30
|
| 16 |
"""
|
| 17 |
from __future__ import annotations
|
| 18 |
import argparse, json, re, subprocess, sys, time
|
| 19 |
+
from concurrent.futures import ThreadPoolExecutor, wait, FIRST_COMPLETED
|
| 20 |
from pathlib import Path
|
| 21 |
from urllib.error import HTTPError, URLError
|
| 22 |
from urllib.request import Request, urlopen
|
|
|
|
| 155 |
return
|
| 156 |
|
| 157 |
|
| 158 |
+
def _jobs_for_item(item):
|
| 159 |
+
jobs = [(False, None)]
|
| 160 |
+
for reply in item.get("replies") or []:
|
| 161 |
+
if should_fetch_reply(reply):
|
| 162 |
+
jobs.append((True, reply))
|
| 163 |
+
return jobs
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def _fetch_job(term, collection, item, reply):
|
| 167 |
+
url = body_url(term, collection, item.get("num"), reply)
|
| 168 |
+
raw, hdrs = _get(url)
|
| 169 |
+
if raw is None:
|
| 170 |
+
return url, None, hdrs.get("error")
|
| 171 |
+
kind = _KIND[(collection, bool(reply))]
|
| 172 |
+
rec = normalize_document(kind, item, raw.decode("utf-8", "replace"), reply)
|
| 173 |
+
return url, rec, None
|
| 174 |
+
|
| 175 |
+
|
| 176 |
def main(argv=None) -> int:
|
| 177 |
ap = argparse.ArgumentParser()
|
| 178 |
ap.add_argument("--out", default="~/speakleash")
|
|
|
|
| 180 |
help="comma-separated Sejm terms (default 7-10)")
|
| 181 |
ap.add_argument("--collections", default="interpellations,writtenQuestions")
|
| 182 |
ap.add_argument("--page-size", type=int, default=50)
|
| 183 |
+
ap.add_argument("--workers", type=int, default=4,
|
| 184 |
+
help="parallel body fetches (default 4)")
|
| 185 |
ap.add_argument("--max-docs", type=int, default=0, help="stop after N kept rows")
|
| 186 |
args = ap.parse_args(argv)
|
| 187 |
+
workers = max(1, args.workers)
|
| 188 |
|
| 189 |
terms = [int(t) for t in args.terms.split(",") if t.strip()]
|
| 190 |
collections = [c.strip() for c in args.collections.split(",") if c.strip()]
|
|
|
|
| 201 |
pass
|
| 202 |
print(f"resume: {len(done):,} already fetched")
|
| 203 |
|
| 204 |
+
kept = seen = skipped = finished = 0
|
| 205 |
t0 = time.time()
|
| 206 |
+
stop = False
|
| 207 |
+
|
| 208 |
+
def consume(fut, fo):
|
| 209 |
+
nonlocal kept, skipped, finished
|
| 210 |
+
url, rec, err = fut.result()
|
| 211 |
+
done.add(url)
|
| 212 |
+
finished += 1
|
| 213 |
+
if err:
|
| 214 |
+
skipped += 1
|
| 215 |
+
print(f" WARN skip {url} {err}", file=sys.stderr, flush=True)
|
| 216 |
+
elif rec:
|
| 217 |
+
fo.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
| 218 |
+
fo.flush()
|
| 219 |
+
kept += 1
|
| 220 |
+
else:
|
| 221 |
+
skipped += 1
|
| 222 |
+
if finished % 200 == 0:
|
| 223 |
+
print(f" seen {seen:,} kept {kept:,} skip {skipped:,} "
|
| 224 |
+
f"{finished / max(time.time() - t0, 1):.1f}/s", flush=True)
|
| 225 |
+
|
| 226 |
+
with jsonl.open("a", encoding="utf-8") as fo, \
|
| 227 |
+
ThreadPoolExecutor(max_workers=workers) as pool:
|
| 228 |
+
pending = set()
|
| 229 |
+
limit = max(workers * 4, workers)
|
| 230 |
+
|
| 231 |
+
def drain(block=False):
|
| 232 |
+
nonlocal pending
|
| 233 |
+
if not pending:
|
| 234 |
+
return
|
| 235 |
+
if block:
|
| 236 |
+
finished = pending
|
| 237 |
+
wait(finished)
|
| 238 |
+
else:
|
| 239 |
+
finished, pending = wait(pending, return_when=FIRST_COMPLETED)
|
| 240 |
+
for fut in finished:
|
| 241 |
+
if not block:
|
| 242 |
+
pending.discard(fut)
|
| 243 |
+
consume(fut, fo)
|
| 244 |
+
if block:
|
| 245 |
+
pending = set()
|
| 246 |
+
|
| 247 |
+
print(f"workers={workers}", flush=True)
|
| 248 |
for term in terms:
|
| 249 |
+
if stop:
|
| 250 |
+
break
|
| 251 |
for collection in collections:
|
| 252 |
+
if stop:
|
| 253 |
+
break
|
| 254 |
print(f"term {term} {collection}", flush=True)
|
| 255 |
for item in iter_listing(term, collection, args.page_size):
|
| 256 |
+
if stop:
|
| 257 |
+
break
|
| 258 |
+
for is_reply, reply in _jobs_for_item(item):
|
|
|
|
|
|
|
| 259 |
url = body_url(term, collection, item.get("num"), reply)
|
| 260 |
seen += 1
|
| 261 |
if url in done:
|
| 262 |
continue
|
| 263 |
+
pending.add(pool.submit(
|
| 264 |
+
_fetch_job, term, collection, item, reply,
|
| 265 |
+
))
|
| 266 |
+
if len(pending) >= limit:
|
| 267 |
+
drain()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
if args.max_docs and kept >= args.max_docs:
|
| 269 |
+
stop = True
|
| 270 |
break
|
| 271 |
+
if stop:
|
| 272 |
break
|
| 273 |
+
drain(block=True)
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
print(f"fetched {kept:,} new docs ({skipped:,} skipped); compressing...", flush=True)
|
| 276 |
subprocess.run(
|
src/make_docs.py
CHANGED
|
@@ -13,8 +13,8 @@ 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.
|
| 17 |
-
RELEASE_DATE = "2026-
|
| 18 |
CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests
|
| 19 |
|
| 20 |
# 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.6"
|
| 17 |
+
RELEASE_DATE = "2026-09-05"
|
| 18 |
CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests
|
| 19 |
|
| 20 |
# Dupochron: documented good-faith provenance + no-warranty + takedown + PII.
|
src/sources.py
CHANGED
|
@@ -101,7 +101,7 @@ SOURCES = {
|
|
| 101 |
},
|
| 102 |
"sejm_interpellations": {
|
| 103 |
"file_key": "sejm_interpellations",
|
| 104 |
-
"pretty": "Sejm interpellations and written questions (
|
| 105 |
"license": "public-domain (official documents)",
|
| 106 |
"license_spdx": "LicenseRef-Polish-Official-Documents",
|
| 107 |
"traceable": "Official parliamentary materials excluded from copyright "
|
|
@@ -110,11 +110,12 @@ SOURCES = {
|
|
| 110 |
"upstream": "https://api.sejm.gov.pl/",
|
| 111 |
"provenance": "Fetched from api.sejm.gov.pl HTML body endpoints by "
|
| 112 |
"src/fetch_sejm_interpellations.py (interpellations + "
|
| 113 |
-
"writtenQuestions,
|
| 114 |
-
"
|
|
|
|
| 115 |
"src/scrub_pii.py applied before jsonl write.",
|
| 116 |
"domain": "political/written",
|
| 117 |
-
"created": "
|
| 118 |
"is_ocr": False,
|
| 119 |
"custom_datasheet": True,
|
| 120 |
},
|
|
|
|
| 101 |
},
|
| 102 |
"sejm_interpellations": {
|
| 103 |
"file_key": "sejm_interpellations",
|
| 104 |
+
"pretty": "Sejm interpellations and written questions (10th term)",
|
| 105 |
"license": "public-domain (official documents)",
|
| 106 |
"license_spdx": "LicenseRef-Polish-Official-Documents",
|
| 107 |
"traceable": "Official parliamentary materials excluded from copyright "
|
|
|
|
| 110 |
"upstream": "https://api.sejm.gov.pl/",
|
| 111 |
"provenance": "Fetched from api.sejm.gov.pl HTML body endpoints by "
|
| 112 |
"src/fetch_sejm_interpellations.py (interpellations + "
|
| 113 |
+
"writtenQuestions, term 10). Term 9 listed empty on the "
|
| 114 |
+
"API at fetch time. Header chrome stripped into meta; "
|
| 115 |
+
"attachment-only and keyless replies skipped; "
|
| 116 |
"src/scrub_pii.py applied before jsonl write.",
|
| 117 |
"domain": "political/written",
|
| 118 |
+
"created": "2023-11-15, 2026-09-03",
|
| 119 |
"is_ocr": False,
|
| 120 |
"custom_datasheet": True,
|
| 121 |
},
|
src/test_sejm_interpellations_contract.py
CHANGED
|
@@ -1,12 +1,19 @@
|
|
| 1 |
"""TDD contract for Sejm interpellations / written-questions ingestion."""
|
|
|
|
| 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 fetch_sejm_interpellations import (
|
| 9 |
MIN_CHARS,
|
|
|
|
| 10 |
normalize_document,
|
| 11 |
should_fetch_reply,
|
| 12 |
)
|
|
@@ -115,6 +122,48 @@ class SejmInterpellationsContractTest(unittest.TestCase):
|
|
| 115 |
self.assertTrue(row["meta"]["url"].endswith("/writtenQuestions/1/body"))
|
| 116 |
self.assertEqual(row["meta"]["kind"], "written_question")
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|
| 120 |
unittest.main()
|
|
|
|
| 1 |
"""TDD contract for Sejm interpellations / written-questions ingestion."""
|
| 2 |
+
import json
|
| 3 |
import sys
|
| 4 |
import unittest
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 8 |
|
| 9 |
+
ROOT = Path(__file__).resolve().parent.parent
|
| 10 |
+
PARQUET = ROOT / "data" / "sejm_interpellations" / "sejm_interpellations.parquet"
|
| 11 |
+
STATS = ROOT / "data" / "sejm_interpellations" / "sejm_interpellations.stats.json"
|
| 12 |
+
CANON = ["id", "text", "source", "added", "created", "token_count", "license", "author"]
|
| 13 |
+
|
| 14 |
from fetch_sejm_interpellations import (
|
| 15 |
MIN_CHARS,
|
| 16 |
+
_jobs_for_item,
|
| 17 |
normalize_document,
|
| 18 |
should_fetch_reply,
|
| 19 |
)
|
|
|
|
| 122 |
self.assertTrue(row["meta"]["url"].endswith("/writtenQuestions/1/body"))
|
| 123 |
self.assertEqual(row["meta"]["kind"], "written_question")
|
| 124 |
|
| 125 |
+
def test_jobs_include_html_replies_only(self):
|
| 126 |
+
item = {
|
| 127 |
+
**ITEM,
|
| 128 |
+
"replies": [
|
| 129 |
+
{"key": "KEEP", "onlyAttachment": False},
|
| 130 |
+
{"key": "PDF", "onlyAttachment": True},
|
| 131 |
+
{"onlyAttachment": False},
|
| 132 |
+
],
|
| 133 |
+
}
|
| 134 |
+
jobs = _jobs_for_item(item)
|
| 135 |
+
self.assertEqual(jobs[0], (False, None))
|
| 136 |
+
self.assertEqual(len(jobs), 2)
|
| 137 |
+
self.assertEqual(jobs[1][1]["key"], "KEEP")
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class SejmInterpellationsParquetTest(unittest.TestCase):
|
| 141 |
+
@classmethod
|
| 142 |
+
def setUpClass(cls):
|
| 143 |
+
if not PARQUET.is_file():
|
| 144 |
+
raise unittest.SkipTest("parquet not built yet")
|
| 145 |
+
import pyarrow.parquet as pq
|
| 146 |
+
cls.tbl = pq.read_table(PARQUET)
|
| 147 |
+
cls.stats = json.loads(STATS.read_text(encoding="utf-8"))
|
| 148 |
+
|
| 149 |
+
def test_canonical_schema_and_uniform_source_license(self):
|
| 150 |
+
self.assertEqual(self.tbl.column_names, CANON)
|
| 151 |
+
src = set(self.tbl["source"].to_pylist())
|
| 152 |
+
lic = set(self.tbl["license"].to_pylist())
|
| 153 |
+
self.assertEqual(src, {"sejm_interpellations"})
|
| 154 |
+
self.assertEqual(lic, {"public-domain (official documents)"})
|
| 155 |
+
|
| 156 |
+
def test_nonempty_text_and_positive_tokens(self):
|
| 157 |
+
texts = self.tbl["text"].to_pylist()
|
| 158 |
+
toks = self.tbl["token_count"].to_pylist()
|
| 159 |
+
self.assertTrue(all(t and t.strip() for t in texts))
|
| 160 |
+
self.assertTrue(all(n > 0 for n in toks))
|
| 161 |
+
|
| 162 |
+
def test_stats_match_parquet(self):
|
| 163 |
+
self.assertEqual(self.stats["kept"], self.tbl.num_rows)
|
| 164 |
+
self.assertEqual(self.stats["tokens"], sum(self.tbl["token_count"].to_pylist()))
|
| 165 |
+
self.assertEqual(self.stats["authors_with_value"], self.tbl.num_rows)
|
| 166 |
+
|
| 167 |
|
| 168 |
if __name__ == "__main__":
|
| 169 |
unittest.main()
|