kultura_bez_barier_pl: mask the coordinator phones, cite the PDF licence line (v2#57)

#95
by ppuzio - opened
artifacts/kultura_bez_barier_pl_ontology_manifest.json CHANGED
@@ -19,7 +19,7 @@
19
  "id": "claim:replayable",
20
  "statement": "The retained dataset files replay from the pinned catalogue and PDF snapshot under the published protocol.",
21
  "supported_by": [
22
- "evidence:checksums:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922"
23
  ]
24
  },
25
  {
@@ -27,7 +27,7 @@
27
  "id": "claim:rights-qualified",
28
  "statement": "The official catalogue presents the linked foundation-authored publications as CC BY-SA 3.0; per-PDF embedded licensing is not asserted.",
29
  "supported_by": [
30
- "evidence:qa:87b67c4b2f35b27cb6f9b0f80efcd335df4d6f96351635f262e527361277dd19"
31
  ]
32
  }
33
  ],
@@ -90,6 +90,68 @@
90
  }
91
  },
92
  "produced_by": "run:e451d83a46337b6ac0db4abe552a9775b110b06876b6ec252922ddb4c18fd657"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
  ],
95
  "objects": [
@@ -106,7 +168,8 @@
106
  "cross-source deduplication",
107
  "benchmark contamination check",
108
  "maintainer/legal review of catalogue-level license scope",
109
- "controlled training ablation"
 
110
  ],
111
  "protocols": [
112
  {
@@ -116,6 +179,10 @@
116
  {
117
  "id": "protocol:contract-v1",
118
  "procedure": "schema, checksum, sample, rights-evidence and ontology contract checks"
 
 
 
 
119
  }
120
  ],
121
  "relations": [
@@ -133,6 +200,16 @@
133
  "predicate": "VALIDATED_AGAINST",
134
  "source": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
135
  "target": "run:3aa251975f82e4a35004fad877d29b933ed49d4308072502e3b193f90babd737"
 
 
 
 
 
 
 
 
 
 
136
  }
137
  ],
138
  "runs": [
@@ -163,6 +240,13 @@
163
  },
164
  "success": true,
165
  "target_main_revision": "a916edecabc2be8832e08fb2bd9dfafcc1d2dd71"
 
 
 
 
 
 
 
166
  }
167
  ],
168
  "schema": "slayer-research-ontology-profile-v1",
@@ -176,6 +260,11 @@
176
  "content_address": "99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
177
  "id": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
178
  "object": "object:dataset:kultura-bez-barier-pl"
 
 
 
 
 
179
  }
180
  ]
181
  }
 
19
  "id": "claim:replayable",
20
  "statement": "The retained dataset files replay from the pinned catalogue and PDF snapshot under the published protocol.",
21
  "supported_by": [
22
+ "evidence:checksums:16a096fdb709a0f894d8b9c50feac5bdf44a5356b28f27fdee639b17f7fc9992"
23
  ]
24
  },
25
  {
 
27
  "id": "claim:rights-qualified",
28
  "statement": "The official catalogue presents the linked foundation-authored publications as CC BY-SA 3.0; per-PDF embedded licensing is not asserted.",
29
  "supported_by": [
30
+ "evidence:qa:5c3b4f16abc604614e14388f5c11dd051c4452ff815f79cdb8365f687ecc290e"
31
  ]
32
  }
33
  ],
 
90
  }
91
  },
92
  "produced_by": "run:e451d83a46337b6ac0db4abe552a9775b110b06876b6ec252922ddb4c18fd657"
