ppuzio Claude Opus 5.5 commited on
Commit
185dc3c
·
1 Parent(s): b263479

Add source: sejm_interpellations (10th-term written Q&A)

Browse files

Rebased onto main and scoped to this source per AGENTS.md: release
bookkeeping (README/CHANGELOG/VERSION), AGENTS.md, build_dynaword.py and
the stale findings drift are dropped. Fetcher and test base are main's.

- data/sejm_interpellations: 25,950 docs / 28,180,895 tokens (term 10);
datasheet carries the review answers (NERGAL release gate, inclusion
rationale, caveats) from #43.
- sources.py: entry now describes the shipped shard (10th term,
2023-11-15 – 2026-09-03, added 2026-07-19, pre-#38 regex scrub only).
- contract test: parquet schema / text / token / stats checks.
- source_findings.md: one appended entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

artifacts/source_findings.md CHANGED
@@ -578,3 +578,36 @@ prompts are user-contributed speech material).
578
  a pretraining corpus's document gate; measure the length distribution BEFORE
579
  promising the source, and keep the unit question in the PR description up
580
  front — it is the first thing a reviewer will ask.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  a pretraining corpus's document gate; measure the length distribution BEFORE
579
  promising the source, and keep the unit question in the PR description up
580
  front — it is the first thing a reviewer will ask.
