ppuzio commited on
Commit
7444b7d
·
1 Parent(s): eb5c9fa

Add CC BY-SA 3.0 Polish cultural-accessibility guides (#27)

Browse files

- Add kultura_bez_barier_pl: accessibility guides (scoped to source files) (2ae87973217935bf33958d0e51cc72587ed08071)

artifacts/kultura_bez_barier_pl_ontology_manifest.json ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "actors": [
3
+ {
4
+ "id": "actor:piotrsty",
5
+ "type": "Contributor"
6
+ },
7
+ {
8
+ "id": "actor:fundacja-kultury-bez-barier",
9
+ "type": "Organization"
10
+ },
11
+ {
12
+ "id": "actor:codex",
13
+ "type": "Agent"
14
+ }
15
+ ],
16
+ "claims": [
17
+ {
18
+ "falsification_condition": "A published checksum differs or the builder cannot reproduce retained text from the pinned raw PDFs.",
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
+ {
26
+ "falsification_condition": "The pinned catalogue lacks that declaration or a selected file is outside its demonstrated scope.",
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
+ ],
34
+ "evidence": [
35
+ {
36
+ "id": "evidence:checksums:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
37
+ "observation_type": "checksums",
38
+ "payload": {
39
+ "NOTICE.md": "69db282ba649ab9d7dee2d52cee24005b046fdf3371198642ecbb15f6d110d12",
40
+ "README.md": "04ff8ca176daa3b7a5ca926c1ee9c0f9aa481d05c9f7b68e074ca91c98cb1d77",
41
+ "artifacts/attribution.jsonl": "4e592737d4d9c93a67c6437d5ad3881e92f8fb9aec62064eaaa84625144cf538",
42
+ "artifacts/catalog.html": "7bc2a7c995dd67a58e592e63311a53f5bebe0c2c580ca403574437a3254253bf",
43
+ "artifacts/decisions.jsonl": "edc18820ed6819721650d59d530375246daa32e86fd7ff6e66d8bcada08ea16e",
44
+ "artifacts/inventory.json": "496bd4655b15e9573e346fc6322b42a59b40739580fc249c9b318e0c91d9acc5",
45
+ "artifacts/qa.json": "3946eb001b0f43248a54256099ff98021cf14eec4e9e94c402210f88563ead58",
46
+ "artifacts/raw/abc_gosc_niepelnosprawny.pdf": "8918966789ed103efca9c2272363ff7ea51e703bb90585633f16e6198dbe6ff6",
47
+ "artifacts/raw/abc_gosc_niepelnosprawny_cz2.pdf": "ad16b7ed02fb1aebd03c640d52c1baf664b6f7e77e013230985e5902c4dffcf1",
48
+ "artifacts/raw/audiodeskrypcja_obrazow.pdf": "ee6b90bf064f3ab9affc5a2568bc28a89a519a9a1cf87506ed1e0b877cba0664",
49
+ "artifacts/raw/audiodeskrypcja_zasady.pdf": "ada6db63e05aa2f4dd3474d1f7c7a41b74fd10c19de335015d40eb814ecba97f",
50
+ "artifacts/raw/checklisty_warsztaty_kulinarne.pdf": "ca8b0adbe3142fdad18bac76b35e1406b3ed020a556c26a3187efdc1d5f31095",
51
+ "artifacts/raw/filmolekcje.pdf": "fde70eecb7c26bbb7c3881d3c1ad1931c1ceb16e6d5ff13dfe102ddfa4aedd2a",
52
+ "artifacts/raw/jak_udostepniac_kulture.pdf": "9b3ad5a21a15d41025ad9d1b9ecbac95149ba8b192e85429871c57458a7d7f04",
53
+ "artifacts/raw/model_dostepnej_kultury_2023.pdf": "96f0600ec29fb3e4845099c03eee3c08e89d2c703ddc08db305d5c1c043abeea",
54
+ "artifacts/raw/napisy_dla_nieslyszacych.pdf": "ca979ff6fd85dde0d2a5e1affb5e9b6bb83e8cda6743ab231eebf0f96f8dce96",
55
+ "artifacts/raw/paszport_do_sztuki.pdf": "d07ae6db501eeb7cf73972e5a9efcf92f9ada5786163d87d8df20d8bc8ca539e",
56
+ "artifacts/raw/podsumowanie_wizyt_studyjnych.pdf": "7df24e84f13fb51ef9b4257dce527e626c18c2c55fc80b3ef38489a96f6b6ac5",
57
+ "artifacts/raw/przewodnik_po_dostepnosci.pdf": "84cf7c9694556be3c5926fee6613cd81a57416346c69a6e03a749c9432931fc8",
58
+ "artifacts/run.json": "d2513ac92491de72a18ddbec55c38b79d17f37d6060cd49a0671be9e07df6c25",
59
+ "artifacts/sample.jsonl": "9ce1a4cc8f2b6a8882f1a795d3b7f8bbb133c9c81ae6507830bb7b2a2f1bd7e5",
60
+ "artifacts/stats.json": "5fc1c11510ed0536bb3a4f2c86397006642911d8542c9c28bc88dacefa392ac3",
61
+ "data/train-00000-of-00001.parquet": "1d9cd403ab297b3a8a84ce6ae7a25e4f4fd5025b37be959e4692a5170ed64642",
62
+ "src/build_kultura_bez_barier_pl.py": "18ce80a8e4fcc7555c687e5fc810b97565eef51255667f69375b3dd6e5932b27",
63
+ "src/requirements.txt": "807ccb72d622706ea3b41d39190c6258a17d4f5472eeab294a9d483eb4c44ac1",
64
+ "src/test_kultura_bez_barier_contribution.py": "68bce1bd6c383130f94b27e2c8dea384298e45848e002a22be6718158c967777"
65
+ },
66
+ "produced_by": "run:3aa251975f82e4a35004fad877d29b933ed49d4308072502e3b193f90babd737"
67
+ },
68
+ {
69
+ "id": "evidence:qa:87b67c4b2f35b27cb6f9b0f80efcd335df4d6f96351635f262e527361277dd19",
70
+ "observation_type": "qa",
71
+ "payload": {
72
+ "benchmark_overlap": "pending",
73
+ "cross_source_dedup": "pending target integration",
74
+ "exact_normalized_dedup": true,
75
+ "license_gate": "official catalogue-level CC BY-SA 3.0 declaration; per-PDF embedded notices not required or asserted",
76
+ "limitations": [
77
+ "catalogue-level rights statement requires maintainer/legal interpretation for each linked publication",
78
+ "PDF extraction can flatten tables and omit images",
79
+ "embedded third-party quotations require review",
80
+ "pattern checks are not comprehensive de-identification",
81
+ "text novelty and training benefit are not asserted"
82
+ ],
83
+ "near_dedup": {
84
+ "method": "seeded MinHash 128 / LSH 0.8 candidates / exact 5-word Jaccard >= 0.9",
85
+ "removed": []
86
+ },
87
+ "pii_pattern_matches": {
88
+ "email": 16,
89
+ "labelled_phone": 1
90
+ }
91
+ },
92
+ "produced_by": "run:e451d83a46337b6ac0db4abe552a9775b110b06876b6ec252922ddb4c18fd657"
93
+ }
94
+ ],
95
+ "objects": [
96
+ {
97
+ "id": "object:source:kultura-bez-barier",
98
+ "type": "Source"
99
+ },
100
+ {
101
+ "id": "object:dataset:kultura-bez-barier-pl",
102
+ "type": "Dataset"
103
+ }
104
+ ],
105
+ "pending": [
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
+ {
113
+ "id": "protocol:pdf-text-v1",
114
+ "procedure": "allowlist, pdfplumber extraction, normalization, PII patterns, exact and seeded near dedup"
115
+ },
116
+ {
117
+ "id": "protocol:contract-v1",
118
+ "procedure": "schema, checksum, sample, rights-evidence and ontology contract checks"
119
+ }
120
+ ],
121
+ "relations": [
122
+ {
123
+ "predicate": "DERIVED_FROM",
124
+ "source": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
125
+ "target": "version:source:a0e0c66be7bd6125a223d7d3be7143f0cc9bd7cc6026e8c4051ebdd8670c3c00"
126
+ },
127
+ {
128
+ "predicate": "GENERATED_BY",
129
+ "source": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
130
+ "target": "run:e451d83a46337b6ac0db4abe552a9775b110b06876b6ec252922ddb4c18fd657"
131
+ },
132
+ {
133
+ "predicate": "VALIDATED_AGAINST",
134
+ "source": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
135
+ "target": "run:3aa251975f82e4a35004fad877d29b933ed49d4308072502e3b193f90babd737"
136
+ }
137
+ ],
138
+ "runs": [
139
+ {
140
+ "finished_at": "2026-09-07T06:52:45.774841+00:00",
141
+ "id": "run:e451d83a46337b6ac0db4abe552a9775b110b06876b6ec252922ddb4c18fd657",
142
+ "protocol": "protocol:pdf-text-v1",
143
+ "started_at": "2026-09-07T06:51:36.737857+00:00",
144
+ "success": true
145
+ },
146
+ {
147
+ "finished_at": "2026-09-07T06:56:10.112370+00:00",
148
+ "id": "run:3aa251975f82e4a35004fad877d29b933ed49d4308072502e3b193f90babd737",
149
+ "protocol": "dataset-contract-and-checksum-validation-v1",
150
+ "started_at": "2026-09-07T06:56:10.112370+00:00",
151
+ "stats": {
152
+ "acquired": 12,
153
+ "added": "2026-09-07",
154
+ "author_coverage": 1.0,
155
+ "characters": 608827,
156
+ "discovered": 12,
157
+ "kept": 9,
158
+ "pages": 316,
159
+ "rejected": 3,
160
+ "sample_count": 9,
161
+ "tokens": 217932,
162
+ "unknown_created": 0
163
+ },
164
+ "success": true,
165
+ "target_main_revision": "a916edecabc2be8832e08fb2bd9dfafcc1d2dd71"
166
+ }
167
+ ],
168
+ "schema": "slayer-research-ontology-profile-v1",
169
+ "versions": [
170
+ {
171
+ "content_address": "a0e0c66be7bd6125a223d7d3be7143f0cc9bd7cc6026e8c4051ebdd8670c3c00",
172
+ "id": "version:source:a0e0c66be7bd6125a223d7d3be7143f0cc9bd7cc6026e8c4051ebdd8670c3c00",
173
+ "object": "object:source:kultura-bez-barier"
174
+ },
175
+ {
176
+ "content_address": "99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
177
+ "id": "version:dataset:99aefe134f168e718b685ddd6c7b7cd722ff56b66afa3ed27742fc827c02a922",
178
+ "object": "object:dataset:kultura-bez-barier-pl"
179
+ }
180
+ ]
181
+ }
artifacts/source_findings.md CHANGED
@@ -685,3 +685,38 @@ suffices.
685
  label-anchored patterns (same lesson as `open_icm_pl`'s glyph noise): a zero
686
  pattern count is not evidence in contact-bearing registers — run the spot check
687
  and the model scrubber.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
685
  label-anchored patterns (same lesson as `open_icm_pl`'s glyph noise): a zero
686
  pattern count is not evidence in contact-bearing registers — run the spot check
687
  and the model scrubber.
688
+
689
+ ---
690
+
691
+ ## kultura_bez_barier_pl — cultural-accessibility guides (FKzB)
692
+
693
+ **Investigated** — 2026-09-07 (review round 2026-09-28).
694
+
695
+ **Verdict** — `added` (proposed with `release: None`). 9 guides / 218k
696
+ `cl100k_base` tokens (316 pages) of prepared didactic Polish for cultural-sector
697
+ accessibility work - tiny, but a clean CC BY-SA 3.0 source with preserved raw
698
+ PDFs and per-record evidence.
699
+
700
+ **Enumeration** — the foundation's catalogue <https://kulturabezbarier.org/publikacje/>:
701
+ 12 linked publications discovered, 9 retained. 3 rejected conservatively: 2 NIMOZ
702
+ co-published volumes (PDF copyright notices name the third-party institute) and
703
+ 1 for legacy-font extraction damage.
704
+
705
+ **License evidence** — the catalogue's own statement (quoted in the datasheet)
706
+ offers the foundation-authored publications under CC BY-SA 3.0 with attribution
707
+ and share-alike terms; reading is catalogue-level ("plik pierwotny"), pictograms
708
+ explicitly included, no per-PDF embedded assertion claimed. Per-record
709
+ corroboration: PDF metadata + credit lines; `attribution.jsonl` pins the
710
+ evidence URL and scope note.
711
+
712
+ **Blockers** — none to merge with `release: None`. Before release: NERGAL pass —
713
+ the all-9 spot check found **real residual contacts** in
714
+ `podsumowanie_wizyt_studyjnych` (coordinator names + phones under `Tel./SMS`
715
+ label variants the pattern misses, e-mails beside them redacted) — and
716
+ maintainer sign-off on the catalogue-level scope reading.
717
+
718
+ **Lesson** — catalogue-level license statements need the reading written down
719
+ (what "je" covers), and the safest per-record confirmation is negative: reject
720
+ every item with third-party authorship signals, as this PR does with the NIMOZ
721
+ volumes. Also: `Tel./SMS`-style label variants defeat label-anchored phone
722
+ patterns — third independent pattern-evasion case in this review round.
data/kultura_bez_barier_pl/NOTICE.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Notice and attribution
2
+
3
+ Source: https://kulturabezbarier.org/publikacje/
4
+
5
+ The official catalogue describes the linked publications as authored by Fundacja Kultury bez Barier and states that they are made available under CC BY-SA 3.0. The catalogue HTML, raw PDFs, source URLs and SHA-256 digests are preserved. This is catalogue-level evidence; an embedded per-PDF license assertion is not claimed.
6
+
7
+ Dataset transformations: text extraction, removal of page-number-only lines, line-wrap repair, Unicode/whitespace normalization, limited PII-pattern redaction, exact and near deduplication. Images are not included in the training text. Attribution and a modification notice must be preserved under CC BY-SA 3.0.
data/kultura_bez_barier_pl/kultura_bez_barier_pl.attribution.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e592737d4d9c93a67c6437d5ad3881e92f8fb9aec62064eaaa84625144cf538
3
+ size 15320
data/kultura_bez_barier_pl/kultura_bez_barier_pl.decisions.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edc18820ed6819721650d59d530375246daa32e86fd7ff6e66d8bcada08ea16e
3
+ size 4288
data/kultura_bez_barier_pl/kultura_bez_barier_pl.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-3.0
3
+ language:
4
+ - pl
5
+ task_categories:
6
+ - text-generation
7
+ configs:
8
+ - config_name: default
9
+ data_files:
10
+ - split: train
11
+ path: data/train-00000-of-00001.parquet
12
+ ---
13
+
14
+ # Kultura bez Barier PL
15
+
16
+ Polish text extracted from openly published accessibility guides by Fundacja Kultury bez Barier.
17
+
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
+
25
+ See `NOTICE.md` and `artifacts/` for the source inventory, raw PDFs, attribution, selection decisions, QA, checksums, samples and Slayer ontology manifest.
26
+
27
+ ## License at the origin (and per-guide coverage)
28
+
29
+ The origin is the foundation's own publication catalogue:
30
+ <https://kulturabezbarier.org/publikacje/>. Its statement, verbatim: "Poniżej
31
+ znajdują się publikacje autorstwa Fundacji Kultury bez Barier, takie jak
32
+ przewodniki i poradniki pomocne w pracy z osobami z niepełnosprawnościami. Wśród
33
+ nich znajdują się piktogramy ilustrujące dostępność. Oddajemy je na licencji
34
+ Creative Commons (CC BY-SA 3.0). Oznacza to, że można ich używać (podając
35
+ autora), zmieniać (wskazując te zmiany) i rozpowszechniać (na tej samej
36
+ licencji co plik pierwotny, czyli nasz)." The grant ("Oddajemy je na licencji…",
37
+ with the distribution terms referring to "plik pierwotny") covers the offered
38
+ foundation-authored publication files, with the accessibility pictograms
39
+ 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
+
55
+ - **Genre**: accessibility guides and handbooks for cultural institutions -
56
+ practical checklists ("Warsztaty kulinarne dla osób niewidomych"), rules and
57
+ how-to guides ("Napisy dla osób niesłyszących", "Przewodnik po dostępności"),
58
+ a strategic report ("Model dostępnej kultury 2023"), study-visit summaries.
59
+ - **Register**: prepared didactic/institutional Polish - clear instructive prose,
60
+ lists, checklists, directory-style contact sections; professionally edited,
61
+ aimed at cultural-sector staff. Not OCR'd (born-digital PDFs), not
62
+ machine-translated.
63
+ - **Time span**: PDF creation dates `2017-11-20` - `2024-04-19` (per-record
64
+ `created`; `created_semantics` records the provenance of each date).
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.
data/kultura_bez_barier_pl/kultura_bez_barier_pl.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d9cd403ab297b3a8a84ce6ae7a25e4f4fd5025b37be959e4692a5170ed64642
3
+ size 245697
data/kultura_bez_barier_pl/kultura_bez_barier_pl.qa.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "benchmark_overlap": "pending",
3
+ "cross_source_dedup": "pending target integration",
4
+ "exact_normalized_dedup": true,
5
+ "license_gate": "official catalogue-level CC BY-SA 3.0 declaration; per-PDF embedded notices not required or asserted",
6
+ "limitations": [
7
+ "catalogue-level rights statement requires maintainer/legal interpretation for each linked publication",
8
+ "PDF extraction can flatten tables and omit images",
9
+ "embedded third-party quotations require review",
10
+ "pattern checks are not comprehensive de-identification",
11
+ "text novelty and training benefit are not asserted"
12
+ ],
13
+ "near_dedup": {
14
+ "method": "seeded MinHash 128 / LSH 0.8 candidates / exact 5-word Jaccard >= 0.9",
15
+ "removed": []
16
+ },
17
+ "pii_pattern_matches": {
18
+ "email": 16,
19
+ "labelled_phone": 1
20
+ }
21
+ }
data/kultura_bez_barier_pl/kultura_bez_barier_pl.sample.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/kultura_bez_barier_pl/kultura_bez_barier_pl.stats.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
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
+ }
src/build_kultura_bez_barier_pl.py ADDED
@@ -0,0 +1,578 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Acquire, normalize, validate and publish Polish Kultura bez Barier publications."""
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import ast
7
+ from collections import Counter
8
+ from datetime import datetime, timezone
9
+ import hashlib
10
+ import json
11
+ import os
12
+ from pathlib import Path
13
+ import pprint
14
+ import re
15
+ import shutil
16
+ import subprocess
17
+ import sys
18
+ 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"
28
+ OWN_REPO = "PiotrSty/kultura-bez-barier-pl"
29
+ TARGET = "SlayerLab/polish-dynaword"
30
+ LICENSE = "CC-BY-SA-3.0"
31
+ LICENSE_URL = "https://creativecommons.org/licenses/by-sa/3.0/"
32
+ AUTHOR = "Fundacja Kultury bez Barier"
33
+ FIELDS = ["id", "text", "source", "added", "created", "token_count", "license", "author"]
34
+ UA = "KulturaBezBarierTextResearch/1.0 (PiotrSty; open Polish publication corpus)"
35
+
36
+ PUBLICATIONS = (
37
+ ("checklisty_warsztaty_kulinarne", "Checklisty - warsztaty kulinarne dla osob z niepelnosprawnosciami", "https://kulturabezbarier.org/wp-content/uploads/2024/04/Checklisty-%E2%80%94-warsztaty-kulinarne-dla-osob-z-niepelnosprawnosciami.pdf"),
38
+ ("model_dostepnej_kultury_2023", "Model dostepnej kultury", "https://kulturabezbarier.org/wp-content/uploads/2024/04/Model_Dostepnej_Kultury_2023.pdf"),
39
+ ("audiodeskrypcja_obrazow", "Audiodeskrypcja obrazow - publikacja na 10 lat wspolnej pracy", "https://kulturabezbarier.org/wp-content/uploads/2022/04/Audiodeskrypcja-obrazo%CC%81w_publikacja-na-10-lat-wspo%CC%81lnej-pracy.pdf"),
40
+ ("jak_udostepniac_kulture", "Jak udostepniac kulture osobom z niepelnosprawnosciami", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Publikacja_FKBB.pdf"),
41
+ ("podsumowanie_wizyt_studyjnych", "Podsumowanie wizyt studyjnych", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Podsumowanie.pdf"),
42
+ ("przewodnik_po_dostepnosci", "Przewodnik po dostepnosci", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Otwarci-dla-wszystkich-publikacja-www.pdf"),
43
+ ("paszport_do_sztuki", "Paszport do sztuki - dziennik z wyprawy", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Gietko_FKBB_Paszport_do_sztuki_publikacja_do_netu.pdf"),
44
+ ("filmolekcje", "Filmolekcje dla kazdego", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Filmolekcje-2.pdf"),
45
+ ("abc_gosc_niepelnosprawny", "ABC Gosc niepelnosprawny w muzeum", "https://kulturabezbarier.org/wp-content/uploads/2019/12/ABC_Gosc_niepelnosprawny_lekki.pdf"),
46
+ ("abc_gosc_niepelnosprawny_cz2", "ABC Gosc niepelnosprawny w muzeum cz. 2", "https://kulturabezbarier.org/wp-content/uploads/2019/12/ABC_Gosc_niepelnosprawny_cz2.pdf"),
47
+ ("audiodeskrypcja_zasady", "Audiodeskrypcja - zasady tworzenia", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Audiodeskrypcja-zasady-tworzenia.pdf"),
48
+ ("napisy_dla_nieslyszacych", "Napisy dla osob nieslyszacych i slaboslyszacych - zasady tworzenia", "https://kulturabezbarier.org/wp-content/uploads/2019/12/Napisy-dla-nieslyszacych_zasady-tworzenia_2019.pdf"),
49
+ )
50
+
51
+ AUTHORS = {
52
+ "checklisty_warsztaty_kulinarne": "Julianna Matuszewska",
53
+ "model_dostepnej_kultury_2023": "Fundacja Kultury bez Barier; Robert Więckowski",
54
+ "audiodeskrypcja_obrazow": "Robert Więckowski; Anna Żórawska; Fundacja Kultury bez Barier",
55
+ "jak_udostepniac_kulture": "Fundacja Kultury bez Barier",
56
+ "podsumowanie_wizyt_studyjnych": "Fundacja Kultury bez Barier",
57
+ "przewodnik_po_dostepnosci": "Monika Dubiel; Izabela Sopalska-Rybak; Aleksandra Szorc; Aleksandra Sztajerwald; Robert Więckowski",
58
+ "paszport_do_sztuki": "Fundacja Kultury bez Barier",
59
+ "filmolekcje": "Monika Dubiel; Aleksandra Szorc",
60
+ "napisy_dla_nieslyszacych": "Izabela Künstler; Urszula Butkiewicz",
61
+ }
62
+
63
+ RIGHTS_CONFLICTS = {
64
+ "abc_gosc_niepelnosprawny": "PDF copyright notice names Narodowy Instytut Muzealnictwa i Ochrony Zbiorów",
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",
71
+ )
72
+
73
+
74
+ def now():
75
+ return datetime.now(timezone.utc).isoformat()
76
+
77
+
78
+ def sha(value):
79
+ if not isinstance(value, bytes):
80
+ value = json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
81
+ return hashlib.sha256(value).hexdigest()
82
+
83
+
84
+ def save(path, value):
85
+ path.parent.mkdir(parents=True, exist_ok=True)
86
+ path.write_text(json.dumps(value, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8")
87
+
88
+
89
+ def load(path):
90
+ return json.loads(path.read_text(encoding="utf-8"))
91
+
92
+
93
+ def write_lines(path, rows):
94
+ path.parent.mkdir(parents=True, exist_ok=True)
95
+ path.write_text("".join(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n" for row in rows), encoding="utf-8")
96
+
97
+
98
+ def read_lines(path):
99
+ return [json.loads(line) for line in path.read_text(encoding="utf-8").splitlines() if line]
100
+
101
+
102
+ def normalize(text):
103
+ text = unicodedata.normalize("NFKC", text).replace("\u00ad", "").replace("\u200b", "")
104
+ text = re.sub(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]", "", text)
105
+ lines = [re.sub(r"[ \t\xa0]+", " ", line).strip() for line in text.splitlines()]
106
+ return re.sub(r"\n{3,}", "\n\n", "\n".join(lines)).strip()
107
+
108
+
109
+ def http_get(url, attempts=5):
110
+ response = None
111
+ for attempt in range(attempts):
112
+ response = requests.get(url, timeout=(20, 120), headers={"User-Agent": UA, "Accept-Language": "pl"})
113
+ if response.status_code not in (429, 500, 502, 503, 504):
114
+ response.raise_for_status()
115
+ return response
116
+ time.sleep(2 ** attempt)
117
+ response.raise_for_status()
118
+
119
+
120
+ def catalog_license_evidence(html):
121
+ text = normalize(re.sub(r"<[^>]+>", " ", html))
122
+ compact = " ".join(text.split())
123
+ required = ("publikacje autorstwa Fundacji Kultury bez Barier", "CC BY-SA 3.0")
124
+ if not all(phrase.casefold() in compact.casefold() for phrase in required):
125
+ raise ValueError("catalogue-level authorship/license declaration not found")
126
+ if re.search(r"(?i)CC\s*BY[- ]NC|licenses/by-nc", compact):
127
+ raise ValueError("noncommercial marker found in catalogue")
128
+ marker = compact.casefold().index("publikacje autorstwa")
129
+ return compact[marker:marker + 700]
130
+
131
+
132
+ def pdf_created(metadata):
133
+ raw = str((metadata or {}).get("/CreationDate", ""))
134
+ match = re.search(r"D:(\d{4})(\d{2})(\d{2})", raw)
135
+ if match:
136
+ year, month, day = map(int, match.groups())
137
+ if 1990 <= year <= datetime.now().year and 1 <= month <= 12 and 1 <= day <= 31:
138
+ return f"{year:04d}-{month:02d}-{day:02d}"
139
+ return "unknown"
140
+
141
+
142
+ def extract_pdf(path):
143
+ reader = PdfReader(path)
144
+ pages = []
145
+ failures = []
146
+ with pdfplumber.open(path) as document:
147
+ for index, page in enumerate(document.pages, 1):
148
+ try:
149
+ pages.append(normalize(page.extract_text() or ""))
150
+ except Exception as error:
151
+ pages.append("")
152
+ failures.append({"page": index, "error": str(error)})
153
+ return {
154
+ "page_count": len(reader.pages),
155
+ "metadata": {str(k): str(v) for k, v in (reader.metadata or {}).items()},
156
+ "pages": pages,
157
+ "page_failures": failures,
158
+ }
159
+
160
+
161
+ def acquire(out):
162
+ if (out / "inventory.json").exists():
163
+ raise ValueError("inventory exists; use a fresh output for a new immutable acquisition")
164
+ out.mkdir(parents=True, exist_ok=True)
165
+ raw_dir = out / "raw"
166
+ raw_dir.mkdir(exist_ok=True)
167
+ catalog = http_get(CATALOG)
168
+ (out / "catalog.html").write_bytes(catalog.content)
169
+ declaration = catalog_license_evidence(catalog.text)
170
+ normalized_catalog = unicodedata.normalize("NFC", unquote(catalog.text)).casefold()
171
+ records, failures = [], []
172
+ for index, (slug, title, url) in enumerate(PUBLICATIONS, 1):
173
+ try:
174
+ normalized_name = unicodedata.normalize("NFC", unquote(Path(url).name)).casefold()
175
+ if normalized_name not in normalized_catalog:
176
+ raise ValueError("allowlisted URL not found in catalogue HTML")
177
+ response = http_get(url)
178
+ if not response.content.startswith(b"%PDF"):
179
+ raise ValueError("response is not a PDF")
180
+ path = raw_dir / f"{slug}.pdf"
181
+ path.write_bytes(response.content)
182
+ extracted = extract_pdf(path)
183
+ records.append({"slug": slug, "title": title, "url": url, "observed_at": now(),
184
+ "pdf_sha256": sha(response.content), "bytes": len(response.content), **extracted})
185
+ except Exception as error:
186
+ failures.append({"slug": slug, "url": url, "error": str(error)})
187
+ print(f"Acquired {index}/{len(PUBLICATIONS)}; failures={len(failures)}", flush=True)
188
+ time.sleep(0.2)
189
+ save(out / "inventory.json", {"catalog_url": CATALOG, "catalog_sha256": sha(catalog.content),
190
+ "catalog_observed_at": now(), "catalog_license_evidence": declaration,
191
+ "license_scope_note": "Catalogue-level declaration adjacent to the linked publications; not a per-PDF embedded assertion.",
192
+ "selected_publications": [list(item) for item in PUBLICATIONS], "records": records, "failures": failures,
193
+ "explicit_exclusions": ["German Model edition", "PNG/SVG pictograms", "Igor comic", "duplicate DOCX rendition"]})
194
+ if failures:
195
+ raise ValueError("acquisition incomplete; inspect inventory failures")
196
+
197
+
198
+ def repair_wrapped_text(pages):
199
+ output = []
200
+ for page in pages:
201
+ lines = [line for line in page.splitlines() if not re.fullmatch(r"\s*\d{1,3}\s*", line)]
202
+ text = "\n".join(lines)
203
+ text = re.sub(r"(?<=\w)-\n(?=[a-ząćęłńóśźż])", "", text)
204
+ text = re.sub(r"(?<![.!?:;])\n(?=[a-ząćęłńóśźż])", " ", text)
205
+ output.append(normalize(text))
206
+ return normalize("\n\n".join(part for part in output if part))
207
+
208
+
209
+ def credit_lines(pages):
210
+ selected = pages[:3] + pages[-3:]
211
+ pattern = re.compile(r"(?i)(?:^|\b)(autor(?:zy|ka|ki)?|teksty|opracowanie|redakcja|publikację wspólnie stworzyli|copyright|©)(?:\b|:)")
212
+ return [normalize(line)[:500] for page in selected for line in page.splitlines() if pattern.search(line)][:40]
213
+
214
+
215
+ def near_dedup(rows):
216
+ from datasketch import MinHash, MinHashLSH
217
+ index = MinHashLSH(threshold=0.8, num_perm=128)
218
+ features, kept, removed = {}, [], []
219
+ for row in rows:
220
+ words = re.findall(r"\w+", row["text"].casefold())
221
+ shingles = {" ".join(words[i:i + 5]).encode() for i in range(max(0, len(words) - 4))}
222
+ sig = MinHash(num_perm=128, seed=1)
223
+ if not shingles:
224
+ kept.append(row)
225
+ continue
226
+ sig.update_batch(sorted(shingles))
227
+ for candidate in sorted(index.query(sig)):
228
+ score = len(shingles & features[candidate]) / len(shingles | features[candidate])
229
+ if score >= 0.9:
230
+ removed.append({"id": row["id"], "duplicate_of": candidate, "jaccard": score})
231
+ break
232
+ else:
233
+ kept.append(row)
234
+ features[row["id"]] = shingles
235
+ index.insert(row["id"], sig)
236
+ return kept, removed
237
+
238
+
239
+ def build(out):
240
+ import pyarrow as pa
241
+ import pyarrow.parquet as pq
242
+ import tiktoken
243
+ from langid.langid import LanguageIdentifier, model
244
+ inventory = load(out / "inventory.json")
245
+ if inventory["failures"] or len(inventory["records"]) != len(PUBLICATIONS):
246
+ raise ValueError("cannot build from incomplete inventory")
247
+ encoder = tiktoken.get_encoding("cl100k_base")
248
+ identifier = LanguageIdentifier.from_modelstring(model, norm_probs=True)
249
+ identifier.set_languages(["pl", "en", "de", "cs", "sk", "uk", "ru"])
250
+ rows, attribution, decisions, seen = [], [], [], {}
251
+ pii = Counter()
252
+ added = inventory["catalog_observed_at"][:10]
253
+ for record in sorted(inventory["records"], key=lambda item: item["slug"]):
254
+ path = out / "raw" / f"{record['slug']}.pdf"
255
+ if sha(path.read_bytes()) != record["pdf_sha256"]:
256
+ raise ValueError("raw PDF checksum mismatch: " + record["slug"])
257
+ body = repair_wrapped_text(record["pages"])
258
+ letters = len(re.findall(r"[A-Za-zĄĆĘŁŃÓŚŹŻąćęłńóśźż]", body))
259
+ garbled_controls = sum(0x80 <= ord(char) <= 0x9F or ord(char) == 0xFFFD for char in body)
260
+ combining_marks = sum(unicodedata.combining(char) > 0 for char in body)
261
+ legacy_garble_words = sum(body.casefold().count(word.casefold()) for word in LEGACY_GARBLE_WORDS)
262
+ reason = ""
263
+ if record["slug"] in RIGHTS_CONFLICTS:
264
+ reason = "rights_or_authorship_conflict"
265
+ elif record["page_failures"]:
266
+ reason = "page_extraction_failure"
267
+ elif garbled_controls:
268
+ reason = "text_extraction_garbled"
269
+ elif combining_marks:
270
+ reason = "text_extraction_split_diacritics"
271
+ elif legacy_garble_words > 10:
272
+ reason = "text_extraction_legacy_font_mapping"
273
+ elif len(body) < 1000:
274
+ reason = "too_little_extractable_text"
275
+ elif letters / max(len(body), 1) < 0.55:
276
+ reason = "low_letter_ratio"
277
+ language, confidence = identifier.classify(body[:20000]) if body else ("unknown", 0.0)
278
+ if not reason and language != "pl" and confidence >= 0.98:
279
+ reason = "non_polish"
280
+ body, emails = re.subn(r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b", "[REDACTED:EMAIL]", body)
281
+ body, phones = re.subn(r"(?i)(?:\btelefon|\btel\.)\s*:?[ \t]*(?:\+48[ \t]*)?\d(?:[ .-]?\d){8}\b", "[REDACTED:PHONE]", body)
282
+ pii.update(email=emails, labelled_phone=phones)
283
+ text = body
284
+ key = " ".join(text.casefold().split())
285
+ if not reason and key in seen:
286
+ reason = "normalized_duplicate"
287
+ row_id = SOURCE + "_" + record["slug"]
288
+ decisions.append({"id": row_id, "selected": not bool(reason), "reason": reason or "include",
289
+ "pdf_sha256": record["pdf_sha256"], "page_count": record["page_count"],
290
+ "language": language, "language_confidence": float(confidence), "garbled_controls": garbled_controls,
291
+ "combining_marks": combining_marks, "legacy_garble_words": legacy_garble_words,
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"]]
298
+ rows.append({"id": row_id, "text": text, "source": SOURCE, "added": added,
299
+ "created": created, "token_count": len(encoder.encode_ordinary(text)), "license": LICENSE, "author": author})
300
+ attribution.append({"id": row_id, "slug": record["slug"], "title": record["title"], "url": record["url"], "publisher": AUTHOR,
301
+ "author": author, "author_basis": "Official catalogue authorship statement plus PDF metadata or publication credit lines where available.",
302
+ "pdf_metadata": record["metadata"], "credit_lines": credit_lines(record["pages"]),
303
+ "created": created, "created_semantics": "PDF CreationDate metadata when valid; otherwise unknown",
304
+ "license": LICENSE, "license_url": LICENSE_URL, "license_evidence_url": CATALOG,
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:
312
+ if decision["id"] in removed:
313
+ decision.update(selected=False, reason="near_duplicate", duplicate_of=removed[decision["id"]]["duplicate_of"], jaccard=removed[decision["id"]]["jaccard"])
314
+ kept_ids = {row["id"] for row in rows}
315
+ attribution = [item for item in attribution if item["id"] in kept_ids]
316
+ root = out / "hf_repo"
317
+ (root / "data").mkdir(parents=True, exist_ok=True)
318
+ (root / "artifacts/raw").mkdir(parents=True, exist_ok=True)
319
+ schema = pa.schema([(field, pa.int64() if field == "token_count" else pa.string()) for field in FIELDS])
320
+ pq.write_table(pa.Table.from_pylist(rows, schema=schema), root / "data/train-00000-of-00001.parquet", compression="zstd")
321
+ write_lines(root / "artifacts/attribution.jsonl", attribution)
322
+ write_lines(root / "artifacts/decisions.jsonl", decisions)
323
+ samples = sorted(rows, key=lambda row: sha(("sample:" + row["id"]).encode()))[:12]
324
+ write_lines(root / "artifacts/sample.jsonl", samples)
325
+ inventory_copy = dict(inventory)
326
+ inventory_copy["records"] = [{k: v for k, v in item.items() if k != "pages"} for item in inventory["records"]]
327
+ save(root / "artifacts/inventory.json", inventory_copy)
328
+ catalog_snapshot = out / "catalog.html"
329
+ if sha(catalog_snapshot.read_bytes()) != inventory["catalog_sha256"]:
330
+ raise ValueError("catalogue snapshot checksum mismatch")
331
+ shutil.copy2(catalog_snapshot, root / "artifacts/catalog.html")
332
+ for record in inventory["records"]:
333
+ shutil.copy2(out / "raw" / f"{record['slug']}.pdf", root / "artifacts/raw" / f"{record['slug']}.pdf")
334
+ stats = {"discovered": len(PUBLICATIONS), "acquired": len(inventory["records"]), "kept": len(rows),
335
+ "rejected": len(decisions) - len(rows), "tokens": sum(row["token_count"] for row in rows),
336
+ "characters": sum(len(row["text"]) for row in rows), "pages": sum(item["page_count"] for item in attribution),
337
+ "sample_count": len(samples), "author_coverage": sum(bool(row["author"]) for row in rows) / len(rows) if rows else 0,
338
+ "unknown_created": sum(row["created"] == "unknown" for row in rows), "added": added}
339
+ qa = {"license_gate": "official catalogue-level CC BY-SA 3.0 declaration; per-PDF embedded notices not required or asserted",
340
+ "pii_pattern_matches": dict(pii), "exact_normalized_dedup": True,
341
+ "near_dedup": {"method": "seeded MinHash 128 / LSH 0.8 candidates / exact 5-word Jaccard >= 0.9", "removed": near_removed},
342
+ "cross_source_dedup": "pending target integration", "benchmark_overlap": "pending",
343
+ "limitations": ["catalogue-level rights statement requires maintainer/legal interpretation for each linked publication",
344
+ "PDF extraction can flatten tables and omit images", "embedded third-party quotations require review",
345
+ "pattern checks are not comprehensive de-identification", "text novelty and training benefit are not asserted"]}
346
+ save(root / "artifacts/stats.json", stats)
347
+ save(root / "artifacts/qa.json", qa)
348
+ run = {"id": "run:" + sha({"code": sha(Path(__file__).read_bytes()), "catalog": inventory["catalog_sha256"],
349
+ "pdfs": [item["pdf_sha256"] for item in inventory["records"]]}), "started_at": inventory["catalog_observed_at"],
350
+ "finished_at": now(), "code_sha256": sha(Path(__file__).read_bytes()), "success": True,
351
+ "inputs": {"catalog_sha256": inventory["catalog_sha256"], "pdf_sha256": [item["pdf_sha256"] for item in inventory["records"]]}, "stats": stats}
352
+ save(root / "artifacts/run.json", run)
353
+ print(json.dumps(stats, ensure_ascii=False, indent=2), flush=True)
354
+
355
+
356
+ def checksums(root):
357
+ excluded = {"artifacts/checksums.json", "artifacts/ontology.json", "artifacts/validation_run.json"}
358
+ return {path.relative_to(root).as_posix(): sha(path.read_bytes()) for path in sorted(root.rglob("*"))
359
+ if path.is_file() and path.relative_to(root).as_posix() not in excluded}
360
+
361
+
362
+ def registry(base):
363
+ tree = ast.parse(base)
364
+ node = next(item.value for item in tree.body if isinstance(item, ast.Assign)
365
+ and any(isinstance(target, ast.Name) and target.id == "SOURCES" for target in item.targets))
366
+ if SOURCE in ast.literal_eval(node):
367
+ raise ValueError("source already registered")
368
+ entry = {"file_key": SOURCE, "pretty": "Kultura bez Barier - Polish accessibility guides",
369
+ "license": LICENSE, "license_spdx": LICENSE,
370
+ "traceable": "Official publication catalogue declares the linked foundation-authored materials CC BY-SA 3.0; raw PDFs, catalogue HTML, URLs, hashes, attribution and exclusions are preserved.",
371
+ "upstream": CATALOG, "provenance": "Pinned PiotrSty/kultura-bez-barier-pl snapshot acquired from the official Fundacja Kultury bez Barier publication catalogue.",
372
+ "domain": "instructional/cultural-accessibility", "created": "per-record PDF metadata or unknown", "is_ocr": False, "custom_datasheet": True}
373
+ offset = sum(len(line) for line in base.splitlines(keepends=True)[:node.lineno - 1]) + node.col_offset + 1
374
+ return base[:offset] + "\n " + repr(SOURCE) + ": " + pprint.pformat(entry, width=96, sort_dicts=False).replace("\n", "\n ") + "," + base[offset:]
375
+
376
+
377
+ def verify_core(out):
378
+ import pyarrow.parquet as pq
379
+ root = out / "hf_repo"
380
+ table = pq.read_table(root / "data/train-00000-of-00001.parquet")
381
+ rows = table.to_pylist()
382
+ stats = load(root / "artifacts/stats.json")
383
+ attribution = read_lines(root / "artifacts/attribution.jsonl")
384
+ decisions = read_lines(root / "artifacts/decisions.jsonl")
385
+ sample = read_lines(root / "artifacts/sample.jsonl")
386
+ assert table.column_names == FIELDS
387
+ assert len(rows) == stats["kept"] == len(attribution)
388
+ assert len(decisions) == stats["discovered"]
389
+ assert sum(bool(item["selected"]) for item in decisions) == stats["kept"]
390
+ assert sum(row["token_count"] for row in rows) == stats["tokens"]
391
+ assert {row["id"] for row in rows} == {item["id"] for item in attribution}
392
+ assert all(row["source"] == SOURCE and row["license"] == LICENSE and row["author"] for row in rows)
393
+ assert not ({item["slug"] for item in attribution} & set(RIGHTS_CONFLICTS))
394
+ assert all(not re.search(r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b", row["text"]) for row in rows)
395
+ by_id = {row["id"]: row for row in rows}
396
+ assert len(sample) == min(12, len(rows)) and all(by_id[item["id"]] == item for item in sample)
397
+ if (root / "artifacts/checksums.json").exists():
398
+ for name, digest in load(root / "artifacts/checksums.json").items():
399
+ assert sha((root / name).read_bytes()) == digest
400
+ return stats
401
+
402
+
403
+ def prepare(out, target_revision):
404
+ root = out / "hf_repo"
405
+ (root / "src").mkdir(exist_ok=True)
406
+ shutil.copy2(Path(__file__), root / "src/build_kultura_bez_barier_pl.py")
407
+ shutil.copy2(Path(__file__).with_name("kultura_bez_barier_requirements.txt"), root / "src/requirements.txt")
408
+ shutil.copy2(Path(__file__).with_name("test_kultura_bez_barier_contribution.py"), root / "src/test_kultura_bez_barier_contribution.py")
409
+ stats = load(root / "artifacts/stats.json")
410
+ notice = f"""# Notice and attribution\n\nSource: {CATALOG}\n\nThe official catalogue describes the linked publications as authored by Fundacja Kultury bez Barier and states that they are made available under CC BY-SA 3.0. The catalogue HTML, raw PDFs, source URLs and SHA-256 digests are preserved. This is catalogue-level evidence; an embedded per-PDF license assertion is not claimed.\n\nDataset transformations: text extraction, removal of page-number-only lines, line-wrap repair, Unicode/whitespace normalization, limited PII-pattern redaction, exact and near deduplication. Images are not included in the training text. Attribution and a modification notice must be preserved under CC BY-SA 3.0.\n"""
411
+ (root / "NOTICE.md").write_text(notice, encoding="utf-8")
412
+ readme = f"""---\nlicense: cc-by-sa-3.0\nlanguage:\n- pl\ntask_categories:\n- text-generation\nconfigs:\n- config_name: default\n data_files:\n - split: train\n path: data/train-00000-of-00001.parquet\n---\n\n# Kultura bez Barier PL\n\nPolish text extracted from openly published accessibility guides by Fundacja Kultury bez Barier.\n\n- Input publications: {stats['discovered']}\n- Retained records: {stats['kept']}\n- Extracted pages: {stats['pages']}\n- Tokens: {stats['tokens']:,} (`cl100k_base` proxy)\n- License evidence: catalogue-level CC BY-SA 3.0 declaration\n- Author coverage: {stats['author_coverage']:.1%}\n\nSee `NOTICE.md` and `artifacts/` for the source inventory, raw PDFs, attribution, selection decisions, QA, checksums, samples and Slayer ontology manifest.\n\n## Limitations\n\nThe 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.\n"""
413
+ (root / "README.md").write_text(readme, encoding="utf-8")
414
+ digest_map = checksums(root)
415
+ save(root / "artifacts/checksums.json", digest_map)
416
+ verified_stats = verify_core(out)
417
+ validation = {"id": "run:" + sha({"checksums": digest_map, "target": target_revision}), "started_at": now(),
418
+ "finished_at": now(), "success": True, "protocol": "dataset-contract-and-checksum-validation-v1",
419
+ "target_main_revision": target_revision, "stats": verified_stats}
420
+ save(root / "artifacts/validation_run.json", validation)
421
+ build_run = load(root / "artifacts/run.json")
422
+ check_id = "evidence:checksums:" + sha(digest_map)
423
+ qa = load(root / "artifacts/qa.json")
424
+ qa_id = "evidence:qa:" + sha(qa)
425
+ dataset_version = "version:dataset:" + sha(digest_map)
426
+ source_version = "version:source:" + sha({"pdfs": build_run["inputs"]["pdf_sha256"], "catalog": build_run["inputs"]["catalog_sha256"]})
427
+ ontology = {"schema": "slayer-research-ontology-profile-v1", "objects": [
428
+ {"id": "object:source:kultura-bez-barier", "type": "Source"}, {"id": "object:dataset:kultura-bez-barier-pl", "type": "Dataset"}],
429
+ "versions": [{"id": source_version, "object": "object:source:kultura-bez-barier", "content_address": source_version.rsplit(":", 1)[-1]},
430
+ {"id": dataset_version, "object": "object:dataset:kultura-bez-barier-pl", "content_address": dataset_version.rsplit(":", 1)[-1]}],
431
+ "protocols": [{"id": "protocol:pdf-text-v1", "procedure": "allowlist, pdfplumber extraction, normalization, PII patterns, exact and seeded near dedup"},
432
+ {"id": "protocol:contract-v1", "procedure": "schema, checksum, sample, rights-evidence and ontology contract checks"}],
433
+ "runs": [{"id": build_run["id"], "protocol": "protocol:pdf-text-v1", "success": True,
434
+ "started_at": build_run["started_at"], "finished_at": build_run["finished_at"]}, validation],
435
+ "evidence": [{"id": check_id, "observation_type": "checksums", "payload": digest_map, "produced_by": validation["id"]},
436
+ {"id": qa_id, "observation_type": "qa", "payload": qa, "produced_by": build_run["id"]}],
437
+ "claims": [{"id": "claim:replayable", "statement": "The retained dataset files replay from the pinned catalogue and PDF snapshot under the published protocol.",
438
+ "supported_by": [check_id], "falsification_condition": "A published checksum differs or the builder cannot reproduce retained text from the pinned raw PDFs."},
439
+ {"id": "claim:rights-qualified", "statement": "The official catalogue presents the linked foundation-authored publications as CC BY-SA 3.0; per-PDF embedded licensing is not asserted.",
440
+ "supported_by": [qa_id], "falsification_condition": "The pinned catalogue lacks that declaration or a selected file is outside its demonstrated scope."}],
441
+ "actors": [{"id": "actor:piotrsty", "type": "Contributor"}, {"id": "actor:fundacja-kultury-bez-barier", "type": "Organization"},
442
+ {"id": "actor:codex", "type": "Agent"}],
443
+ "relations": [{"source": dataset_version, "predicate": "DERIVED_FROM", "target": source_version},
444
+ {"source": dataset_version, "predicate": "GENERATED_BY", "target": build_run["id"]},
445
+ {"source": dataset_version, "predicate": "VALIDATED_AGAINST", "target": validation["id"]}],
446
+ "pending": ["cross-source deduplication", "benchmark contamination check", "maintainer/legal review of catalogue-level license scope", "controlled training ablation"]}
447
+ save(root / "artifacts/ontology.json", ontology)
448
+
449
+
450
+ def verify(out):
451
+ stats = verify_core(out)
452
+ root = out / "hf_repo"
453
+ manifest = load(root / "artifacts/ontology.json")
454
+ evidence_ids = {item["id"] for item in manifest["evidence"]}
455
+ assert all(item["falsification_condition"] and set(item["supported_by"]) <= evidence_ids for item in manifest["claims"])
456
+ assert len(manifest["runs"]) >= 2 and all(item["success"] for item in manifest["runs"])
457
+ assert any(item["predicate"] == "VALIDATED_AGAINST" for item in manifest["relations"])
458
+ print(json.dumps({"verified": True, **stats}, ensure_ascii=False, indent=2), flush=True)
459
+
460
+
461
+ def hf_token():
462
+ value = os.environ.get("HF_TOKEN")
463
+ if not value and os.name == "nt":
464
+ import winreg
465
+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment") as key:
466
+ value = winreg.QueryValueEx(key, "HF_TOKEN")[0]
467
+ if not value or not value.startswith("hf_"):
468
+ raise ValueError("HF_TOKEN unavailable")
469
+ return value
470
+
471
+
472
+ def all_files(root):
473
+ return [path for path in sorted(root.rglob("*")) if path.is_file() and "__pycache__" not in path.parts and ".pytest_cache" not in path.parts]
474
+
475
+
476
+ def assemble_pr(out, base, source_commit):
477
+ root = out / "hf_repo"
478
+ pr = out / "dynaword_pr"
479
+ data = pr / "data" / SOURCE
480
+ data.mkdir(parents=True, exist_ok=True)
481
+ (pr / "src").mkdir(exist_ok=True)
482
+ (pr / "artifacts").mkdir(exist_ok=True)
483
+ shutil.copy2(root / "data/train-00000-of-00001.parquet", data / f"{SOURCE}.parquet")
484
+ for name in ("attribution.jsonl", "decisions.jsonl", "sample.jsonl", "stats.json", "qa.json"):
485
+ shutil.copy2(root / "artifacts" / name, data / f"{SOURCE}.{name}")
486
+ shutil.copy2(root / "NOTICE.md", data / "NOTICE.md")
487
+ shutil.copy2(root / "README.md", data / f"{SOURCE}.md")
488
+ shutil.copy2(root / "artifacts/ontology.json", pr / f"artifacts/{SOURCE}_ontology_manifest.json")
489
+ shutil.copy2(Path(__file__), pr / "src/build_kultura_bez_barier_pl.py")
490
+ shutil.copy2(Path(__file__).with_name("test_kultura_bez_barier_contribution.py"), pr / "src/test_kultura_bez_barier_contribution.py")
491
+ (pr / "src/sources.py").write_text(registry(base), encoding="utf-8")
492
+ stats = load(root / "artifacts/stats.json")
493
+ description = f"""## Add Polish cultural-accessibility guides\n\nAdds `{SOURCE}`: **{stats['kept']} records, {stats['pages']} extracted pages and {stats['tokens']:,} measured `cl100k_base` proxy tokens** from the official Fundacja Kultury bez Barier publication catalogue.\n\nSource dataset: https://huggingface.co/datasets/{OWN_REPO}/tree/{source_commit}\n\n### Data sample\n\n- [{stats['sample_count']} complete deterministic sample records](https://huggingface.co/datasets/{OWN_REPO}/blob/{source_commit}/artifacts/sample.jsonl)\n- [Per-record attribution, URLs and rights evidence](https://huggingface.co/datasets/{OWN_REPO}/blob/{source_commit}/artifacts/attribution.jsonl)\n- [Selection decisions](https://huggingface.co/datasets/{OWN_REPO}/blob/{source_commit}/artifacts/decisions.jsonl)\n\n### Rights and method\n\nThe official catalogue describes these linked foundation-authored publications as CC BY-SA 3.0. The contribution preserves the catalogue HTML, raw PDFs, URLs, hashes, attribution and modification notice. This is catalogue-level evidence; it does not assert that every PDF embeds a separate license notice. Text was extracted with pdfplumber, normalized, checked for limited PII patterns, and exact/near-deduplicated within source.\n\n### Slayer ontology and remaining gates\n\nThe manifest separates content-addressed source/dataset Versions, processing and validation Protocols, executed Runs, Evidence, falsifiable Claims, Actors and typed lineage. Cross-source DynaWord deduplication, benchmark-overlap testing, legal interpretation of the catalogue-level scope and controlled training ablations remain pending. PDF extraction may flatten tables and omit visual meaning. This PR proposes a source, not a merged or stable release.\n"""
494
+ (out / "pr_description.md").write_text(description, encoding="utf-8")
495
+ return pr
496
+
497
+
498
+ def publish(out):
499
+ from huggingface_hub import CommitOperationAdd, HfApi
500
+ api = HfApi(token=hf_token())
501
+ if api.whoami()["name"].casefold() != "piotrsty":
502
+ raise ValueError("unexpected HF account")
503
+ target = api.dataset_info(TARGET)
504
+ registry_url = f"https://huggingface.co/datasets/{TARGET}/resolve/{target.sha}/src/sources.py"
505
+ base = http_get(registry_url).content.decode("utf-8")
506
+ discussions = list(api.get_repo_discussions(TARGET, repo_type="dataset"))
507
+ if SOURCE in base or any("kultura bez barier" in item.title.casefold() for item in discussions):
508
+ raise ValueError("source registration or proposal already exists")
509
+ prepare(out, target.sha)
510
+ verify(out)
511
+ root = out / "hf_repo"
512
+ receipt_path = out / "publication.json"
513
+ receipt = load(receipt_path) if receipt_path.exists() else {}
514
+ if not receipt:
515
+ if api.repo_exists(OWN_REPO, repo_type="dataset"):
516
+ raise ValueError("own HF repository already exists without this run receipt")
517
+ api.create_repo(OWN_REPO, repo_type="dataset", private=True)
518
+ receipt = {"source_repo": OWN_REPO, "target_main_revision": target.sha, "created_at": now()}
519
+ save(receipt_path, receipt)
520
+ if receipt["target_main_revision"] != target.sha:
521
+ raise ValueError("target main changed since publication started; inspect before continuing")
522
+ if not receipt.get("source_commit"):
523
+ source_commit = api.create_commit(OWN_REPO, repo_type="dataset", commit_message="Add validated Kultura bez Barier Polish publications",
524
+ operations=[CommitOperationAdd(path_in_repo=path.relative_to(root).as_posix(), path_or_fileobj=str(path)) for path in all_files(root)])
525
+ receipt["source_commit"] = source_commit.oid
526
+ save(receipt_path, receipt)
527
+ source_revision = receipt["source_commit"]
528
+ if not any(item.name == "v1.0.0" for item in api.list_repo_refs(OWN_REPO, repo_type="dataset").tags):
529
+ api.create_tag(OWN_REPO, repo_type="dataset", tag="v1.0.0", revision=source_revision)
530
+ api.update_repo_settings(OWN_REPO, repo_type="dataset", private=False)
531
+ pr = assemble_pr(out, base, source_revision)
532
+ subprocess.run([sys.executable, "-m", "pytest", "-q", str(pr / "src/test_kultura_bez_barier_contribution.py")], check=True)
533
+ if not receipt.get("pr_url"):
534
+ result = api.create_commit(TARGET, repo_type="dataset", parent_commit=target.sha, create_pr=True,
535
+ commit_message="Add CC BY-SA 3.0 Polish cultural-accessibility guides",
536
+ commit_description=(out / "pr_description.md").read_text(encoding="utf-8"),
537
+ operations=[CommitOperationAdd(path_in_repo=path.relative_to(pr).as_posix(), path_or_fileobj=str(path)) for path in all_files(pr)])
538
+ receipt.update(tag="v1.0.0", pr_url=result.pr_url, pr_commit=result.oid, published_at=now())
539
+ save(receipt_path, receipt)
540
+ print(json.dumps(receipt, ensure_ascii=False, indent=2), flush=True)
541
+
542
+
543
+ def audit(out):
544
+ from huggingface_hub import HfApi, hf_hub_download
545
+ api = HfApi(token=False)
546
+ receipt = load(out / "publication.json")
547
+ info = api.dataset_info(OWN_REPO)
548
+ if info.private or info.sha != receipt["source_commit"]:
549
+ raise ValueError("source repo visibility or revision mismatch")
550
+ if not any(item.name == receipt["tag"] and item.target_commit == info.sha for item in api.list_repo_refs(OWN_REPO, repo_type="dataset").tags):
551
+ raise ValueError("release tag mismatch")
552
+ number = int(receipt["pr_url"].rsplit("/", 1)[-1])
553
+ discussion = api.get_discussion_details(TARGET, number, repo_type="dataset")
554
+ pr_info = api.dataset_info(TARGET, revision=f"refs/pr/{number}")
555
+ if not discussion.is_pull_request or pr_info.sha != receipt["pr_commit"]:
556
+ raise ValueError("PR identity mismatch")
557
+ checked = []
558
+ for repo, revision, root in ((OWN_REPO, info.sha, out / "hf_repo"), (TARGET, pr_info.sha, out / "dynaword_pr")):
559
+ for path in all_files(root):
560
+ name = path.relative_to(root).as_posix()
561
+ remote = Path(hf_hub_download(repo, name, repo_type="dataset", revision=revision, token=False,
562
+ cache_dir=str(out / "remote_cache")))
563
+ if sha(remote.read_bytes()) != sha(path.read_bytes()):
564
+ raise ValueError("remote mismatch: " + name)
565
+ checked.append({"repo": repo, "revision": revision, "path": name, "sha256": sha(remote.read_bytes())})
566
+ result = {"observed_at": now(), "source_revision": info.sha, "pr_revision": pr_info.sha,
567
+ "pr_status": discussion.status, "target_main_revision": api.dataset_info(TARGET).sha, "verified_files": checked}
568
+ save(out / "publication_audit.json", result)
569
+ shutil.rmtree(out / "remote_cache", ignore_errors=True)
570
+ print(json.dumps({**result, "verified_files": len(checked)}, ensure_ascii=False, indent=2), flush=True)
571
+
572
+
573
+ if __name__ == "__main__":
574
+ parser = argparse.ArgumentParser(description=__doc__)
575
+ parser.add_argument("--output", type=Path, required=True)
576
+ parser.add_argument("command", choices=["acquire", "build", "verify", "publish", "audit"])
577
+ arguments = parser.parse_args()
578
+ globals()[arguments.command](arguments.output)
src/test_kultura_bez_barier_contribution.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract checks run from the prepared DynaWord contribution tree."""
2
+ import hashlib
3
+ import json
4
+ from pathlib import Path
5
+ import re
6
+
7
+ import pyarrow.parquet as pq
8
+
9
+ SOURCE = "kultura_bez_barier_pl"
10
+ LICENSE = "CC-BY-SA-3.0"
11
+ FIELDS = ["id", "text", "source", "added", "created", "token_count", "license", "author"]
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):
18
+ return hashlib.sha256(payload).hexdigest()
19
+
20
+
21
+ def rows(path):
22
+ return [json.loads(line) for line in path.read_text(encoding="utf-8").splitlines() if line]
23
+
24
+
25
+ def test_dataset_contract_and_samples():
26
+ table = pq.read_table(DATA / f"{SOURCE}.parquet")
27
+ data = table.to_pylist()
28
+ stats = json.loads((DATA / f"{SOURCE}.stats.json").read_text(encoding="utf-8"))
29
+ attribution = rows(DATA / f"{SOURCE}.attribution.jsonl")
30
+ decisions = rows(DATA / f"{SOURCE}.decisions.jsonl")
31
+ sample = rows(DATA / f"{SOURCE}.sample.jsonl")
32
+ assert table.column_names == FIELDS
33
+ assert len(data) == stats["kept"] == len(attribution)
34
+ assert len(decisions) == stats["discovered"]
35
+ assert sum(bool(item["selected"]) for item in decisions) == stats["kept"]
36
+ assert sum(item["token_count"] for item in data) == stats["tokens"]
37
+ assert {item["id"] for item in data} == {item["id"] for item in attribution}
38
+ assert all(item["source"] == SOURCE and item["license"] == LICENSE and item["author"] for item in data)
39
+ assert all(not re.search(r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b", item["text"]) for item in data)
40
+ by_id = {item["id"]: item for item in data}
41
+ assert len(sample) == stats["sample_count"] == min(12, len(data))
42
+ assert all(by_id[item["id"]] == item for item in sample)
43
+
44
+
45
+ def test_ontology_is_addressed_and_falsifiable():
46
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
47
+ evidence = {item["id"] for item in manifest["evidence"]}
48
+ assert all(item["falsification_condition"] for item in manifest["claims"])
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",
56
+ "artifacts/decisions.jsonl": DATA / f"{SOURCE}.decisions.jsonl",
57
+ "artifacts/sample.jsonl": DATA / f"{SOURCE}.sample.jsonl",
58
+ "artifacts/stats.json": DATA / f"{SOURCE}.stats.json",
59
+ "artifacts/qa.json": DATA / f"{SOURCE}.qa.json",
60
+ "src/build_kultura_bez_barier_pl.py": ROOT / "src/build_kultura_bez_barier_pl.py",
61
+ "src/test_kultura_bez_barier_contribution.py": ROOT / "src/test_kultura_bez_barier_contribution.py",
62
+ }
63
+ for name, path in mapping.items():
64
+ assert digest(path.read_bytes()) == checks[name]