93
+ },
94
+ {
95
+ "id": "evidence:checksums:16a096fdb709a0f894d8b9c50feac5bdf44a5356b28f27fdee639b17f7fc9992",
96
+ "observation_type": "checksums",
97
+ "payload": {
98
+ "NOTICE.md": "69db282ba649ab9d7dee2d52cee24005b046fdf3371198642ecbb15f6d110d12",
99
+ "README.md": "04ff8ca176daa3b7a5ca926c1ee9c0f9aa481d05c9f7b68e074ca91c98cb1d77",
100
+ "artifacts/attribution.jsonl": "0d8880a355fe0b02d9adbaf65fc58464ba95b835fd7fd663b303381573c437d9",
101
+ "artifacts/catalog.html": "7bc2a7c995dd67a58e592e63311a53f5bebe0c2c580ca403574437a3254253bf",
102
+ "artifacts/decisions.jsonl": "edc18820ed6819721650d59d530375246daa32e86fd7ff6e66d8bcada08ea16e",
103
+ "artifacts/inventory.json": "496bd4655b15e9573e346fc6322b42a59b40739580fc249c9b318e0c91d9acc5",
104
+ "artifacts/qa.json": "1108104bf119d9eb30b9dbcb1a979f4a138ca5de10c3848306e59f2d2333da1d",
105
+ "artifacts/raw/abc_gosc_niepelnosprawny.pdf": "8918966789ed103efca9c2272363ff7ea51e703bb90585633f16e6198dbe6ff6",
106
+ "artifacts/raw/abc_gosc_niepelnosprawny_cz2.pdf": "ad16b7ed02fb1aebd03c640d52c1baf664b6f7e77e013230985e5902c4dffcf1",
107
+ "artifacts/raw/audiodeskrypcja_obrazow.pdf": "ee6b90bf064f3ab9affc5a2568bc28a89a519a9a1cf87506ed1e0b877cba0664",
108
+ "artifacts/raw/audiodeskrypcja_zasady.pdf": "ada6db63e05aa2f4dd3474d1f7c7a41b74fd10c19de335015d40eb814ecba97f",
109
+ "artifacts/raw/checklisty_warsztaty_kulinarne.pdf": "ca8b0adbe3142fdad18bac76b35e1406b3ed020a556c26a3187efdc1d5f31095",
110
+ "artifacts/raw/filmolekcje.pdf": "fde70eecb7c26bbb7c3881d3c1ad1931c1ceb16e6d5ff13dfe102ddfa4aedd2a",
111
+ "artifacts/raw/jak_udostepniac_kulture.pdf": "9b3ad5a21a15d41025ad9d1b9ecbac95149ba8b192e85429871c57458a7d7f04",
112
+ "artifacts/raw/model_dostepnej_kultury_2023.pdf": "96f0600ec29fb3e4845099c03eee3c08e89d2c703ddc08db305d5c1c043abeea",
113
+ "artifacts/raw/napisy_dla_nieslyszacych.pdf": "ca979ff6fd85dde0d2a5e1affb5e9b6bb83e8cda6743ab231eebf0f96f8dce96",
114
+ "artifacts/raw/paszport_do_sztuki.pdf": "d07ae6db501eeb7cf73972e5a9efcf92f9ada5786163d87d8df20d8bc8ca539e",
115
+ "artifacts/raw/podsumowanie_wizyt_studyjnych.pdf": "7df24e84f13fb51ef9b4257dce527e626c18c2c55fc80b3ef38489a96f6b6ac5",
116
+ "artifacts/raw/przewodnik_po_dostepnosci.pdf": "84cf7c9694556be3c5926fee6613cd81a57416346c69a6e03a749c9432931fc8",
117
+ "artifacts/run.json": "d2513ac92491de72a18ddbec55c38b79d17f37d6060cd49a0671be9e07df6c25",
118
+ "artifacts/sample.jsonl": "e8b7d7d5962d69b6103ac6359798c2ceb6e72e63c3e933667a8e33d85e23146c",
119
+ "artifacts/stats.json": "87ee0cfa7fbadfc734cf7ebc25be88eea8496cf9924d486db7bb0cc3f41289ad",
120
+ "data/train-00000-of-00001.parquet": "76c36ab04179e6106e97343372f855956503968f6f0bfe1f7949e36995e3b8fb",
121
+ "src/build_kultura_bez_barier_pl.py": "ee0771bbf46243a8a65b790fe245b468028e61724ea1b7339b5dd2a2206ff4cc",
122
+ "src/requirements.txt": "807ccb72d622706ea3b41d39190c6258a17d4f5472eeab294a9d483eb4c44ac1",
123
+ "src/test_kultura_bez_barier_contribution.py": "0962312fc13fdd8fc33a729b505896311455dcd623dcd543317378efcbfcb523"
124
+ },
125
+ "produced_by": "run:0996ebdceaa8dd914080d2bd00e1b4730faf91bbc4c17cb66371a143302d9f2a"
126
+ },
127
+ {
128
+ "id": "evidence:qa:5c3b4f16abc604614e14388f5c11dd051c4452ff815f79cdb8365f687ecc290e",
129
+ "observation_type": "qa",
130
+ "payload": {
131
+ "benchmark_overlap": "pending",
132
+ "cross_source_dedup": "pending target integration",
133
+ "exact_normalized_dedup": true,
134
+ "license_gate": "official catalogue-level CC BY-SA 3.0 declaration; per-PDF embedded notices not required or asserted",
135
+ "limitations": [
136
+ "catalogue-level rights statement requires maintainer/legal interpretation for each linked publication",
137
+ "PDF extraction can flatten tables and omit images",
138
+ "embedded third-party quotations require review",
139
+ "pattern checks are not comprehensive de-identification",
140
+ "text novelty and training benefit are not asserted"
141
+ ],
142
+ "near_dedup": {
143
+ "method": "seeded MinHash 128 / LSH 0.8 candidates / exact 5-word Jaccard >= 0.9",
144
+ "removed": []
145
+ },
146
+ "pii_pattern_matches": {
147
+ "email": 16,
148
+ "labelled_phone": 1,
149
+ "ted_pl_email": 0,
150
+ "ted_pl_national_id": 0,
151
+ "ted_pl_phone": 12
152
+ }
153
+ },
154
+ "produced_by": "run:0996ebdceaa8dd914080d2bd00e1b4730faf91bbc4c17cb66371a143302d9f2a"
155
  }
156
  ],
157
  "objects": [
 
168
  "cross-source deduplication",
169
  "benchmark contamination check",
170
  "maintainer/legal review of catalogue-level license scope",
171
+ "controlled training ablation",
172
+ "replay of the v0.2.6 second PII pass from the raw PDFs (applied offline to the published text)"
173
  ],
174
  "protocols": [
175
  {
 
179
  {
180
  "id": "protocol:contract-v1",
181
  "procedure": "schema, checksum, sample, rights-evidence and ontology contract checks"
182
+ },
183
+ {
184
+ "id": "protocol:pii-rescrub-v1",
185
+ "procedure": "src/clean_kultura_bez_barier_pl.py: the builder's second PII pass (ted_pl patterns) applied to the published text; token counts, attribution text hashes, sample, stats and qa recomputed"
186
  }
187
  ],
188
  "relations": [
 
200
  "predicate": "VALIDATED_AGAINST",
201
  "source": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
202
  "target": "run:3aa251975f82e4a35004fad877d29b933ed49d4308072502e3b193f90babd737"
203
+ },
204
+ {
205
+ "predicate": "DERIVED_FROM",
206
+ "source": "version:dataset:16a096fdb709a0f894d8b9c50feac5bdf44a5356b28f27fdee639b17f7fc9992",
207
+ "target": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922"
208
+ },
209
+ {
210
+ "predicate": "GENERATED_BY",
211
+ "source": "version:dataset:16a096fdb709a0f894d8b9c50feac5bdf44a5356b28f27fdee639b17f7fc9992",
212
+ "target": "run:0996ebdceaa8dd914080d2bd00e1b4730faf91bbc4c17cb66371a143302d9f2a"
213
  }
214
  ],
