sejm_api: speaker allowlist for plenary sittings (v2#99)

#158
by ppuzio - opened
Commit history is no longer available for this pull request.
Fabryka AI org

Applies the parliamentary / sejm_committee_transcripts speaker allowlist to the plenary speeches of sejm_api (v2#99). A content change: 123 rows (615,478 characters) leave the source. You decide it at the merge. The same filter for sejm_api_2011_2022 is a second PR; merge this one first (see the end).

What it does. A row stays when its speaker held an allowed role on that sitting day: MPs and senators, government members, organs acting in office, chancellery staff. External experts and guests go (initiative representatives, agency heads, prosecutors, the President's Chancellery, a foreign parliament's speaker). Texts attached to the sitting record but not spoken ("tekst niewygłoszony") are judged by their speaker like spoken ones. The rules are not copied: src/sejm_api_speakers.py imports classify_speaker and the member rules of parliamentary.

  • data/sejm_api/sejm_api.speaker-filter.csv: one decision per (speaker, term, day), 21,904 keys, pinned by SHA-256 in src/clean_sejm_api.py; a key without a decision, or a changed table, stops the build. Written offline from the PPC TEI plenary headers (terms 7-10 to 2025-04-24) and the sejm_committee_transcripts speaker list (allow-only evidence). Regenerate: python3 src/sejm_api_speakers.py --dump <ppc dump> --inputs <sidecars>.
  • Order of the decision: bare "Marszałek" kept; no evidence in the term dropped; same-day evidence; MP or senator elsewhere in the term kept; nearest day with evidence (a tie with a refused role drops).
  • Card: new "Speaker allowlist" section and statistics row; stats.json gains drop_speaker and speaker_filter (per rule, basis, group, role).

Result. 39,899 → 39,776 rows, 83,482,628 → 82,867,150 characters, 30,860,439 → 30,637,660 tokens (0.3% of the rows, 0.7% of the characters).

Dropped Rows Characters Example
No role evidence (name in no source, or a sentence fragment read as a speaker) 58 205,466 "Robert Brochocki" 2026-05-13; "finansów przedłożył dwie kandydatury na szefa Rady Fiskalnej"
Legislative-initiative representatives 35 234,811 Przedstawiciel Komitetu Inicjatywy Ustawodawczej, 2024-02-09
Agencies and other bodies 18 100,035 Pierwszy Zastępca Prezesa NBP 2025-07-24; Wiceprezes UOKiK 2025-11-06; Prezes UODO 2024-01-26
President's Chancellery 9 59,216 Sekretarz Stanu w Kancelarii Prezydenta RP, 2023-06-16
Prosecution 2 4,927 Zastępca Prokuratora Generalnego, 2023-03-09
Foreign parliament 1 11,023 Przewodniczący Rady Najwyższej Ukrainy, 2023-05-25

By basis: same-day evidence 59 rows (358,434 characters), nearest day 6 (51,578), none 58 (205,466). Kept by basis: day 22,542, member 16,366, nearest 574, role_only 294.

Measured (hand labels by one labeller, Claude; seed 20261019; findings in artifacts/source_findings.md).

  • Kept: 120 rows read, 30 per basis; 0 guests. Upper 95% limit of the guest share 3.1%. After 2025-04-24 (23,702 rows) the evidence is the committee list alone: 81 of the 120 rows, 0 guests, upper limit 4.5%.
  • Dropped: all 123 read. 34 guests (239,557 characters, intended); 50 officials the allowlist does not name (262,885; mostly the President's Chancellery and agency heads); 39 misses (113,036 characters, 0.1% of the rows): MPs or government members. 32 had no role evidence (an MP named Gut-Mostowy, 7 rows; Brochocki, 3; a garbled Marshal label, 1; 21 sentence fragments), 4 hold offices the shared rule table lacks (Minister do Spraw Społeczeństwa Obywatelskiego 2, Zastępca Szefa KPRM 2), 3 are MPs speaking for a citizens' initiative (dropped by the label's role, as in parliamentary).
  • Not caught: 30 kept rows (267,755 characters) hold the label line of a refused-role speaker inside another speaker's row (11 are the chair's); the filter works on the speaker of a row.
  • Not established: the labels are one labeller's and no human checked a subsample; the 58 none rows could be resolved from the Sejm API (not fetched).

sejm_api_2011_2022 in this PR (no filter). sejm_api is a pinned reference of its dedup, so the builder is re-pinned to the new parquet (462c63b8…) and the data rebuilt: 3 more rows are published (34,598 → 34,601; Wiewiórowski 2014-08-29, Bielak-Jomaa 2015-04-22, Nowak 2019-05-16; all three contained in one sejm_api document that this PR removes), drop_cross_source_dup 92,369 → 92,366, tokens 28,712,009 → 28,712,340. The card and sources.py follow. The filter PR for that source drops the same 3 rows again, so its kept set (33,930 rows) is the same under either pin.

Merge order. Merge this PR first. The sejm_api_2011_2022 PR then needs its sejm_api pin bumped to 462c63b8… and a rebuild (kept set unchanged, dedup and speaker counts shift as above); both touch the 2011_2022 data files, the card, the builder and the sources.py provenance line, so whichever merges second is rebuilt.

Left out. README, CHANGELOG and totals (release commit); PAPER.md (the document and token counts of both sources, the allowlist description and the speaker-filter step need updating there). Rule gaps above (offices, plenipotentiaries) are a follow-up in the shared rules, which also touch the committee transcripts and parliamentary.

Tests: src/test_sejm_api_speakers.py (20; kept and dropped labels, every decision basis, fail-closed on a missing key and a changed table), test_sejm_api_contract.py extended (filter report sums to the dropped rows and to the stats, card figures). Full suite: 1,235 passed, 7 skipped, 1 failed (test_studia_bas_contract.py::test_studia_bas_artifacts, which fails on main as well), on main 4be16d1; after main moved to f4a95a1 (only uzp files changed) the sejm_api and uzp tests were rerun: 152 passed, 7 skipped.

🤖 Generated with Claude Code

ppuzio changed pull request status to open
ppuzio changed pull request status to merged
ppuzio deleted the refs/pr/158 ref

Sign up or log in to comment