Datasets:
sejm_api_2011_2022: relabel provenance, drop speeches contained in parliamentary / sejm_api (118,902 -> 32,460)
What and why
Rights audit v0.2.6, tracker slayerlabs/polish-dynaword-v2#57. sejm_api_2011_2022 (release: None, stays None) is the contributor snapshot PiotrSty/sejm-speeches-corpus@v1.0.1 (commit 124557799608ce4212cf22fa90ca7904618de1b6). The audit found two problems:
- The registry, card and NOTICE described the data as fetched from the official Sejm API. It is a Hugging Face snapshot, and every
source_urlis a day-levelhttps://api.sejm.gov.pl/sejm/term{N}/videos/{date}listing (all 32,460 sidecar rows match), not a per-speech URL. Wording is corrected; a contract test pins the URL pattern. - The source re-publishes text that
parliamentary(released 0.2.0) already ships. This PR drops those speeches with a committed script,src/clean_sejm_api_2011_2022.py.
Admission still waits for the NERGAL pass (polish-dynaword-v2#60); whether parliamentary is withdrawn or loses its committee slice is polish-dynaword-v2#54, which this PR does not decide. The overlap is reported per reference source and per slice so the effect of each outcome can be read below.
Before -> after
| before (main 3bab9f9) | after | |
|---|---|---|
| documents | 118,902 | 32,460 |
| chars | 361,275,710 | 81,385,172 |
| tokens (cl100k_base proxy) | 135,072,403 | 30,766,807 |
| parquet sha256 | 606d49ab...a756c1 | 8fad4b4eab069fb8a652f9dc6a2e7dbc8f49d1e1b6bfae0decd2b318d160a20a |
Of the 157,714 read, 38,812 are outside the date window (unchanged, drop_after_end) and 86,442 are dropped here (drop_cross_source_dup). 118,902 - 86,442 = 32,460.
Rule: cross-source containment (86,442 dropped)
Drop a speech when one document of a pinned reference set holds >= 0.5 of the speech's 5-word shingles. Containment = |S(speech) & S(ref)| / |S(speech)|, one-directional, shingles over NFKC-casefolded \w+ tokens (the tokenisation of the repo's near-dedup; src/shingle_containment.py is byte-identical to the copy in Hub PR #67). The "Przebieg posiedzenia ... (dd-mm-yyyy) [N punkt porządku dziennego ...]" headers the snapshot interleaves with speeches are stripped from speeches and references before shingling; on 14,090 mid-text headers the title end was exact in 98.7%, too short in 0.9%, too long in 0.4%.
- Reference set: every Parquet whose registry
releaseis notNone:parliamentary(0.2.0) andsejm_api(0.2.5).parlamint_plwas removed from the registry in Hub PR #54 and has no data, so it is not a reference. The script asserts each reference has a release. - Pins:
REFERENCESin the script holds the sha256 of each reference Parquet (parliamentary 64b94993...c60488c8, sejm_api 56f7b034...a81cf161) and of the three input files. A mismatch aborts the build before anything is written. Outputs are written atomically and the stats arithmetic is checked. - Exact search, no MinHash/LSH: speeches are indexed by their rarest shingles (prefix filter, exact by pigeonhole), references are streamed by row group, every candidate is scored on full shingle sets. No sampling error. A synthetic brute-force comparison is in the contract test.
- Speeches under 5 words have no shingles and are never dropped (271).
- Another 899 speeches score 0.3-0.5 and are kept.
sejm_api_2011_2022.decisions.jsonl(new, 26.0 MB, LFS, 87,341 lines = 86,442 drops + 899 kept) lists every speech scoring >= 0.3 with its best score per reference group, so any #54 outcome can be recomputed without rerunning the build.- Determinism: a second run from the pinned inputs gave byte-identical parquet, attribution, stats and decisions files.
Overlap per reference source and slice (of 118,902 speeches; a speech can match several slices)
| Reference set | Dropped |
|---|---|
parliamentary + sejm_api (this build) |
86,442 |
parliamentary, all slices |
86,417 |
parliamentary, plenary slice alone |
48,660 |
parliamentary, committee slice alone |
38,539 |
parliamentary, interpellation question / reply / other alone |
190 / 47 / 143 |
sejm_api alone (#54 outcome A: parliamentary withdrawn) |
216 |
sejm_api + parliamentary without its committee slice (#54 outcome B) |
48,833 |
Outcome A leaves 118,686 speeches (216 dropped); outcome B leaves 70,069 (48,833 dropped); this build, which assumes parliamentary ships unchanged, leaves 32,460.
By best group among the 86,442 drops: plenary 48,270, committee 38,083, other 52, interpellation question 2, sejm_api 35.
By year: 86,272 of the drops are dated 2011-2019 and 170 are dated 2020-2022. Kept per year 2011-2019: 1, 10, 36, 36, 78, 187, 130, 78, 1,141; 2020/2021/2022: 7,632 / 9,997 / 13,134.
By speech size (5-word shingles): <10: 1,236; 10-19: 1,177; 20-49: 3,153; 50-199: 35,360; >=200: 45,516.
The slice split is not reliable. The slices come from the audit's heuristic classifier (ppc_classify.py, unvalidated, polish-dynaword-v2#54), mirrored in the script as ppc_slice. In a 20-pair hand check, 10 of the 11 references it labelled "committee" were plenary sittings (heads like "(Początek posiedzenia ...) (Na posiedzeniu przewodniczą marszałek Sejmu ...)"); one was a genuine committee. So outcome B is the number that classifier gives, not a count of committee transcripts. The classifier regexes were compared with the audit's file by hand once; the audit file is not in the Hub repo.
Hand check: 20 boundary pairs (containment 0.3-0.7)
Seeded sample (random.Random(20261006)) of 10 pairs from the 0.3-0.5 pool (899, kept) and 10 from the 0.5-0.7 pool (2,005, dropped), read against the reference document. A pair counts as a true duplicate when the speech's own wording (not a stock phrase, a stage direction used at other sittings, a report template or a quotation) appears in the reference.
- 0.3-0.5 (kept): 4 of 10 are true duplicates (interjection fragments from the matched sitting; dates 2013-2018). They stay in the data, since the threshold is 0.5. The 6 that are not: chair formulas (1), report templates (2, one against a
sejm_apireference), a quotation of a 2013 speech (1), "Wicemarszałek wyłącza mikrofon ..." stage directions (2). All 6 are dated 2020 or later. - 0.5-0.7 (dropped): 10 of 10 are true duplicates, longest verbatim runs 26-138 words. One of them (2021) is reuse of a bill's justification that was read at a committee first reading, i.e. text reuse and not the same speech.
Overall 14 of 20. Nine of the 10 dropped pairs are dated 2011-2019, so they say little about the 2020+ drops; see the next section.
Known false positives (not fixed here)
The spec has no size floor, so none was applied. Of the 170 drops dated 2020 or later, 78 have <10 shingles, 21 have 10-19, 6 have 20-49 and 65 have >=50. In a random 12 of the 170, 9 were stock phrases or stage directions, 2 were report templates (0.50-0.58) and 1 was real reuse (0.90 verbatim). So about 100 post-2019 short drops are probably false positives. Of the 65 with >=50 shingles, only two were read; the rest are unverified. Recommendation: add a minimum-shingles or date guard before this source is admitted; the decisions file has what is needed to size it.
Other limits: containment is against single reference documents, not a union, so a speech split across two reference documents can be missed; unnumbered agenda titles ("Oświadczenia.") are not stripped from the header text.
If #54 changes parliamentary
The reference set must be re-pinned and the script re-run. The pinned parliamentary Parquet (sha256 64b94993...) is the 0.2.0 file. If #54 withdraws it or removes its committee slice, edit REFERENCES in src/clean_sejm_api_2011_2022.py, restore the inputs (command in the script docstring: git checkout 3bab9f9 -- data/sejm_api_2011_2022/sejm_api_2011_2022.{parquet,attribution.jsonl,stats.json}) and rerun. The committed output follows from the pinned inputs only, and a contract test checks that.
Provenance and licence
- Registry (
src/sources.py), card and NOTICE: "Sejm API data via contributor snapshot": text fromPiotrSty/sejm-speeches-corpus@v1.0.1(commit 1245577), not fetched from the live API by SlayerLab. The registrycreatedvalue now reads "2011-12-14, 2022-12-14" (the actual range). - Licence basis unchanged: Polish official documents, Art. 4 copyright-exclusion basis (not a CC licence). The API documents no licence; whether the www.sejm.gov.pl terms reach API output is unverified.
- Live-API spot check: see the section below. The API offers per-speech URLs;
source_urlstays day-level. - NERGAL did not run;
release: Nonestays (polish-dynaword-v2#60). src/fetch_sejm_api_2011_2022.pyis deliberately not edited:artifacts/sejm_api_2011_2022_ontology_manifest.jsonpins itscode_sha256. A rebuild with it would restore the old wording and 118,902 rows. The manifest test now compares the manifest with the pre-dedup input pins (clean.INPUT_SHA256) instead of the shipped files.
Live-API spot check (20 rows)
Result: 4 match, 16 mismatch, 0 not found. The API needed no key and showed no terms prompt.
Method. Read-only GETs on https://api.sejm.gov.pl, 0.4 s apart, run on 2026-10-06. Rows: random.Random(20261006).sample(range(32460), 20) over the parquet in this PR (32,460 rows, file order); speaker and date from the attribution sidecar. Term mix: all 20 rows are from term 9 (2019-11-21 to 2022-11-04); none is from terms 7-8, which hold the 597 rows dated before 2019-11-12 (the API lists those terms; I sampled none). Per row: /sejm/term{N}/proceedings gives the proceeding that lists the date, .../proceedings/{p}/{date}/transcripts lists its statements, .../transcripts/{num} returns one statement as HTML. Candidates were tried in this order: statements with the same speaker name, the chair ("Marszałek"), then every statement of the day. API text = the <p> paragraphs of the page without the agenda title (p.punkt-tytul) and p.marsz label paragraphs. Normalisation: Unicode NFC, whitespace collapsed, redaction tokens such as [EMAIL] treated as wildcards (none of the 20 rows has one). match = our whole text occurs verbatim in an API statement; mismatch = it does not (the best-overlapping statement is reported); not found = no statement of that day overlaps. The scripts are scratch files, not in the repository.
Rows. API statement = term/proceeding/statement number, URL https://api.sejm.gov.pl/sejm/term{N}/proceedings/{proceeding}/{date}/transcripts/{num}.
| row | date | speaker | chars | API statement | result | note |
|---|---|---|---|---|---|---|
| 1052 | 2019-11-21 | Krystyna Skowrońska | 1,213 | term9/1/92 | mismatch | trailer; plus API has '(Oklaski)' that our text lacks |
| 2664 | 2020-02-12 | Janusz Korwin-Mikke | 3,648 | term9/5/11 | mismatch | trailer; text before it = whole statement |
| 6459 | 2020-09-16 | Sprawozdawca Radosław Fogiel | 1,369 | term9/17/229 | mismatch | trailer; text before it = whole statement |
| 7641 | 2020-11-18 | Sprawozdawca Anna Paluch | 435 | term9/21/121 | match | verbatim segment of the API statement (no trailer) |
| 9390 | 2021-01-21 | Konrad Frysztak | 1,196 | term9/25/20 | mismatch | trailer; text before it = whole statement |
| 9459 | 2021-01-21 | Katarzyna Lubnauer | 1,806 | term9/25/113 | match | verbatim segment of the API statement (no trailer) |
| 16213 | 2021-10-28 | Konrad Berkowicz | 1,121 | term9/40/21 | mismatch | trailer; text before it = whole statement |
| 16705 | 2021-10-29 | Grzegorz Braun | 726 | term9/40/166 | match | verbatim segment of the API statement (no trailer) |
| 17154 | 2021-11-16 | Krzysztof Gawkowski | 1,152 | term9/42/268 | mismatch | trailer; text before it = whole statement |
| 17194 | 2021-11-16 | Krzysztof Szulowski | 1,216 | term9/42/304 | mismatch | trailer; text before it = whole statement |
| 17855 | 2021-12-01 | Mirosław Suchoń | 491 | term9/43/199 | mismatch | trailer; text before it = one segment of statement |
| 18318 | 2021-12-08 | Monika Falej | 2,580 | term9/43/172 | mismatch | trailer; text before it = whole statement |
| 20492 | 2022-02-23 | Mirosław Suchoń | 2,959 | term9/49/47 | match | verbatim segment of the API statement (no trailer) |
| 22086 | 2022-04-07 | Michał Gramatyka | 1,421 | term9/52/59 | mismatch | trailer; text before it = whole statement |
| 23225 | 2022-05-12 | Jarosław Rzepa | 1,300 | term9/54/177 | mismatch | trailer; text before it = whole statement |
| 24761 | 2022-06-23 | Sprawozdawca Anna Milczanowska | 737 | term9/57/65 | mismatch | trailer; text before it = whole statement |
| 24884 | 2022-07-06 | Piotr Król | 3,940 | term9/58/8 | mismatch | trailer; text before it = whole statement |
| 25656 | 2022-07-20 | Piotr Kaleta | 620 | term9/59/157 | mismatch | trailer; text before it = one segment of statement |
| 28161 | 2022-09-29 | Janusz Korwin-Mikke | 2,839 | term9/62/216 | mismatch | trailer; text before it = whole statement |
| 30053 | 2022-11-04 | Bożena Żelazowska | 2,768 | term9/65/162 | mismatch | trailer; text before it = whole statement |
What the mismatches are. All 16 share one cause: our text ends with a trailer that the API statement does not contain. The trailer starts with "Przebieg posiedzenia" (the text of the page's <a class="przebieg"> link) and continues with the name, page title, date and agenda-item title of the next statement; in all 16 rows the name is the speaker of statement num+1 in the API listing. With the trailer cut off, our text equals the whole API statement in 13 rows and is one verbatim segment of it in 2 rows (a statement page can hold several speakers' paragraphs, introduced by label paragraphs such as "Wicemarszałek Ryszard Terlecki:"; a row is one segment without its label). In 1 row (row 1052) the API statement also has one "(Oklaski)" that our text lacks, directly before another parenthetical; I cannot tell whether the snapshot lost it or the API changed after the snapshot. The 4 matching rows are non-final segments of multi-speaker statements (a further segment follows in the API statement); they carry no trailer, which is why they match.
How common the trailer is. A regex over the whole parquet ("Przebieg posiedzenia", then up to 300 characters, then "N. kadencja, M. posiedzenie, K. dzień") matches in 28,033 of 32,460 rows (86.4%). The text from the marker to the end of the row is 20,669,063 of 81,385,172 characters (25.4%). In 2,101 rows it is over 1,000 characters (largest 48,070); in the one long example I read, it continues from the agenda title into what reads as speech text, and I did not check whether that text is also another row. Rows dated 2011-2014: 0 of 83.
What this PR does about it. No row changes. The containment above strips the header itself before shingling (HEADER in src/clean_sejm_api_2011_2022.py), but not any speech text that follows the header inside the same row, and the header names the next statement's speaker, not the row's (16 of 16 mismatching rows above). I did not measure whether the long-trailer rows change a drop decision. The 2020+ short-phrase drops are unchanged by this check.
Per-speech URLs. The API has them (the pattern above). source_url in the data is the day-level /sejm/term{N}/videos/{date} listing, which carries no proceeding or statement number, so the 20 rows could only be mapped to a statement by text search; one statement can hold several rows (segments). No row or URL is changed here.
Limits. 20 rows per source is a spot check; it does not bound a rate. The API was read in October 2026 and the snapshot is v1.0.1, so a difference can be a later API edit as well as a snapshot artefact.
Files
artifacts/source_findings.md, data/sejm_api_2011_2022/{NOTICE.md, sejm_api_2011_2022.md, .parquet, .attribution.jsonl, .stats.json, .decisions.jsonl}, src/sources.py, src/clean_sejm_api_2011_2022.py (new), src/test_sejm_api_2011_2022_contract.py. Also src/shingle_containment.py and src/test_shingle_containment.py: byte-identical copies of the files in Hub PR #67, added so the script has the tokenisation; they merge cleanly if #67 lands first.
Not touched, to fix in the release commit: README.md (lines 75, 173, 246), CHANGELOG.md (15, 112) and src/make_docs.py (285, 383) still say 118,902 docs / 135.1M tokens and "official Sejm API".
Tests
python -m pytest -q from the repo root:
- before (main 3bab9f9): 21 failed, 261 passed, 7 errors
- after: 21 failed, 276 passed, 7 errors
The failure and error sets are identical (28 lines each; govpl, sejm_interpellations and others, unrelated to this PR). The 15 new passes: pin check for inputs and references, fail-closed build that writes nothing on mismatch, shipped files follow from the pinned inputs, synthetic containment boundaries (exactly 0.5 dropped, 0.4 reported but kept), search vs brute force with tie-breaking, header stripping, slice labels, a synthetic end-to-end build, refusal of an unreleased reference, registry/card wording, day-level URL pattern.
Sample (python3 src/render_sample.py data/sejm_api_2011_2022/sejm_api_2011_2022.parquet -n 3)
id: sejm_api_2011_2022_0ec971834464ba925f3423e8f27f35392ca49f930f384f82feeda1ff74ceb109
source: sejm_api_2011_2022
added: 2026-08-31
created: 2020-01-23
token_count: 1996
license: public-domain (official documents)
author: Marszałek
Proszę państwa, naprawdę w takim harmiderze nie słychać kompletnie nic. Panie pośle, proszę usiąść na miejsce. Były pytania... (Poseł Sławomir Nitras: Ale na które pytanie odpowiada pan minister?) (Głos z sali: Pani Kidawy-Błońskiej.) Proszę posłuchać, to pan usłyszy, panie pośle. Panie ministrze, proszę. Sekretarz Stanu w Ministerstwie Sprawiedliwości Michał Wójcik: Szanowni Państwo! Niech naród posłucha, dlaczego krzyczycie. (Głos z sali: Mają zdrowie.) Przechodzę do mafii lekowej. (Głos z sali: Niech pan nie krzyczy.) Co zrobiliście kilka miesięcy przed przejęciem przez nas władzy? Zmieniliście przepisy ustawy. Karami administracyjnymi chcieliście z mafiami walczyć. Przecież oni się śmiali z tego. Wykorzystali prezent od was, kiedy wy rządziliście. To właśnie my przygotowaliśmy zmiany […]
id: sejm_api_2011_2022_7c5a37a22b50d9b419a68097491b05b089c1ea3bc27641a07f8d20a353af69ed
source: sejm_api_2011_2022
added: 2026-08-31
created: 2022-07-20
token_count: 287
license: public-domain (official documents)
author: Maria Kurowska
Panie Marszałku! Wysoka Izbo! Europejska polityka klimatyczna, której nasza opozycja jest tak wielką zwolenniczką, umiera na naszych oczach, a ludzie i gospodarka zaczynają mieć wielkie problemy. Dotyczy to również Polski. Uważam, że przedstawiony projekt jest dobrym projektem, a to dlatego, że nie pozostawia tych, którzy mają najmniej pieniędzy, borykają się... (Poseł Jakub Rutnicki: A mieszkanie w spółdzielniach...) ...z problemami finansowymi, samych. Nie mówimy: taki jest klimat, nie mówimy: mogliście się ubezpieczyć, tylko realnie pomagamy. (Gwar na sali) (Głos z sali: Zbieraj chrust.) Rząd stara się reagować na to wszystko, co się dzieje w polityce polskiej, i pomaga ludziom. (Głos z sali: Brawo!) (Poseł Jakub Rutnicki: Nie jedz, zbieraj chrust.)
id: sejm_api_2011_2022_f7a6f5a267e6cccb3b9bf69a72e74ceefa52f4c784372f4e40d15f2e4f68b3a1
source: sejm_api_2011_2022
added: 2026-08-31
created: 2022-09-16
token_count: 1000
license: public-domain (official documents)
author: Mirosław Suchoń
Bardzo uprzejmie dziękuję. Szanowny Panie Marszałku! Panie Ministrze! Wysoka Izbo! Mam zaszczyt przedstawić stanowisko Koła Parlamentarnego Polska 2050 w sprawie rządowego projektu ustawy o ratyfikacji Porozumienia między Rzecząpospolitą Polską a Republiką Austrii o wygaśnięciu skutków prawnych artykułu 11 ustęp 3 Umowy między Polską Rzecząpospolitą Ludową a Republiką Austrii w sprawie popierania i ochrony inwestycji, sporządzonej w Wiedniu dnia 24 listopada 1988 r. Szanowni Państwo! Jak mówi sam tytuł ustawy, umowa o ochronie inwestycji została zawarta jeszcze za czasów PRL-u w 1988 r. i miała znaczenie dla prowadzenia inwestycji, zwłaszcza zagranicznych inwestycji w Polsce, ale na zasadach równości obejmowała również polskie inwestycje w Austrii. Oczywiście te umowy zawierane z wieloma […]
🤖 Generated with Claude Code
refs/pr/76 ref