215
  "runs": [
 
240
  },
241
  "success": true,
242
  "target_main_revision": "a916edecabc2be8832e08fb2bd9dfafcc1d2dd71"
243
+ },
244
+ {
245
+ "finished_at": "2026-10-06T19:11:30.915407+00:00",
246
+ "id": "run:0996ebdceaa8dd914080d2bd00e1b4730faf91bbc4c17cb66371a143302d9f2a",
247
+ "protocol": "protocol:pii-rescrub-v1",
248
+ "started_at": "2026-10-06T19:11:30.669739+00:00",
249
+ "success": true
250
  }
251
  ],
252
  "schema": "slayer-research-ontology-profile-v1",
 
260
  "content_address": "99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
261
  "id": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
262
  "object": "object:dataset:kultura-bez-barier-pl"
263
+ },
264
+ {
265
+ "content_address": "16a096fdb709a0f894d8b9c50feac5bdf44a5356b28f27fdee639b17f7fc9992",
266
+ "id": "version:dataset:16a096fdb709a0f894d8b9c50feac5bdf44a5356b28f27fdee639b17f7fc9992",
267
+ "object": "object:dataset:kultura-bez-barier-pl"
268
  }
269
  ]
270
  }
data/kultura_bez_barier_pl/kultura_bez_barier_pl.attribution.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4e592737d4d9c93a67c6437d5ad3881e92f8fb9aec62064eaaa84625144cf538
3
- size 15320
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d8880a355fe0b02d9adbaf65fc58464ba95b835fd7fd663b303381573c437d9
3
+ size 16004
data/kultura_bez_barier_pl/kultura_bez_barier_pl.md CHANGED
@@ -18,7 +18,7 @@ Polish text extracted from openly published accessibility guides by Fundacja Kul
18
  - Input publications: 12
19
  - Retained records: 9
20
  - Extracted pages: 316
21
- - Tokens: 217,932 (`cl100k_base` proxy)
22
  - License evidence: catalogue-level CC BY-SA 3.0 declaration
23
  - Author coverage: 100.0%
24
 
@@ -40,15 +40,23 @@ highlighted as included; the pronoun sits next to "piktogramy", so the reading
40
  is catalogue-level, not per-PDF — exactly what `license_scope_note` records in
41
  `attribution.jsonl`. The catalogue HTML is pinned in the source snapshot.
42
 
 
 
 
 
 
43
  Per-guide coverage for the 9 retained records: each is a foundation-authored
44
  entry of that catalogue (authorship corroborated per record by the catalogue
45
- statement plus PDF metadata/credit lines in `attribution.jsonl`). The 3 other
46
- catalogue items were **rejected on rights/authorship grounds** - both volumes of
47
- `ABC gość niepełnosprawny` name Narodowy Instytut Muzealnictwa i Ochrony
48
- Zbiorów (NIMOZ) in the PDF copyright notice (the foundation is a project
49
- partner there), and `Audiodeskrypcja - zasady` was dropped for legacy-font
50
- extraction damage. A third-party-authorship red flag therefore removes the item
51
- rather than being argued away.
 
 
 
52
 
53
  ## What the texts are
54
 
@@ -65,27 +73,36 @@ rather than being argued away.
65
 
66
  ## Scrubber and residual-PII spot check
67
 
68
- Scrubber that ran: **pattern redaction in `src/build_kultura_bez_barier_pl.py`**
69
- (e-mail -> `[REDACTED:EMAIL]`, labelled phone -> `[REDACTED:PHONE]`, limited
70
- patterns). This is **not**
71
- [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL); the shard must be
72
- re-run through NERGAL before it is admitted to a release. Merge with
73
- `release: None` is fine meanwhile.
74
-
75
- The spot check covers **all 9 records** (the shard is tiny): 14 e-mail
76
- redactions confirm the scrubber works, but **real residual contacts survive in
77
- `kultura_bez_barier_pl_podsumowanie_wizyt_studyjnych`** - a published directory
78
- of museum accessibility coordinators where names and phones stay while the
79
- e-mail beside them is redacted: "Emila Kamola Tel./SMS + 48 509 490 034
80
- e-mail: [REDACTED:EMAIL]", "Katarzyna Lubas Tel./SMS: 535 36 37 09", and a bare
81
- "Tel/SMS: 504449027". The label-anchored phone pattern misses the `Tel./SMS` /
82
- `Tel/SMS` label variants and unlabelled numbers, and personal names are out of
83
- its scope entirely. Other hits are benign: 8 museum addresses (`ul.`), 17
84
- instructive mentions of "telefon", one Facebook URL with an id. These are
85
- published professional contacts in a CC BY-SA guide, but they are identifiable
86
- individuals' data - residual risk is HIGH for this record, low for the other
87
- eight.
 
 
 
 
 
 
 
 
 
88
 
89
  ## Limitations
90
 
91
- The source catalogue provides the licensing statement; an embedded statement was not found or required for every PDF. Maintainer/legal review of that scope remains appropriate. PDF extraction may flatten tables and omit visual meaning. Cross-source DynaWord deduplication, benchmark-overlap checks and controlled training ablations remain pending.
 
18
  - Input publications: 12
19
  - Retained records: 9
20
  - Extracted pages: 316
21
+ - Tokens: 217,888 (`cl100k_base` proxy)
22
  - License evidence: catalogue-level CC BY-SA 3.0 declaration
