Datasets:
Add plwiki talk pages (ns 1+5) - conversational Polish (#36)
Browse files- Add plwiki talk pages (ns 1+5) - conversational Polish (d3c7b3995a44abb8b801e25f33ce64ecc2755838)
- Address review: samples, scrubber + PII spot check, inclusion argument, text overlap (c95ab8895f20b4ac47365c27c31b729d54b05800)
Co-authored-by: Piotr Styla <PiotrSty@users.noreply.huggingface.co>
- artifacts/plwiki_talk_ontology_manifest.json +128 -0
- artifacts/source_findings.md +30 -0
- data/plwiki_talk/NOTICE.md +7 -0
- data/plwiki_talk/plwiki_talk.attribution.jsonl +3 -0
- data/plwiki_talk/plwiki_talk.checksums.json +11 -0
- data/plwiki_talk/plwiki_talk.decisions.jsonl +3 -0
- data/plwiki_talk/plwiki_talk.md +99 -0
- data/plwiki_talk/plwiki_talk.overlap_audit.json +11 -0
- data/plwiki_talk/plwiki_talk.parquet +3 -0
- data/plwiki_talk/plwiki_talk.qa.json +18 -0
- data/plwiki_talk/plwiki_talk.sample.jsonl +0 -0
- data/plwiki_talk/plwiki_talk.stats.json +15 -0
- src/build_plwiki_talk_pl.py +840 -0
- src/plwiki_talk_requirements.txt +7 -0
- src/sources.py +15 -0
- src/test_build_plwiki_talk_pl.py +179 -0
artifacts/plwiki_talk_ontology_manifest.json
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"actors": [
|
| 3 |
+
{
|
| 4 |
+
"id": "actor:piotrsty",
|
| 5 |
+
"type": "Contributor"
|
| 6 |
+
},
|
| 7 |
+
{
|
| 8 |
+
"id": "actor:wikimedia",
|
| 9 |
+
"type": "Organization"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"id": "actor:devin",
|
| 13 |
+
"type": "Agent"
|
| 14 |
+
}
|
| 15 |
+
],
|
| 16 |
+
"claims": [
|
| 17 |
+
{
|
| 18 |
+
"falsification_condition": "The pinned Parquet or decisions do not reproduce this count.",
|
| 19 |
+
"id": "claim:plw-talk-target-retention",
|
| 20 |
+
"statement": "The proposed DynaWord slice contains 43054 records.",
|
| 21 |
+
"supported_by": [
|
| 22 |
+
"evidence:plw-talk-target-stats:d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4"
|
| 23 |
+
]
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"falsification_condition": "Target-wide text deduplication and controlled ablations establish those properties.",
|
| 27 |
+
"id": "claim:plw-talk-training-value-untested",
|
| 28 |
+
"statement": "Net text novelty and training benefit remain untested hypotheses; quoted-fragment overlap vs wikipedia is untested.",
|
| 29 |
+
"supported_by": [
|
| 30 |
+
"evidence:plw-talk-target-overlap:af980dd0047c9251573be63a6dcb28bc51a6eafa77d614d19e1be25b447cefca"
|
| 31 |
+
]
|
| 32 |
+
}
|
| 33 |
+
],
|
| 34 |
+
"evidence": [
|
| 35 |
+
{
|
| 36 |
+
"artifact": "data/plwiki_talk/plwiki_talk.stats.json",
|
| 37 |
+
"content_address": "d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4",
|
| 38 |
+
"id": "evidence:plw-talk-target-stats:d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4",
|
| 39 |
+
"observation_type": "target_slice_counts",
|
| 40 |
+
"produced_by": "run:plwiki-talk-dynaword-integration:d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"artifact": "data/plwiki_talk/plwiki_talk.overlap_audit.json",
|
| 44 |
+
"content_address": "af980dd0047c9251573be63a6dcb28bc51a6eafa77d614d19e1be25b447cefca",
|
| 45 |
+
"id": "evidence:plw-talk-target-overlap:af980dd0047c9251573be63a6dcb28bc51a6eafa77d614d19e1be25b447cefca",
|
| 46 |
+
"observation_type": "namespace_overlap_audit",
|
| 47 |
+
"produced_by": "run:plwiki-talk-dynaword-integration:d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4"
|
| 48 |
+
}
|
| 49 |
+
],
|
| 50 |
+
"objects": [
|
| 51 |
+
{
|
| 52 |
+
"id": "object:dataset:plwiki-talk",
|
| 53 |
+
"type": "Dataset"
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"id": "object:dataset:plwiki-talk-dynaword-slice",
|
| 57 |
+
"type": "Dataset"
|
| 58 |
+
}
|
| 59 |
+
],
|
| 60 |
+
"pending": [
|
| 61 |
+
"quoted-fragment dedup vs wikipedia shard",
|
| 62 |
+
"cross-source text deduplication",
|
| 63 |
+
"benchmark contamination check",
|
| 64 |
+
"abuse/vandalism screening",
|
| 65 |
+
"controlled training ablation"
|
| 66 |
+
],
|
| 67 |
+
"protocols": [
|
| 68 |
+
{
|
| 69 |
+
"id": "protocol:plwiki-talk-dynaword-integration-v1",
|
| 70 |
+
"procedure": "carry over the source slice verbatim; namespace disjointness already audited vs wikipedia shard"
|
| 71 |
+
}
|
| 72 |
+
],
|
| 73 |
+
"relations": [
|
| 74 |
+
{
|
| 75 |
+
"predicate": "DERIVED_FROM",
|
| 76 |
+
"source": "version:dataset:plwiki-talk-dynaword:32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59",
|
| 77 |
+
"target": "hf:dataset:PiotrSty/plwiki-talk-pages@20c74a6da0cbaef5d2a644d0accf7e90262ea24c"
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"predicate": "GENERATED_BY",
|
| 81 |
+
"source": "version:dataset:plwiki-talk-dynaword:32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59",
|
| 82 |
+
"target": "run:plwiki-talk-dynaword-integration:d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"predicate": "VALIDATED_AGAINST",
|
| 86 |
+
"source": "version:dataset:plwiki-talk-dynaword:32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59",
|
| 87 |
+
"target": "hf:dataset:SlayerLab/polish-dynaword@fe44303ea2db290c7a195264226477f724973357"
|
| 88 |
+
}
|
| 89 |
+
],
|
| 90 |
+
"runs": [
|
| 91 |
+
{
|
| 92 |
+
"actor": "actor:devin",
|
| 93 |
+
"finished_at": "2026-09-11T18:35:14.234988+00:00",
|
| 94 |
+
"id": "run:plwiki-talk-dynaword-integration:d2af18f1b2618d8ac166cc110976992e97052b28e2647c2143063aaf2ff5e1b4",
|
| 95 |
+
"protocol": "protocol:plwiki-talk-dynaword-integration-v1",
|
| 96 |
+
"started_at": "2026-09-11T18:35:14.234988+00:00",
|
| 97 |
+
"stats": {
|
| 98 |
+
"added": "2026-09-11",
|
| 99 |
+
"boilerplate_lines_removed": 1,
|
| 100 |
+
"characters": 144604697,
|
| 101 |
+
"dump_date": "20260901",
|
| 102 |
+
"kept": 43054,
|
| 103 |
+
"license_counts": {
|
| 104 |
+
"CC-BY-SA-4.0": 43054
|
| 105 |
+
},
|
| 106 |
+
"sample_count": 12,
|
| 107 |
+
"source_slice_kept": 43054,
|
| 108 |
+
"talk_pages": 544591,
|
| 109 |
+
"target_revision": "fe44303ea2db290c7a195264226477f724973357",
|
| 110 |
+
"tokens": 55568733
|
| 111 |
+
},
|
| 112 |
+
"success": true
|
| 113 |
+
}
|
| 114 |
+
],
|
| 115 |
+
"schema": "slayer-research-ontology-profile-v1",
|
| 116 |
+
"versions": [
|
| 117 |
+
{
|
| 118 |
+
"content_address": "20c74a6da0cbaef5d2a644d0accf7e90262ea24c",
|
| 119 |
+
"id": "hf:dataset:PiotrSty/plwiki-talk-pages@20c74a6da0cbaef5d2a644d0accf7e90262ea24c",
|
| 120 |
+
"object": "object:dataset:plwiki-talk"
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"content_address": "32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59",
|
| 124 |
+
"id": "version:dataset:plwiki-talk-dynaword:32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59",
|
| 125 |
+
"object": "object:dataset:plwiki-talk-dynaword-slice"
|
| 126 |
+
}
|
| 127 |
+
]
|
| 128 |
+
}
|
artifacts/source_findings.md
CHANGED
|
@@ -720,3 +720,33 @@ maintainer sign-off on the catalogue-level scope reading.
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 723 |
+
|
| 724 |
+
---
|
| 725 |
+
|
| 726 |
+
## plwiki_talk — Polish Wikipedia talk pages (ns 1+5)
|
| 727 |
+
|
| 728 |
+
**Investigated** — 2026-09-11 (review round 2026-09-28).
|
| 729 |
+
|
| 730 |
+
**Verdict** — `added` (proposed with `release: None`). 43,054 pages / 55.6M
|
| 731 |
+
`cl100k_base` tokens of **user-generated** editorial discussion — article talk
|
| 732 |
+
(ns 1, 41,828 pages) and project talk (ns 5, 1,226 pages). Exact namespace
|
| 733 |
+
complement to `wikipedia` (ns 0) and `plwiki_user_talk` (ns 3).
|
| 734 |
+
|
| 735 |
+
**Enumeration** — the same pinned `plwiki-20260901-pages-meta-current` dump as
|
| 736 |
+
the ns-3 slice (7 sha1-verified shards); 544,591 non-redirect talk pages
|
| 737 |
+
enumerated, 43,054 retained after QA/dedup (500,652 dropped as <500 chars).
|
| 738 |
+
|
| 739 |
+
**License evidence** — Wikimedia Terms of Use section 7 (CC BY-SA 4.0):
|
| 740 |
+
<https://foundation.wikimedia.org/w/index.php?title=Policy:Terms_of_Use/pl&oldid=584706>.
|
| 741 |
+
Per-record canonical URL + page history is the attribution trail.
|
| 742 |
+
|
| 743 |
+
**Blockers** — none to merge with `release: None`. Before release: NERGAL pass
|
| 744 |
+
(user-generated talk; a 60-record residual spot check found only a DOI false
|
| 745 |
+
positive and public signatures, but free text can hide more), and text-level
|
| 746 |
+
cross-shard dedup per the measured overlap with `plwiki_user_talk` / `wikipedia`
|
| 747 |
+
(review thread).
|
| 748 |
+
|
| 749 |
+
**Lesson** — namespace partitioning prevents page-level duplication but not
|
| 750 |
+
text-level repetition: talk pages quote article text and share templated notices
|
| 751 |
+
across namespaces. Measure overlap at text level before claiming novelty — the
|
| 752 |
+
ID-only audit said "0 collisions" and proved nothing.
|
data/plwiki_talk/NOTICE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Attribution and license notice
|
| 2 |
+
|
| 3 |
+
Source: Polish Wikipedia talk pages, https://pl.wikipedia.org/ - Wikimedia Foundation.
|
| 4 |
+
|
| 5 |
+
Text is available under the Creative Commons Attribution-ShareAlike 4.0 License (https://creativecommons.org/licenses/by-sa/4.0/). Attribution is provided via the per-record canonical page URL in `artifacts/attribution.jsonl`; each page's revision history lists its contributors.
|
| 6 |
+
|
| 7 |
+
Preparation: Piotr Styla with Devin. Changes: namespace filtering (1 and 5), wikitext stripping, cross-document boilerplate removal, Unicode and whitespace normalization, limited email/labelled-phone/IP/labelled-national-ID/account-candidate redaction, language/quality filtering and within-source deduplication. No endorsement by the Wikimedia Foundation or page contributors is implied.
|
data/plwiki_talk/plwiki_talk.attribution.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:234a3eaa9183fee2bb65b9b958c21de0232ffd5bf21b690967d074cae0f46c42
|
| 3 |
+
size 56093022
|
data/plwiki_talk/plwiki_talk.checksums.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"NOTICE.md": "6152672b3c0246d5a394341342ebaf4d8438cefde9a42f8e89d7ea60d620a99a",
|
| 3 |
+
"plwiki_talk.attribution.jsonl": "234a3eaa9183fee2bb65b9b958c21de0232ffd5bf21b690967d074cae0f46c42",
|
| 4 |
+
"plwiki_talk.decisions.jsonl": "465b292a05a8b55c4f07d255fda0ba5cda90ed5b2b666c541848b50f8cd48cac",
|
| 5 |
+
"plwiki_talk.md": "7276c0bb52ca4c310435cdeca9f0d0db0db637a3dd4d82acc227e09a38bd621b",
|
| 6 |
+
"plwiki_talk.overlap_audit.json": "5ef4592279700c06e3f74b99a46b1ddd80a0c732ba44c17caba130b18f9d39c0",
|
| 7 |
+
"plwiki_talk.parquet": "32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59",
|
| 8 |
+
"plwiki_talk.qa.json": "a4b7fac7b749edccb265cfe93f850027342cca43665ca50ea2ab99347aa26e40",
|
| 9 |
+
"plwiki_talk.sample.jsonl": "1c8b44bee9c23d490dfdfc4f9c6cc1975d9cc4f56997537bd08456049eb34cdd",
|
| 10 |
+
"plwiki_talk.stats.json": "65838c75bdc7681d564554b012adf1a1121c43c671ff128e5fa2953817a2c031"
|
| 11 |
+
}
|
data/plwiki_talk/plwiki_talk.decisions.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:465b292a05a8b55c4f07d255fda0ba5cda90ed5b2b666c541848b50f8cd48cac
|
| 3 |
+
size 112135891
|
data/plwiki_talk/plwiki_talk.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Polish Wikipedia talk pages (namespaces 1+5) - CC BY-SA 4.0
|
| 2 |
+
|
| 3 |
+
This slice is rebuilt deterministically from the pinned official Wikimedia dump
|
| 4 |
+
`plwiki-20260901-pages-meta-current` (7 sha1-verified shards;
|
| 5 |
+
https://dumps.wikimedia.org/plwiki/20260901/). Scope is namespaces 1
|
| 6 |
+
(article talk) and 5 (project talk); mainspace (ns=0) is covered by the existing
|
| 7 |
+
`wikipedia` shard and user-talk (ns=3) is excluded by scope decision (not
|
| 8 |
+
measured). This is conversational written Polish - editorial disputes,
|
| 9 |
+
coordination, questions and answers - a register otherwise nearly absent from
|
| 10 |
+
the corpus.
|
| 11 |
+
|
| 12 |
+
- Non-redirect talk pages enumerated: 544,591
|
| 13 |
+
- Source slice retained after QA/dedup: 43,054
|
| 14 |
+
- Proposed records: 43,054
|
| 15 |
+
- Proposed tokens: 55,568,733 (`cl100k_base` proxy)
|
| 16 |
+
- Characters: 144,604,697
|
| 17 |
+
- License: CC BY-SA 4.0 per record (Wikimedia Terms of Use section 7: https://foundation.wikimedia.org/w/index.php?title=Policy:Terms_of_Use/pl&oldid=584706)
|
| 18 |
+
- Immutable source snapshot: https://huggingface.co/datasets/PiotrSty/plwiki-talk-pages/tree/20c74a6da0cbaef5d2a644d0accf7e90262ea24c
|
| 19 |
+
|
| 20 |
+
Per-record page id, title, namespace, last-revision timestamp and canonical URL
|
| 21 |
+
are preserved; page history is the contributor-attribution trail. Wikitext is
|
| 22 |
+
stripped with mwparserfromhell; lines occurring in >=1% of documents are removed
|
| 23 |
+
as cross-document boilerplate; emails, labelled phones, IP literals, labelled
|
| 24 |
+
national identifiers and 26-digit account candidates are redacted (pattern
|
| 25 |
+
redaction is not complete anonymization); exact and near deduplication applied
|
| 26 |
+
within source. The user-talk namespace (ns=3) is excluded by scope decision;
|
| 27 |
+
its quality was not measured.
|
| 28 |
+
|
| 29 |
+
## What the texts are (user-generated)
|
| 30 |
+
|
| 31 |
+
These are **user-generated** wiki talk pages: discussion between volunteer
|
| 32 |
+
editors about article content (ns=1, article talk) and about the project itself
|
| 33 |
+
(ns=5, "Dyskusja Wikipedii" - policies, classifications, deletion debates).
|
| 34 |
+
Genre: editorial discussion - source requests, wording and naming disputes,
|
| 35 |
+
style fixes, merge/delete debates, project-wide consultations. Register:
|
| 36 |
+
informal written Polish with typos, wiki jargon ("WP:OR", "SDU"), signed
|
| 37 |
+
comments (`user name + timestamp`). Not OCR'd, not machine-translated. Record
|
| 38 |
+
model: one whole talk page; comments are not split.
|
| 39 |
+
|
| 40 |
+
Time span: per-record `created` is the dump last-revision date (2003-02-13 –
|
| 41 |
+
2026-09-01 across 43,054 records); the talk activity itself spans the whole
|
| 42 |
+
life of plwiki (ns split: 41,828 article-talk pages, 1,226 project-talk pages).
|
| 43 |
+
|
| 44 |
+
## Scrubber and residual-PII spot check
|
| 45 |
+
|
| 46 |
+
Scrubber that ran: **pattern redaction in `src/build_plwiki_talk_pl.py`** -
|
| 47 |
+
e-mail, labelled phone (`telefon`/`tel.`/`phone`), IPv4, parsed IPv6 (incl.
|
| 48 |
+
compressed notation), labelled PESEL/NIP/REGON, 26-digit account candidates ->
|
| 49 |
+
`[REDACTED:*]`. This is **not**
|
| 50 |
+
[SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL); these are
|
| 51 |
+
user-generated talk pages, so the shard must be re-run through NERGAL before it
|
| 52 |
+
is admitted to a release.
|
| 53 |
+
|
| 54 |
+
Residual-PII spot check (deterministic sample of 60 records, seed 20260928):
|
| 55 |
+
25 `[REDACTED:IP]` placeholders remain as evidence of the applied redaction
|
| 56 |
+
(including unregistered editors' signatures); the single long-digit-run hit is
|
| 57 |
+
an academic DOI citation (`10.1017/9781108668675.006`) - not PII; all other
|
| 58 |
+
residual classes (26-digit runs, IBAN-like, unlabelled IPs, e-mail-like incl.
|
| 59 |
+
obfuscated "at"/"malpa" forms, `ul.`/`al.`/`os.` street cues, GG/ICQ/Skype,
|
| 60 |
+
PESEL mentions) have 0 hits. Manual reading of 8 sampled records found only
|
| 61 |
+
public wiki attribution and editorial discussion - no private personal data.
|
| 62 |
+
Residual risk low but non-zero (60 of 43,054 records, 0.14%), which is why the
|
| 63 |
+
NERGAL pass stays a release gate.
|
| 64 |
+
|
| 65 |
+
## Inclusion argument
|
| 66 |
+
|
| 67 |
+
What this adds that `wikipedia` does not: the editorial process around the
|
| 68 |
+
articles - talk pages where editors argue about sources, wording, naming,
|
| 69 |
+
merges and deletions. That is conversational, multi-voice, disagreement-laden
|
| 70 |
+
Polish; the `wikipedia` shard holds only the finished encyclopedic prose. The
|
| 71 |
+
namespace partition is exact: `wikipedia` = ns 0, this slice = ns 1+5,
|
| 72 |
+
`plwiki_user_talk` (PR #40) = ns 3 - no page is in two slices, and the text
|
| 73 |
+
overlap numbers below quantify what still repeats across them.
|
| 74 |
+
|
| 75 |
+
## Text overlap with the wikipedia / plwiki_user_talk shards (review audit)
|
| 76 |
+
|
| 77 |
+
Measured post-build by normalized exact-line and exact-paragraph containment
|
| 78 |
+
(64-bit blake2b; lines >= 30 chars, paragraphs >= 100 chars; exact-verbatim
|
| 79 |
+
only):
|
| 80 |
+
|
| 81 |
+
- vs `wikipedia` (ns 0): 418 of 567,171 talk lines match (75,163 chars =
|
| 82 |
+
**0.053%** of this slice's line chars); 1 paragraph (271 chars). Verbatim
|
| 83 |
+
article quoting in talk pages is negligible at this unit size.
|
| 84 |
+
- vs `plwiki_user_talk` (ns 3): 5,556 lines match (1,207,378 chars = **0.85%**);
|
| 85 |
+
1,111 paragraphs (547,695 chars = **0.39%**); 1,965 of 43,054 records (4.6%)
|
| 86 |
+
contain at least one matched line. The matched lines are almost all
|
| 87 |
+
page-unique (4,941 of 5,138 distinct matched lines occur on exactly one talk
|
| 88 |
+
page) - genuine thread fragments mirrored between article talk and user talk,
|
| 89 |
+
not template duplication.
|
| 90 |
+
|
| 91 |
+
Integration gate: cross-shard verbatim dedup at integration would move ~0.9% of
|
| 92 |
+
chars; no other treatment needed. Method and numbers are in the review thread
|
| 93 |
+
(`overlap_check_pr36.py`, `overlap_pr36.json`).
|
| 94 |
+
|
| 95 |
+
Limitations: talk pages are informal (typos, edit disputes, occasional vandalism);
|
| 96 |
+
comments may quote article text (measured at review: 0.053% of chars match the
|
| 97 |
+
`wikipedia` shard verbatim at line level; 0.85% matches `plwiki_user_talk`, almost
|
| 98 |
+
all page-unique thread fragments);
|
| 99 |
+
Record model is a whole talk page; comments are not split.
|
data/plwiki_talk/plwiki_talk.overlap_audit.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"candidate_records": 544591,
|
| 3 |
+
"collision_count": 0,
|
| 4 |
+
"id_collisions": [],
|
| 5 |
+
"method": "Literal dataset-record ID comparison only. Source-specific ID prefixes make zero collisions uninformative about page identity or text overlap. No target namespace or text audit was performed.",
|
| 6 |
+
"observed_at": "2026-09-11T08:19:24.301215+00:00",
|
| 7 |
+
"target": "SlayerLab/polish-dynaword:data/wikipedia",
|
| 8 |
+
"target_revision": "fe44303ea2db290c7a195264226477f724973357",
|
| 9 |
+
"target_rows": 1171897,
|
| 10 |
+
"text_overlap": "not tested; quoted-article passages and target-wide text dedup remain integration gates"
|
| 11 |
+
}
|
data/plwiki_talk/plwiki_talk.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:32e8100276998f8a1c9a531968ec554cc1372e3797c4f3b21532dc45f4629a59
|
| 3 |
+
size 69202724
|
data/plwiki_talk/plwiki_talk.qa.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"benchmark_overlap": "pending",
|
| 3 |
+
"cross_source_text_dedup": "pending target integration",
|
| 4 |
+
"id_collisions_vs_wikipedia_shard": 0,
|
| 5 |
+
"license_terms_url": "https://foundation.wikimedia.org/w/index.php?title=Policy:Terms_of_Use/pl&oldid=584706",
|
| 6 |
+
"limitations": [
|
| 7 |
+
"talk pages contain informal text with typos, edit disputes and occasional abuse/vandalism",
|
| 8 |
+
"user-talk namespace (ns=3) excluded by scope decision; its quality was not measured",
|
| 9 |
+
"comments may quote article text; quoted passages are not disjoint from the wikipedia shard",
|
| 10 |
+
"record model is a whole talk page; individual comments are not split",
|
| 11 |
+
"pattern checks are not comprehensive de-identification"
|
| 12 |
+
],
|
| 13 |
+
"overlap_method": "Literal dataset-record ID comparison only. Source-specific ID prefixes make zero collisions uninformative about page identity or text overlap. No target namespace or text audit was performed.",
|
| 14 |
+
"pii_policy": "IPv6 parsed including compressed notation; labelled PESEL/NIP/REGON and 26-digit account candidates masked conservatively without checksum validation; not complete anonymization",
|
| 15 |
+
"scope": "DynaWord proposal: Polish Wikipedia talk pages (ns 1+5); namespace complement to the wikipedia shard (ns=0)",
|
| 16 |
+
"source_text_qa_rejected": 501537,
|
| 17 |
+
"within_source_exact_and_near_dedup": true
|
| 18 |
+
}
|
data/plwiki_talk/plwiki_talk.sample.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/plwiki_talk/plwiki_talk.stats.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added": "2026-09-11",
|
| 3 |
+
"boilerplate_lines_removed": 1,
|
| 4 |
+
"characters": 144604697,
|
| 5 |
+
"dump_date": "20260901",
|
| 6 |
+
"kept": 43054,
|
| 7 |
+
"license_counts": {
|
| 8 |
+
"CC-BY-SA-4.0": 43054
|
| 9 |
+
},
|
| 10 |
+
"sample_count": 12,
|
| 11 |
+
"source_slice_kept": 43054,
|
| 12 |
+
"talk_pages": 544591,
|
| 13 |
+
"target_revision": "fe44303ea2db290c7a195264226477f724973357",
|
| 14 |
+
"tokens": 55568733
|
| 15 |
+
}
|
src/build_plwiki_talk_pl.py
ADDED
|
@@ -0,0 +1,840 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build an auditable slice of Polish Wikipedia talk pages (ns 1+5, CC BY-SA 4.0)."""
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import argparse
|
| 6 |
+
import bz2
|
| 7 |
+
from collections import Counter
|
| 8 |
+
from concurrent.futures import ProcessPoolExecutor
|
| 9 |
+
from datetime import datetime, timezone
|
| 10 |
+
from difflib import SequenceMatcher
|
| 11 |
+
import gzip
|
| 12 |
+
import hashlib
|
| 13 |
+
import ipaddress
|
| 14 |
+
import json
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
import re
|
| 17 |
+
import time
|
| 18 |
+
import unicodedata
|
| 19 |
+
from xml.etree.ElementTree import iterparse
|
| 20 |
+
from urllib.parse import quote
|
| 21 |
+
|
| 22 |
+
import requests
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
SOURCE = "plwiki_talk"
|
| 26 |
+
OWN_REPO = "PiotrSty/plwiki-talk-pages"
|
| 27 |
+
TARGET = "SlayerLab/polish-dynaword"
|
| 28 |
+
DUMP_DATE = "20260901"
|
| 29 |
+
DUMP_BASE = f"https://dumps.wikimedia.org/plwiki/{DUMP_DATE}"
|
| 30 |
+
DUMPSTATUS_URL = DUMP_BASE + "/dumpstatus.json"
|
| 31 |
+
INDEX_URL = "https://dumps.wikimedia.org/plwiki/"
|
| 32 |
+
SOURCE_URL = "https://pl.wikipedia.org/"
|
| 33 |
+
FIELDS = ["id", "text", "source", "added", "created", "token_count", "license", "author"]
|
| 34 |
+
UA = {"User-Agent": "polish-dynaword/0.2 (+research; openly-licensed corpus)"}
|
| 35 |
+
LICENSE_SPDX = "CC-BY-SA-4.0"
|
| 36 |
+
LICENSE_TERMS_URL = "https://foundation.wikimedia.org/w/index.php?title=Policy:Terms_of_Use/pl&oldid=584706"
|
| 37 |
+
TALK_NS = {"1", "5"}
|
| 38 |
+
MIN_TEXT_CHARS = 500
|
| 39 |
+
BOILERPLATE_MIN_DOC_FREQ = 0.01
|
| 40 |
+
EMAIL_RE = re.compile(r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b")
|
| 41 |
+
PHONE_RE = re.compile(r"(?i)(?:\btelefon|\btel\.|\bphone)\s*:?[ \t]*(?:\+48[ \t]*)?\d(?:[ .-]?\d){8}\b")
|
| 42 |
+
IPV4_RE = re.compile(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")
|
| 43 |
+
IPV6_RE = re.compile(r"(?i)\b(?:[0-9a-f]{1,4}:){3,}[0-9a-f]{1,4}\b")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
IPV6_CANDIDATE_RE = re.compile(r"(?<![\w:])(?:[0-9a-fA-F]{0,4}:){2,}[0-9a-fA-F:.]*(?![\w:])")
|
| 47 |
+
NATIONAL_ID_RE = re.compile(r"(?i)\b(PESEL|NIP|REGON)\s*[:=]?\s*\d(?:[ -]?\d){8,13}\b")
|
| 48 |
+
BANK_ACCOUNT_RE = re.compile(r"(?<!\d)(?:PL\s*)?\d{2}(?:[ -]?\d){24}(?!\d)")
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def is_ipv6(value):
|
| 52 |
+
try:
|
| 53 |
+
return ipaddress.ip_address(value.rstrip(".")).version == 6
|
| 54 |
+
except ValueError:
|
| 55 |
+
return False
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def redact_pii(text):
|
| 59 |
+
counts = Counter()
|
| 60 |
+
|
| 61 |
+
def replace_ipv6(match):
|
| 62 |
+
value = match.group().rstrip(".")
|
| 63 |
+
if not is_ipv6(value):
|
| 64 |
+
return match.group()
|
| 65 |
+
counts["ipv6"] += 1
|
| 66 |
+
return "[REDACTED:IP]" + match.group()[len(value):]
|
| 67 |
+
|
| 68 |
+
text = IPV6_CANDIDATE_RE.sub(replace_ipv6, text)
|
| 69 |
+
for name, pattern, replacement in (
|
| 70 |
+
("email", EMAIL_RE, "[REDACTED:EMAIL]"),
|
| 71 |
+
("labelled_phone", PHONE_RE, "[REDACTED:PHONE]"),
|
| 72 |
+
("ipv4", IPV4_RE, "[REDACTED:IP]"),
|
| 73 |
+
("ipv6_legacy_pattern", IPV6_RE, "[REDACTED:IP]"),
|
| 74 |
+
("national_identifier", NATIONAL_ID_RE, lambda match: match.group(1) + " [REDACTED:ID]"),
|
| 75 |
+
("account_candidate", BANK_ACCOUNT_RE, "[REDACTED:ACCOUNT]"),
|
| 76 |
+
):
|
| 77 |
+
text, count = pattern.subn(replacement, text)
|
| 78 |
+
counts[name] += count
|
| 79 |
+
return text, counts
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def now():
|
| 83 |
+
return datetime.now(timezone.utc).isoformat()
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def digest(value):
|
| 87 |
+
if not isinstance(value, bytes):
|
| 88 |
+
value = json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8")
|
| 89 |
+
return hashlib.sha256(value).hexdigest()
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def sha1_file(path):
|
| 93 |
+
h = hashlib.sha1()
|
| 94 |
+
with path.open("rb") as handle:
|
| 95 |
+
while chunk := handle.read(1 << 22):
|
| 96 |
+
h.update(chunk)
|
| 97 |
+
return h.hexdigest()
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def save(path, value):
|
| 101 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 102 |
+
path.write_text(json.dumps(value, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8")
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def write_lines(path, rows):
|
| 106 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 107 |
+
path.write_text("".join(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n" for row in rows), encoding="utf-8")
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def read_lines(path):
|
| 111 |
+
return [json.loads(line) for line in path.read_text(encoding="utf-8").split("\n") if line]
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def load(path):
|
| 115 |
+
return json.loads(path.read_text(encoding="utf-8"))
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def request(url, attempts=5, timeout=(15, 90)):
|
| 119 |
+
response = None
|
| 120 |
+
for attempt in range(attempts):
|
| 121 |
+
response = requests.get(url, headers=UA, timeout=timeout)
|
| 122 |
+
if response.status_code not in (429, 500, 502, 503, 504):
|
| 123 |
+
response.raise_for_status()
|
| 124 |
+
return response
|
| 125 |
+
time.sleep(2 ** attempt)
|
| 126 |
+
response.raise_for_status()
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def request_json(url):
|
| 130 |
+
return request(url).json()
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def _local(tag):
|
| 134 |
+
return tag.rsplit("}", 1)[-1]
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def strip_wikitext(wikitext):
|
| 138 |
+
import mwparserfromhell
|
| 139 |
+
try:
|
| 140 |
+
return mwparserfromhell.parse(wikitext).strip_code(normalize=True, collapse=True).strip()
|
| 141 |
+
except Exception:
|
| 142 |
+
return ""
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _strip_batch(items):
|
| 146 |
+
return [strip_wikitext(wikitext) for _, _, _, _, wikitext in items]
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def discover(out):
|
| 150 |
+
status = request_json(DUMPSTATUS_URL)
|
| 151 |
+
jobs = status.get("jobs", {})
|
| 152 |
+
files = []
|
| 153 |
+
for job in jobs.values():
|
| 154 |
+
if job.get("status") != "done":
|
| 155 |
+
continue
|
| 156 |
+
for name, meta in (job.get("files") or {}).items():
|
| 157 |
+
if re.fullmatch(r"plwiki-\d+-pages-meta-current\d+\.xml-p\d+p\d+\.bz2", name):
|
| 158 |
+
files.append({"name": name, "url": f"{DUMP_BASE}/{name}",
|
| 159 |
+
"size": meta.get("size"), "sha1": meta.get("sha1")})
|
| 160 |
+
files.sort(key=lambda item: item["name"])
|
| 161 |
+
if not files:
|
| 162 |
+
raise ValueError("no meta-current shards found")
|
| 163 |
+
selection = {
|
| 164 |
+
"observed_at": now(), "dump_date": DUMP_DATE, "dump_base": DUMP_BASE,
|
| 165 |
+
"dumpstatus_url": DUMPSTATUS_URL, "files": files,
|
| 166 |
+
"total_bytes": sum(item["size"] for item in files),
|
| 167 |
+
"talk_namespaces": sorted(TALK_NS), "min_text_chars": MIN_TEXT_CHARS,
|
| 168 |
+
"license": "CC BY-SA 4.0 (Wikimedia dump terms, same basis as the shipped wikipedia shard)",
|
| 169 |
+
"files_sha256": digest(files),
|
| 170 |
+
}
|
| 171 |
+
save(out / "selection.json", selection)
|
| 172 |
+
print(json.dumps({k: selection[k] for k in ("dump_date", "total_bytes")}, indent=2))
|
| 173 |
+
print("files:", len(files))
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def parse_shard(path):
|
| 177 |
+
records = []
|
| 178 |
+
with bz2.open(path, "rb") as fh:
|
| 179 |
+
title = ns = pageid = timestamp = text = None
|
| 180 |
+
redirect = False
|
| 181 |
+
for ev, el in iterparse(fh, events=("end",)):
|
| 182 |
+
tag = _local(el.tag)
|
| 183 |
+
if tag == "title":
|
| 184 |
+
title = el.text
|
| 185 |
+
elif tag == "ns":
|
| 186 |
+
ns = el.text
|
| 187 |
+
elif tag == "id" and pageid is None:
|
| 188 |
+
pageid = el.text
|
| 189 |
+
elif tag == "timestamp":
|
| 190 |
+
timestamp = el.text
|
| 191 |
+
elif tag == "redirect":
|
| 192 |
+
redirect = True
|
| 193 |
+
elif tag == "text":
|
| 194 |
+
text = el.text
|
| 195 |
+
elif tag == "page":
|
| 196 |
+
if ns in TALK_NS and not redirect and text:
|
| 197 |
+
records.append((pageid, ns, title, timestamp, text))
|
| 198 |
+
title = ns = pageid = timestamp = text = None
|
| 199 |
+
redirect = False
|
| 200 |
+
el.clear()
|
| 201 |
+
return records
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def acquire(out, workers):
|
| 205 |
+
selection = load(out / "selection.json")
|
| 206 |
+
dump_dir = out / "raw_dump"
|
| 207 |
+
dump_dir.mkdir(parents=True, exist_ok=True)
|
| 208 |
+
extracted_dir = out / "extracted"
|
| 209 |
+
extracted_dir.mkdir(exist_ok=True)
|
| 210 |
+
manifest = []
|
| 211 |
+
for item in selection["files"]:
|
| 212 |
+
dst = dump_dir / item["name"]
|
| 213 |
+
if not dst.exists() or dst.stat().st_size != item["size"]:
|
| 214 |
+
print(f" pobieram {item['name']} ({item['size']/1e6:.0f} MB)", flush=True)
|
| 215 |
+
for attempt in range(8):
|
| 216 |
+
have = dst.stat().st_size if dst.exists() else 0
|
| 217 |
+
headers = dict(UA)
|
| 218 |
+
if have:
|
| 219 |
+
headers["Range"] = f"bytes={have}-"
|
| 220 |
+
try:
|
| 221 |
+
with requests.get(item["url"], headers=headers, stream=True, timeout=(15, 300)) as r:
|
| 222 |
+
r.raise_for_status()
|
| 223 |
+
if have and r.status_code != 206:
|
| 224 |
+
have = 0
|
| 225 |
+
with dst.open("ab" if have else "wb") as f:
|
| 226 |
+
for chunk in r.iter_content(1 << 22):
|
| 227 |
+
f.write(chunk)
|
| 228 |
+
break
|
| 229 |
+
except requests.RequestException as error:
|
| 230 |
+
print(f" retry {item['name']}: {type(error).__name__}", flush=True)
|
| 231 |
+
time.sleep(min(2 ** attempt, 60))
|
| 232 |
+
else:
|
| 233 |
+
raise RuntimeError(f"download failed: {item['name']}")
|
| 234 |
+
sha = sha1_file(dst)
|
| 235 |
+
if item["sha1"] and sha != item["sha1"]:
|
| 236 |
+
raise ValueError(f"sha1 mismatch {item['name']}: {sha} != {item['sha1']}")
|
| 237 |
+
print(f" {item['name']} sha1 OK", flush=True)
|
| 238 |
+
|
| 239 |
+
out_path = extracted_dir / (item["name"] + ".jsonl.gz")
|
| 240 |
+
if not out_path.exists():
|
| 241 |
+
records = parse_shard(dst)
|
| 242 |
+
batches = [records[i:i + 2000] for i in range(0, len(records), 2000)]
|
| 243 |
+
with ProcessPoolExecutor(max_workers=workers) as pool:
|
| 244 |
+
texts = [text for batch in pool.map(_strip_batch, batches) for text in batch]
|
| 245 |
+
with gzip.open(out_path, "wt", encoding="utf-8") as f:
|
| 246 |
+
for (pageid, ns, title, timestamp, wikitext), text in zip(records, texts):
|
| 247 |
+
f.write(json.dumps({"pageid": pageid, "ns": ns, "title": title,
|
| 248 |
+
"timestamp": timestamp, "wikitext_chars": len(wikitext),
|
| 249 |
+
"text": text}, ensure_ascii=False) + "\n")
|
| 250 |
+
shard_records = 0
|
| 251 |
+
kept_chars = 0
|
| 252 |
+
with gzip.open(out_path, "rt", encoding="utf-8") as f:
|
| 253 |
+
for line in f:
|
| 254 |
+
row = json.loads(line)
|
| 255 |
+
shard_records += 1
|
| 256 |
+
kept_chars += len(row["text"])
|
| 257 |
+
manifest.append({"pageid": row["pageid"], "ns": row["ns"], "title": row["title"],
|
| 258 |
+
"timestamp": row["timestamp"],
|
| 259 |
+
"url": page_url(row["title"])})
|
| 260 |
+
print(f" {item['name']}: {shard_records} stron dyskusji", flush=True)
|
| 261 |
+
write_lines(out / "source_manifest.jsonl", manifest)
|
| 262 |
+
acquisition = {
|
| 263 |
+
"observed_at": now(), "dump_date": selection["dump_date"],
|
| 264 |
+
"files": selection["files"], "talk_pages": len(manifest),
|
| 265 |
+
"manifest_sha256": digest((out / "source_manifest.jsonl").read_bytes()),
|
| 266 |
+
}
|
| 267 |
+
save(out / "acquisition.json", acquisition)
|
| 268 |
+
print(json.dumps(acquisition, ensure_ascii=False, indent=2))
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def strip_boilerplate(texts_index):
|
| 272 |
+
counts = Counter()
|
| 273 |
+
for lines in texts_index:
|
| 274 |
+
counts.update(set(re.sub(r"\s+", " ", line).strip() for line in lines if line.strip()))
|
| 275 |
+
n = len(texts_index)
|
| 276 |
+
return {line for line, count in counts.items()
|
| 277 |
+
if count / n >= BOILERPLATE_MIN_DOC_FREQ and len(line) < 160}
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
def normalize(text):
|
| 281 |
+
text = unicodedata.normalize("NFKC", text or "").replace("", "").replace("", "")
|
| 282 |
+
text = re.sub(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]", "", text)
|
| 283 |
+
lines = [re.sub(r"[ \t\xa0]+", " ", line).strip() for line in text.splitlines()]
|
| 284 |
+
lines = [line for line in lines if not re.fullmatch(r"\d{1,4}", line)]
|
| 285 |
+
text = "\n".join(lines)
|
| 286 |
+
text = re.sub(r"(?<=\w)-\n(?=[a-ząćęłńóśźż])", "", text)
|
| 287 |
+
text = re.sub(r"(?<![.!?:;\n])\n(?!\n)(?=[a-ząćęłńóśźż])", " ", text)
|
| 288 |
+
return re.sub(r"\n{3,}", "\n\n", text).strip()
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
def page_url(title):
|
| 292 |
+
return SOURCE_URL + "wiki/" + quote((title or "").replace(" ", "_"), safe="/:")
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
def normalize_title(text):
|
| 296 |
+
text = unicodedata.normalize("NFKD", text or "").casefold()
|
| 297 |
+
text = "".join(character for character in text if not unicodedata.combining(character))
|
| 298 |
+
return " ".join(re.findall(r"\w+", text))
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def shingle_sketch(text, limit=5_000):
|
| 302 |
+
words = re.findall(r"\w+", text.casefold())
|
| 303 |
+
hashes = set()
|
| 304 |
+
for index in range(max(0, len(words) - 4)):
|
| 305 |
+
value = " ".join(words[index:index + 5]).encode("utf-8")
|
| 306 |
+
hashes.add(int.from_bytes(hashlib.blake2b(value, digest_size=8).digest(), "big"))
|
| 307 |
+
if len(hashes) > limit:
|
| 308 |
+
return set(sorted(hashes)[:limit])
|
| 309 |
+
return hashes
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
class NearDuplicateIndex:
|
| 313 |
+
def __init__(self):
|
| 314 |
+
self.postings = {}
|
| 315 |
+
self.records = []
|
| 316 |
+
self.comparisons = 0
|
| 317 |
+
|
| 318 |
+
@staticmethod
|
| 319 |
+
def prefix(sketch):
|
| 320 |
+
return sorted(sketch)[:len(sketch) - (9 * len(sketch) + 9) // 10 + 1]
|
| 321 |
+
|
| 322 |
+
def find(self, sketch):
|
| 323 |
+
candidates = set()
|
| 324 |
+
for value in self.prefix(sketch):
|
| 325 |
+
candidates.update(self.postings.get(value, ()))
|
| 326 |
+
for position in sorted(candidates):
|
| 327 |
+
row_id, other = self.records[position]
|
| 328 |
+
if 10 * min(len(sketch), len(other)) < 9 * max(len(sketch), len(other)):
|
| 329 |
+
continue
|
| 330 |
+
self.comparisons += 1
|
| 331 |
+
intersection = len(sketch & other)
|
| 332 |
+
score = intersection / max(len(sketch) + len(other) - intersection, 1)
|
| 333 |
+
if score >= 0.90:
|
| 334 |
+
return row_id, score
|
| 335 |
+
return None, 0.0
|
| 336 |
+
|
| 337 |
+
def add(self, row_id, sketch):
|
| 338 |
+
position = len(self.records)
|
| 339 |
+
self.records.append((row_id, sketch))
|
| 340 |
+
for value in self.prefix(sketch):
|
| 341 |
+
self.postings.setdefault(value, []).append(position)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def language_vote(identifier, text):
|
| 345 |
+
chunks = [text[:30_000], text[max(0, len(text) // 2 - 15_000):len(text) // 2 + 15_000], text[-30_000:]]
|
| 346 |
+
classified = {chunk: identifier.classify(chunk) for chunk in dict.fromkeys(chunks) if chunk.strip()}
|
| 347 |
+
votes = [classified[chunk] for chunk in chunks if chunk in classified]
|
| 348 |
+
languages = Counter(language for language, _ in votes)
|
| 349 |
+
return (languages.most_common(1)[0][0] if languages else "unknown", votes)
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
def audit_target(out):
|
| 353 |
+
info = request_json(f"https://huggingface.co/api/datasets/{TARGET}")
|
| 354 |
+
revision = info["sha"]
|
| 355 |
+
tree = request_json(f"https://huggingface.co/api/datasets/{TARGET}/tree/{revision}?recursive=true&expand=false")
|
| 356 |
+
discussions = request_json(f"https://huggingface.co/api/datasets/{TARGET}/discussions?status=open&p=0")
|
| 357 |
+
paths = sorted(item.get("path", "") for item in tree)
|
| 358 |
+
open_rows = [{"num": item.get("num"), "title": item.get("title"), "status": item.get("status"),
|
| 359 |
+
"author": item.get("author", {}).get("name")} for item in discussions.get("discussions", [])]
|
| 360 |
+
terms = ("plwiki_talk", "wikipedia_talk", "talk", "dyskusja")
|
| 361 |
+
matches = [path for path in paths if any(term in path.casefold() for term in terms)]
|
| 362 |
+
discussion_matches = [row for row in open_rows if any(term in (row.get("title") or "").casefold()
|
| 363 |
+
for term in terms)]
|
| 364 |
+
report = {
|
| 365 |
+
"target": TARGET, "revision": revision, "last_modified": info.get("lastModified"),
|
| 366 |
+
"tree_paths": len(paths), "source_path_matches": matches, "open_discussions": open_rows,
|
| 367 |
+
"matching_open_discussions": discussion_matches, "source_absent": not matches and not discussion_matches,
|
| 368 |
+
"observed_at": now(),
|
| 369 |
+
}
|
| 370 |
+
save(out / "target_audit.json", report)
|
| 371 |
+
print(json.dumps({"revision": revision, "source_absent": report["source_absent"],
|
| 372 |
+
"tree_matches": matches, "discussion_matches": discussion_matches}, ensure_ascii=False, indent=2))
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
def audit_overlap(out):
|
| 376 |
+
import pyarrow.parquet as pq
|
| 377 |
+
from huggingface_hub import HfApi, HfFileSystem
|
| 378 |
+
|
| 379 |
+
acquisition = load(out / "acquisition.json")
|
| 380 |
+
revision = HfApi().dataset_info(TARGET).sha
|
| 381 |
+
remote = f"datasets/{TARGET}@{revision}/data/wikipedia/wikipedia.parquet"
|
| 382 |
+
with HfFileSystem().open(remote, "rb") as handle:
|
| 383 |
+
table = pq.read_table(handle, columns=["id"])
|
| 384 |
+
target_ids = set(table.column("id").to_pylist())
|
| 385 |
+
candidate_ids = {f"{SOURCE}_{row['pageid']}" for row in read_lines(out / "source_manifest.jsonl")}
|
| 386 |
+
collisions = sorted(candidate_ids & target_ids)
|
| 387 |
+
report = {
|
| 388 |
+
"target": f"{TARGET}:data/wikipedia", "target_revision": revision,
|
| 389 |
+
"method": "Literal dataset-record ID comparison only. Source-specific ID prefixes make zero collisions "
|
| 390 |
+
"uninformative about page identity or text overlap. No target namespace or text audit was performed.",
|
| 391 |
+
"target_rows": table.num_rows, "candidate_records": len(candidate_ids),
|
| 392 |
+
"id_collisions": collisions[:50], "collision_count": len(collisions),
|
| 393 |
+
"text_overlap": "not tested; quoted-article passages and target-wide text dedup remain integration gates",
|
| 394 |
+
"observed_at": now(),
|
| 395 |
+
}
|
| 396 |
+
save(out / "overlap_audit.json", report)
|
| 397 |
+
print(json.dumps({key: report[key] for key in ("target_revision", "target_rows", "candidate_records",
|
| 398 |
+
"collision_count")}, ensure_ascii=False, indent=2))
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def build(out):
|
| 402 |
+
import pyarrow as pa
|
| 403 |
+
import pyarrow.parquet as pq
|
| 404 |
+
import tiktoken
|
| 405 |
+
from langid.langid import LanguageIdentifier, model
|
| 406 |
+
|
| 407 |
+
build_started_at = now()
|
| 408 |
+
acquisition = load(out / "acquisition.json")
|
| 409 |
+
selection = load(out / "selection.json")
|
| 410 |
+
encoder = tiktoken.get_encoding("cl100k_base")
|
| 411 |
+
identifier = LanguageIdentifier.from_modelstring(model, norm_probs=True)
|
| 412 |
+
identifier.set_languages(["pl", "en", "de", "uk", "ru"])
|
| 413 |
+
|
| 414 |
+
candidates = []
|
| 415 |
+
for shard in sorted((out / "extracted").glob("*.jsonl.gz")):
|
| 416 |
+
with gzip.open(shard, "rt", encoding="utf-8") as f:
|
| 417 |
+
for line in f:
|
| 418 |
+
row = json.loads(line)
|
| 419 |
+
row["text"] = normalize(row["text"])
|
| 420 |
+
candidates.append(row)
|
| 421 |
+
boilerplate = strip_boilerplate([row["text"].splitlines() for row in candidates])
|
| 422 |
+
print(f"boilerplate lines: {len(boilerplate)}", flush=True)
|
| 423 |
+
|
| 424 |
+
rows, attribution, decisions, exact_seen = [], [], [], {}
|
| 425 |
+
near_index = NearDuplicateIndex()
|
| 426 |
+
pii = Counter()
|
| 427 |
+
added = acquisition["observed_at"][:10]
|
| 428 |
+
started = last_progress = time.monotonic()
|
| 429 |
+
for processed, record in enumerate(candidates, 1):
|
| 430 |
+
current = time.monotonic()
|
| 431 |
+
if current - last_progress >= 10 or processed == len(candidates):
|
| 432 |
+
print(f" processed={processed - 1}/{len(candidates)} kept={len(rows)} "
|
| 433 |
+
f"rate={(processed - 1) / max(current - started, 0.001):.1f}/s "
|
| 434 |
+
f"near_comparisons={near_index.comparisons}", flush=True)
|
| 435 |
+
last_progress = current
|
| 436 |
+
text = "\n".join(line for line in record["text"].splitlines()
|
| 437 |
+
if re.sub(r"\s+", " ", line).strip() not in boilerplate)
|
| 438 |
+
text = re.sub(r"\n{3,}", "\n\n", text).strip()
|
| 439 |
+
replacement_count = text.count("\ufffd")
|
| 440 |
+
letters = len(re.findall(r"[A-Za-zĄĆĘŁŃÓŚŹŻąćęłńóśźż]", text))
|
| 441 |
+
language, votes = "not_checked", []
|
| 442 |
+
reason = ""
|
| 443 |
+
if len(text) < MIN_TEXT_CHARS:
|
| 444 |
+
reason = "too_little_text"
|
| 445 |
+
elif letters / max(len(text), 1) < 0.5:
|
| 446 |
+
reason = "low_letter_ratio"
|
| 447 |
+
elif replacement_count > 100 or replacement_count / max(len(text), 1) > 0.002:
|
| 448 |
+
reason = "excessive_replacement_characters"
|
| 449 |
+
if not reason:
|
| 450 |
+
language, votes = language_vote(identifier, text)
|
| 451 |
+
if language != "pl":
|
| 452 |
+
reason = "non_polish_text"
|
| 453 |
+
text = text.replace("\ufffd", "[UNREADABLE_GLYPH]")
|
| 454 |
+
text, pii_counts = redact_pii(text)
|
| 455 |
+
pii.update(pii_counts)
|
| 456 |
+
if not reason and len(text) < MIN_TEXT_CHARS:
|
| 457 |
+
reason = "too_little_text_after_redaction"
|
| 458 |
+
exact_key = digest(" ".join(text.casefold().split()).encode("utf-8"))
|
| 459 |
+
duplicate_of, duplicate_score = None, 0.0
|
| 460 |
+
if not reason and exact_key in exact_seen:
|
| 461 |
+
reason, duplicate_of, duplicate_score = "normalized_duplicate", exact_seen[exact_key], 1.0
|
| 462 |
+
if not reason:
|
| 463 |
+
sketch = shingle_sketch(text)
|
| 464 |
+
duplicate_of, duplicate_score = near_index.find(sketch)
|
| 465 |
+
if duplicate_of is not None:
|
| 466 |
+
reason = "near_duplicate"
|
| 467 |
+
row_id = f"{SOURCE}_{record['pageid']}"
|
| 468 |
+
decision = {
|
| 469 |
+
"id": row_id, "selected": not bool(reason), "reason": reason or "include",
|
| 470 |
+
"characters": len(text), "letter_ratio": letters / max(len(text), 1),
|
| 471 |
+
"replacement_characters": replacement_count, "language": language,
|
| 472 |
+
"language_votes": [{"language": lang, "confidence": float(score)} for lang, score in votes],
|
| 473 |
+
}
|
| 474 |
+
if duplicate_of:
|
| 475 |
+
decision.update({"duplicate_of": duplicate_of, "jaccard": duplicate_score})
|
| 476 |
+
decisions.append(decision)
|
| 477 |
+
if reason:
|
| 478 |
+
continue
|
| 479 |
+
exact_seen[exact_key] = row_id
|
| 480 |
+
near_index.add(row_id, sketch)
|
| 481 |
+
row = {
|
| 482 |
+
"id": row_id, "text": text, "source": SOURCE, "added": added,
|
| 483 |
+
"created": (record["timestamp"] or "")[:10] or "unknown",
|
| 484 |
+
"token_count": len(encoder.encode_ordinary(text)),
|
| 485 |
+
"license": LICENSE_SPDX, "author": "plwiki contributors",
|
| 486 |
+
}
|
| 487 |
+
rows.append(row)
|
| 488 |
+
attribution.append({
|
| 489 |
+
"id": row_id, "pageid": record["pageid"], "ns": record["ns"], "title": record["title"],
|
| 490 |
+
"url": page_url(record["title"]),
|
| 491 |
+
"last_revision_at": record["timestamp"], "wikitext_chars": record["wikitext_chars"],
|
| 492 |
+
"license": LICENSE_SPDX,
|
| 493 |
+
"license_evidence": LICENSE_TERMS_URL + " (section 7, text licensing and attribution by page URL)",
|
| 494 |
+
"dump": {"date": selection["dump_date"], "files": [f["name"] for f in selection["files"]]},
|
| 495 |
+
"text_sha256": digest(text.encode("utf-8")),
|
| 496 |
+
"transformations": ["official pages-meta-current dump", "mwparserfromhell wikitext strip",
|
| 497 |
+
"cross-document boilerplate-line removal",
|
| 498 |
+
"Unicode/whitespace normalization", "page-number-only removal",
|
| 499 |
+
"line-wrap repair", "email/labelled-phone/IP/labelled-national-ID/account-candidate pattern redaction"],
|
| 500 |
+
})
|
| 501 |
+
|
| 502 |
+
root = out / "hf_repo"
|
| 503 |
+
(root / "data").mkdir(parents=True, exist_ok=True)
|
| 504 |
+
(root / "artifacts").mkdir(parents=True, exist_ok=True)
|
| 505 |
+
schema = pa.schema([(field, pa.int64() if field == "token_count" else pa.string()) for field in FIELDS])
|
| 506 |
+
pq.write_table(pa.Table.from_pylist(rows, schema=schema), root / "data/train-00000-of-00001.parquet", compression="zstd")
|
| 507 |
+
write_lines(root / "artifacts/attribution.jsonl", attribution)
|
| 508 |
+
write_lines(root / "artifacts/decisions.jsonl", decisions)
|
| 509 |
+
write_lines(root / "artifacts/source_manifest.jsonl", read_lines(out / "source_manifest.jsonl"))
|
| 510 |
+
sample = sorted(rows, key=lambda row: digest(("sample:" + row["id"]).encode("utf-8")))[:12]
|
| 511 |
+
write_lines(root / "artifacts/sample.jsonl", sample)
|
| 512 |
+
save(root / "artifacts/selection.json", selection)
|
| 513 |
+
save(root / "artifacts/acquisition.json", acquisition)
|
| 514 |
+
save(root / "artifacts/boilerplate_lines.json", sorted(boilerplate))
|
| 515 |
+
overlap = load(out / "overlap_audit.json") if (out / "overlap_audit.json").exists() else None
|
| 516 |
+
target_audit = load(out / "target_audit.json") if (out / "target_audit.json").exists() else None
|
| 517 |
+
if overlap:
|
| 518 |
+
save(root / "artifacts/overlap_audit.json", overlap)
|
| 519 |
+
if target_audit:
|
| 520 |
+
save(root / "artifacts/target_audit.json", target_audit)
|
| 521 |
+
stats = {
|
| 522 |
+
"dump_date": selection["dump_date"], "dump_files": len(selection["files"]),
|
| 523 |
+
"talk_pages": acquisition["talk_pages"],
|
| 524 |
+
"kept": len(rows), "rejected": len(decisions) - len(rows),
|
| 525 |
+
"tokens": sum(row["token_count"] for row in rows),
|
| 526 |
+
"characters": sum(len(row["text"]) for row in rows),
|
| 527 |
+
"license_counts": dict(Counter(row["license"] for row in rows)),
|
| 528 |
+
"boilerplate_lines_removed": len(boilerplate),
|
| 529 |
+
"sample_count": len(sample), "added": added,
|
| 530 |
+
}
|
| 531 |
+
qa = {
|
| 532 |
+
"scope": "Polish Wikipedia article-talk (ns=1) and project-talk (ns=5) pages from the pinned pages-meta-current dump",
|
| 533 |
+
"license_terms_url": LICENSE_TERMS_URL,
|
| 534 |
+
"license_gate": "Wikimedia Terms of Use section 7: CC BY-SA 4.0 and page-URL attribution; third-party notices still require review",
|
| 535 |
+
"rejection_counts": dict(Counter(item["reason"] for item in decisions if not item["selected"])),
|
| 536 |
+
"minimum_final_text_characters": MIN_TEXT_CHARS,
|
| 537 |
+
"created_field_semantics": "Last revision date from the dump, not the page creation date",
|
| 538 |
+
"language_gate": "independent three-window langid vote",
|
| 539 |
+
"pii_pattern_matches": dict(pii), "exact_dedup": True,
|
| 540 |
+
"pii_policy": "IPv6 parsed including compressed notation; labelled PESEL/NIP/REGON and 26-digit account candidates masked conservatively without checksum validation; counts cover all candidates before rejection",
|
| 541 |
+
"pii_limitations": "Unlabelled national identifiers, free-form phone numbers, names and personal disclosures may remain; this is not complete anonymization",
|
| 542 |
+
"near_dedup": "deterministic capped 5-word-shingle hash Jaccard >= 0.90 within source",
|
| 543 |
+
"boilerplate": f"lines occurring in >= {BOILERPLATE_MIN_DOC_FREQ:.0%} of documents removed ({len(boilerplate)} patterns)",
|
| 544 |
+
"wikipedia_shard_overlap": overlap or "pending", "cross_source_text_dedup": "pending target integration",
|
| 545 |
+
"benchmark_overlap": "pending", "limitations": [
|
| 546 |
+
"talk pages contain informal text with typos, edit disputes and occasional abuse/vandalism",
|
| 547 |
+
"user-talk namespace (ns=3) excluded by scope decision; its quality was not measured",
|
| 548 |
+
"comments may quote article text; quoted passages are not disjoint from the wikipedia shard",
|
| 549 |
+
"record model is a whole talk page; individual comments are not split",
|
| 550 |
+
"pattern checks are not comprehensive de-identification",
|
| 551 |
+
],
|
| 552 |
+
}
|
| 553 |
+
save(root / "artifacts/stats.json", stats)
|
| 554 |
+
save(root / "artifacts/qa.json", qa)
|
| 555 |
+
protocol_id = "protocol:plwiki-talk-v1"
|
| 556 |
+
run = {
|
| 557 |
+
"id": "run:" + digest({"script": digest(Path(__file__).read_bytes()), "selection": selection,
|
| 558 |
+
"acquisition": digest(acquisition)}),
|
| 559 |
+
"protocol": protocol_id, "started_at": build_started_at, "finished_at": now(),
|
| 560 |
+
"success": True, "actor": "actor:devin", "stats": stats,
|
| 561 |
+
}
|
| 562 |
+
save(root / "artifacts/run.json", run)
|
| 563 |
+
excluded = {"README.md", "NOTICE.md", "artifacts/checksums.json", "artifacts/ontology.json"}
|
| 564 |
+
checks = {path.relative_to(root).as_posix(): digest(path.read_bytes()) for path in sorted(root.rglob("*"))
|
| 565 |
+
if path.is_file()
|
| 566 |
+
and path.relative_to(root).as_posix() not in excluded
|
| 567 |
+
and not path.relative_to(root).as_posix().startswith("src/")}
|
| 568 |
+
save(root / "artifacts/checksums.json", checks)
|
| 569 |
+
source_version = "version:source:" + digest(selection["files"])
|
| 570 |
+
dataset_version = "version:dataset:" + digest(checks)
|
| 571 |
+
selection_evidence = "evidence:selection:" + digest(selection)
|
| 572 |
+
acquisition_evidence = "evidence:acquisition:" + digest(acquisition)
|
| 573 |
+
qa_evidence = "evidence:qa:" + digest(qa)
|
| 574 |
+
evidence = [
|
| 575 |
+
{"id": selection_evidence, "observation_type": "dump_inventory_and_pinning",
|
| 576 |
+
"artifact": "artifacts/selection.json", "content_address": digest(selection), "produced_by": run["id"]},
|
| 577 |
+
{"id": acquisition_evidence, "observation_type": "dump_download_sha1_and_extraction",
|
| 578 |
+
"artifact": "artifacts/acquisition.json", "content_address": digest(acquisition), "produced_by": run["id"]},
|
| 579 |
+
{"id": qa_evidence, "observation_type": "source_qa", "artifact": "artifacts/qa.json",
|
| 580 |
+
"content_address": digest(qa), "produced_by": run["id"]},
|
| 581 |
+
]
|
| 582 |
+
overlap_evidence = None
|
| 583 |
+
if overlap:
|
| 584 |
+
overlap_evidence = "evidence:overlap:" + digest(overlap)
|
| 585 |
+
evidence.append({"id": overlap_evidence, "observation_type": "namespace_overlap_audit",
|
| 586 |
+
"artifact": "artifacts/overlap_audit.json", "content_address": digest(overlap),
|
| 587 |
+
"produced_by": run["id"]})
|
| 588 |
+
target_evidence = None
|
| 589 |
+
if target_audit:
|
| 590 |
+
target_evidence = "evidence:target:" + digest(target_audit)
|
| 591 |
+
evidence.append({"id": target_evidence, "observation_type": "target_registry_audit",
|
| 592 |
+
"artifact": "artifacts/target_audit.json", "content_address": digest(target_audit),
|
| 593 |
+
"produced_by": run["id"]})
|
| 594 |
+
ontology = {
|
| 595 |
+
"schema": "slayer-research-ontology-profile-v1",
|
| 596 |
+
"objects": [{"id": "object:source:plwiki-dump-" + selection["dump_date"], "type": "Source"},
|
| 597 |
+
{"id": "object:dataset:plwiki-talk", "type": "Dataset"}],
|
| 598 |
+
"versions": [{"id": source_version, "object": "object:source:plwiki-dump-" + selection["dump_date"],
|
| 599 |
+
"content_address": source_version.rsplit(":", 1)[-1]},
|
| 600 |
+
{"id": dataset_version, "object": "object:dataset:plwiki-talk",
|
| 601 |
+
"content_address": dataset_version.rsplit(":", 1)[-1]}],
|
| 602 |
+
"protocols": [{"id": protocol_id, "procedure": "pinned dump; sha1-verified shards; namespaces 1+5; wikitext strip; boilerplate removal; normalization; PII patterns; exact and near dedup"}],
|
| 603 |
+
"runs": [run], "evidence": evidence,
|
| 604 |
+
"claims": [
|
| 605 |
+
{"id": "claim:talk-pages-observed",
|
| 606 |
+
"statement": f"The pinned dump {selection['dump_date']} yielded {acquisition['talk_pages']} non-redirect talk pages in namespaces 1 and 5.",
|
| 607 |
+
"supported_by": [selection_evidence, acquisition_evidence],
|
| 608 |
+
"falsification_condition": "The pinned dump shards do not reproduce the count."},
|
| 609 |
+
{"id": "claim:slice-retention",
|
| 610 |
+
"statement": f"The slice retained {stats['kept']} records after text QA and within-source deduplication.",
|
| 611 |
+
"supported_by": [acquisition_evidence, qa_evidence],
|
| 612 |
+
"falsification_condition": "The decisions, Parquet rows, or checksums do not reproduce the retention count."},
|
| 613 |
+
{"id": "claim:source-absence-at-audit",
|
| 614 |
+
"statement": "Talk-namespace Wikipedia content was not registered as a source in the pinned DynaWord data tree or open pull-request list at audit time.",
|
| 615 |
+
"supported_by": [target_evidence] if target_evidence else [qa_evidence],
|
| 616 |
+
"falsification_condition": "The pinned target evidence contains a matching source or proposal."},
|
| 617 |
+
{"id": "claim:training-value-untested",
|
| 618 |
+
"statement": "Net corpus novelty and training benefit remain untested hypotheses.",
|
| 619 |
+
"supported_by": [qa_evidence] + ([overlap_evidence] if overlap_evidence else []),
|
| 620 |
+
"falsification_condition": "Target-wide text deduplication and controlled ablations establish those properties."},
|
| 621 |
+
],
|
| 622 |
+
"actors": [{"id": "actor:piotrsty", "type": "Contributor"},
|
| 623 |
+
{"id": "actor:wikimedia", "type": "Organization"}, {"id": "actor:devin", "type": "Agent"}],
|
| 624 |
+
"relations": [{"source": dataset_version, "predicate": "DERIVED_FROM", "target": source_version},
|
| 625 |
+
{"source": dataset_version, "predicate": "GENERATED_BY", "target": run["id"]}] +
|
| 626 |
+
([{"source": dataset_version, "predicate": "VALIDATED_AGAINST",
|
| 627 |
+
"target": f"hf:dataset:{TARGET}@{target_audit['revision']}"}] if target_audit else []),
|
| 628 |
+
"pending": ["quoted-article-fragment dedup vs wikipedia shard", "cross-source text deduplication",
|
| 629 |
+
"benchmark contamination check", "abuse/vandalism content screening",
|
| 630 |
+
"controlled training ablation"],
|
| 631 |
+
}
|
| 632 |
+
save(root / "artifacts/ontology.json", ontology)
|
| 633 |
+
card = f"""---
|
| 634 |
+
license: cc-by-sa-4.0
|
| 635 |
+
language:
|
| 636 |
+
- pl
|
| 637 |
+
task_categories:
|
| 638 |
+
- text-generation
|
| 639 |
+
configs:
|
| 640 |
+
- config_name: default
|
| 641 |
+
data_files:
|
| 642 |
+
- split: train
|
| 643 |
+
path: data/train-00000-of-00001.parquet
|
| 644 |
+
---
|
| 645 |
+
|
| 646 |
+
# Polish Wikipedia talk pages (plwiki, namespaces 1+5)
|
| 647 |
+
|
| 648 |
+
Article-talk and project-talk pages from the pinned `plwiki-{selection['dump_date']}-pages-meta-current`
|
| 649 |
+
dump (https://dumps.wikimedia.org/plwiki/{selection['dump_date']}/).
|
| 650 |
+
The source selects namespaces 1 and 5; zero collisions of source-prefixed record
|
| 651 |
+
IDs do not establish disjointness from the target `wikipedia` shard. Target-wide
|
| 652 |
+
text deduplication remains pending. This is conversational written Polish:
|
| 653 |
+
editorial disputes, coordination, questions and answers.
|
| 654 |
+
|
| 655 |
+
- Dump files: {stats['dump_files']} shards, sha1-verified against dumpstatus.json
|
| 656 |
+
- Non-redirect talk pages (ns 1+5): {stats['talk_pages']:,}
|
| 657 |
+
- Retained after text QA and within-source deduplication: {stats['kept']:,}
|
| 658 |
+
- Characters: {stats['characters']:,}
|
| 659 |
+
- Tokens: {stats['tokens']:,} (`cl100k_base` proxy)
|
| 660 |
+
- License: CC BY-SA 4.0 per record; authorship via per-page history link
|
| 661 |
+
|
| 662 |
+
## Provenance and rights
|
| 663 |
+
|
| 664 |
+
Each record keeps its page id, title, namespace, last-revision timestamp and
|
| 665 |
+
canonical URL (history is the attribution trail, per [Wikimedia Terms of Use,
|
| 666 |
+
section 7]({LICENSE_TERMS_URL})). That section grants CC BY-SA 4.0 rights to
|
| 667 |
+
contributor text and allows attribution via the source-page URL. Additional
|
| 668 |
+
third-party attribution notices must be preserved and remain a review item.
|
| 669 |
+
The user-talk namespace (ns=3) is excluded by scope decision; its quality was
|
| 670 |
+
not measured. The `created` field is the last revision date, not page creation.
|
| 671 |
+
|
| 672 |
+
## Processing and limitations
|
| 673 |
+
|
| 674 |
+
Wikitext is stripped with mwparserfromhell; lines occurring in at least
|
| 675 |
+
{BOILERPLATE_MIN_DOC_FREQ:.0%} of documents are removed as
|
| 676 |
+
cross-document boilerplate (see `artifacts/boilerplate_lines.json`). Unicode and
|
| 677 |
+
whitespace normalization, email/labelled-phone/IP/labelled-national-ID/account-candidate pattern redaction, three-window langid
|
| 678 |
+
vote, exact and near deduplication within source. The final text must contain at
|
| 679 |
+
least {MIN_TEXT_CHARS} characters after redaction. Rejection counts:
|
| 680 |
+
|
| 681 |
+
```json
|
| 682 |
+
{json.dumps(qa['rejection_counts'], ensure_ascii=False, indent=2)}
|
| 683 |
+
```
|
| 684 |
+
|
| 685 |
+
PII filtering masks parsed IPv6 addresses (including compressed forms), labelled
|
| 686 |
+
PESEL/NIP/REGON and 26-digit account candidates as well as the existing patterns.
|
| 687 |
+
The account filter is conservative and may mask non-account numbers; unlabelled
|
| 688 |
+
identifiers, free-form phone numbers, names and personal disclosures may remain.
|
| 689 |
+
This is not complete anonymization.
|
| 690 |
+
|
| 691 |
+
Talk pages are informal: they contain typos, edit disputes, quoted article
|
| 692 |
+
fragments and occasional vandalism or abuse. Quoted article text is not disjoint
|
| 693 |
+
from the shipped `wikipedia` shard; text-level dedup against it remains a target
|
| 694 |
+
integration gate. The record model is a whole talk page; comments are not split.
|
| 695 |
+
|
| 696 |
+
## Review artifacts
|
| 697 |
+
|
| 698 |
+
See `artifacts/sample.jsonl`, `attribution.jsonl`, `decisions.jsonl`,
|
| 699 |
+
`source_manifest.jsonl`, `overlap_audit.json`, `stats.json`, `qa.json`,
|
| 700 |
+
`checksums.json`, `run.json` and `ontology.json`.
|
| 701 |
+
"""
|
| 702 |
+
(root / "README.md").write_text(card, encoding="utf-8")
|
| 703 |
+
(root / "NOTICE.md").write_text(
|
| 704 |
+
"# Attribution and license notice\n\n"
|
| 705 |
+
"Source: Polish Wikipedia talk pages, https://pl.wikipedia.org/ - Wikimedia Foundation.\n\n"
|
| 706 |
+
"Text is available under the Creative Commons Attribution-ShareAlike 4.0 License "
|
| 707 |
+
"(https://creativecommons.org/licenses/by-sa/4.0/). Attribution is provided via the per-record "
|
| 708 |
+
"canonical page URL in `artifacts/attribution.jsonl`; each page's revision history lists its "
|
| 709 |
+
"contributors.\n\n"
|
| 710 |
+
"Preparation: Piotr Styla with Devin. Changes: namespace filtering (1 and 5), wikitext "
|
| 711 |
+
"stripping, cross-document boilerplate removal, Unicode and whitespace normalization, limited "
|
| 712 |
+
"email/labelled-phone/IP/labelled-national-ID/account-candidate redaction, language/quality filtering and within-source deduplication. No "
|
| 713 |
+
"endorsement by the Wikimedia Foundation or page contributors is implied.\n",
|
| 714 |
+
encoding="utf-8",
|
| 715 |
+
)
|
| 716 |
+
print(json.dumps(stats, ensure_ascii=False, indent=2))
|
| 717 |
+
|
| 718 |
+
|
| 719 |
+
def verify(out):
|
| 720 |
+
import pyarrow.parquet as pq
|
| 721 |
+
|
| 722 |
+
root = out / "hf_repo"
|
| 723 |
+
table = pq.read_table(root / "data/train-00000-of-00001.parquet")
|
| 724 |
+
rows = table.to_pylist()
|
| 725 |
+
stats = load(root / "artifacts/stats.json")
|
| 726 |
+
decisions = read_lines(root / "artifacts/decisions.jsonl")
|
| 727 |
+
attribution = read_lines(root / "artifacts/attribution.jsonl")
|
| 728 |
+
sample = read_lines(root / "artifacts/sample.jsonl")
|
| 729 |
+
assert table.column_names == FIELDS
|
| 730 |
+
assert len(rows) == stats["kept"] == len(attribution)
|
| 731 |
+
assert sum(item["selected"] for item in decisions) == len(rows)
|
| 732 |
+
assert sum(row["token_count"] for row in rows) == stats["tokens"]
|
| 733 |
+
assert all(row["source"] == SOURCE and row["license"] == LICENSE_SPDX for row in rows)
|
| 734 |
+
assert all(EMAIL_RE.search(row["text"]) is None for row in rows)
|
| 735 |
+
by_id = {row["id"]: row for row in rows}
|
| 736 |
+
assert len(sample) == stats["sample_count"] and all(by_id[row["id"]] == row for row in sample)
|
| 737 |
+
ontology = load(root / "artifacts/ontology.json")
|
| 738 |
+
evidence = {item["id"] for item in ontology["evidence"]}
|
| 739 |
+
assert all(item["falsification_condition"] and set(item["supported_by"]) <= evidence for item in ontology["claims"])
|
| 740 |
+
checks = load(root / "artifacts/checksums.json")
|
| 741 |
+
assert all((root / path).is_file() and digest((root / path).read_bytes()) == checksum for path, checksum in checks.items())
|
| 742 |
+
for item in ontology["evidence"]:
|
| 743 |
+
artifact = root / item["artifact"]
|
| 744 |
+
assert artifact.is_file() and digest(load(artifact)) == item["content_address"]
|
| 745 |
+
import tiktoken
|
| 746 |
+
|
| 747 |
+
encoder = tiktoken.get_encoding("cl100k_base")
|
| 748 |
+
assert len(by_id) == len(rows)
|
| 749 |
+
assert set(by_id) == {item["id"] for item in attribution}
|
| 750 |
+
assert set(by_id) == {item["id"] for item in decisions if item["selected"]}
|
| 751 |
+
assert len(decisions) == stats["talk_pages"]
|
| 752 |
+
assert len(decisions) - len(rows) == stats["rejected"]
|
| 753 |
+
assert sum(len(row["text"]) for row in rows) == stats["characters"]
|
| 754 |
+
short_ids = [row["id"] for row in rows if len(row["text"]) < MIN_TEXT_CHARS]
|
| 755 |
+
assert all(row["token_count"] > 0 for row in rows)
|
| 756 |
+
assert all(len(row["created"]) == 10 and row["author"] for row in rows)
|
| 757 |
+
assert all(item["ns"] in TALK_NS and item["url"] == page_url(item["title"])
|
| 758 |
+
and item["text_sha256"] == digest(by_id[item["id"]]["text"].encode("utf-8"))
|
| 759 |
+
for item in attribution)
|
| 760 |
+
assert all(len(encoder.encode_ordinary(row["text"])) == row["token_count"] for row in rows)
|
| 761 |
+
boilerplate = set(load(root / "artifacts/boilerplate_lines.json"))
|
| 762 |
+
review_ids = {row["id"] for row in sorted(sample, key=lambda item: len(item["text"]))[:3]}
|
| 763 |
+
comparisons = []
|
| 764 |
+
reconstructed = set()
|
| 765 |
+
for shard in sorted((out / "extracted").glob("*.jsonl.gz")):
|
| 766 |
+
with gzip.open(shard, "rt", encoding="utf-8") as handle:
|
| 767 |
+
for line in handle:
|
| 768 |
+
original = json.loads(line)
|
| 769 |
+
row_id = f"{SOURCE}_{original['pageid']}"
|
| 770 |
+
if row_id not in by_id:
|
| 771 |
+
continue
|
| 772 |
+
text = normalize(original["text"])
|
| 773 |
+
text = "\n".join(line for line in text.splitlines()
|
| 774 |
+
if re.sub(r"\s+", " ", line).strip() not in boilerplate)
|
| 775 |
+
text = re.sub(r"\n{3,}", "\n\n", text).strip().replace("\ufffd", "[UNREADABLE_GLYPH]")
|
| 776 |
+
text, _ = redact_pii(text)
|
| 777 |
+
before = redact_pii(original["text"])[0] if row_id in review_ids else ""
|
| 778 |
+
assert text == by_id[row_id]["text"], row_id
|
| 779 |
+
assert row_id not in reconstructed
|
| 780 |
+
reconstructed.add(row_id)
|
| 781 |
+
if row_id in review_ids:
|
| 782 |
+
comparisons.append({"id": row_id, "title": original["title"],
|
| 783 |
+
"before_normalization_pii_patterns_redacted": before,
|
| 784 |
+
"after": text})
|
| 785 |
+
assert reconstructed == set(by_id)
|
| 786 |
+
write_lines(out / "validation_samples.jsonl", comparisons)
|
| 787 |
+
lengths = sorted(len(row["text"]) for row in rows)
|
| 788 |
+
rejection_counts = dict(Counter(item["reason"] for item in decisions if not item["selected"]))
|
| 789 |
+
residuals = {name: sum(bool(pattern.search(row["text"])) for row in rows)
|
| 790 |
+
for name, pattern in {"email": EMAIL_RE, "labelled_phone": PHONE_RE,
|
| 791 |
+
"ipv4": IPV4_RE, "ipv6_current_pattern": IPV6_RE}.items()}
|
| 792 |
+
privacy_review = {
|
| 793 |
+
"compressed_ipv6_documents": sum(any(is_ipv6(match.group()) for match in IPV6_CANDIDATE_RE.finditer(row["text"])) for row in rows),
|
| 794 |
+
"labelled_national_identifier_candidates": sum(bool(NATIONAL_ID_RE.search(row["text"])) for row in rows),
|
| 795 |
+
"bank_account_candidates": sum(bool(BANK_ACCOUNT_RE.search(row["text"])) for row in rows),
|
| 796 |
+
}
|
| 797 |
+
report = {
|
| 798 |
+
"observed_at": now(), "verified": not short_ids and not any(residuals.values()) and not any(privacy_review.values()), "stats": stats,
|
| 799 |
+
"additional_privacy_review_document_counts": privacy_review,
|
| 800 |
+
"below_minimum_length_ids": short_ids,
|
| 801 |
+
"rejection_counts": rejection_counts,
|
| 802 |
+
"retained_namespaces": dict(Counter(item["ns"] for item in attribution)),
|
| 803 |
+
"length_quantiles": {str(q): lengths[int((len(lengths) - 1) * q)] for q in (0, 0.5, 0.9, 0.99, 1)},
|
| 804 |
+
"residual_pattern_document_counts": residuals,
|
| 805 |
+
"all_token_counts_recomputed": True,
|
| 806 |
+
"texts_reconstructed_from_extracted_source": len(reconstructed),
|
| 807 |
+
"before_after_samples": len(comparisons),
|
| 808 |
+
"publication_ready": False,
|
| 809 |
+
"pending": ["license evidence and attribution review", "PII coverage review",
|
| 810 |
+
"target overlap audit methodology review", "manual text quality review"],
|
| 811 |
+
}
|
| 812 |
+
save(out / "validation_report.json", report)
|
| 813 |
+
print(json.dumps(report, ensure_ascii=False, indent=2))
|
| 814 |
+
assert report["verified"], "Validation failures: see validation_report.json"
|
| 815 |
+
|
| 816 |
+
|
| 817 |
+
def main():
|
| 818 |
+
parser = argparse.ArgumentParser()
|
| 819 |
+
parser.add_argument("--output", type=Path, required=True)
|
| 820 |
+
parser.add_argument("--workers", type=int, default=8)
|
| 821 |
+
parser.add_argument("command", choices=["discover", "acquire", "audit_target", "audit_overlap",
|
| 822 |
+
"build", "verify"])
|
| 823 |
+
args = parser.parse_args()
|
| 824 |
+
if args.command == "discover":
|
| 825 |
+
discover(args.output)
|
| 826 |
+
elif args.command == "acquire":
|
| 827 |
+
acquire(args.output, args.workers)
|
| 828 |
+
elif args.command == "audit_target":
|
| 829 |
+
audit_target(args.output)
|
| 830 |
+
elif args.command == "audit_overlap":
|
| 831 |
+
audit_overlap(args.output)
|
| 832 |
+
elif args.command == "build":
|
| 833 |
+
build(args.output)
|
| 834 |
+
else:
|
| 835 |
+
verify(args.output)
|
| 836 |
+
|
| 837 |
+
|
| 838 |
+
if __name__ == "__main__":
|
| 839 |
+
main()
|
| 840 |
+
|
src/plwiki_talk_requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests==2.32.5
|
| 2 |
+
pyarrow==23.0.1
|
| 3 |
+
tiktoken==0.12.0
|
| 4 |
+
langid==1.1.6
|
| 5 |
+
mwparserfromhell==0.7.2
|
| 6 |
+
huggingface_hub>=1.0,<2
|
| 7 |
+
pytest>=8,<10
|
src/sources.py
CHANGED
|
@@ -65,6 +65,21 @@ SOURCES = {
|
|
| 65 |
'created': '2023-2026',
|
| 66 |
'is_ocr': False,
|
| 67 |
'custom_datasheet': True},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
"wikipedia": {
|
| 69 |
"added": "2026-07-02",
|
| 70 |
"release": "0.2.0",
|
|
|
|
| 65 |
'created': '2023-2026',
|
| 66 |
'is_ocr': False,
|
| 67 |
'custom_datasheet': True},
|
| 68 |
+
"plwiki_talk": {
|
| 69 |
+
"added": "2026-09-11",
|
| 70 |
+
"release": None,
|
| 71 |
+
"file_key": "plwiki_talk",
|
| 72 |
+
"pretty": "Polish Wikipedia talk pages (ns 1+5)",
|
| 73 |
+
"license": "CC BY-SA 4.0",
|
| 74 |
+
"license_spdx": "CC-BY-SA-4.0",
|
| 75 |
+
"traceable": "Records come from the pinned official Wikimedia pages-meta-current dump (sha1-verified shards). Per-record page id, title, namespace, last-revision timestamp and canonical URL are preserved; page history carries contributor attribution per Wikimedia Terms of Use section 7.",
|
| 76 |
+
"upstream": "https://pl.wikipedia.org/",
|
| 77 |
+
"provenance": "Rebuilt deterministically from the Wikimedia XML dump. Scope is namespaces 1 and 5 only; mainspace (ns=0) is covered by the existing wikipedia shard and user-talk (ns=3) is excluded by scope decision (not measured). Wikitext stripped with mwparserfromhell, cross-document boilerplate lines removed, normalized, PII patterns redacted (email, labelled phone, IPv4, parsed IPv6 including compressed notation, labelled PESEL/NIP/REGON, 26-digit account candidates), language/quality filtered and within-source deduplicated. Pattern redaction is not complete anonymization.",
|
| 78 |
+
"domain": "conversational/community-moderation",
|
| 79 |
+
"created": "2002-2026",
|
| 80 |
+
"is_ocr": False,
|
| 81 |
+
"custom_datasheet": True,
|
| 82 |
+
},
|
| 83 |
"wikipedia": {
|
| 84 |
"added": "2026-07-02",
|
| 85 |
"release": "0.2.0",
|
src/test_build_plwiki_talk_pl.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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location("build_plwiki_talk_pl", SCRIPT)
|
| 7 |
+
MODULE = importlib.util.module_from_spec(SPEC)
|
| 8 |
+
SPEC.loader.exec_module(MODULE)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def test_talk_namespaces_exclude_user_talk_and_mainspace():
|
| 12 |
+
assert MODULE.TALK_NS == {"1", "5"}
|
| 13 |
+
assert "0" not in MODULE.TALK_NS and "3" not in MODULE.TALK_NS
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def test_normalize_repairs_hyphenation_and_page_numbers():
|
| 17 |
+
assert MODULE.normalize("Pierw-\nszy akapit.\n12\n\ndrugi wiersz") == "Pierwszy akapit.\n\ndrugi wiersz"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_title_normalization_is_case_and_diacritic_insensitive():
|
| 21 |
+
assert MODULE.normalize_title("Dyskusja:Łódź (woj.)") == "dyskusja łodz woj"
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_boilerplate_lines_removed_only_when_frequent():
|
| 25 |
+
docs = [["Baner wikiprojektu", f"Prawdziwa dyskusja {i}."] for i in range(150)]
|
| 26 |
+
lines = MODULE.strip_boilerplate(docs)
|
| 27 |
+
assert "Baner wikiprojektu" in lines
|
| 28 |
+
assert "Prawdziwa dyskusja 0." not in lines
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_boilerplate_long_lines_never_dropped():
|
| 32 |
+
docs = [["x" * 200] * 1 for _ in range(150)]
|
| 33 |
+
assert MODULE.strip_boilerplate(docs) == set()
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def test_ip_redaction_patterns():
|
| 37 |
+
text = "Podpisano przez 83.4.55.1 dnia 2 maja"
|
| 38 |
+
assert MODULE.IPV4_RE.search(text)
|
| 39 |
+
assert not MODULE.IPV4_RE.search("wersja 1.2 wydana")
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def test_redaction_covers_compressed_ipv6_and_labelled_identifiers():
|
| 43 |
+
text = "Adres [2001:db8::1], ::ffff:192.0.2.1. PESEL: 00000000000 NIP 000-000-00-00 REGON: 000000000 Rachunek PL00 " + "0000 " * 6
|
| 44 |
+
cleaned, counts = MODULE.redact_pii(text)
|
| 45 |
+
assert "2001:db8" not in cleaned and "192.0.2.1" not in cleaned
|
| 46 |
+
assert cleaned.count("[REDACTED:IP]") == 2
|
| 47 |
+
assert cleaned.count("[REDACTED:ID]") == 3
|
| 48 |
+
assert "[REDACTED:ACCOUNT]" in cleaned
|
| 49 |
+
assert counts["ipv6"] == 2 and counts["national_identifier"] == 3
|
| 50 |
+
assert MODULE.redact_pii(cleaned)[0] == cleaned
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def test_redaction_preserves_time_and_version_numbers():
|
| 54 |
+
text = "Wersja 1.2.3, godzina 12:30:45. Adres 2001:db8::2."
|
| 55 |
+
cleaned, _ = MODULE.redact_pii(text)
|
| 56 |
+
assert cleaned == "Wersja 1.2.3, godzina 12:30:45. Adres [REDACTED:IP]."
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def test_attribution_url_quotes_fragments_and_polish_characters():
|
| 60 |
+
from urllib.parse import unquote, urlsplit
|
| 61 |
+
|
| 62 |
+
url = MODULE.page_url("Dyskusja:Łódź/C#")
|
| 63 |
+
assert url.isascii()
|
| 64 |
+
assert not urlsplit(url).fragment
|
| 65 |
+
assert unquote(urlsplit(url).path) == "/wiki/Dyskusja:Łódź/C#"
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def test_text_bound_and_license():
|
| 69 |
+
assert MODULE.MIN_TEXT_CHARS == 500
|
| 70 |
+
assert MODULE.LICENSE_SPDX == "CC-BY-SA-4.0"
|
| 71 |
+
assert MODULE.DUMP_DATE.startswith("20")
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def test_indexed_dedup_matches_exhaustive_comparison():
|
| 75 |
+
import random
|
| 76 |
+
|
| 77 |
+
rng = random.Random(42)
|
| 78 |
+
sketches = [set(), {1}, {1}, set(range(10)), set(range(9)), set(range(8))]
|
| 79 |
+
for _ in range(200):
|
| 80 |
+
base = set(rng.sample(range(10000), rng.randint(10, 200)))
|
| 81 |
+
sketches.extend([base, base | {10001}, set(sorted(base)[1:]), base | set(range(20))])
|
| 82 |
+
index = MODULE.NearDuplicateIndex()
|
| 83 |
+
retained = []
|
| 84 |
+
for sketch in sketches:
|
| 85 |
+
expected = (None, 0.0)
|
| 86 |
+
for row_id, other in retained:
|
| 87 |
+
score = len(sketch & other) / max(len(sketch | other), 1)
|
| 88 |
+
if score >= 0.90:
|
| 89 |
+
expected = (row_id, score)
|
| 90 |
+
break
|
| 91 |
+
assert index.find(sketch) == expected
|
| 92 |
+
if expected[0] is None:
|
| 93 |
+
row_id = str(len(retained))
|
| 94 |
+
retained.append((row_id, sketch))
|
| 95 |
+
index.add(row_id, sketch)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def test_index_avoids_comparing_disjoint_sketches():
|
| 99 |
+
index = MODULE.NearDuplicateIndex()
|
| 100 |
+
for i in range(1000):
|
| 101 |
+
sketch = set(range(i * 100, (i + 1) * 100))
|
| 102 |
+
assert index.find(sketch) == (None, 0.0)
|
| 103 |
+
index.add(str(i), sketch)
|
| 104 |
+
assert index.comparisons == 0
|
| 105 |
+
assert index.find(set(range(90000, 90100))) == ("900", 1.0)
|
| 106 |
+
assert index.comparisons == 1
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def test_language_vote_reuses_identical_windows_without_changing_votes():
|
| 110 |
+
class Identifier:
|
| 111 |
+
def __init__(self):
|
| 112 |
+
self.calls = 0
|
| 113 |
+
|
| 114 |
+
def classify(self, text):
|
| 115 |
+
self.calls += 1
|
| 116 |
+
return "pl", 0.99
|
| 117 |
+
|
| 118 |
+
identifier = Identifier()
|
| 119 |
+
language, votes = MODULE.language_vote(identifier, "Przykładowy polski tekst.")
|
| 120 |
+
assert language == "pl" and votes == [("pl", 0.99)] * 3
|
| 121 |
+
assert identifier.calls == 1
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def write_test_source(tmp_path, texts):
|
| 125 |
+
import gzip
|
| 126 |
+
import json
|
| 127 |
+
|
| 128 |
+
MODULE.save(tmp_path / "selection.json", {"dump_date": "20260901", "files": [], "observed_at": "2026-09-11T00:00:00Z"})
|
| 129 |
+
MODULE.save(tmp_path / "acquisition.json", {"talk_pages": len(texts), "observed_at": "2026-09-11T00:00:00Z"})
|
| 130 |
+
records = [{"pageid": str(index), "ns": "1", "title": f"Dyskusja:Test {index}", "timestamp": "2026-09-01",
|
| 131 |
+
"wikitext_chars": len(text), "text": text} for index, text in enumerate(texts, 1)]
|
| 132 |
+
MODULE.write_lines(tmp_path / "source_manifest.jsonl", records)
|
| 133 |
+
(tmp_path / "extracted").mkdir()
|
| 134 |
+
with gzip.open(tmp_path / "extracted/test.jsonl.gz", "wt", encoding="utf-8") as handle:
|
| 135 |
+
for record in records:
|
| 136 |
+
handle.write(json.dumps(record) + "\n")
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def test_build_rechecks_length_after_redaction(tmp_path, monkeypatch):
|
| 140 |
+
text = ("To jest przykładowa wypowiedź po polsku. " * 20)[:470] + " " + "kontakt" * 8 + "@example.org"
|
| 141 |
+
write_test_source(tmp_path, [text])
|
| 142 |
+
monkeypatch.setattr(MODULE, "language_vote", lambda identifier, text: ("pl", [("pl", 1.0)]))
|
| 143 |
+
MODULE.build(tmp_path)
|
| 144 |
+
decision = MODULE.read_lines(tmp_path / "hf_repo/artifacts/decisions.jsonl")[0]
|
| 145 |
+
assert not decision["selected"]
|
| 146 |
+
assert decision["reason"] == "too_little_text_after_redaction"
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def test_build_verify_roundtrip_and_tamper_detection(tmp_path, monkeypatch):
|
| 150 |
+
import pytest
|
| 151 |
+
import pyarrow as pa
|
| 152 |
+
import pyarrow.parquet as pq
|
| 153 |
+
|
| 154 |
+
text = "To jest przykładowa wypowiedź po polsku dotycząca edycji encyklopedii. " * 15
|
| 155 |
+
write_test_source(tmp_path, [text, text, "Krótki tekst."])
|
| 156 |
+
monkeypatch.setattr(MODULE, "language_vote", lambda identifier, text: ("pl", [("pl", 1.0)]))
|
| 157 |
+
MODULE.build(tmp_path)
|
| 158 |
+
MODULE.verify(tmp_path)
|
| 159 |
+
report = MODULE.load(tmp_path / "validation_report.json")
|
| 160 |
+
assert report["verified"]
|
| 161 |
+
assert report["texts_reconstructed_from_extracted_source"] == 1
|
| 162 |
+
assert report["rejection_counts"] == {"normalized_duplicate": 1, "too_little_text": 1}
|
| 163 |
+
assert report["before_after_samples"] == 1
|
| 164 |
+
assert not report["publication_ready"]
|
| 165 |
+
path = tmp_path / "hf_repo/data/train-00000-of-00001.parquet"
|
| 166 |
+
table = pq.read_table(path)
|
| 167 |
+
rows = table.to_pylist()
|
| 168 |
+
rows[0]["token_count"] += 1
|
| 169 |
+
pq.write_table(pa.Table.from_pylist(rows, schema=table.schema), path)
|
| 170 |
+
with pytest.raises(AssertionError):
|
| 171 |
+
MODULE.verify(tmp_path)
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def test_shard_filename_pattern_is_strict():
|
| 175 |
+
import re
|
| 176 |
+
pat = re.compile(r"plwiki-\d+-pages-meta-current\d+\.xml-p\d+p\d+\.bz2")
|
| 177 |
+
assert pat.fullmatch("plwiki-20260901-pages-meta-current1.xml-p1p187037.bz2")
|
| 178 |
+
assert not pat.fullmatch("plwiki-20260901-pages-articles.xml.bz2")
|
| 179 |
+
assert not pat.fullmatch("plwiki-20260901-pages-meta-current.xml.bz2")
|