581
+
582
+ ---
583
+
584
+ ## sejm_interpellations — 10th-term written Q&A (interpellations + replies)
585
+
586
+ **Investigated** — 2026-09-05 (review round 2026-09-28).
587
+
588
+ **Verdict** — `added` (proposed with `release: None`). 25,950 documents /
589
+ 28.2M `cl100k_base` tokens of written MP questions and ministry replies —
590
+ argumentative administrative prose, a register the floor-speech shards do not
591
+ carry.
592
+
593
+ **Enumeration** — `GET /sejm/term10/interpellations` and `.../writtenQuestions`
594
+ plus `/reply/{key}/body` on api.sejm.gov.pl (the endpoints the 2026-08-27
595
+ "hold — recheck" entry above could not confirm; they exist and page fine).
596
+ PDF-only replies (`onlyAttachment`) and keyless stubs skipped. Term 9 returned
597
+ `X-Total-Count: 0`; terms 7–8 skipped (PPC covers through 2019).
598
+
599
+ **License evidence** — same basis as `sejm_api`: Copyright Act art. 4(2)
600
+ (<https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf>) + Open Data Act
601
+ arts. 2(12), 5, 14, 17 (<https://eli.gov.pl/api/acts/DU/2023/1524/text.html>).
602
+ No CC grant claimed.
603
+
604
+ **Blockers** — none to merge with `release: None`. Before release: **NERGAL
605
+ pass** — interpellations name private constituents (constituent letters and
606
+ citizen cases are quoted in questions), which is exactly the case the old
607
+ `scrub_pii` (#20) could not cover and #38 moved out of this repo. Caveats for
608
+ the card: single term (10th), private citizens named.
609
+
610
+ **Lesson** — the header chrome (nr / recipient / title / signatories / date)
611
+ belongs in meta, not text: stripping it makes the body comparable across
612
+ question and reply docs, and the before/after is the fastest reviewer evidence
613
+ for any Sejm HTML source.
data/sejm_interpellations/sejm_interpellations.md ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 pattern PII redaction (the `scrub_pii` pass from #20 at build time —
49
+ phones → `[Telefon]`; e-mail / PESEL / NIP / REGON / IBAN → `[PII]`). That
50
+ in-repo scrubber was removed in #38; PII now goes through
51
+ [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL) and **this shard
52
+ must be re-run through NERGAL before it is admitted to a release** (it quotes
53
+ constituency casework naming private persons). Names of public officials stay.
54
+ `build_dynaword.py` applies the usual gates (strip, `< 200` chars, Polish
55
+ diacritic ratio, exact sha1).
56
+
57
+ ## Why include it
58
+
59
+ The corpus already has spoken Sejm (`parliamentary`, `sejm_api`). This adds
60
+ the written Q&A register for the current term: longer, formal, ministry-voiced
61
+ replies that do not appear in the speech shards — the argumentative
62
+ question/answer pair is a document type the corpus otherwise lacks entirely.
63
+ Caveats for downstream users: single term (10th, 2023-11-15 – 2026-09-03), and
64
+ interpellations quote constituency casework that can name private citizens (see
65
+ Privacy below — a NERGAL pass is a release gate).
66
+
67
+ ## Statistics
68
+
69
+ | Measure | Value |
70
+ |---|---:|
71
+ | JSONL rows read | 26,503 |
72
+ | Exact duplicate texts removed | 553 |
73
+ | Documents published | 25,950 |
74
+ | Characters | 78,607,831 |
75
+ | Tokens (`cl100k_base` proxy) | 28,180,895 |
76
+ | Documents with author attribution | 25,950 |
77
+
78
+ JSONL mix before dedup: 19,413 interpellations, 3,889 written questions,
79
+ 2,730 interpellation replies, 471 written-question replies. All term 10.
80
+
81
+ ## Filters applied (build_dynaword.py)
82
+
83
+ - drop documents < 200 chars: **0**
84
+ - drop non-Polish (diacritic ratio): **0**
85
+ - exact sha1 dedup: **553**
86
+ - OCR alpha-ratio: **0**
87
+ - read 26,503 → kept 25,950
88
+
89
+ ## Sample
90
+
91
+ Question (author `Daniel Milewski`):
92
+
93
+ ```
94
+ Szanowny Panie Ministrze,
95
+
96
+ latem 2022 roku na podlaskiej części granicy z Białorusią ukończono zaporę
97
+ fizyczną, czyli 5,5-metrowy płot ze stalowych przęseł zwieńczony drutem
98
+ żyletkowym. Ogrodzenie stoi na 186 kilometrach. […]
99
+ ```
100
+
101
+ Reply (author `sekretarz stanu w Ministerstwie Spraw Zagranicznych
102
+ Władysław Teofil Bartoszewski`):
103
+
104
+ ```
105
+ Szanowny Panie Marszałku,
106
+
107
+ w odpowiedzi na zapytanie poselskie nr 3472 pana posła Bronisława Foltyna
108
+ w sprawie Instytutu Polskiego w Szwajcarii, uprzejmie informuję, co
109
+ następuje. […]
110
+ ```
111
+
112
+ ## Privacy and limitations
113
+
114
+ Regex PII scrub at fetch time is not a guarantee of zero personal data.
115
+ Constituency casework in interpellations can name private persons; those
116
+ names are left in (officials acting in capacity are not treated as PII).
117
+ Downstream users must review applicable privacy and source terms. Per
118
+ AGENTS.md the shard must be re-run through
119
+ [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL) before release;
120
+ merge with `release: None` is fine meanwhile.
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/sources.py CHANGED
@@ -143,9 +143,10 @@ SOURCES = {
143
  "is_ocr": False,
144
  },
145
  "sejm_interpellations": {
 
146
  "release": None,
147
  "file_key": "sejm_interpellations",
148
- "pretty": "Sejm interpellations and written questions (terms 7–10)",
149
  "license": "public-domain (official documents)",
150
  "license_spdx": "LicenseRef-Polish-Official-Documents",
151
  "traceable": "Official parliamentary materials excluded from copyright "
@@ -154,11 +155,12 @@ SOURCES = {
154
  "upstream": "https://api.sejm.gov.pl/",
155
  "provenance": "Fetched from api.sejm.gov.pl HTML body endpoints by "
156
  "src/fetch_sejm_interpellations.py (interpellations + "
157
- "writtenQuestions, terms 7–10). Header chrome stripped into "
158
  "meta; attachment-only and keyless replies skipped; "
159
- "PII via SlayerLab/NERGAL, not this repo.",
 
160
  "domain": "political/written",
161
- "created": "2011-11-08, 2026-09-04",
162
  "is_ocr": False,
163
  "custom_datasheet": True,
164
  },
 
143
  "is_ocr": False,
144
  },
145
  "sejm_interpellations": {
146
+ "added": "2026-07-19",
147
  "release": None,
148
  "file_key": "sejm_interpellations",
149
+ "pretty": "Sejm interpellations and written questions (10th term)",
150
  "license": "public-domain (official documents)",
151
  "license_spdx": "LicenseRef-Polish-Official-Documents",
152
  "traceable": "Official parliamentary materials excluded from copyright "
 
155
  "upstream": "https://api.sejm.gov.pl/",
156
  "provenance": "Fetched from api.sejm.gov.pl HTML body endpoints by "
157
  "src/fetch_sejm_interpellations.py (interpellations + "
158
+ "writtenQuestions, --terms 10). Header chrome stripped into "
159
  "meta; attachment-only and keyless replies skipped; "
160
+ "pre-#38 regex PII scrub only — needs a SlayerLab/NERGAL "
161
+ "pass before release.",
162
  "domain": "political/written",
163
+ "created": "2023-11-15, 2026-09-03",
164
  "is_ocr": False,
165
  "custom_datasheet": True,
166
  },
src/test_sejm_interpellations_contract.py CHANGED
@@ -1,10 +1,16 @@
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,
@@ -116,5 +122,34 @@ class SejmInterpellationsContractTest(unittest.TestCase):
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
  normalize_document,
 
122
  self.assertEqual(row["meta"]["kind"], "written_question")
123
 
124
 
125
+
126
+ class SejmInterpellationsParquetTest(unittest.TestCase):
127
+ @classmethod
128
+ def setUpClass(cls):
129
+ if not PARQUET.is_file():
130
+ raise unittest.SkipTest("parquet not built yet")
131
+ import pyarrow.parquet as pq
132
+ cls.tbl = pq.read_table(PARQUET)
133
+ cls.stats = json.loads(STATS.read_text(encoding="utf-8"))
134
+
135
+ def test_canonical_schema_and_uniform_source_license(self):
136
+ self.assertEqual(self.tbl.column_names, CANON)
137
+ src = set(self.tbl["source"].to_pylist())
138
+ lic = set(self.tbl["license"].to_pylist())
139
+ self.assertEqual(src, {"sejm_interpellations"})
140
+ self.assertEqual(lic, {"public-domain (official documents)"})
141
+
142
+ def test_nonempty_text_and_positive_tokens(self):
143
+ texts = self.tbl["text"].to_pylist()
144
+ toks = self.tbl["token_count"].to_pylist()
145
+ self.assertTrue(all(t and t.strip() for t in texts))
146
+ self.assertTrue(all(n > 0 for n in toks))
147
+
148
+ def test_stats_match_parquet(self):
149
+ self.assertEqual(self.stats["kept"], self.tbl.num_rows)
150
+ self.assertEqual(self.stats["tokens"], sum(self.tbl["token_count"].to_pylist()))
151
+ self.assertEqual(self.stats["authors_with_value"], self.tbl.num_rows)
152
+
153
+
154
  if __name__ == "__main__":
155
  unittest.main()