23
  - Author coverage: 100.0%
24
 
 
40
  is catalogue-level, not per-PDF — exactly what `license_scope_note` records in
41
  `attribution.jsonl`. The catalogue HTML is pinned in the source snapshot.
42
 
43
+ One retained PDF carries its own licence line: `jak_udostepniac_kulture` says
44
+ "Publikacja jest dostępna na licencji CC BY-SA." It gives no version; the
45
+ catalogue says 3.0, and this card assumes the same version. No other retained
46
+ record mentions a licence.
47
+
48
  Per-guide coverage for the 9 retained records: each is a foundation-authored
49
  entry of that catalogue (authorship corroborated per record by the catalogue
50
+ statement plus PDF metadata/credit lines in `attribution.jsonl`). Six of the 9
51
+ credit individual authors (`author`). The v0.2.6 rights audit assumes they
52
+ assigned or licensed their rights to the foundation, which offers the files;
53
+ no such assignment is published. The 3 other catalogue items were **rejected**:
54
+ both volumes of `ABC gość niepełnosprawny` on rights/authorship grounds (they
55
+ name Narodowy Instytut Muzealnictwa i Ochrony Zbiorów (NIMOZ) in the PDF
56
+ copyright notice; the foundation is a project partner there), and
57
+ `Audiodeskrypcja - zasady` for legacy-font extraction damage. A
58
+ third-party-authorship red flag therefore removes the item rather than being
59
+ argued away.
60
 
61
  ## What the texts are
62
 
 
73
 
74
  ## Scrubber and residual-PII spot check
75
 
76
+ Two pattern scrubbers ran, both in `src/build_kultura_bez_barier_pl.py`:
77
+
78
+ 1. the builder's own pass: e-mail -> `[REDACTED:EMAIL]`, labelled phone ->
79
+ `[REDACTED:PHONE]`;
80
+ 2. since v0.2.6 (rights audit, slayerlabs/polish-dynaword-v2#57), a second
81
+ pass with `ted_pl`'s e-mail, PESEL/NIP/REGON and phone patterns (phone ->
82
+ `[Telefon]`). The raw PDFs are not in this repo, so
83
+ `src/clean_kultura_bez_barier_pl.py` applied it to the published text.
84
+
85
+ Neither is [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL); the
86
+ shard must be re-run through NERGAL before it is admitted to a release. Merge
87
+ with `release: None` is fine meanwhile.
88
+
89
+ The spot check covers **all 9 records** (the shard is tiny). Only
90
+ `kultura_bez_barier_pl_podsumowanie_wizyt_studyjnych` has personal contacts: a
91
+ published directory of museum accessibility coordinators. The first pass masked
92
+ its 13 e-mails and 1 phone but missed the `Tel./SMS`, `tel:` and `+ 48` label
93
+ variants and landlines with an extension; the second pass masked those 12
94
+ numbers. One of them has a stray extra digit in the PDF, so a single digit
95
+ follows its `[Telefon]` token. The record therefore mixes `[REDACTED:EMAIL]`,
96
+ `[REDACTED:PHONE]` and `[Telefon]` tokens.
97
+
98
+ Left for NERGAL in the same record: the coordinators' names next to the masked
99
+ contacts, and study-visit participants' self-written bios (names,
100
+ organisations, a personal website, and statements about their own disability,
101
+ which are health data). Residual risk is HIGH for this record and low for the
102
+ other eight. Other hits are benign: the museums' street addresses in this
103
+ record, institutional Facebook links, and instructive mentions of "telefon"
104
+ across the shard.
105
 
106
  ## Limitations
107
 
108
+ The source catalogue provides the licensing statement; only `jak_udostepniac_kulture` embeds one, without a version (see above). Maintainer/legal review of that scope remains appropriate. PDF extraction may flatten tables and omit visual meaning. Cross-source DynaWord deduplication, benchmark-overlap checks and controlled training ablations remain pending.
data/kultura_bez_barier_pl/kultura_bez_barier_pl.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1d9cd403ab297b3a8a84ce6ae7a25e4f4fd5025b37be959e4692a5170ed64642
3
- size 245697
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76c36ab04179e6106e97343372f855956503968f6f0bfe1f7949e36995e3b8fb
3
+ size 245584
data/kultura_bez_barier_pl/kultura_bez_barier_pl.qa.json CHANGED
@@ -16,6 +16,9 @@
16
  },
17
  "pii_pattern_matches": {
18
  "email": 16,
19
- "labelled_phone": 1
 
 
 
20
  }
21
  }
 
16
  },
17
  "pii_pattern_matches": {
18
  "email": 16,
19
+ "labelled_phone": 1,
20
+ "ted_pl_email": 0,
21
+ "ted_pl_national_id": 0,
22
+ "ted_pl_phone": 12
23
  }
24
  }
data/kultura_bez_barier_pl/kultura_bez_barier_pl.sample.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
data/kultura_bez_barier_pl/kultura_bez_barier_pl.stats.json CHANGED
@@ -2,12 +2,12 @@
2
  "acquired": 12,
3
  "added": "2026-09-07",
4
  "author_coverage": 1.0,
5
- "characters": 608827,
6
  "discovered": 12,
7
  "kept": 9,
8
  "pages": 316,
9
  "rejected": 3,
10
  "sample_count": 9,
11
- "tokens": 217932,
12
  "unknown_created": 0
13
  }
 
2
  "acquired": 12,
3
  "added": "2026-09-07",
4
  "author_coverage": 1.0,
5
+ "characters": 608794,
6
  "discovered": 12,
7
  "kept": 9,
8
  "pages": 316,
