ppuzio commited on
Commit
7dcf1ea
·
1 Parent(s): af12d0a

sejm_committee_transcripts: redact() counts only actual replacements; card corrects the 454 (#109)

Browse files

- sejm_committee_transcripts: redact() counts only actual replacements (c490370a509b27f494f0c003ec9f7b1e72e59c02)
- sejm_committee_transcripts: card says the 454 pre-dedup count included checksum failures (4161f56071fe6480f03cd272dfc72fd1a55a9747)

data/sejm_committee_transcripts/sejm_committee_transcripts.md CHANGED
@@ -73,7 +73,10 @@ reproducible from the script alone. Requires `pdftotext` (poppler).
73
  Counted in the shipped shard: **403 redactions** (396 `[ADRES_EMAIL]`, 6
74
  `[DANE_NUMERY]`, 1 `[DANE_KONTAKTOWE]`; the pipeline's pre-dedup counter read
75
  454 because it also counted rows later dropped as joint-sitting duplicates or,
76
- since the speaker filter, as statements by non-official speakers).
 
 
 
77
  This is **not**
78
  [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL): the shard must be
79
  re-run through NERGAL before it is admitted to a release (it quotes citizens'
 
73
  Counted in the shipped shard: **403 redactions** (396 `[ADRES_EMAIL]`, 6
74
  `[DANE_NUMERY]`, 1 `[DANE_KONTAKTOWE]`; the pipeline's pre-dedup counter read
75
  454 because it also counted rows later dropped as joint-sitting duplicates or,
76
+ since the speaker filter, as statements by non-official speakers, and because
77
+ it counted PESEL/NIP/REGON candidates that failed the checksum and were left
78
+ in the text - at least 10 of the 454; the script now counts only actual
79
+ replacements).
80
  This is **not**
81
  [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL): the shard must be
82
  re-run through NERGAL before it is admitted to a release (it quotes citizens'
src/fetch_sejm_committee_transcripts.py CHANGED
@@ -631,8 +631,9 @@ def redact(text: str) -> tuple[str, int]:
631
  def sub(replacement):
632
  def repl(m):
633
  nonlocal n
634
- n += 1
635
- return replacement if isinstance(replacement, str) else replacement(m)
 
636
  return repl
637
 
638
  text = EMAIL.sub(sub(lambda m: "[ADRES_EMAIL]" if "@" in m.group(0) else "[DANE_NUMERY]"), text)
 
631
  def sub(replacement):
632
  def repl(m):
633
  nonlocal n
634
+ out = replacement if isinstance(replacement, str) else replacement(m)
635
+ n += out != m.group(0) # a checksum-failing PESEL/NIP/REGON comes back unchanged
636
+ return out
637
  return repl
638
 
639
  text = EMAIL.sub(sub(lambda m: "[ADRES_EMAIL]" if "@" in m.group(0) else "[DANE_NUMERY]"), text)
src/test_sejm_committee_transcripts_contract.py CHANGED
@@ -276,6 +276,13 @@ class RedactionTest(unittest.TestCase):
276
  text, _ = redact("PESEL 44040501357 nie przechodzi sumy kontrolnej.")
277
  self.assertIn("44040501357", text)
278
 
 
 
 
 
 
 
 
279
  def test_email_phone_iban_masked(self):
280
  text, n = redact("pisać na jan.kowalski@sejm.gov.pl, tel. 22 694 12 34, IBAN PL61109010140000071219812874")
281
  self.assertGreaterEqual(n, 3)
 
276
  text, _ = redact("PESEL 44040501357 nie przechodzi sumy kontrolnej.")
277
  self.assertIn("44040501357", text)
278
 
279
+ def test_checksum_failing_ids_not_counted(self):
280
+ raw = "PESEL 44040501357, NIP 1234567891 i REGON 123456786 nie przechodzą sumy kontrolnej."
281
+ self.assertEqual(redact(raw), (raw, 0))
282
+ text, n = redact(raw + " Ważny PESEL 44040501356.")
283
+ self.assertEqual(n, 1)
284
+ self.assertEqual(text.count("[DANE_NUMERY]"), 1)
285
+
286
  def test_email_phone_iban_masked(self):
287
  text, n = redact("pisać na jan.kowalski@sejm.gov.pl, tel. 22 694 12 34, IBAN PL61109010140000071219812874")
288
  self.assertGreaterEqual(n, 3)