9
  "rejected": 3,
10
  "sample_count": 9,
11
+ "tokens": 217888,
12
  "unknown_created": 0
13
  }
src/build_kultura_bez_barier_pl.py CHANGED
@@ -19,9 +19,9 @@ import time
19
  import unicodedata
20
  from urllib.parse import unquote
21
 
22
- import pdfplumber
23
  import requests
24
- from pypdf import PdfReader
 
25
 
26
  CATALOG = "https://kulturabezbarier.org/publikacje/"
27
  SOURCE = "kultura_bez_barier_pl"
@@ -65,6 +65,10 @@ RIGHTS_CONFLICTS = {
65
  "abc_gosc_niepelnosprawny_cz2": "PDF identifies the NIMOZ training series and foundation as a project partner",
66
  }
67
 
 
 
 
 
68
  LEGACY_GARBLE_WORDS = (
69
  "widad", "dad", "mied", "byd", "kooca", "przestrzeo", "poznad", "zostad",
70
  "współgrad", "uwzględnid", "zamieścid",
@@ -140,6 +144,8 @@ def pdf_created(metadata):
140
 
141
 
142
  def extract_pdf(path):
 
 
143
  reader = PdfReader(path)
144
  pages = []
145
  failures = []
@@ -292,6 +298,8 @@ def build(out):
292
  "rights_conflict": RIGHTS_CONFLICTS.get(record["slug"])})
293
  if reason:
294
  continue
 
 
295
  seen[key] = row_id
296
  created = pdf_created(record["metadata"])
297
  author = AUTHORS[record["slug"]]
@@ -305,7 +313,7 @@ def build(out):
305
  "license_scope_note": inventory["license_scope_note"], "pdf_sha256": record["pdf_sha256"],
306
  "text_sha256": sha(text.encode()), "page_count": record["page_count"], "language": language,
307
  "language_confidence": float(confidence), "transformations": ["pdfplumber page text extraction", "page-number removal",
308
- "line-wrap and hyphen repair", "Unicode and whitespace normalization", "email and labelled-phone redaction"]})
309
  rows, near_removed = near_dedup(rows)
310
  removed = {item["id"]: item for item in near_removed}
311
  for decision in decisions:
 
19
  import unicodedata
20
  from urllib.parse import unquote
21
 
 
22
  import requests
23
+
24
+ from build_ted_pl import redact_pii as redact_wider_pii
25
 
26
  CATALOG = "https://kulturabezbarier.org/publikacje/"
27
  SOURCE = "kultura_bez_barier_pl"
 
65
  "abc_gosc_niepelnosprawny_cz2": "PDF identifies the NIMOZ training series and foundation as a project partner",
66
  }
67
 
68
+ # v0.2.6 rights audit: the labelled-phone regex in build() misses "Tel./SMS", "tel:", "+ 48" and landlines with "wew.",
69
+ # so retained records get a second pass with ted_pl's patterns (src/clean_kultura_bez_barier_pl.py applies it offline).
70
+ WIDER_PII_STEP = "second PII pass with ted_pl's e-mail, PESEL/NIP/REGON and phone patterns"
71
+
72
  LEGACY_GARBLE_WORDS = (
73
  "widad", "dad", "mied", "byd", "kooca", "przestrzeo", "poznad", "zostad",
74
  "współgrad", "uwzględnid", "zamieścid",
 
144
 
145
 
146
  def extract_pdf(path):
147
+ import pdfplumber
148
+ from pypdf import PdfReader
149
  reader = PdfReader(path)
150
  pages = []
151
  failures = []
 
298
  "rights_conflict": RIGHTS_CONFLICTS.get(record["slug"])})
299
  if reason:
300
  continue
301
+ text, wider = redact_wider_pii(text)
302
+ pii.update({"ted_pl_" + name: hits for name, hits in wider.items()})
303
  seen[key] = row_id
304
  created = pdf_created(record["metadata"])
305
  author = AUTHORS[record["slug"]]
 
313
  "license_scope_note": inventory["license_scope_note"], "pdf_sha256": record["pdf_sha256"],
314
  "text_sha256": sha(text.encode()), "page_count": record["page_count"], "language": language,
315
  "language_confidence": float(confidence), "transformations": ["pdfplumber page text extraction", "page-number removal",
316
+ "line-wrap and hyphen repair", "Unicode and whitespace normalization", "email and labelled-phone redaction", WIDER_PII_STEP]})
317
  rows, near_removed = near_dedup(rows)
318
  removed = {item["id"]: item for item in near_removed}
319
  for decision in decisions:
src/clean_kultura_bez_barier_pl.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Mask the phone numbers left in kultura_bez_barier_pl (v0.2.6 rights audit, slayerlabs/polish-dynaword-v2#57).
3
+
4
+ The builder's labelled-phone regex missed "Tel./SMS", "tel:", "+ 48" and landlines with "wew.", so the
5
+ accessibility-coordinator directory in `podsumowanie_wizyt_studyjnych` shipped with names and phone numbers.
6
+ The builder now runs a second pass with ted_pl's patterns on retained records (`redact_wider_pii`). The raw PDFs
7
+ are not in this repo, so this script applies that same pass to the published text instead of rebuilding it:
8
+ the first pass already ran on it, and the second pass runs last in build(), so the output is what build() now
9
+ produces from the pinned PDFs (not re-checked against them here).
10
+
11
+ Rewritten: the Parquet `text` and `token_count`, the attribution `text_sha256` and `transformations`, the sample,
12
+ stats `tokens`/`characters`, qa `pii_pattern_matches`, and the ontology manifest, which gains a run, a dataset
13
+ version and checksum/qa evidence for the new files (computed last, so edit the builder and the test first).
14
+ The input is the Parquet and sidecars as contributed in PR #27 (unchanged since), pinned by SHA-256. Restore
15
+ them before a rerun:
16
+ git checkout 7444b7d -- 'data/kultura_bez_barier_pl/*.parquet' 'data/kultura_bez_barier_pl/*.jsonl' \
17
+ 'data/kultura_bez_barier_pl/*.json' artifacts/kultura_bez_barier_pl_ontology_manifest.json
18
+ python3 src/clean_kultura_bez_barier_pl.py
19
+ """
20
+ from __future__ import annotations
21
+
22
+ from collections import Counter
23
+ import json
24
+ import os
25
+ from pathlib import Path
26
+ import sys
27
+
28
+ import pyarrow as pa
29
+ import pyarrow.parquet as pq
30
+ import tiktoken
31
+
32
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
33
+ from build_kultura_bez_barier_pl import SOURCE, WIDER_PII_STEP, now, read_lines, redact_wider_pii, sha # noqa: E402
34
+
35
+ ROOT = Path(__file__).resolve().parents[1]
36
+ DATA = ROOT / "data" / SOURCE
37
+ MANIFEST = ROOT / "artifacts" / f"{SOURCE}_ontology_manifest.json"
38
+ INPUT_SHA256 = {
39
+ DATA / f"{SOURCE}.parquet": "1d9cd403ab297b3a8a84ce6ae7a25e4f4fd5025b37be959e4692a5170ed64642",
40
+ DATA / f"{SOURCE}.attribution.jsonl": "4e592737d4d9c93a67c6437d5ad3881e92f8fb9aec62064eaaa84625144cf538",
41
+ DATA / f"{SOURCE}.sample.jsonl": "9ce1a4cc8f2b6a8882f1a795d3b7f8bbb133c9c81ae6507830bb7b2a2f1bd7e5",
42
+ DATA / f"{SOURCE}.stats.json": "5fc1c11510ed0536bb3a4f2c86397006642911d8542c9c28bc88dacefa392ac3",
43
+ DATA / f"{SOURCE}.qa.json": "3946eb001b0f43248a54256099ff98021cf14eec4e9e94c402210f88563ead58",
44
+ MANIFEST: "2e7c26bb3985c1a2255bef59bf02675b2dc09bf127717d4bf02f8ce09b4268dc",
45
+ }
46
+ OLD_TRANSFORMATIONS = ["pdfplumber page text extraction", "page-number removal", "line-wrap and hyphen repair",
47
+ "Unicode and whitespace normalization", "email and labelled-phone redaction"]
48
+ SAMPLE_SIZE = 12
49
+ PROTOCOL = {"id": "protocol:pii-rescrub-v1",
50
+ "procedure": "src/clean_kultura_bez_barier_pl.py: the builder's second PII pass (ted_pl patterns) applied "
51
+ "to the published text; token counts, attribution text hashes, sample, stats and qa recomputed"}
52
+
53
+
54
+ def lines(rows: list[dict]) -> str:
55
+ return "".join(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n" for row in rows)
56
+
57
+
58
+ def dump(value: dict) -> str:
59
+ return json.dumps(value, ensure_ascii=False, sort_keys=True, indent=2) + "\n"
60
+
61
+
62
+ def crlf(text: str) -> bytes:
63
+ """The contributed text files use CRLF (written on Windows); keep it so the diff shows only the changes."""
64
+ return text.replace("\n", "\r\n").encode("utf-8")
65
+
66
+
67
+ def rescrub(rows: list[dict], attribution: list[dict]) -> tuple[list[dict], list[dict], Counter]:
68
+ """Rows and attribution after the second pass, plus its hit counts keyed as build() keys them."""
69
+ if [row["id"] for row in rows] != [item["id"] for item in attribution]:
70
+ raise SystemExit("Parquet and attribution sidecar do not list the same ids in the same order")
71
+ encoder = tiktoken.get_encoding("cl100k_base")
72
+ counts, new_rows, new_attribution = Counter(), [], []
73
+ for row, item in zip(rows, attribution):
74
+ if item["transformations"] != OLD_TRANSFORMATIONS or item["text_sha256"] != sha(row["text"].encode()):
75
+ raise SystemExit(f"{row['id']}: attribution does not describe the PR #27 text")
76
+ text, wider = redact_wider_pii(row["text"])
77
+ counts.update({"ted_pl_" + name: hits for name, hits in wider.items()})
78
+ new_rows.append({**row, "text": text, "token_count": len(encoder.encode_ordinary(text))})
79
+ new_attribution.append({**item, "text_sha256": sha(text.encode()),
80
+ "transformations": OLD_TRANSFORMATIONS + [WIDER_PII_STEP]})
81
+ return new_rows, new_attribution, counts
82
+
83
+
84
+ def manifest_update(manifest: dict, files: dict[str, bytes], qa: dict, run: dict) -> dict:
85
+ """`manifest` plus a run, a dataset version and evidence for `files` (manifest path -> new bytes)."""
86
+ old_checks = next(item for item in manifest["evidence"] if item["observation_type"] == "checksums")
87
+ if unknown := files.keys() - old_checks["payload"].keys():
88
+ raise SystemExit(f"not in the manifest checksums: {sorted(unknown)}")
89
+ checks = {**old_checks["payload"], **{name: sha(data) for name, data in files.items()}}
90
+ old_version = next(item["id"] for item in manifest["versions"] if item["object"] == "object:dataset:kultura-bez-barier-pl"
91
+ and item["content_address"] == sha(old_checks["payload"]))
92
+ version = "version:dataset:" + sha(checks)
93
+ check_id, qa_id = "evidence:checksums:" + sha(checks), "evidence:qa:" + sha(qa)
94
+ supported = {"claim:replayable": [check_id], "claim:rights-qualified": [qa_id]}
95
+ return {**manifest,
96
+ "protocols": manifest["protocols"] + [PROTOCOL],
97
+ "runs": manifest["runs"] + [run],
98
+ "versions": manifest["versions"] + [{"id": version, "object": "object:dataset:kultura-bez-barier-pl",
99
+ "content_address": sha(checks)}],
100
+ "evidence": manifest["evidence"] + [
101
+ {"id": check_id, "observation_type": "checksums", "payload": checks, "produced_by": run["id"]},
102
+ {"id": qa_id, "observation_type": "qa", "payload": qa, "produced_by": run["id"]}],
103
+ "claims": [{**claim, "supported_by": supported[claim["id"]]} for claim in manifest["claims"]],
104
+ "relations": manifest["relations"] + [
105
+ {"source": version, "predicate": "DERIVED_FROM", "target": old_version},
106
+ {"source": version, "predicate": "GENERATED_BY", "target": run["id"]}],
107
+ "pending": manifest["pending"] + ["replay of the v0.2.6 second PII pass from the raw PDFs (applied offline "
108
+ "to the published text)"]}
109
+
110
+
111
+ def main() -> None:
112
+ for path, expected in INPUT_SHA256.items():
113
+ if sha(path.read_bytes()) != expected:
114
+ raise SystemExit(f"{path} is not the PR #27 input; restore it with the command in this script's docstring")
115
+ started = now()
116
+ table = pq.read_table(DATA / f"{SOURCE}.parquet")
117
+ rows, attribution, counts = rescrub(table.to_pylist(), read_lines(DATA / f"{SOURCE}.attribution.jsonl"))
118
+ samples = sorted(rows, key=lambda row: sha(("sample:" + row["id"]).encode()))[:SAMPLE_SIZE]
119
+ stats = {**json.loads((DATA / f"{SOURCE}.stats.json").read_text(encoding="utf-8")),
120
+ "tokens": sum(row["token_count"] for row in rows), "characters": sum(len(row["text"]) for row in rows)}
121
+ qa = json.loads((DATA / f"{SOURCE}.qa.json").read_text(encoding="utf-8"))
122
+ qa["pii_pattern_matches"] = {**qa["pii_pattern_matches"], **counts}
123
+
124
+ sink = pa.BufferOutputStream()
125
+ pq.write_table(pa.Table.from_pylist(rows, schema=table.schema), sink, compression="zstd")
126
+ staged = { # manifest path -> (repo path, bytes)
127
+ "data/train-00000-of-00001.parquet": (DATA / f"{SOURCE}.parquet", sink.getvalue().to_pybytes()),
128
+ "artifacts/attribution.jsonl": (DATA / f"{SOURCE}.attribution.jsonl", crlf(lines(attribution))),
129
+ "artifacts/sample.jsonl": (DATA / f"{SOURCE}.sample.jsonl", crlf(lines(samples))),
130
+ "artifacts/stats.json": (DATA / f"{SOURCE}.stats.json", crlf(dump(stats))),
131
+ "artifacts/qa.json": (DATA / f"{SOURCE}.qa.json", crlf(dump(qa))),
132
+ }
133
+ code = {name: (ROOT / name).read_bytes() for name in ("src/build_kultura_bez_barier_pl.py",
134
+ "src/test_kultura_bez_barier_contribution.py")}
135
+ run = {"id": "run:" + sha({"script": sha(Path(__file__).read_bytes()), "builder": sha(code["src/build_kultura_bez_barier_pl.py"]),
136
+ "inputs": sorted(INPUT_SHA256.values())}),
137
+ "protocol": PROTOCOL["id"], "started_at": started, "finished_at": now(), "success": True}
138
+ manifest = manifest_update(json.loads(MANIFEST.read_text(encoding="utf-8")),
139
+ {**{name: data for name, (_, data) in staged.items()}, **code}, qa, run)
140
+
141
+ staged["manifest"] = (MANIFEST, crlf(dump(manifest)))
142
+ for path, data in staged.values():
143
+ path.with_name(path.name + ".tmp").write_bytes(data)
144
+ for path, _ in staged.values():
145
+ os.replace(path.with_name(path.name + ".tmp"), path)
146
+ print(json.dumps({"pii_pattern_matches": qa["pii_pattern_matches"], "tokens": stats["tokens"],
147
+ "characters": stats["characters"], "changed_rows": [r["id"] for r, o in zip(rows, table.to_pylist())
148
+ if r["text"] != o["text"]]}, indent=2))
149
+
150
+
151
+ if __name__ == "__main__":
152
+ main()
src/sources.py CHANGED
@@ -944,16 +944,20 @@ SOURCES = {
944
  "traceable": "The official Fundacja Kultury bez Barier publication catalogue "
945
  "presents the linked foundation-authored publications as CC BY-SA "
946
  "3.0; catalogue HTML, raw PDFs, source URLs and SHA-256 digests are "
947
- "preserved as evidence. Catalogue-level declaration only — an "
948
- "embedded per-PDF license assertion is not claimed.",
 
949
  "upstream": "https://kulturabezbarier.org/publikacje/",
950
  "provenance": "Fetched directly from the official catalogue by "
951
  "src/build_kultura_bez_barier_pl.py; pdfplumber page-text "
952
  "extraction, page-number removal, line-wrap/hyphen repair, "
953
- "Unicode/whitespace normalization, limited PII-pattern redaction, "
 
 
954
  "exact and seeded near dedup. 12 publications discovered, 9 "
955
- "retained (3 rejected for rights/authorship conflicts with a "
956
- "third-party project partner); attribution, selection decisions "
 
957
  "and checksums preserved in the sidecar files.",
958
  "domain": "accessibility/disability guides",
959
  "created": "2017-11-20, 2024-04-19",
 
944
  "traceable": "The official Fundacja Kultury bez Barier publication catalogue "
945
  "presents the linked foundation-authored publications as CC BY-SA "
946
  "3.0; catalogue HTML, raw PDFs, source URLs and SHA-256 digests are "
947
+ "preserved as evidence. Catalogue-level declaration; of the 9 "
948
+ "retained PDFs only jak_udostepniac_kulture embeds a licence line "
949
+ "(\"CC BY-SA\", no version).",
950
  "upstream": "https://kulturabezbarier.org/publikacje/",
951
  "provenance": "Fetched directly from the official catalogue by "
952
  "src/build_kultura_bez_barier_pl.py; pdfplumber page-text "
953
  "extraction, page-number removal, line-wrap/hyphen repair, "
954
+ "Unicode/whitespace normalization, limited PII-pattern redaction "
955
+ "plus a second pass with ted_pl's patterns (v0.2.6, applied by "
956
+ "src/clean_kultura_bez_barier_pl.py), "
957
  "exact and seeded near dedup. 12 publications discovered, 9 "
958
+ "retained (2 rejected for a rights/authorship conflict with a "
959
+ "third-party project partner, 1 for legacy-font extraction "
960
+ "damage); attribution, selection decisions "
961
  "and checksums preserved in the sidecar files.",
962
  "domain": "accessibility/disability guides",
963
  "created": "2017-11-20, 2024-04-19",
src/test_kultura_bez_barier_contribution.py CHANGED
@@ -3,6 +3,7 @@ import hashlib
3
  import json
4
  from pathlib import Path
5
  import re
 
6
 
7
  import pyarrow.parquet as pq
8
 
@@ -12,6 +13,7 @@ FIELDS = ["id", "text", "source", "added", "created", "token_count", "license",
12
  ROOT = Path(__file__).resolve().parents[1]
13
  DATA = ROOT / "data" / SOURCE
14
  MANIFEST = ROOT / "artifacts" / f"{SOURCE}_ontology_manifest.json"
 
15
 
16
 
17
  def digest(payload):
@@ -49,7 +51,8 @@ def test_ontology_is_addressed_and_falsifiable():
49
  assert all(set(item["supported_by"]) <= evidence for item in manifest["claims"])
50
  assert len(manifest["runs"]) >= 2 and all(item["success"] for item in manifest["runs"])
51
  assert any(item["predicate"] == "VALIDATED_AGAINST" for item in manifest["relations"])
52
- checks = next(item["payload"] for item in manifest["evidence"] if item["observation_type"] == "checksums")
 
53
  mapping = {
54
  "data/train-00000-of-00001.parquet": DATA / f"{SOURCE}.parquet",
55
  "artifacts/attribution.jsonl": DATA / f"{SOURCE}.attribution.jsonl",
@@ -62,3 +65,19 @@ def test_ontology_is_addressed_and_falsifiable():
62
  }
63
  for name, path in mapping.items():
64
  assert digest(path.read_bytes()) == checks[name]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  import json
4
  from pathlib import Path
5
  import re
6
+ import sys
7
 
8
  import pyarrow.parquet as pq
9
 
 
13
  ROOT = Path(__file__).resolve().parents[1]
14
  DATA = ROOT / "data" / SOURCE
15
  MANIFEST = ROOT / "artifacts" / f"{SOURCE}_ontology_manifest.json"
16
+ CARD = DATA / f"{SOURCE}.md"
17
 
18
 
19
  def digest(payload):
 
51
  assert all(set(item["supported_by"]) <= evidence for item in manifest["claims"])
52
  assert len(manifest["runs"]) >= 2 and all(item["success"] for item in manifest["runs"])
53
  assert any(item["predicate"] == "VALIDATED_AGAINST" for item in manifest["relations"])
54
+ current = next(item["supported_by"] for item in manifest["claims"] if item["id"] == "claim:replayable")
55
+ checks = next(item["payload"] for item in manifest["evidence"] if item["id"] in current)
56
  mapping = {
57
  "data/train-00000-of-00001.parquet": DATA / f"{SOURCE}.parquet",
58
  "artifacts/attribution.jsonl": DATA / f"{SOURCE}.attribution.jsonl",
 
65
  }
66
  for name, path in mapping.items():
67
  assert digest(path.read_bytes()) == checks[name]
68
+
69
+
70
+ def test_no_phone_left_for_the_wider_patterns():
71
+ """v0.2.6 rights audit (v2#57): ted_pl's patterns find nothing left to mask in the text or the card."""
72
+ sys.path.insert(0, str(ROOT / "src"))
73
+ from build_ted_pl import redact_pii
74
+ for item in pq.read_table(DATA / f"{SOURCE}.parquet").to_pylist():
75
+ assert redact_pii(item["text"])[0] == item["text"], item["id"]
76
+ assert redact_pii(CARD.read_text(encoding="utf-8"))[1]["phone"] == 0
77
+
78
+
79
+ def test_card_cites_the_only_embedded_licence_line():
80
+ line = "Publikacja jest dostępna na licencji CC BY-SA."
81
+ texts = {item["id"]: item["text"] for item in pq.read_table(DATA / f"{SOURCE}.parquet").to_pylist()}
82
+ assert [key for key, text in texts.items() if line in text] == [f"{SOURCE}_jak_udostepniac_kulture"]
83
+ assert line in CARD.read_text(encoding="utf-8")