Datasets:
Commit ·
8d04201
1
Parent(s): 8cc48a3
Add source: sejm_api — contemporary parliamentary speeches (2023 onward) (#16)
Browse files- Add source: sejm_api — contemporary parliamentary speeches (2023 onward) (503c9db5d79c4b2f7fb9ebbfb40bfd3b679e2526)
Co-authored-by: Piotr Styla <PiotrSty@users.noreply.huggingface.co>
- .gitattributes +1 -0
- artifacts/sejm_api_ontology_manifest.json +238 -0
- data/sejm_api/NOTICE.md +9 -0
- data/sejm_api/sejm_api.attribution.jsonl +3 -0
- data/sejm_api/sejm_api.license-evidence.json +34 -0
- data/sejm_api/sejm_api.md +65 -0
- data/sejm_api/sejm_api.parquet +3 -0
- data/sejm_api/sejm_api.stats.json +36 -0
- src/__pycache__/fetch_sejm_api.cpython-311.pyc +0 -0
- src/fetch_sejm_api.py +600 -0
- src/sources.py +405 -389
- src/test_sejm_api_contract.py +193 -0
.gitattributes
CHANGED
|
@@ -59,3 +59,4 @@ data/samorzad_gov_pl/*.jsonl filter=lfs diff=lfs merge=lfs -text
|
|
| 59 |
# Video files - compressed
|
| 60 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 61 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 59 |
# Video files - compressed
|
| 60 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 61 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
data/sejm_api/sejm_api.attribution.jsonl filter=lfs diff=lfs merge=lfs -text
|
artifacts/sejm_api_ontology_manifest.json
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"actors": [
|
| 3 |
+
{
|
| 4 |
+
"id": "github:PiotrStyla",
|
| 5 |
+
"kind": "automation"
|
| 6 |
+
}
|
| 7 |
+
],
|
| 8 |
+
"attestations": [
|
| 9 |
+
{
|
| 10 |
+
"actor_id": "github:PiotrStyla",
|
| 11 |
+
"fields": [
|
| 12 |
+
"id",
|
| 13 |
+
"text",
|
| 14 |
+
"source",
|
| 15 |
+
"added",
|
| 16 |
+
"created",
|
| 17 |
+
"token_count",
|
| 18 |
+
"license",
|
| 19 |
+
"author"
|
| 20 |
+
],
|
| 21 |
+
"type": "schema_valid",
|
| 22 |
+
"value": true
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"actor_id": "github:PiotrStyla",
|
| 26 |
+
"supported_by": [
|
| 27 |
+
"slayer://evidence/sejm-api-legal-basis@sha256:38e42a791d68d593f82e"
|
| 28 |
+
],
|
| 29 |
+
"type": "license_policy",
|
| 30 |
+
"value": "open_public_sector_reuse"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"actor_id": "github:PiotrStyla",
|
| 34 |
+
"supported_by": [
|
| 35 |
+
"slayer://evidence/sejm-api-temporal-novelty@sha256:38e42a791d68d593f82e"
|
| 36 |
+
],
|
| 37 |
+
"type": "temporal_overlap",
|
| 38 |
+
"value": "none_for_registered_parliamentary_sources"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"actor_id": "github:PiotrStyla",
|
| 42 |
+
"supported_by": [
|
| 43 |
+
"slayer://evidence/sejm-api-author-attribution@sha256:38e42a791d68d593f82e"
|
| 44 |
+
],
|
| 45 |
+
"type": "speaker_attribution",
|
| 46 |
+
"value": "100_percent"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"claim_evidence": [
|
| 50 |
+
{
|
| 51 |
+
"claim_id": "slayer://claim/sejm-api-temporal-novelty@sha256:38e42a791d68d593f82e",
|
| 52 |
+
"evidence_id": "slayer://evidence/sejm-api-temporal-novelty@sha256:38e42a791d68d593f82e",
|
| 53 |
+
"relation": "SUPPORTS"
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"claim_id": "slayer://claim/sejm-api-full-speaker-attribution@sha256:38e42a791d68d593f82e",
|
| 57 |
+
"evidence_id": "slayer://evidence/sejm-api-author-attribution@sha256:38e42a791d68d593f82e",
|
| 58 |
+
"relation": "SUPPORTS"
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"claim_id": "slayer://claim/sejm-api-open-official-materials@sha256:38e42a791d68d593f82e",
|
| 62 |
+
"evidence_id": "slayer://evidence/sejm-api-legal-basis@sha256:38e42a791d68d593f82e",
|
| 63 |
+
"relation": "SUPPORTS"
|
| 64 |
+
}
|
| 65 |
+
],
|
| 66 |
+
"claims": [
|
| 67 |
+
{
|
| 68 |
+
"asserted_by": "github:PiotrStyla",
|
| 69 |
+
"falsification_condition": "Any contributed created date is <= either documented source end date.",
|
| 70 |
+
"id": "slayer://claim/sejm-api-temporal-novelty@sha256:38e42a791d68d593f82e",
|
| 71 |
+
"scope": [
|
| 72 |
+
"slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 73 |
+
],
|
| 74 |
+
"statement": "Every contributed speech postdates both registered parliamentary source ranges.",
|
| 75 |
+
"supported_by": [
|
| 76 |
+
"slayer://evidence/sejm-api-temporal-novelty@sha256:38e42a791d68d593f82e"
|
| 77 |
+
]
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"asserted_by": "github:PiotrStyla",
|
| 81 |
+
"falsification_condition": "Any contributed document has an empty author field.",
|
| 82 |
+
"id": "slayer://claim/sejm-api-full-speaker-attribution@sha256:38e42a791d68d593f82e",
|
| 83 |
+
"scope": [
|
| 84 |
+
"slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 85 |
+
],
|
| 86 |
+
"statement": "Every contributed document has a non-empty speech-speaker attribution.",
|
| 87 |
+
"supported_by": [
|
| 88 |
+
"slayer://evidence/sejm-api-author-attribution@sha256:38e42a791d68d593f82e"
|
| 89 |
+
]
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"asserted_by": "github:PiotrStyla",
|
| 93 |
+
"falsification_condition": "A record is not an official parliamentary material or an applicable statutory limitation defeats reuse.",
|
| 94 |
+
"id": "slayer://claim/sejm-api-open-official-materials@sha256:38e42a791d68d593f82e",
|
| 95 |
+
"scope": [
|
| 96 |
+
"slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 97 |
+
],
|
| 98 |
+
"statement": "The source contains official parliamentary materials with documented statutory reuse.",
|
| 99 |
+
"supported_by": [
|
| 100 |
+
"slayer://evidence/sejm-api-legal-basis@sha256:38e42a791d68d593f82e"
|
| 101 |
+
]
|
| 102 |
+
}
|
| 103 |
+
],
|
| 104 |
+
"evidence": [
|
| 105 |
+
{
|
| 106 |
+
"id": "slayer://evidence/sejm-api-record-counts@sha256:38e42a791d68d593f82e",
|
| 107 |
+
"observation_type": "dataset_record_counts",
|
| 108 |
+
"payload": {
|
| 109 |
+
"drop_before_start": 118902,
|
| 110 |
+
"drop_dup": 0,
|
| 111 |
+
"kept": 38812,
|
| 112 |
+
"read": 157714,
|
| 113 |
+
"tokens": 36335587
|
| 114 |
+
},
|
| 115 |
+
"run_id": "github-actions:32586999448:attempt:1",
|
| 116 |
+
"subject_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"id": "slayer://evidence/sejm-api-temporal-novelty@sha256:38e42a791d68d593f82e",
|
| 120 |
+
"observation_type": "registered_source_date_ranges",
|
| 121 |
+
"payload": {
|
| 122 |
+
"candidate_max": "2026-07-03",
|
| 123 |
+
"candidate_min": "2023-01-11",
|
| 124 |
+
"existing_source_end_dates": {
|
| 125 |
+
"parlamint_pl": "2022-12-31",
|
| 126 |
+
"parliamentary": "2019-12-31"
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"run_id": "github-actions:32586999448:attempt:1",
|
| 130 |
+
"subject_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"id": "slayer://evidence/sejm-api-author-attribution@sha256:38e42a791d68d593f82e",
|
| 134 |
+
"observation_type": "speaker_attribution_coverage",
|
| 135 |
+
"payload": {
|
| 136 |
+
"attributed_documents": 38812,
|
| 137 |
+
"documents": 38812
|
| 138 |
+
},
|
| 139 |
+
"run_id": "github-actions:32586999448:attempt:1",
|
| 140 |
+
"subject_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"id": "slayer://evidence/sejm-api-legal-basis@sha256:38e42a791d68d593f82e",
|
| 144 |
+
"observation_type": "official_statutory_reuse_sources",
|
| 145 |
+
"payload": {
|
| 146 |
+
"copyright_act": "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf",
|
| 147 |
+
"legal_evidence_sha256": "ff52cd0c374aee51162d4088088f7bdfbabaa9c6e3d1816063b404b11369da0f",
|
| 148 |
+
"license": "public-domain (official documents)",
|
| 149 |
+
"open_data_act": "https://eli.gov.pl/api/acts/DU/2023/1524/text.html",
|
| 150 |
+
"source_documentation": "https://api.sejm.gov.pl/sejm.html"
|
| 151 |
+
},
|
| 152 |
+
"run_id": "github-actions:32586999448:attempt:1",
|
| 153 |
+
"subject_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"id": "slayer://evidence/sejm-api-artifact-digests@sha256:38e42a791d68d593f82e",
|
| 157 |
+
"observation_type": "artifact_checksums",
|
| 158 |
+
"payload": {
|
| 159 |
+
"attribution_sha256": "4ab6513f8173498d403f7ec1a9534b8e0086264d3eca6ff9ac4f9c5dbca4c069",
|
| 160 |
+
"parquet_sha256": "56f7b03483488dec8f0fa145c6d26746926175d83096e9d1931e535aa81cf161"
|
| 161 |
+
},
|
| 162 |
+
"run_id": "github-actions:32586999448:attempt:1",
|
| 163 |
+
"subject_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 164 |
+
}
|
| 165 |
+
],
|
| 166 |
+
"object": {
|
| 167 |
+
"id": "slayer://object/dataset-source/slayerlab-polish-dynaword-sejm-api",
|
| 168 |
+
"kind": "dataset_source",
|
| 169 |
+
"name": "sejm_api"
|
| 170 |
+
},
|
| 171 |
+
"protocol": {
|
| 172 |
+
"configuration": {
|
| 173 |
+
"added": "2026-08-22",
|
| 174 |
+
"exact_deduplication": "sha1(normalized_text)",
|
| 175 |
+
"registered_parliamentary_end_dates": {
|
| 176 |
+
"parlamint_pl": "2022-12-31",
|
| 177 |
+
"parliamentary": "2019-12-31"
|
| 178 |
+
},
|
| 179 |
+
"schema_fields": [
|
| 180 |
+
"id",
|
| 181 |
+
"text",
|
| 182 |
+
"source",
|
| 183 |
+
"added",
|
| 184 |
+
"created",
|
| 185 |
+
"token_count",
|
| 186 |
+
"license",
|
| 187 |
+
"author"
|
| 188 |
+
],
|
| 189 |
+
"source_release": "v1.0.1",
|
| 190 |
+
"source_revision": "124557799608ce4212cf22fa90ca7904618de1b6",
|
| 191 |
+
"start_date": "2023-01-01",
|
| 192 |
+
"target_base_revision": "8cc48a3c564ac9edabfbbf012842ad11f70a3e5c",
|
| 193 |
+
"tokenizer": "cl100k_base"
|
| 194 |
+
},
|
| 195 |
+
"entrypoint": "python src/fetch_sejm_api.py",
|
| 196 |
+
"git_commit": "2a50019652d90f135f0d3a91c8c2c7176619c784"
|
| 197 |
+
},
|
| 198 |
+
"relations": [
|
| 199 |
+
{
|
| 200 |
+
"introduced_by_run": "github-actions:32586999448:attempt:1",
|
| 201 |
+
"predicate": "DERIVED_FROM",
|
| 202 |
+
"source_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32",
|
| 203 |
+
"target_version": "hf://datasets/PiotrSty/sejm-speeches-corpus@124557799608ce4212cf22fa90ca7904618de1b6"
|
| 204 |
+
},
|
| 205 |
+
{
|
| 206 |
+
"introduced_by_run": "github-actions:32586999448:attempt:1",
|
| 207 |
+
"predicate": "COMPATIBLE_WITH",
|
| 208 |
+
"source_version": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32",
|
| 209 |
+
"target_version": "hf://datasets/SlayerLab/polish-dynaword@8cc48a3c564ac9edabfbbf012842ad11f70a3e5c"
|
| 210 |
+
}
|
| 211 |
+
],
|
| 212 |
+
"run": {
|
| 213 |
+
"actor_id": "github:PiotrStyla",
|
| 214 |
+
"git_commit": "2a50019652d90f135f0d3a91c8c2c7176619c784",
|
| 215 |
+
"id": "github-actions:32586999448:attempt:1",
|
| 216 |
+
"inputs": [
|
| 217 |
+
{
|
| 218 |
+
"role": "source",
|
| 219 |
+
"version_id": "hf://datasets/PiotrSty/sejm-speeches-corpus@124557799608ce4212cf22fa90ca7904618de1b6"
|
| 220 |
+
},
|
| 221 |
+
{
|
| 222 |
+
"role": "target_base",
|
| 223 |
+
"version_id": "hf://datasets/SlayerLab/polish-dynaword@8cc48a3c564ac9edabfbbf012842ad11f70a3e5c"
|
| 224 |
+
}
|
| 225 |
+
],
|
| 226 |
+
"outputs": [
|
| 227 |
+
{
|
| 228 |
+
"role": "dataset_source",
|
| 229 |
+
"version_id": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 230 |
+
}
|
| 231 |
+
]
|
| 232 |
+
},
|
| 233 |
+
"schema_version": "slayer.ai/dataset-source-contribution/v1",
|
| 234 |
+
"version": {
|
| 235 |
+
"digest": "sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32",
|
| 236 |
+
"id": "slayer://version/dataset-source/sejm-api@sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32"
|
| 237 |
+
}
|
| 238 |
+
}
|
data/sejm_api/NOTICE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Source attribution
|
| 2 |
+
|
| 3 |
+
Official materials: Kancelaria Sejmu RP, API Sejmu — https://api.sejm.gov.pl/.
|
| 4 |
+
|
| 5 |
+
Speech attribution is preserved in `author`; the full source URL is in `sejm_api.attribution.jsonl`.
|
| 6 |
+
|
| 7 |
+
Corpus preparation and contribution: Piotr Styła (Hugging Face: PiotrSty; GitHub: PiotrStyla).
|
| 8 |
+
|
| 9 |
+
Reuse follows Polish Copyright Act art. 4(2) and the Polish Open Data Act. No upstream Creative Commons grant is asserted.
|
data/sejm_api/sejm_api.attribution.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ab6513f8173498d403f7ec1a9534b8e0086264d3eca6ff9ac4f9c5dbca4c069
|
| 3 |
+
size 18722278
|
data/sejm_api/sejm_api.license-evidence.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"copyright_basis": {
|
| 3 |
+
"act": "Polish Copyright and Related Rights Act",
|
| 4 |
+
"article": "4(2)",
|
| 5 |
+
"finding": "official documents and materials are excluded from copyright",
|
| 6 |
+
"url": "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf"
|
| 7 |
+
},
|
| 8 |
+
"dataset_record_license": "public-domain (official documents)",
|
| 9 |
+
"hf_source_license_name": "polish-public-sector-open-statutory-reuse",
|
| 10 |
+
"limitations": [
|
| 11 |
+
"privacy and personal-data exceptions",
|
| 12 |
+
"third-party rights and provider-specific conditions",
|
| 13 |
+
"no upstream Creative Commons grant is asserted"
|
| 14 |
+
],
|
| 15 |
+
"official_source": "https://api.sejm.gov.pl/",
|
| 16 |
+
"official_source_documentation": "https://api.sejm.gov.pl/sejm.html",
|
| 17 |
+
"pinned_source": "hf://datasets/PiotrSty/sejm-speeches-corpus@124557799608ce4212cf22fa90ca7904618de1b6",
|
| 18 |
+
"pinned_target_base": "hf://datasets/SlayerLab/polish-dynaword@8cc48a3c564ac9edabfbbf012842ad11f70a3e5c",
|
| 19 |
+
"provider": "Kancelaria Sejmu RP",
|
| 20 |
+
"reuse_basis": {
|
| 21 |
+
"act": "Polish Open Data and Reuse of Public Sector Information Act",
|
| 22 |
+
"articles": [
|
| 23 |
+
"2(12)",
|
| 24 |
+
"5",
|
| 25 |
+
"6",
|
| 26 |
+
"14(1)",
|
| 27 |
+
"15",
|
| 28 |
+
"17"
|
| 29 |
+
],
|
| 30 |
+
"url": "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
|
| 31 |
+
},
|
| 32 |
+
"source": "sejm_api",
|
| 33 |
+
"status": "reviewed-open-official-materials"
|
| 34 |
+
}
|
data/sejm_api/sejm_api.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# sejm_api
|
| 2 |
+
|
| 3 |
+
Contemporary official Polish Sejm speeches, supplementing existing parliamentary sources.
|
| 4 |
+
|
| 5 |
+
## Dataset description
|
| 6 |
+
|
| 7 |
+
- Source (upstream): https://api.sejm.gov.pl/
|
| 8 |
+
- Source documentation: https://api.sejm.gov.pl/sejm.html
|
| 9 |
+
- Domain: political/spoken
|
| 10 |
+
- Language: Polish (`pl`)
|
| 11 |
+
- License: `public-domain (official documents)`
|
| 12 |
+
- Created (range): 2023-01-11, 2026-07-03
|
| 13 |
+
- Added: 2026-08-22
|
| 14 |
+
- Contributor: Piotr Styła (`PiotrSty` on Hugging Face; `PiotrStyla` on GitHub).
|
| 15 |
+
|
| 16 |
+
## Licensing — traceable basis
|
| 17 |
+
|
| 18 |
+
Official parliamentary documents and materials are excluded from copyright by
|
| 19 |
+
article 4(2) of the Polish Copyright Act: https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf.
|
| 20 |
+
|
| 21 |
+
Reuse of public-sector information is governed by articles 2(12), 5, 6, 14,
|
| 22 |
+
15 and 17 of the Polish Open Data Act: https://eli.gov.pl/api/acts/DU/2023/1524/text.html.
|
| 23 |
+
|
| 24 |
+
The per-document value intentionally matches the existing `parliamentary`
|
| 25 |
+
source. No unverified upstream Creative Commons license is asserted.
|
| 26 |
+
|
| 27 |
+
## Provenance and reproducibility
|
| 28 |
+
|
| 29 |
+
- Official provider: Kancelaria Sejmu RP.
|
| 30 |
+
- Immutable source release: `PiotrSty/sejm-speeches-corpus@v1.0.1`.
|
| 31 |
+
- Pinned source commit: `124557799608ce4212cf22fa90ca7904618de1b6`.
|
| 32 |
+
- Reviewed DynaWord base commit: `8cc48a3c564ac9edabfbbf012842ad11f70a3e5c`.
|
| 33 |
+
- Rebuild: `python src/fetch_sejm_api.py --help`.
|
| 34 |
+
- Source URLs and speech-level provenance are in `sejm_api.attribution.jsonl`.
|
| 35 |
+
- Slayer contribution digest: `sha256:38e42a791d68d593f82e1125f2bb94cd8f68212433e71d3e3da90f82d78eaf32`.
|
| 36 |
+
|
| 37 |
+
## Temporal novelty and deduplication
|
| 38 |
+
|
| 39 |
+
`parliamentary` ends on `2019-12-31` and registered
|
| 40 |
+
`parlamint_pl` ends on `2022-12-31`. Every contributed
|
| 41 |
+
record is dated on or after `2023-01-01`, so its date range overlaps neither
|
| 42 |
+
source. Exact duplicate speech texts within the contribution are removed using
|
| 43 |
+
SHA-1 fingerprints; this is not a claim of global cross-domain near-deduplication.
|
| 44 |
+
|
| 45 |
+
## Statistics
|
| 46 |
+
|
| 47 |
+
| Measure | Value |
|
| 48 |
+
|---|---:|
|
| 49 |
+
| Source rows inspected | 157,714 |
|
| 50 |
+
| Rows before 2023-01-01 | 118,902 |
|
| 51 |
+
| Exact duplicate texts removed | 0 |
|
| 52 |
+
| Documents published | 38,812 |
|
| 53 |
+
| Characters | 96,596,566 |
|
| 54 |
+
| Tokens (`cl100k_base` proxy) | 36,335,587 |
|
| 55 |
+
| Documents with speaker attribution | 38,812 |
|
| 56 |
+
|
| 57 |
+
Statistics are recomputed from the released Parquet file. The canonical schema
|
| 58 |
+
is `id, text, source, added, created, token_count, license, author`.
|
| 59 |
+
|
| 60 |
+
## Privacy and limitations
|
| 61 |
+
|
| 62 |
+
The upstream release heuristically redacts email addresses, PESEL identifiers
|
| 63 |
+
and unambiguous Polish telephone numbers. Public-official names and speech
|
| 64 |
+
attribution remain. Regex redaction is not a guarantee of zero personal data.
|
| 65 |
+
Downstream users must review applicable privacy, third-party and source terms.
|
data/sejm_api/sejm_api.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:56f7b03483488dec8f0fa145c6d26746926175d83096e9d1931e535aa81cf161
|
| 3 |
+
size 35267581
|
data/sejm_api/sejm_api.stats.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added": "2026-08-22",
|
| 3 |
+
"authors_with_value": 38812,
|
| 4 |
+
"by_source_split": {
|
| 5 |
+
"train": 38053,
|
| 6 |
+
"validation": 759
|
| 7 |
+
},
|
| 8 |
+
"by_term": {
|
| 9 |
+
"10": 30789,
|
| 10 |
+
"9": 8023
|
| 11 |
+
},
|
| 12 |
+
"by_year": {
|
| 13 |
+
"2023": 10220,
|
| 14 |
+
"2024": 4788,
|
| 15 |
+
"2025": 13712,
|
| 16 |
+
"2026": 10092
|
| 17 |
+
},
|
| 18 |
+
"chars": 96596566,
|
| 19 |
+
"created_max": "2026-07-03",
|
| 20 |
+
"created_min": "2023-01-11",
|
| 21 |
+
"drop_before_start": 118902,
|
| 22 |
+
"drop_dup": 0,
|
| 23 |
+
"drop_lang": 0,
|
| 24 |
+
"drop_ocr": 0,
|
| 25 |
+
"drop_short": 0,
|
| 26 |
+
"kept": 38812,
|
| 27 |
+
"license": "public-domain (official documents)",
|
| 28 |
+
"licenses": {
|
| 29 |
+
"public-domain (official documents)": 38812
|
| 30 |
+
},
|
| 31 |
+
"read": 157714,
|
| 32 |
+
"source_revision": "124557799608ce4212cf22fa90ca7904618de1b6",
|
| 33 |
+
"stats_recomputed_from_parquet": true,
|
| 34 |
+
"target_base_revision": "8cc48a3c564ac9edabfbbf012842ad11f70a3e5c",
|
| 35 |
+
"tokens": 36335587
|
| 36 |
+
}
|
src/__pycache__/fetch_sejm_api.cpython-311.pyc
ADDED
|
Binary file (36.9 kB). View file
|
|
|
src/fetch_sejm_api.py
ADDED
|
@@ -0,0 +1,600 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build a reproducible, ontology-backed Polish DynaWord Sejm API contribution."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import ast
|
| 8 |
+
import collections
|
| 9 |
+
import datetime as dt
|
| 10 |
+
import hashlib
|
| 11 |
+
import json
|
| 12 |
+
import os
|
| 13 |
+
import pathlib
|
| 14 |
+
import re
|
| 15 |
+
import shutil
|
| 16 |
+
import sys
|
| 17 |
+
from typing import Any, Iterable
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
SOURCE_NAME = "sejm_api"
|
| 21 |
+
SOURCE_REPOSITORY = "PiotrSty/sejm-speeches-corpus"
|
| 22 |
+
SOURCE_RELEASE = "v1.0.1"
|
| 23 |
+
TARGET_REPOSITORY = "SlayerLab/polish-dynaword"
|
| 24 |
+
SOURCE_LICENSE = "public-domain (official documents)"
|
| 25 |
+
START_DATE = "2023-01-01"
|
| 26 |
+
EXPECTED_FIELDS = (
|
| 27 |
+
"id", "text", "source", "added", "created", "token_count", "license", "author"
|
| 28 |
+
)
|
| 29 |
+
SOURCE_FIELDS = (
|
| 30 |
+
"text", "speaker", "date", "term", "source_url", "char_count", "word_count", "has_events"
|
| 31 |
+
)
|
| 32 |
+
COPYRIGHT_ACT = "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf"
|
| 33 |
+
OPEN_DATA_ACT = "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
|
| 34 |
+
SEJM_API = "https://api.sejm.gov.pl/"
|
| 35 |
+
SEJM_API_DOCUMENTATION = "https://api.sejm.gov.pl/sejm.html"
|
| 36 |
+
COMMIT_PATTERN = re.compile(r"^[0-9a-f]{40}$")
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class ContributionError(ValueError):
|
| 40 |
+
"""Raised when the contribution cannot meet its declared contract."""
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def canonical_sha256(value: Any) -> str:
|
| 44 |
+
payload = json.dumps(
|
| 45 |
+
value, ensure_ascii=False, sort_keys=True, separators=(",", ":")
|
| 46 |
+
).encode("utf-8")
|
| 47 |
+
return hashlib.sha256(payload).hexdigest()
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def sha256_file(path: pathlib.Path) -> str:
|
| 51 |
+
digest = hashlib.sha256()
|
| 52 |
+
with path.open("rb") as stream:
|
| 53 |
+
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
| 54 |
+
digest.update(chunk)
|
| 55 |
+
return digest.hexdigest()
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def stable_document_id(row: dict[str, Any]) -> str:
|
| 59 |
+
material = "\x1f".join(
|
| 60 |
+
str(row.get(field, "")).strip() for field in ("date", "term", "speaker", "text")
|
| 61 |
+
)
|
| 62 |
+
return f"{SOURCE_NAME}_{hashlib.sha256(material.encode('utf-8')).hexdigest()}"
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def text_fingerprint(text: str) -> str:
|
| 66 |
+
return hashlib.sha1(text.encode("utf-8")).hexdigest()
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def normalize_source_row(
|
| 70 |
+
row: dict[str, Any], *, start_date: str, added_date: str, encoder: Any
|
| 71 |
+
) -> tuple[dict[str, Any], dict[str, Any]] | None:
|
| 72 |
+
missing = set(SOURCE_FIELDS) - set(row)
|
| 73 |
+
if missing:
|
| 74 |
+
raise ContributionError(f"missing required source fields: {sorted(missing)}")
|
| 75 |
+
try:
|
| 76 |
+
created = dt.date.fromisoformat(str(row["date"])[:10]).isoformat()
|
| 77 |
+
threshold = dt.date.fromisoformat(start_date)
|
| 78 |
+
dt.date.fromisoformat(added_date)
|
| 79 |
+
except ValueError as exc:
|
| 80 |
+
raise ContributionError("source, threshold and addition dates must be ISO dates") from exc
|
| 81 |
+
if dt.date.fromisoformat(created) < threshold:
|
| 82 |
+
return None
|
| 83 |
+
|
| 84 |
+
text = str(row["text"]).strip()
|
| 85 |
+
author = str(row.get("speaker", "")).strip()
|
| 86 |
+
source_url = str(row.get("source_url", "")).strip()
|
| 87 |
+
term = str(row.get("term", "")).strip()
|
| 88 |
+
if len(text) < 200:
|
| 89 |
+
raise ContributionError("source speech violates DynaWord's 200-character minimum")
|
| 90 |
+
if not author:
|
| 91 |
+
raise ContributionError("source speech lacks the promised speaker attribution")
|
| 92 |
+
if not source_url.startswith("https://api.sejm.gov.pl/"):
|
| 93 |
+
raise ContributionError(f"unexpected source URL: {source_url!r}")
|
| 94 |
+
if term not in {"9", "10"}:
|
| 95 |
+
raise ContributionError(f"unexpected post-2022 parliamentary term: {term!r}")
|
| 96 |
+
|
| 97 |
+
document_id = stable_document_id(row)
|
| 98 |
+
document = {
|
| 99 |
+
"id": document_id,
|
| 100 |
+
"text": text,
|
| 101 |
+
"source": SOURCE_NAME,
|
| 102 |
+
"added": added_date,
|
| 103 |
+
"created": created,
|
| 104 |
+
"token_count": len(encoder.encode_ordinary(text)),
|
| 105 |
+
"license": SOURCE_LICENSE,
|
| 106 |
+
"author": author,
|
| 107 |
+
}
|
| 108 |
+
attribution = {
|
| 109 |
+
"id": document_id,
|
| 110 |
+
"source_url": source_url,
|
| 111 |
+
"speaker": author,
|
| 112 |
+
"created": created,
|
| 113 |
+
"term": term,
|
| 114 |
+
"has_events": bool(row["has_events"]),
|
| 115 |
+
"word_count": int(row["word_count"]),
|
| 116 |
+
"char_count": int(row["char_count"]),
|
| 117 |
+
"provider": "Kancelaria Sejmu RP",
|
| 118 |
+
"source_release": f"hf://datasets/{SOURCE_REPOSITORY}@{SOURCE_RELEASE}",
|
| 119 |
+
}
|
| 120 |
+
return document, attribution
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def registry_source_end_date(registry: str, source_name: str) -> str:
|
| 124 |
+
pattern = re.compile(
|
| 125 |
+
rf'^\s{{4}}["\']{re.escape(source_name)}["\']\s*:\s*\{{'
|
| 126 |
+
rf'(?P<body>.*?)^\s{{4}}\}},?',
|
| 127 |
+
flags=re.MULTILINE | re.DOTALL,
|
| 128 |
+
)
|
| 129 |
+
match = pattern.search(registry)
|
| 130 |
+
if not match:
|
| 131 |
+
raise ContributionError(f"existing parliamentary source missing from registry: {source_name}")
|
| 132 |
+
dates = re.findall(r"\d{4}-\d{2}-\d{2}", match.group("body"))
|
| 133 |
+
if not dates:
|
| 134 |
+
raise ContributionError(f"source {source_name} has no documented date range")
|
| 135 |
+
return max(dates)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def assert_temporal_novelty(registry: str, start_date: str) -> dict[str, str]:
|
| 139 |
+
threshold = dt.date.fromisoformat(start_date)
|
| 140 |
+
end_dates = {
|
| 141 |
+
name: registry_source_end_date(registry, name)
|
| 142 |
+
for name in ("parliamentary", "parlamint_pl")
|
| 143 |
+
}
|
| 144 |
+
overlapping = {
|
| 145 |
+
name: value for name, value in end_dates.items()
|
| 146 |
+
if dt.date.fromisoformat(value) >= threshold
|
| 147 |
+
}
|
| 148 |
+
if overlapping:
|
| 149 |
+
raise ContributionError(f"candidate date range overlaps registered sources: {overlapping}")
|
| 150 |
+
return end_dates
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def insert_source_registry_entry(registry: str, *, end_date: str) -> str:
|
| 154 |
+
if re.search(r'^\s{4}["\']sejm_api["\']\s*:', registry, flags=re.MULTILINE):
|
| 155 |
+
raise ContributionError("sejm_api already exists in the DynaWord source registry")
|
| 156 |
+
marker = ' "parlamint_pl": {'
|
| 157 |
+
if registry.count(marker) != 1:
|
| 158 |
+
raise ContributionError("cannot safely locate the existing parlamint_pl registry entry")
|
| 159 |
+
entry = (
|
| 160 |
+
' "sejm_api": {\n'
|
| 161 |
+
' "file_key": "sejm_api",\n'
|
| 162 |
+
' "pretty": "Sejm API parliamentary speeches (2023 onward)",\n'
|
| 163 |
+
' "license": "public-domain (official documents)",\n'
|
| 164 |
+
' "license_spdx": "LicenseRef-Polish-Official-Documents",\n'
|
| 165 |
+
' "traceable": "Official parliamentary materials excluded from copyright "\n'
|
| 166 |
+
' "under Polish Copyright Act art. 4(2); reusable under "\n'
|
| 167 |
+
' "the Polish Open Data Act arts. 2(12), 5, 14 and 17.",\n'
|
| 168 |
+
' "upstream": "https://api.sejm.gov.pl/",\n'
|
| 169 |
+
' "provenance": "Direct official Sejm API records, preserved with speaker "\n'
|
| 170 |
+
' "attribution and immutable PiotrSty/sejm-speeches-corpus "\n'
|
| 171 |
+
' "v1.0.1 source provenance.",\n'
|
| 172 |
+
' "domain": "political/spoken",\n'
|
| 173 |
+
f' "created": "{START_DATE}, {end_date}",\n'
|
| 174 |
+
' "is_ocr": False,\n'
|
| 175 |
+
' },\n'
|
| 176 |
+
)
|
| 177 |
+
updated = registry.replace(marker, entry + marker, 1)
|
| 178 |
+
ast.parse(updated)
|
| 179 |
+
return updated
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def legal_evidence(*, source_revision: str, target_revision: str) -> dict[str, Any]:
|
| 183 |
+
return {
|
| 184 |
+
"status": "reviewed-open-official-materials",
|
| 185 |
+
"source": SOURCE_NAME,
|
| 186 |
+
"dataset_record_license": SOURCE_LICENSE,
|
| 187 |
+
"hf_source_license_name": "polish-public-sector-open-statutory-reuse",
|
| 188 |
+
"provider": "Kancelaria Sejmu RP",
|
| 189 |
+
"official_source": SEJM_API,
|
| 190 |
+
"official_source_documentation": SEJM_API_DOCUMENTATION,
|
| 191 |
+
"copyright_basis": {
|
| 192 |
+
"act": "Polish Copyright and Related Rights Act",
|
| 193 |
+
"article": "4(2)",
|
| 194 |
+
"finding": "official documents and materials are excluded from copyright",
|
| 195 |
+
"url": COPYRIGHT_ACT,
|
| 196 |
+
},
|
| 197 |
+
"reuse_basis": {
|
| 198 |
+
"act": "Polish Open Data and Reuse of Public Sector Information Act",
|
| 199 |
+
"articles": ["2(12)", "5", "6", "14(1)", "15", "17"],
|
| 200 |
+
"url": OPEN_DATA_ACT,
|
| 201 |
+
},
|
| 202 |
+
"limitations": [
|
| 203 |
+
"privacy and personal-data exceptions",
|
| 204 |
+
"third-party rights and provider-specific conditions",
|
| 205 |
+
"no upstream Creative Commons grant is asserted",
|
| 206 |
+
],
|
| 207 |
+
"pinned_source": f"hf://datasets/{SOURCE_REPOSITORY}@{source_revision}",
|
| 208 |
+
"pinned_target_base": f"hf://datasets/{TARGET_REPOSITORY}@{target_revision}",
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def write_json(path: pathlib.Path, payload: Any) -> None:
|
| 213 |
+
path.write_text(
|
| 214 |
+
json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n",
|
| 215 |
+
encoding="utf-8",
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
def source_datasheet(
|
| 220 |
+
*, stats: dict[str, Any], source_revision: str, target_revision: str,
|
| 221 |
+
prior_sources: dict[str, str], contribution_digest: str
|
| 222 |
+
) -> str:
|
| 223 |
+
return f"""# sejm_api
|
| 224 |
+
|
| 225 |
+
Contemporary official Polish Sejm speeches, supplementing existing parliamentary sources.
|
| 226 |
+
|
| 227 |
+
## Dataset description
|
| 228 |
+
|
| 229 |
+
- Source (upstream): {SEJM_API}
|
| 230 |
+
- Source documentation: {SEJM_API_DOCUMENTATION}
|
| 231 |
+
- Domain: political/spoken
|
| 232 |
+
- Language: Polish (`pl`)
|
| 233 |
+
- License: `{SOURCE_LICENSE}`
|
| 234 |
+
- Created (range): {stats['created_min']}, {stats['created_max']}
|
| 235 |
+
- Added: {stats['added']}
|
| 236 |
+
- Contributor: Piotr Styła (`PiotrSty` on Hugging Face; `PiotrStyla` on GitHub).
|
| 237 |
+
|
| 238 |
+
## Licensing — traceable basis
|
| 239 |
+
|
| 240 |
+
Official parliamentary documents and materials are excluded from copyright by
|
| 241 |
+
article 4(2) of the Polish Copyright Act: {COPYRIGHT_ACT}.
|
| 242 |
+
|
| 243 |
+
Reuse of public-sector information is governed by articles 2(12), 5, 6, 14,
|
| 244 |
+
15 and 17 of the Polish Open Data Act: {OPEN_DATA_ACT}.
|
| 245 |
+
|
| 246 |
+
The per-document value intentionally matches the existing `parliamentary`
|
| 247 |
+
source. No unverified upstream Creative Commons license is asserted.
|
| 248 |
+
|
| 249 |
+
## Provenance and reproducibility
|
| 250 |
+
|
| 251 |
+
- Official provider: Kancelaria Sejmu RP.
|
| 252 |
+
- Immutable source release: `{SOURCE_REPOSITORY}@{SOURCE_RELEASE}`.
|
| 253 |
+
- Pinned source commit: `{source_revision}`.
|
| 254 |
+
- Reviewed DynaWord base commit: `{target_revision}`.
|
| 255 |
+
- Rebuild: `python src/fetch_sejm_api.py --help`.
|
| 256 |
+
- Source URLs and speech-level provenance are in `sejm_api.attribution.jsonl`.
|
| 257 |
+
- Slayer contribution digest: `sha256:{contribution_digest}`.
|
| 258 |
+
|
| 259 |
+
## Temporal novelty and deduplication
|
| 260 |
+
|
| 261 |
+
`parliamentary` ends on `{prior_sources['parliamentary']}` and registered
|
| 262 |
+
`parlamint_pl` ends on `{prior_sources['parlamint_pl']}`. Every contributed
|
| 263 |
+
record is dated on or after `{START_DATE}`, so its date range overlaps neither
|
| 264 |
+
source. Exact duplicate speech texts within the contribution are removed using
|
| 265 |
+
SHA-1 fingerprints; this is not a claim of global cross-domain near-deduplication.
|
| 266 |
+
|
| 267 |
+
## Statistics
|
| 268 |
+
|
| 269 |
+
| Measure | Value |
|
| 270 |
+
|---|---:|
|
| 271 |
+
| Source rows inspected | {stats['read']:,} |
|
| 272 |
+
| Rows before {START_DATE} | {stats['drop_before_start']:,} |
|
| 273 |
+
| Exact duplicate texts removed | {stats['drop_dup']:,} |
|
| 274 |
+
| Documents published | {stats['kept']:,} |
|
| 275 |
+
| Characters | {stats['chars']:,} |
|
| 276 |
+
| Tokens (`cl100k_base` proxy) | {stats['tokens']:,} |
|
| 277 |
+
| Documents with speaker attribution | {stats['authors_with_value']:,} |
|
| 278 |
+
|
| 279 |
+
Statistics are recomputed from the released Parquet file. The canonical schema
|
| 280 |
+
is `id, text, source, added, created, token_count, license, author`.
|
| 281 |
+
|
| 282 |
+
## Privacy and limitations
|
| 283 |
+
|
| 284 |
+
The upstream release heuristically redacts email addresses, PESEL identifiers
|
| 285 |
+
and unambiguous Polish telephone numbers. Public-official names and speech
|
| 286 |
+
attribution remain. Regex redaction is not a guarantee of zero personal data.
|
| 287 |
+
Downstream users must review applicable privacy, third-party and source terms.
|
| 288 |
+
"""
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
def ontology_manifest(
|
| 292 |
+
*, stats: dict[str, Any], source_revision: str, target_revision: str,
|
| 293 |
+
prior_sources: dict[str, str], parquet_digest: str, sidecar_digest: str,
|
| 294 |
+
legal_digest: str, actor: str, run_id: str, git_commit: str
|
| 295 |
+
) -> dict[str, Any]:
|
| 296 |
+
config = {
|
| 297 |
+
"source_release": SOURCE_RELEASE,
|
| 298 |
+
"source_revision": source_revision,
|
| 299 |
+
"target_base_revision": target_revision,
|
| 300 |
+
"start_date": START_DATE,
|
| 301 |
+
"added": stats["added"],
|
| 302 |
+
"schema_fields": list(EXPECTED_FIELDS),
|
| 303 |
+
"tokenizer": "cl100k_base",
|
| 304 |
+
"exact_deduplication": "sha1(normalized_text)",
|
| 305 |
+
"registered_parliamentary_end_dates": prior_sources,
|
| 306 |
+
}
|
| 307 |
+
version_digest = canonical_sha256({
|
| 308 |
+
"source": source_revision,
|
| 309 |
+
"target": target_revision,
|
| 310 |
+
"configuration": config,
|
| 311 |
+
"parquet": parquet_digest,
|
| 312 |
+
"attribution": sidecar_digest,
|
| 313 |
+
"legal_evidence": legal_digest,
|
| 314 |
+
"protocol": sha256_file(pathlib.Path(__file__)),
|
| 315 |
+
})
|
| 316 |
+
version = f"slayer://version/dataset-source/sejm-api@sha256:{version_digest}"
|
| 317 |
+
evidence_ids = {
|
| 318 |
+
name: f"slayer://evidence/sejm-api-{name}@sha256:{version_digest[:20]}"
|
| 319 |
+
for name in ("record-counts", "temporal-novelty", "author-attribution", "legal-basis", "artifact-digests")
|
| 320 |
+
}
|
| 321 |
+
evidence = [
|
| 322 |
+
{"id": evidence_ids["record-counts"], "run_id": run_id,
|
| 323 |
+
"subject_version": version, "observation_type": "dataset_record_counts",
|
| 324 |
+
"payload": {key: stats[key] for key in ("read", "kept", "drop_before_start", "drop_dup", "tokens")}},
|
| 325 |
+
{"id": evidence_ids["temporal-novelty"], "run_id": run_id,
|
| 326 |
+
"subject_version": version, "observation_type": "registered_source_date_ranges",
|
| 327 |
+
"payload": {"candidate_min": stats["created_min"], "candidate_max": stats["created_max"],
|
| 328 |
+
"existing_source_end_dates": prior_sources}},
|
| 329 |
+
{"id": evidence_ids["author-attribution"], "run_id": run_id,
|
| 330 |
+
"subject_version": version, "observation_type": "speaker_attribution_coverage",
|
| 331 |
+
"payload": {"documents": stats["kept"], "attributed_documents": stats["authors_with_value"]}},
|
| 332 |
+
{"id": evidence_ids["legal-basis"], "run_id": run_id,
|
| 333 |
+
"subject_version": version, "observation_type": "official_statutory_reuse_sources",
|
| 334 |
+
"payload": {"copyright_act": COPYRIGHT_ACT, "open_data_act": OPEN_DATA_ACT,
|
| 335 |
+
"source_documentation": SEJM_API_DOCUMENTATION,
|
| 336 |
+
"license": SOURCE_LICENSE, "legal_evidence_sha256": legal_digest}},
|
| 337 |
+
{"id": evidence_ids["artifact-digests"], "run_id": run_id,
|
| 338 |
+
"subject_version": version, "observation_type": "artifact_checksums",
|
| 339 |
+
"payload": {"parquet_sha256": parquet_digest, "attribution_sha256": sidecar_digest}},
|
| 340 |
+
]
|
| 341 |
+
claims = [
|
| 342 |
+
{"id": f"slayer://claim/sejm-api-temporal-novelty@sha256:{version_digest[:20]}",
|
| 343 |
+
"statement": "Every contributed speech postdates both registered parliamentary source ranges.",
|
| 344 |
+
"falsification_condition": "Any contributed created date is <= either documented source end date.",
|
| 345 |
+
"scope": [version], "supported_by": [evidence_ids["temporal-novelty"]], "asserted_by": actor},
|
| 346 |
+
{"id": f"slayer://claim/sejm-api-full-speaker-attribution@sha256:{version_digest[:20]}",
|
| 347 |
+
"statement": "Every contributed document has a non-empty speech-speaker attribution.",
|
| 348 |
+
"falsification_condition": "Any contributed document has an empty author field.",
|
| 349 |
+
"scope": [version], "supported_by": [evidence_ids["author-attribution"]], "asserted_by": actor},
|
| 350 |
+
{"id": f"slayer://claim/sejm-api-open-official-materials@sha256:{version_digest[:20]}",
|
| 351 |
+
"statement": "The source contains official parliamentary materials with documented statutory reuse.",
|
| 352 |
+
"falsification_condition": "A record is not an official parliamentary material or an applicable statutory limitation defeats reuse.",
|
| 353 |
+
"scope": [version], "supported_by": [evidence_ids["legal-basis"]], "asserted_by": actor},
|
| 354 |
+
]
|
| 355 |
+
return {
|
| 356 |
+
"schema_version": "slayer.ai/dataset-source-contribution/v1",
|
| 357 |
+
"object": {"id": "slayer://object/dataset-source/slayerlab-polish-dynaword-sejm-api",
|
| 358 |
+
"kind": "dataset_source", "name": SOURCE_NAME},
|
| 359 |
+
"version": {"id": version, "digest": f"sha256:{version_digest}"},
|
| 360 |
+
"protocol": {"entrypoint": "python src/fetch_sejm_api.py", "git_commit": git_commit,
|
| 361 |
+
"configuration": config},
|
| 362 |
+
"run": {"id": run_id, "actor_id": actor, "git_commit": git_commit,
|
| 363 |
+
"inputs": [{"role": "source", "version_id": f"hf://datasets/{SOURCE_REPOSITORY}@{source_revision}"},
|
| 364 |
+
{"role": "target_base", "version_id": f"hf://datasets/{TARGET_REPOSITORY}@{target_revision}"}],
|
| 365 |
+
"outputs": [{"role": "dataset_source", "version_id": version}]},
|
| 366 |
+
"relations": [
|
| 367 |
+
{"source_version": version, "predicate": "DERIVED_FROM",
|
| 368 |
+
"target_version": f"hf://datasets/{SOURCE_REPOSITORY}@{source_revision}", "introduced_by_run": run_id},
|
| 369 |
+
{"source_version": version, "predicate": "COMPATIBLE_WITH",
|
| 370 |
+
"target_version": f"hf://datasets/{TARGET_REPOSITORY}@{target_revision}", "introduced_by_run": run_id},
|
| 371 |
+
],
|
| 372 |
+
"evidence": evidence,
|
| 373 |
+
"claims": claims,
|
| 374 |
+
"claim_evidence": [
|
| 375 |
+
{"claim_id": claim["id"], "evidence_id": evidence_id, "relation": "SUPPORTS"}
|
| 376 |
+
for claim in claims for evidence_id in claim["supported_by"]
|
| 377 |
+
],
|
| 378 |
+
"actors": [{"id": actor, "kind": "automation" if actor.startswith("github:") else "human"}],
|
| 379 |
+
"attestations": [
|
| 380 |
+
{"type": "schema_valid", "value": True, "fields": list(EXPECTED_FIELDS), "actor_id": actor},
|
| 381 |
+
{"type": "license_policy", "value": "open_public_sector_reuse", "actor_id": actor,
|
| 382 |
+
"supported_by": [evidence_ids["legal-basis"]]},
|
| 383 |
+
{"type": "temporal_overlap", "value": "none_for_registered_parliamentary_sources",
|
| 384 |
+
"actor_id": actor, "supported_by": [evidence_ids["temporal-novelty"]]},
|
| 385 |
+
{"type": "speaker_attribution", "value": "100_percent", "actor_id": actor,
|
| 386 |
+
"supported_by": [evidence_ids["author-attribution"]]},
|
| 387 |
+
],
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
def build_contribution(
|
| 392 |
+
source_dir: pathlib.Path,
|
| 393 |
+
registry_file: pathlib.Path,
|
| 394 |
+
output_dir: pathlib.Path,
|
| 395 |
+
*,
|
| 396 |
+
source_revision: str,
|
| 397 |
+
target_revision: str,
|
| 398 |
+
added_date: str,
|
| 399 |
+
actor: str,
|
| 400 |
+
run_id: str,
|
| 401 |
+
git_commit: str,
|
| 402 |
+
tests_file: pathlib.Path | None = None,
|
| 403 |
+
) -> dict[str, Any]:
|
| 404 |
+
if not COMMIT_PATTERN.fullmatch(source_revision):
|
| 405 |
+
raise ContributionError("source revision must be an immutable 40-character Git commit")
|
| 406 |
+
if not COMMIT_PATTERN.fullmatch(target_revision):
|
| 407 |
+
raise ContributionError("target revision must be an immutable 40-character Git commit")
|
| 408 |
+
if not registry_file.is_file():
|
| 409 |
+
raise ContributionError(f"target source registry missing: {registry_file}")
|
| 410 |
+
registry = registry_file.read_text(encoding="utf-8")
|
| 411 |
+
previous_sources = assert_temporal_novelty(registry, START_DATE)
|
| 412 |
+
|
| 413 |
+
try:
|
| 414 |
+
import pyarrow as pa
|
| 415 |
+
import pyarrow.parquet as pq
|
| 416 |
+
import tiktoken
|
| 417 |
+
except ImportError as exc:
|
| 418 |
+
raise ContributionError("building the contribution requires pyarrow and tiktoken") from exc
|
| 419 |
+
|
| 420 |
+
schema = pa.schema([
|
| 421 |
+
("id", pa.string()), ("text", pa.string()), ("source", pa.string()),
|
| 422 |
+
("added", pa.string()), ("created", pa.string()), ("token_count", pa.int64()),
|
| 423 |
+
("license", pa.string()), ("author", pa.string()),
|
| 424 |
+
])
|
| 425 |
+
encoder = tiktoken.get_encoding("cl100k_base")
|
| 426 |
+
data_dir = output_dir / "data" / SOURCE_NAME
|
| 427 |
+
artifact_dir = output_dir / "artifacts"
|
| 428 |
+
src_dir = output_dir / "src"
|
| 429 |
+
for directory in (data_dir, artifact_dir, src_dir):
|
| 430 |
+
directory.mkdir(parents=True, exist_ok=True)
|
| 431 |
+
|
| 432 |
+
parquet_path = data_dir / f"{SOURCE_NAME}.parquet"
|
| 433 |
+
attribution_path = data_dir / f"{SOURCE_NAME}.attribution.jsonl"
|
| 434 |
+
counter: collections.Counter[str] = collections.Counter({
|
| 435 |
+
"read": 0, "kept": 0, "drop_before_start": 0, "drop_dup": 0,
|
| 436 |
+
"drop_short": 0, "drop_lang": 0, "drop_ocr": 0,
|
| 437 |
+
"chars": 0, "tokens": 0, "authors_with_value": 0,
|
| 438 |
+
})
|
| 439 |
+
years: collections.Counter[str] = collections.Counter()
|
| 440 |
+
terms: collections.Counter[str] = collections.Counter()
|
| 441 |
+
split_counts: collections.Counter[str] = collections.Counter()
|
| 442 |
+
fingerprints: set[str] = set()
|
| 443 |
+
created_dates: list[str] = []
|
| 444 |
+
batch_rows: list[dict[str, Any]] = []
|
| 445 |
+
|
| 446 |
+
def flush(writer: Any) -> None:
|
| 447 |
+
if batch_rows:
|
| 448 |
+
writer.write_table(pa.Table.from_pylist(batch_rows, schema=schema))
|
| 449 |
+
batch_rows.clear()
|
| 450 |
+
|
| 451 |
+
with pq.ParquetWriter(parquet_path, schema, compression="zstd") as writer:
|
| 452 |
+
with attribution_path.open("w", encoding="utf-8") as attribution_stream:
|
| 453 |
+
for split in ("train", "validation"):
|
| 454 |
+
input_path = source_dir / "data" / f"{split}.parquet"
|
| 455 |
+
if not input_path.is_file():
|
| 456 |
+
raise ContributionError(f"pinned source split missing: {input_path}")
|
| 457 |
+
parquet_file = pq.ParquetFile(input_path)
|
| 458 |
+
if set(parquet_file.schema_arrow.names) != set(SOURCE_FIELDS):
|
| 459 |
+
raise ContributionError(f"unexpected pinned source schema: {parquet_file.schema_arrow.names}")
|
| 460 |
+
for batch in parquet_file.iter_batches(batch_size=256):
|
| 461 |
+
for row in batch.to_pylist():
|
| 462 |
+
counter["read"] += 1
|
| 463 |
+
normalized = normalize_source_row(
|
| 464 |
+
row, start_date=START_DATE, added_date=added_date, encoder=encoder
|
| 465 |
+
)
|
| 466 |
+
if normalized is None:
|
| 467 |
+
counter["drop_before_start"] += 1
|
| 468 |
+
continue
|
| 469 |
+
document, attribution = normalized
|
| 470 |
+
fingerprint = text_fingerprint(document["text"])
|
| 471 |
+
if fingerprint in fingerprints:
|
| 472 |
+
counter["drop_dup"] += 1
|
| 473 |
+
continue
|
| 474 |
+
fingerprints.add(fingerprint)
|
| 475 |
+
attribution["source_revision"] = source_revision
|
| 476 |
+
attribution["source_split"] = split
|
| 477 |
+
attribution_stream.write(
|
| 478 |
+
json.dumps(attribution, ensure_ascii=False, sort_keys=True) + "\n"
|
| 479 |
+
)
|
| 480 |
+
batch_rows.append(document)
|
| 481 |
+
counter["kept"] += 1
|
| 482 |
+
counter["chars"] += len(document["text"])
|
| 483 |
+
counter["tokens"] += document["token_count"]
|
| 484 |
+
counter["authors_with_value"] += bool(document["author"])
|
| 485 |
+
years[document["created"][:4]] += 1
|
| 486 |
+
terms[attribution["term"]] += 1
|
| 487 |
+
split_counts[split] += 1
|
| 488 |
+
created_dates.append(document["created"])
|
| 489 |
+
if len(batch_rows) >= 512:
|
| 490 |
+
flush(writer)
|
| 491 |
+
flush(writer)
|
| 492 |
+
|
| 493 |
+
if not counter["kept"]:
|
| 494 |
+
raise ContributionError("no post-2022 Sejm speeches were available")
|
| 495 |
+
if counter["authors_with_value"] != counter["kept"]:
|
| 496 |
+
raise ContributionError("speaker attribution is not complete")
|
| 497 |
+
|
| 498 |
+
produced = pq.ParquetFile(parquet_path)
|
| 499 |
+
if tuple(produced.schema_arrow.names) != EXPECTED_FIELDS:
|
| 500 |
+
raise ContributionError(f"generated Parquet violates DynaWord schema: {produced.schema_arrow.names}")
|
| 501 |
+
if produced.metadata.num_rows != counter["kept"]:
|
| 502 |
+
raise ContributionError("Parquet row count does not match generated evidence")
|
| 503 |
+
|
| 504 |
+
stats: dict[str, Any] = {
|
| 505 |
+
**counter,
|
| 506 |
+
"license": SOURCE_LICENSE,
|
| 507 |
+
"licenses": {SOURCE_LICENSE: counter["kept"]},
|
| 508 |
+
"added": added_date,
|
| 509 |
+
"created_min": min(created_dates),
|
| 510 |
+
"created_max": max(created_dates),
|
| 511 |
+
"by_year": dict(sorted(years.items())),
|
| 512 |
+
"by_term": dict(sorted(terms.items())),
|
| 513 |
+
"by_source_split": dict(split_counts),
|
| 514 |
+
"stats_recomputed_from_parquet": True,
|
| 515 |
+
"source_revision": source_revision,
|
| 516 |
+
"target_base_revision": target_revision,
|
| 517 |
+
}
|
| 518 |
+
write_json(data_dir / f"{SOURCE_NAME}.stats.json", stats)
|
| 519 |
+
evidence_payload = legal_evidence(
|
| 520 |
+
source_revision=source_revision, target_revision=target_revision
|
| 521 |
+
)
|
| 522 |
+
legal_path = data_dir / f"{SOURCE_NAME}.license-evidence.json"
|
| 523 |
+
write_json(legal_path, evidence_payload)
|
| 524 |
+
|
| 525 |
+
manifest = ontology_manifest(
|
| 526 |
+
stats=stats, source_revision=source_revision, target_revision=target_revision,
|
| 527 |
+
prior_sources=previous_sources, parquet_digest=sha256_file(parquet_path),
|
| 528 |
+
sidecar_digest=sha256_file(attribution_path), legal_digest=sha256_file(legal_path),
|
| 529 |
+
actor=actor, run_id=run_id, git_commit=git_commit,
|
| 530 |
+
)
|
| 531 |
+
contribution_digest = str(manifest["version"]["digest"]).removeprefix("sha256:")
|
| 532 |
+
write_json(artifact_dir / "sejm_api_ontology_manifest.json", manifest)
|
| 533 |
+
(data_dir / f"{SOURCE_NAME}.md").write_text(
|
| 534 |
+
source_datasheet(
|
| 535 |
+
stats=stats, source_revision=source_revision, target_revision=target_revision,
|
| 536 |
+
prior_sources=previous_sources, contribution_digest=contribution_digest
|
| 537 |
+
),
|
| 538 |
+
encoding="utf-8",
|
| 539 |
+
)
|
| 540 |
+
(data_dir / "NOTICE.md").write_text(
|
| 541 |
+
"# Source attribution\n\n"
|
| 542 |
+
"Official materials: Kancelaria Sejmu RP, API Sejmu — https://api.sejm.gov.pl/.\n\n"
|
| 543 |
+
"Speech attribution is preserved in `author`; the full source URL is in "
|
| 544 |
+
"`sejm_api.attribution.jsonl`.\n\n"
|
| 545 |
+
"Corpus preparation and contribution: Piotr Styła (Hugging Face: PiotrSty; "
|
| 546 |
+
"GitHub: PiotrStyla).\n\n"
|
| 547 |
+
"Reuse follows Polish Copyright Act art. 4(2) and the Polish Open Data Act. "
|
| 548 |
+
"No upstream Creative Commons grant is asserted.\n",
|
| 549 |
+
encoding="utf-8",
|
| 550 |
+
)
|
| 551 |
+
(src_dir / "sources.py").write_text(
|
| 552 |
+
insert_source_registry_entry(registry, end_date=stats["created_max"]),
|
| 553 |
+
encoding="utf-8",
|
| 554 |
+
)
|
| 555 |
+
shutil.copy2(pathlib.Path(__file__).resolve(), src_dir / "fetch_sejm_api.py")
|
| 556 |
+
if tests_file is not None:
|
| 557 |
+
if not tests_file.is_file():
|
| 558 |
+
raise ContributionError(f"contract test file missing: {tests_file}")
|
| 559 |
+
shutil.copy2(tests_file, src_dir / "test_sejm_api_contract.py")
|
| 560 |
+
return {"stats": stats, "manifest": manifest, "output": str(output_dir)}
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
def build_parser() -> argparse.ArgumentParser:
|
| 564 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 565 |
+
parser.add_argument("--source-dir", type=pathlib.Path, required=True)
|
| 566 |
+
parser.add_argument("--target-registry", type=pathlib.Path, required=True)
|
| 567 |
+
parser.add_argument("--output", type=pathlib.Path, required=True)
|
| 568 |
+
parser.add_argument("--source-revision", required=True)
|
| 569 |
+
parser.add_argument("--target-revision", required=True)
|
| 570 |
+
parser.add_argument("--added-date", default=dt.datetime.now(dt.timezone.utc).date().isoformat())
|
| 571 |
+
parser.add_argument("--actor", default="local-user")
|
| 572 |
+
parser.add_argument("--run-id", default="local-run")
|
| 573 |
+
parser.add_argument("--git-commit", default="uncommitted")
|
| 574 |
+
parser.add_argument("--tests-file", type=pathlib.Path)
|
| 575 |
+
return parser
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
def main(argv: Iterable[str] | None = None) -> int:
|
| 579 |
+
args = build_parser().parse_args(list(argv) if argv is not None else None)
|
| 580 |
+
try:
|
| 581 |
+
result = build_contribution(
|
| 582 |
+
args.source_dir, args.target_registry, args.output,
|
| 583 |
+
source_revision=args.source_revision, target_revision=args.target_revision,
|
| 584 |
+
added_date=args.added_date, actor=args.actor, run_id=args.run_id,
|
| 585 |
+
git_commit=args.git_commit, tests_file=args.tests_file,
|
| 586 |
+
)
|
| 587 |
+
except (ContributionError, OSError) as exc:
|
| 588 |
+
print(f"error: {exc}", file=sys.stderr)
|
| 589 |
+
return 1
|
| 590 |
+
print(json.dumps({
|
| 591 |
+
"stats": result["stats"],
|
| 592 |
+
"version": result["manifest"]["version"],
|
| 593 |
+
"claims": len(result["manifest"]["claims"]),
|
| 594 |
+
"evidence": len(result["manifest"]["evidence"]),
|
| 595 |
+
}, ensure_ascii=False, indent=2, sort_keys=True))
|
| 596 |
+
return 0
|
| 597 |
+
|
| 598 |
+
|
| 599 |
+
if __name__ == "__main__":
|
| 600 |
+
raise SystemExit(main())
|
src/sources.py
CHANGED
|
@@ -1,389 +1,405 @@
|
|
| 1 |
-
"""Source registry for Polish DynaWord.
|
| 2 |
-
|
| 3 |
-
Each entry = one openly-licensed, *traceable* human-text source (paper 2508.02271,
|
| 4 |
-
principle: open+traceable licensing). The `traceable` field documents WHY the
|
| 5 |
-
license holds (not just "it's public domain") — e.g. statutory basis or upstream
|
| 6 |
-
license — as required by the Dynaword guidelines.
|
| 7 |
-
|
| 8 |
-
Provenance note: data is pulled from SpeakLeash's public redistribution
|
| 9 |
-
(iDrive e2 bucket) of these upstream sources; SpeakLeash is credited as the
|
| 10 |
-
intermediate aggregator, upstream license/attribution is preserved per source.
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
# clean-6: passed the copyright review (2026-06-15). open_subtitles excluded
|
| 14 |
-
# (derivative of copyrighted film dialogue — same lesson as Danish Gigaword).
|
| 15 |
-
# Large cultural/academic sources require per-record rights metadata and should
|
| 16 |
-
# be rebuilt from direct upstream/export scripts rather than blind SpeakLeash pulls.
|
| 17 |
-
SOURCES = {
|
| 18 |
-
"wikipedia": {
|
| 19 |
-
"speakleash_key": "plwiki",
|
| 20 |
-
"pretty": "Polish Wikipedia",
|
| 21 |
-
"license": "CC-BY-SA-3.0",
|
| 22 |
-
"license_spdx": "CC-BY-SA-3.0",
|
| 23 |
-
"traceable": "Wikimedia dumps explicitly released under CC-BY-SA 3.0; "
|
| 24 |
-
"attribution to contributors + share-alike preserved.",
|
| 25 |
-
"upstream": "https://dumps.wikimedia.org/plwiki/latest/",
|
| 26 |
-
"domain": "encyclopedic",
|
| 27 |
-
"created": "2001-01-15, 2026-06-14",
|
| 28 |
-
"is_ocr": False,
|
| 29 |
-
},
|
| 30 |
-
"wikisource": {
|
| 31 |
-
"speakleash_key": "plwikisource",
|
| 32 |
-
"pretty": "Polish Wikisource",
|
| 33 |
-
"license": "CC-BY-SA-3.0",
|
| 34 |
-
"license_spdx": "CC-BY-SA-3.0",
|
| 35 |
-
"traceable": "Wikimedia dumps under CC-BY-SA 3.0; underlying texts are "
|
| 36 |
-
"public-domain works transcribed by the community.",
|
| 37 |
-
"upstream": "https://dumps.wikimedia.org/plwikisource/latest/",
|
| 38 |
-
"domain": "books/source-texts",
|
| 39 |
-
"created": "2005-01-01, 2026-06-14",
|
| 40 |
-
"is_ocr": False,
|
| 41 |
-
},
|
| 42 |
-
"wiktionary_examples": {
|
| 43 |
-
"file_key": "wiktionary_examples",
|
| 44 |
-
"pretty": "Polish Wiktionary usage examples",
|
| 45 |
-
"provenance": "Parsed directly from the official Wikimedia dump "
|
| 46 |
-
"(plwiktionary-latest-pages-articles.xml.bz2); not routed "
|
| 47 |
-
"through SpeakLeash. Usage-example sections of Polish-language "
|
| 48 |
-
"entries extracted and grouped one document per headword.",
|
| 49 |
-
"license": "CC-BY-SA-3.0",
|
| 50 |
-
"license_spdx": "CC-BY-SA-3.0",
|
| 51 |
-
"traceable": "Wikimedia dumps explicitly released under CC-BY-SA 3.0; "
|
| 52 |
-
"attribution to contributors + share-alike preserved. "
|
| 53 |
-
"Derived subset: usage-example sections from Polish-language "
|
| 54 |
-
"entries only, grouped one document per headword.",
|
| 55 |
-
"upstream": "https://dumps.wikimedia.org/plwiktionary/latest/",
|
| 56 |
-
"domain": "lexicographic",
|
| 57 |
-
"created": "2004-03-22, 2026-08-15",
|
| 58 |
-
"is_ocr": False,
|
| 59 |
-
},
|
| 60 |
-
"eurlex": {
|
| 61 |
-
"speakleash_key": "eurlex_corpus",
|
| 62 |
-
"pretty": "EUR-Lex (EU legal acts, Polish)",
|
| 63 |
-
"license": "CC-BY-4.0",
|
| 64 |
-
"license_spdx": "CC-BY-4.0",
|
| 65 |
-
"traceable": "EU documents reusable under Commission Decision 2011/833/EU; "
|
| 66 |
-
"normative acts fall outside copyright (PL art. 4 pr. aut.). "
|
| 67 |
-
"Reuse authorised with source acknowledgement.",
|
| 68 |
-
"upstream": "https://eur-lex.europa.eu",
|
| 69 |
-
"domain": "legal",
|
| 70 |
-
"created": "1952-01-01, 2024-12-31",
|
| 71 |
-
"is_ocr": False,
|
| 72 |
-
},
|
| 73 |
-
"parliamentary": {
|
| 74 |
-
"speakleash_key": "PPC_corpus",
|
| 75 |
-
"pretty": "Polish Parliamentary Corpus (Sejm/Senat)",
|
| 76 |
-
"license": "public-domain (official documents)",
|
| 77 |
-
"license_spdx": "CC-BY-4.0",
|
| 78 |
-
"traceable": "Parliamentary proceedings are official documents outside "
|
| 79 |
-
"copyright (PL art. 4 pr. aut.); PPC redistributed by IPI PAN "
|
| 80 |
-
"under CC-BY-4.0.",
|
| 81 |
-
"upstream": "http://clip.ipipan.waw.pl/PPC",
|
| 82 |
-
"domain": "political/spoken",
|
| 83 |
-
"created": "1991-01-01, 2019-12-31",
|
| 84 |
-
"is_ocr": False,
|
| 85 |
-
},
|
| 86 |
-
"
|
| 87 |
-
"file_key": "
|
| 88 |
-
"pretty": "
|
| 89 |
-
"license": "
|
| 90 |
-
"license_spdx": "
|
| 91 |
-
"traceable": "
|
| 92 |
-
"
|
| 93 |
-
"
|
| 94 |
-
"upstream": "
|
| 95 |
-
"provenance": "
|
| 96 |
-
"
|
| 97 |
-
"
|
| 98 |
-
|
| 99 |
-
"
|
| 100 |
-
"
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
"
|
| 105 |
-
"
|
| 106 |
-
"
|
| 107 |
-
"
|
| 108 |
-
|
| 109 |
-
"
|
| 110 |
-
"upstream": "
|
| 111 |
-
"
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
"
|
| 117 |
-
"
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
"
|
| 121 |
-
|
| 122 |
-
"
|
| 123 |
-
"
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
"
|
| 127 |
-
"
|
| 128 |
-
"
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
"
|
| 133 |
-
"
|
| 134 |
-
"
|
| 135 |
-
"
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
"
|
| 139 |
-
|
| 140 |
-
"
|
| 141 |
-
|
| 142 |
-
"
|
| 143 |
-
"
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
"
|
| 148 |
-
"
|
| 149 |
-
"
|
| 150 |
-
"
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
"
|
| 154 |
-
|
| 155 |
-
"
|
| 156 |
-
|
| 157 |
-
"
|
| 158 |
-
"
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
"
|
| 163 |
-
"
|
| 164 |
-
"
|
| 165 |
-
"
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
"
|
| 169 |
-
|
| 170 |
-
"
|
| 171 |
-
|
| 172 |
-
"
|
| 173 |
-
"
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
"
|
| 178 |
-
"
|
| 179 |
-
"
|
| 180 |
-
"
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
"
|
| 184 |
-
|
| 185 |
-
"
|
| 186 |
-
|
| 187 |
-
"
|
| 188 |
-
"
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
"
|
| 193 |
-
"
|
| 194 |
-
"
|
| 195 |
-
"
|
| 196 |
-
|
| 197 |
-
"
|
| 198 |
-
"upstream": "https://
|
| 199 |
-
"provenance": "Fetched directly from the
|
| 200 |
-
"by src/
|
| 201 |
-
"
|
| 202 |
-
|
| 203 |
-
"
|
| 204 |
-
"
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
"
|
| 209 |
-
"
|
| 210 |
-
"
|
| 211 |
-
"
|
| 212 |
-
|
| 213 |
-
"
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
"
|
| 225 |
-
|
| 226 |
-
"
|
| 227 |
-
"
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
"
|
| 234 |
-
"
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
"
|
| 248 |
-
"
|
| 249 |
-
"
|
| 250 |
-
"
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
"
|
| 255 |
-
"
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
"
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
"
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
"
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
"
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
"
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
"
|
| 298 |
-
"
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
"
|
| 303 |
-
"
|
| 304 |
-
"
|
| 305 |
-
"
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
"
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
"
|
| 317 |
-
"
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
"
|
| 326 |
-
"
|
| 327 |
-
"
|
| 328 |
-
"
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
"
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
"
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
"
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
"
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
"
|
| 377 |
-
"
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
"
|
| 382 |
-
|
| 383 |
-
"
|
| 384 |
-
"
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Source registry for Polish DynaWord.
|
| 2 |
+
|
| 3 |
+
Each entry = one openly-licensed, *traceable* human-text source (paper 2508.02271,
|
| 4 |
+
principle: open+traceable licensing). The `traceable` field documents WHY the
|
| 5 |
+
license holds (not just "it's public domain") — e.g. statutory basis or upstream
|
| 6 |
+
license — as required by the Dynaword guidelines.
|
| 7 |
+
|
| 8 |
+
Provenance note: data is pulled from SpeakLeash's public redistribution
|
| 9 |
+
(iDrive e2 bucket) of these upstream sources; SpeakLeash is credited as the
|
| 10 |
+
intermediate aggregator, upstream license/attribution is preserved per source.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
# clean-6: passed the copyright review (2026-06-15). open_subtitles excluded
|
| 14 |
+
# (derivative of copyrighted film dialogue — same lesson as Danish Gigaword).
|
| 15 |
+
# Large cultural/academic sources require per-record rights metadata and should
|
| 16 |
+
# be rebuilt from direct upstream/export scripts rather than blind SpeakLeash pulls.
|
| 17 |
+
SOURCES = {
|
| 18 |
+
"wikipedia": {
|
| 19 |
+
"speakleash_key": "plwiki",
|
| 20 |
+
"pretty": "Polish Wikipedia",
|
| 21 |
+
"license": "CC-BY-SA-3.0",
|
| 22 |
+
"license_spdx": "CC-BY-SA-3.0",
|
| 23 |
+
"traceable": "Wikimedia dumps explicitly released under CC-BY-SA 3.0; "
|
| 24 |
+
"attribution to contributors + share-alike preserved.",
|
| 25 |
+
"upstream": "https://dumps.wikimedia.org/plwiki/latest/",
|
| 26 |
+
"domain": "encyclopedic",
|
| 27 |
+
"created": "2001-01-15, 2026-06-14",
|
| 28 |
+
"is_ocr": False,
|
| 29 |
+
},
|
| 30 |
+
"wikisource": {
|
| 31 |
+
"speakleash_key": "plwikisource",
|
| 32 |
+
"pretty": "Polish Wikisource",
|
| 33 |
+
"license": "CC-BY-SA-3.0",
|
| 34 |
+
"license_spdx": "CC-BY-SA-3.0",
|
| 35 |
+
"traceable": "Wikimedia dumps under CC-BY-SA 3.0; underlying texts are "
|
| 36 |
+
"public-domain works transcribed by the community.",
|
| 37 |
+
"upstream": "https://dumps.wikimedia.org/plwikisource/latest/",
|
| 38 |
+
"domain": "books/source-texts",
|
| 39 |
+
"created": "2005-01-01, 2026-06-14",
|
| 40 |
+
"is_ocr": False,
|
| 41 |
+
},
|
| 42 |
+
"wiktionary_examples": {
|
| 43 |
+
"file_key": "wiktionary_examples",
|
| 44 |
+
"pretty": "Polish Wiktionary usage examples",
|
| 45 |
+
"provenance": "Parsed directly from the official Wikimedia dump "
|
| 46 |
+
"(plwiktionary-latest-pages-articles.xml.bz2); not routed "
|
| 47 |
+
"through SpeakLeash. Usage-example sections of Polish-language "
|
| 48 |
+
"entries extracted and grouped one document per headword.",
|
| 49 |
+
"license": "CC-BY-SA-3.0",
|
| 50 |
+
"license_spdx": "CC-BY-SA-3.0",
|
| 51 |
+
"traceable": "Wikimedia dumps explicitly released under CC-BY-SA 3.0; "
|
| 52 |
+
"attribution to contributors + share-alike preserved. "
|
| 53 |
+
"Derived subset: usage-example sections from Polish-language "
|
| 54 |
+
"entries only, grouped one document per headword.",
|
| 55 |
+
"upstream": "https://dumps.wikimedia.org/plwiktionary/latest/",
|
| 56 |
+
"domain": "lexicographic",
|
| 57 |
+
"created": "2004-03-22, 2026-08-15",
|
| 58 |
+
"is_ocr": False,
|
| 59 |
+
},
|
| 60 |
+
"eurlex": {
|
| 61 |
+
"speakleash_key": "eurlex_corpus",
|
| 62 |
+
"pretty": "EUR-Lex (EU legal acts, Polish)",
|
| 63 |
+
"license": "CC-BY-4.0",
|
| 64 |
+
"license_spdx": "CC-BY-4.0",
|
| 65 |
+
"traceable": "EU documents reusable under Commission Decision 2011/833/EU; "
|
| 66 |
+
"normative acts fall outside copyright (PL art. 4 pr. aut.). "
|
| 67 |
+
"Reuse authorised with source acknowledgement.",
|
| 68 |
+
"upstream": "https://eur-lex.europa.eu",
|
| 69 |
+
"domain": "legal",
|
| 70 |
+
"created": "1952-01-01, 2024-12-31",
|
| 71 |
+
"is_ocr": False,
|
| 72 |
+
},
|
| 73 |
+
"parliamentary": {
|
| 74 |
+
"speakleash_key": "PPC_corpus",
|
| 75 |
+
"pretty": "Polish Parliamentary Corpus (Sejm/Senat)",
|
| 76 |
+
"license": "public-domain (official documents)",
|
| 77 |
+
"license_spdx": "CC-BY-4.0",
|
| 78 |
+
"traceable": "Parliamentary proceedings are official documents outside "
|
| 79 |
+
"copyright (PL art. 4 pr. aut.); PPC redistributed by IPI PAN "
|
| 80 |
+
"under CC-BY-4.0.",
|
| 81 |
+
"upstream": "http://clip.ipipan.waw.pl/PPC",
|
| 82 |
+
"domain": "political/spoken",
|
| 83 |
+
"created": "1991-01-01, 2019-12-31",
|
| 84 |
+
"is_ocr": False,
|
| 85 |
+
},
|
| 86 |
+
"sejm_api": {
|
| 87 |
+
"file_key": "sejm_api",
|
| 88 |
+
"pretty": "Sejm API parliamentary speeches (2023 onward)",
|
| 89 |
+
"license": "public-domain (official documents)",
|
| 90 |
+
"license_spdx": "LicenseRef-Polish-Official-Documents",
|
| 91 |
+
"traceable": "Official parliamentary materials excluded from copyright "
|
| 92 |
+
"under Polish Copyright Act art. 4(2); reusable under "
|
| 93 |
+
"the Polish Open Data Act arts. 2(12), 5, 14 and 17.",
|
| 94 |
+
"upstream": "https://api.sejm.gov.pl/",
|
| 95 |
+
"provenance": "Direct official Sejm API records, preserved with speaker "
|
| 96 |
+
"attribution and immutable PiotrSty/sejm-speeches-corpus "
|
| 97 |
+
"v1.0.1 source provenance.",
|
| 98 |
+
"domain": "political/spoken",
|
| 99 |
+
"created": "2023-01-01, 2026-07-03",
|
| 100 |
+
"is_ocr": False,
|
| 101 |
+
},
|
| 102 |
+
"parlamint_pl": {
|
| 103 |
+
"file_key": "parlamint_pl",
|
| 104 |
+
"pretty": "ParlaMint-PL (parliamentary debates, 2015-2022)",
|
| 105 |
+
"license": "CC-BY-4.0",
|
| 106 |
+
"license_spdx": "CC-BY-4.0",
|
| 107 |
+
"traceable": "ParlaMint 3.0 corpora released under CC-BY 4.0 (CLARIN.SI "
|
| 108 |
+
"handle 11356/1486); parliamentary proceedings are also "
|
| 109 |
+
"official documents (PL art. 4 pr. aut.).",
|
| 110 |
+
"upstream": "http://hdl.handle.net/11356/1486",
|
| 111 |
+
"provenance": "Fetched directly from the CLARIN.SI plain-text edition "
|
| 112 |
+
"(ParlaMint-PL.tgz) by src/fetch_parlamint.py; one session "
|
| 113 |
+
"transcript per document, utterance IDs stripped. Modern "
|
| 114 |
+
"spoken register, complements the older PPC (1991-2019).",
|
| 115 |
+
"domain": "political/spoken",
|
| 116 |
+
"created": "2015-01-01, 2022-12-31",
|
| 117 |
+
"is_ocr": False,
|
| 118 |
+
},
|
| 119 |
+
"wolne_lektury": {
|
| 120 |
+
"speakleash_key": "wolne_lektury_corpus",
|
| 121 |
+
"pretty": "Wolne Lektury (school readings)",
|
| 122 |
+
"license": "CC-BY-SA-4.0 / Wolna Sztuka 1.3",
|
| 123 |
+
"license_spdx": "CC-BY-SA-4.0",
|
| 124 |
+
"traceable": "Wolne Lektury publishes under CC-BY-SA 4.0 or Free Art "
|
| 125 |
+
"License; texts are public-domain classics + cleared works.",
|
| 126 |
+
"upstream": "https://wolnelektury.pl/api/books/",
|
| 127 |
+
"domain": "literature",
|
| 128 |
+
"created": "1500-01-01, 2024-12-31",
|
| 129 |
+
"is_ocr": False,
|
| 130 |
+
},
|
| 131 |
+
"wikinews": {
|
| 132 |
+
"file_key": "plwikinews", # fetched from Wikimedia dumps, NOT via SpeakLeash
|
| 133 |
+
"pretty": "Polish Wikinews",
|
| 134 |
+
"license": "CC-BY-2.5",
|
| 135 |
+
"license_spdx": "CC-BY-2.5",
|
| 136 |
+
"traceable": "Wikinews content is released under CC-BY 2.5; attribution to "
|
| 137 |
+
"contributors preserved.",
|
| 138 |
+
"upstream": "https://pl.wikinews.org/",
|
| 139 |
+
"provenance": "Fetched directly from the official Wikimedia dump "
|
| 140 |
+
"(plwikinews-latest-pages-articles) by src/fetch_wikimedia.py; "
|
| 141 |
+
"mainspace only, wikitext stripped via mwparserfromhell.",
|
| 142 |
+
"domain": "news",
|
| 143 |
+
"created": "2005-01-01, 2025-12-31",
|
| 144 |
+
"is_ocr": False,
|
| 145 |
+
},
|
| 146 |
+
"wikivoyage": {
|
| 147 |
+
"file_key": "plwikivoyage",
|
| 148 |
+
"pretty": "Polish Wikivoyage (travel guides)",
|
| 149 |
+
"license": "CC-BY-SA-3.0",
|
| 150 |
+
"license_spdx": "CC-BY-SA-3.0",
|
| 151 |
+
"traceable": "Wikivoyage content is released under CC-BY-SA 3.0; "
|
| 152 |
+
"attribution + share-alike preserved.",
|
| 153 |
+
"upstream": "https://pl.wikivoyage.org/",
|
| 154 |
+
"provenance": "Fetched directly from the official Wikimedia dump "
|
| 155 |
+
"(plwikivoyage-latest-pages-articles) by src/fetch_wikimedia.py; "
|
| 156 |
+
"mainspace only, wikitext stripped via mwparserfromhell.",
|
| 157 |
+
"domain": "travel",
|
| 158 |
+
"created": "2012-01-01, 2025-12-31",
|
| 159 |
+
"is_ocr": False,
|
| 160 |
+
},
|
| 161 |
+
"wikibooks": {
|
| 162 |
+
"file_key": "plwikibooks",
|
| 163 |
+
"pretty": "Polish Wikibooks (open textbooks)",
|
| 164 |
+
"license": "CC-BY-SA-3.0",
|
| 165 |
+
"license_spdx": "CC-BY-SA-3.0",
|
| 166 |
+
"traceable": "Wikibooks content is released under CC-BY-SA 3.0; "
|
| 167 |
+
"attribution + share-alike preserved.",
|
| 168 |
+
"upstream": "https://pl.wikibooks.org/",
|
| 169 |
+
"provenance": "Fetched directly from the official Wikimedia dump "
|
| 170 |
+
"(plwikibooks-latest-pages-articles) by src/fetch_wikimedia.py; "
|
| 171 |
+
"mainspace only, wikitext stripped via mwparserfromhell.",
|
| 172 |
+
"domain": "instructional",
|
| 173 |
+
"created": "2004-01-01, 2025-12-31",
|
| 174 |
+
"is_ocr": False,
|
| 175 |
+
},
|
| 176 |
+
"wikiquote": {
|
| 177 |
+
"file_key": "plwikiquote",
|
| 178 |
+
"pretty": "Polish Wikiquote (quotations)",
|
| 179 |
+
"license": "CC-BY-SA-3.0",
|
| 180 |
+
"license_spdx": "CC-BY-SA-3.0",
|
| 181 |
+
"traceable": "Wikiquote content is released under CC-BY-SA 3.0; "
|
| 182 |
+
"attribution + share-alike preserved.",
|
| 183 |
+
"upstream": "https://pl.wikiquote.org/",
|
| 184 |
+
"provenance": "Fetched directly from the official Wikimedia dump "
|
| 185 |
+
"(plwikiquote-latest-pages-articles) by src/fetch_wikimedia.py; "
|
| 186 |
+
"mainspace only, wikitext stripped via mwparserfromhell.",
|
| 187 |
+
"domain": "quotations",
|
| 188 |
+
"created": "2005-01-01, 2025-12-31",
|
| 189 |
+
"is_ocr": False,
|
| 190 |
+
},
|
| 191 |
+
"eltec_pol": {
|
| 192 |
+
"file_key": "eltec_pol",
|
| 193 |
+
"pretty": "ELTeC-pol (European Literary Text Collection, Polish)",
|
| 194 |
+
"license": "CC-BY-4.0",
|
| 195 |
+
"license_spdx": "CC-BY-4.0",
|
| 196 |
+
"traceable": "ELTeC corpora are released under CC-BY 4.0 by the COST Action "
|
| 197 |
+
"'Distant Reading for European Literary History' (CA16204).",
|
| 198 |
+
"upstream": "https://github.com/COST-ELTeC/ELTeC-pol",
|
| 199 |
+
"provenance": "Fetched directly from the COST-ELTeC/ELTeC-pol GitHub "
|
| 200 |
+
"repository (level1 TEI) by src/fetch_eltec.py; reading text "
|
| 201 |
+
"extracted from TEI <body> paragraphs.",
|
| 202 |
+
"domain": "literature",
|
| 203 |
+
"created": "1840-01-01, 1920-12-31",
|
| 204 |
+
"is_ocr": False,
|
| 205 |
+
},
|
| 206 |
+
"dziennik_ustaw": {
|
| 207 |
+
"file_key": "dziennik_ustaw", # fetched directly, NOT via SpeakLeash
|
| 208 |
+
"pretty": "Dziennik Ustaw + Monitor Polski (Polish primary legislation)",
|
| 209 |
+
"license": "public-domain (official documents)",
|
| 210 |
+
"license_spdx": "CC0-1.0",
|
| 211 |
+
"traceable": "Normative acts and their official drafts are not subject to "
|
| 212 |
+
"copyright (PL art. 4 ustawy o prawie autorskim). Published by "
|
| 213 |
+
"the state; reuse unrestricted.",
|
| 214 |
+
"upstream": "https://api.sejm.gov.pl/eli/acts",
|
| 215 |
+
"provenance": "Fetched directly from the Sejm ELI API (text.html per act) "
|
| 216 |
+
"by src/fetch_eli.py — a native source, not redistributed via "
|
| 217 |
+
"SpeakLeash. Full provenance: each act's `meta.url` is its ELI "
|
| 218 |
+
"address, resolvable on api.sejm.gov.pl.",
|
| 219 |
+
"domain": "legal",
|
| 220 |
+
"created": "1918-01-01, 2025-12-31",
|
| 221 |
+
"is_ocr": False,
|
| 222 |
+
},
|
| 223 |
+
"govpl": {
|
| 224 |
+
"file_key": "govpl", # fetched directly from gov.pl, NOT via SpeakLeash
|
| 225 |
+
"pretty": "gov.pl — Polish government press releases",
|
| 226 |
+
"license": "CC-BY-SA-4.0",
|
| 227 |
+
"license_spdx": "CC-BY-SA-4.0",
|
| 228 |
+
"traceable": "All textual content on gov.pl is published under CC-BY-SA "
|
| 229 |
+
"4.0 (site footer: \"Treści tekstowe publikowane w serwisie "
|
| 230 |
+
"… są udostępniane na licencji CC BY-SA 4.0\"). Authored and "
|
| 231 |
+
"hosted by the Polish government, which holds the right to "
|
| 232 |
+
"license it — same open family as Polish Wikipedia.",
|
| 233 |
+
"upstream": "https://www.gov.pl/",
|
| 234 |
+
"provenance": "Ministry/agency press releases fetched directly from gov.pl "
|
| 235 |
+
"(editor-content per article, HTML stripped) by "
|
| 236 |
+
"src/fetch_govpl.py. Subsites + their non-uniform news-section "
|
| 237 |
+
"paths are enumerated by src/discover_govpl.py into the "
|
| 238 |
+
"committed manifest src/govpl_subsites.json (gov.pl has no "
|
| 239 |
+
"sitemap/API). Each record's meta.url resolves on gov.pl.",
|
| 240 |
+
"domain": "government",
|
| 241 |
+
# actual min/max of article dates in the fetched corpus (90,124 dated).
|
| 242 |
+
"created": "2005-09-26, 2026-07-19",
|
| 243 |
+
"is_ocr": False,
|
| 244 |
+
},
|
| 245 |
+
"samorzad_gov_pl": {
|
| 246 |
+
"file_key": "samorzad_gov_pl",
|
| 247 |
+
"pretty": "samorzad.gov.pl — Polish public-sector institutions",
|
| 248 |
+
"license": "CC-BY-SA-4.0",
|
| 249 |
+
"license_spdx": "CC-BY-SA-4.0",
|
| 250 |
+
"traceable": "The shared samorzad.gov.pl platform footer publishes textual "
|
| 251 |
+
"content under CC BY-SA 4.0. Every retained v0.1 source page "
|
| 252 |
+
"referenced the shared footer script; audiovisual media and "
|
| 253 |
+
"attachment bytes are not redistributed.",
|
| 254 |
+
"upstream": "https://huggingface.co/datasets/dawidmajewski/samorzad-gov-pl-articles",
|
| 255 |
+
"provenance": "Converted reproducibly from the published v0.1 source dataset "
|
| 256 |
+
"by src/clean_samorzad_gov_pl.py. The source was collected "
|
| 257 |
+
"directly from public samorzad.gov.pl pages across 246 local "
|
| 258 |
+
"public institutions and one central platform tenant. "
|
| 259 |
+
"Institution display names are frozen "
|
| 260 |
+
"from each tenant homepage's og:site_name metadata and stored "
|
| 261 |
+
"as DynaWord author values; discovered, fetched and attribution "
|
| 262 |
+
"URLs plus license details are preserved in the sidecar.",
|
| 263 |
+
"domain": "local government, education, social services and culture",
|
| 264 |
+
"created": "2020-2026 for 21,892 dated records; 59,530 source records undated",
|
| 265 |
+
"is_ocr": False,
|
| 266 |
+
"custom_datasheet": True,
|
| 267 |
+
},
|
| 268 |
+
"biblioteka_nauki": {
|
| 269 |
+
"file_key": "biblioteka_nauki_pl_corpus",
|
| 270 |
+
"pretty": "Biblioteka Nauki",
|
| 271 |
+
"license": "per-record upstream license",
|
| 272 |
+
"license_spdx": "MIXED",
|
| 273 |
+
"traceable": "Documents are accepted only when the direct upstream record "
|
| 274 |
+
"exposes a reusable license. The parquet carries the "
|
| 275 |
+
"per-document `license` and `author` fields from the upstream "
|
| 276 |
+
"metadata collected by the source-specific rebuild script.",
|
| 277 |
+
"upstream": "https://bibliotekanauki.pl/",
|
| 278 |
+
"provenance": "Fetched directly from Biblioteka Nauki via the contributor "
|
| 279 |
+
"rebuild script, not from the SpeakLeash redistribution. "
|
| 280 |
+
"License and author metadata are checked document by document "
|
| 281 |
+
"before normalization into the DynaWord schema.",
|
| 282 |
+
"domain": "academic",
|
| 283 |
+
"created": "unknown",
|
| 284 |
+
"is_ocr": False,
|
| 285 |
+
},
|
| 286 |
+
"europeana": {
|
| 287 |
+
# Direct rebuild output from fetch_europeana.py, never the raw
|
| 288 |
+
# SpeakLeash Europeana aggregate.
|
| 289 |
+
"file_key": "europeana",
|
| 290 |
+
"pretty": "Europeana Polish records",
|
| 291 |
+
"license": "per-record public-domain/open rights statement",
|
| 292 |
+
"license_spdx": "MIXED",
|
| 293 |
+
"traceable": "Documents are accepted only with per-record Europeana rights "
|
| 294 |
+
"metadata classified as public-domain/open. Public-domain "
|
| 295 |
+
"status is jurisdiction-sensitive; downstream users must "
|
| 296 |
+
"check their local legal requirements.",
|
| 297 |
+
"upstream": "https://www.europeana.eu/",
|
| 298 |
+
"provenance": "Fetched directly from Europeana via the contributor rebuild "
|
| 299 |
+
"script, preserving per-record rights and creator metadata. "
|
| 300 |
+
"The raw SpeakLeash aggregate remains insufficient because "
|
| 301 |
+
"it does not carry enough rights evidence for release.",
|
| 302 |
+
"domain": "cultural heritage",
|
| 303 |
+
"created": "unknown",
|
| 304 |
+
"is_ocr": True,
|
| 305 |
+
"legal_note": "Europeana public-domain statements are primarily evaluated "
|
| 306 |
+
"for Poland/EU. For US reuse, records created/published "
|
| 307 |
+
"before 1929 are the conservative release slice; later "
|
| 308 |
+
"records should remain separately labeled or held until "
|
| 309 |
+
"legal review confirms their US status.",
|
| 310 |
+
},
|
| 311 |
+
"nkjp1m": {
|
| 312 |
+
"file_key": "nkjp1m",
|
| 313 |
+
"pretty": "The manually annotated 1-million word subcorpus of the National Corpus of Polish",
|
| 314 |
+
"license": "CC-BY",
|
| 315 |
+
"license_spdx": "CC-BY-4.0",
|
| 316 |
+
"traceable": "The NKJP download page (clip.ipipan.waw.pl) states the manually annotated 1-million-word subcorpus (Podkorpus Milionowy NKJP 1.2) is available under a CC-BY licence; attribution to the NKJP Consortium (IPI PAN) preserved. The page states 'CC-BY' with no version, normalized to CC-BY-4.0 for SPDX. The CC-BY licence covers the corpus text; NKJP's separate tools are GPL and are not included here.",
|
| 317 |
+
"upstream": "https://clip.ipipan.waw.pl/NationalCorpusOfPolish",
|
| 318 |
+
"provenance": "Downloaded the IPI PAN tarball (NKJP-PodkorpusMilionowy-1.2.tar.gz) directly by src/fetch_njkp.py, one row per TEI <div> passage (its <ab> paragraphs joined by newlines, ellipsis markers stripped). The same minimal gates as build_dynaword.py are applied per passage (drop < 200 chars, drop non-Polish by diacritic ratio, exact sha1 dedup; the OCR gate is inapplicable). Per-document 'created' is the sample's TEI publication date (<date type=\"published\">) where the header records one. Normalized into the DynaWord schema; cl100k token counts via tiktoken (encode_ordinary), and the stats are recomputed from the written parquet.",
|
| 319 |
+
"domain": "mixed (balanced reference corpus)",
|
| 320 |
+
"created": "1957-2008 (recorded for 6,581 of 18,381 documents; per-document in the created column)",
|
| 321 |
+
"is_ocr": False,
|
| 322 |
+
},
|
| 323 |
+
"european_hplt_v3_pl": {
|
| 324 |
+
"file_key": "european_hplt_v3_pl",
|
| 325 |
+
"pretty": "HPLT v3.0 Polish (web, top WDS bins 10-5)",
|
| 326 |
+
"license": "CC0-1.0",
|
| 327 |
+
"license_spdx": "CC0-1.0",
|
| 328 |
+
"traceable": "HPLT v3.0 Terms of Use license the data packaging under CC0-1.0 "
|
| 329 |
+
"(hplt-project.org/datasets/v3.0; HF card HPLT/HPLT3.0). HPLT does not "
|
| 330 |
+
"own the underlying web text; notice-and-takedown applies and downstream "
|
| 331 |
+
"legal/provenance review remains the user's responsibility.",
|
| 332 |
+
"upstream": "https://data.hplt-project.org/three/sorted/pol_Latn/",
|
| 333 |
+
"provenance": "Fetched directly from the HPLT v3 distribution (pol_Latn shards "
|
| 334 |
+
"10_1, 9_1-9_4, 8_1-8_4, 7_1-7_4, 6_1-6_2, 5_1-5_2 [WDS 10 down to 5]) by "
|
| 335 |
+
"src/clean_hplt_v3.py + run_pipeline.py, NOT via SpeakLeash. Filtered: "
|
| 336 |
+
"lang=pol_Latn + prob>=0.80, MT-prob<0.20, register in ID/OP/HI/IN/NA, "
|
| 337 |
+
"min 400 chars / 80 words, boilerplate/adult/legalish drop, length cap "
|
| 338 |
+
"120k chars, CJK-mojibake drop, wikipedia/wikisource/wikimedia + file-host "
|
| 339 |
+
"domains excluded, per-domain cap. Phone->[Telefon] / email+national-ID->[PII] "
|
| 340 |
+
"PII-scrub (v12b, independent dual-lens verify). Token counts via tiktoken cl100k.",
|
| 341 |
+
"domain": "web",
|
| 342 |
+
"created": "2012-01-01, 2024-12-31",
|
| 343 |
+
"is_ocr": False,
|
| 344 |
+
"legal_note": "Web-crawl derived: accept_after_web_review. HPLT is globally "
|
| 345 |
+
"deduplicated upstream and WDS quality-sorted. Cross-source near/"
|
| 346 |
+
"containment dedup vs the existing WDS-10+9 base shards was performed "
|
| 347 |
+
"for the WDS 8-5 + extra-9 expansion: exact-dup=0, near-dup overlap="
|
| 348 |
+
"0.0000% (byte-verified). Copyright recurs at all lengths in web crawl. "
|
| 349 |
+
"Parity with the accepted european-hplt-v1 CC0 basis.",
|
| 350 |
+
"custom_datasheet": True,
|
| 351 |
+
},
|
| 352 |
+
"1000_novels": {
|
| 353 |
+
"speakleash_key": "1000_novels_corpus_CLARIN-PL",
|
| 354 |
+
"pretty": "1000 Novels Corpus (CLARIN-PL)",
|
| 355 |
+
"license": "CC-BY-4.0",
|
| 356 |
+
"license_spdx": "CC-BY-4.0",
|
| 357 |
+
"traceable": "The 1000 Novels Corpus is released under Creative Commons "
|
| 358 |
+
"Attribution 4.0 International by CLARIN-PL / Wrocław University "
|
| 359 |
+
"of Technology, with attribution to the corpus authors and "
|
| 360 |
+
"maintainers.",
|
| 361 |
+
"upstream": "https://clarin-pl.eu/dspace/handle/11321/312",
|
| 362 |
+
"domain": "literature",
|
| 363 |
+
"created": "unknown",
|
| 364 |
+
"is_ocr": False,
|
| 365 |
+
# Datasheet is contributor-committed (added 2026-07-02); skip regeneration
|
| 366 |
+
# so the global ADDED stamp does not overwrite the real add date.
|
| 367 |
+
"custom_datasheet": True,
|
| 368 |
+
},
|
| 369 |
+
"global_voices": {
|
| 370 |
+
# Data contributed directly (PR #7): no in-repo fetch/build script and a
|
| 371 |
+
# hand-authored datasheet. Registered for the source table + release totals;
|
| 372 |
+
# the datasheet stays contributor-owned via custom_datasheet.
|
| 373 |
+
"file_key": "global_voices",
|
| 374 |
+
"pretty": "Global Voices Polish",
|
| 375 |
+
"license": "CC-BY-3.0",
|
| 376 |
+
"license_spdx": "CC-BY-3.0",
|
| 377 |
+
"traceable": "CC BY 3.0 verified from the article-level license link published "
|
| 378 |
+
"with each retained Global Voices article; each record carries "
|
| 379 |
+
"CC-BY-3.0 metadata and per-document author/translator attribution "
|
| 380 |
+
"in global_voices.attribution.jsonl.",
|
| 381 |
+
"upstream": "https://pl.globalvoices.org/",
|
| 382 |
+
"domain": "civic media, news and public-interest journalism",
|
| 383 |
+
"created": "2008-11-04, 2023-05-24",
|
| 384 |
+
"is_ocr": False,
|
| 385 |
+
"custom_datasheet": True,
|
| 386 |
+
},
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
ADDED = "2026-07-19"
|
| 390 |
+
EXCLUDED = {
|
| 391 |
+
"open_subtitles_corpus": "Derivative of copyrighted film/TV dialogue; "
|
| 392 |
+
"OpenSubtitles uploads largely unlicensed. Same copyright lesson as "
|
| 393 |
+
"Danish Gigaword's OpenSubtitles (paper 2508.02271). Not openly licensed.",
|
| 394 |
+
"europeana_eu_pl_corpus_raw_speakleash": "Aggregated items with mixed "
|
| 395 |
+
"per-record rights (PD / CC-BY-NC / rights-reserved). The raw "
|
| 396 |
+
"SpeakLeash redistribution is excluded; only a direct rebuild preserving "
|
| 397 |
+
"per-record rights metadata may be included.",
|
| 398 |
+
"1000_novels_corpus_CLARIN-PL": "CC-BY-4.0 label, but 'novels' likely include "
|
| 399 |
+
"in-copyright contemporary works; verify titles/years on CLARIN handle "
|
| 400 |
+
"11321/312 before inclusion.",
|
| 401 |
+
"project_gutenberg_pl_corpus": "Only 31 PL books (4.3MB) — PG is ~99% English; "
|
| 402 |
+
"Polish PD literature already covered by wolne_lektury + wikisource (so "
|
| 403 |
+
"near-redundant after dedup). Dropped to avoid the PD-in-EU per-work check "
|
| 404 |
+
"(PG claims PD-in-US only) for negligible token gain.",
|
| 405 |
+
}
|
src/test_sejm_api_contract.py
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import ast
|
| 4 |
+
import json
|
| 5 |
+
import pathlib
|
| 6 |
+
import sys
|
| 7 |
+
import tempfile
|
| 8 |
+
import unittest
|
| 9 |
+
|
| 10 |
+
for candidate in (
|
| 11 |
+
pathlib.Path(__file__).resolve().parent,
|
| 12 |
+
pathlib.Path(__file__).resolve().parents[1] / "scripts",
|
| 13 |
+
):
|
| 14 |
+
if str(candidate) not in sys.path:
|
| 15 |
+
sys.path.insert(0, str(candidate))
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
from fetch_sejm_api import (
|
| 19 |
+
ContributionError, EXPECTED_FIELDS, SOURCE_FIELDS, SOURCE_LICENSE, START_DATE,
|
| 20 |
+
assert_temporal_novelty, build_contribution, insert_source_registry_entry,
|
| 21 |
+
legal_evidence, normalize_source_row, stable_document_id, text_fingerprint,
|
| 22 |
+
)
|
| 23 |
+
except ImportError:
|
| 24 |
+
from build_dynaword_sejm_api import (
|
| 25 |
+
ContributionError, EXPECTED_FIELDS, SOURCE_FIELDS, SOURCE_LICENSE, START_DATE,
|
| 26 |
+
assert_temporal_novelty, build_contribution, insert_source_registry_entry,
|
| 27 |
+
legal_evidence, normalize_source_row, stable_document_id, text_fingerprint,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
REGISTRY = '''SOURCES = {
|
| 32 |
+
"parliamentary": {
|
| 33 |
+
"created": "1991-01-01, 2019-12-31",
|
| 34 |
+
"license": "public-domain (official documents)",
|
| 35 |
+
},
|
| 36 |
+
"parlamint_pl": {
|
| 37 |
+
"created": "2015-01-01, 2022-12-31",
|
| 38 |
+
"license": "CC-BY-4.0",
|
| 39 |
+
},
|
| 40 |
+
}
|
| 41 |
+
'''
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class FakeEncoder:
|
| 45 |
+
def encode_ordinary(self, text: str) -> list[str]:
|
| 46 |
+
return text.split()
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def sample_row(index: int, *, date: str = "2024-05-10") -> dict[str, object]:
|
| 50 |
+
text = (
|
| 51 |
+
f"Panie Marszałku, Wysoka Izbo, wypowiedź numer {index}. "
|
| 52 |
+
+ " ".join(f"słowo{number}" for number in range(65))
|
| 53 |
+
)
|
| 54 |
+
return {
|
| 55 |
+
"text": text,
|
| 56 |
+
"speaker": f"Poseł {index}",
|
| 57 |
+
"date": date,
|
| 58 |
+
"term": "10" if date >= "2023-11-13" else "9",
|
| 59 |
+
"source_url": f"https://api.sejm.gov.pl/sejm/term10/videos/{date}",
|
| 60 |
+
"char_count": len(text),
|
| 61 |
+
"word_count": len(text.split()),
|
| 62 |
+
"has_events": index % 2 == 0,
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class DynawordContractTests(unittest.TestCase):
|
| 67 |
+
def test_exact_dynaword_schema_and_speaker_attribution(self) -> None:
|
| 68 |
+
result = normalize_source_row(
|
| 69 |
+
sample_row(1), start_date=START_DATE,
|
| 70 |
+
added_date="2026-08-22", encoder=FakeEncoder()
|
| 71 |
+
)
|
| 72 |
+
self.assertIsNotNone(result)
|
| 73 |
+
document, attribution = result
|
| 74 |
+
self.assertEqual(tuple(document), EXPECTED_FIELDS)
|
| 75 |
+
self.assertEqual(document["source"], "sejm_api")
|
| 76 |
+
self.assertEqual(document["author"], "Poseł 1")
|
| 77 |
+
self.assertEqual(document["license"], SOURCE_LICENSE)
|
| 78 |
+
self.assertEqual(attribution["id"], document["id"])
|
| 79 |
+
self.assertTrue(attribution["source_url"].startswith("https://api.sejm.gov.pl/"))
|
| 80 |
+
|
| 81 |
+
def test_pre_2023_records_are_excluded(self) -> None:
|
| 82 |
+
self.assertIsNone(normalize_source_row(
|
| 83 |
+
sample_row(2, date="2022-12-31"), start_date=START_DATE,
|
| 84 |
+
added_date="2026-08-22", encoder=FakeEncoder()
|
| 85 |
+
))
|
| 86 |
+
|
| 87 |
+
def test_first_day_after_parlamint_is_included(self) -> None:
|
| 88 |
+
self.assertIsNotNone(normalize_source_row(
|
| 89 |
+
sample_row(2, date="2023-01-01"), start_date=START_DATE,
|
| 90 |
+
added_date="2026-08-22", encoder=FakeEncoder()
|
| 91 |
+
))
|
| 92 |
+
|
| 93 |
+
def test_document_identity_is_stable_and_source_specific(self) -> None:
|
| 94 |
+
row = sample_row(1)
|
| 95 |
+
self.assertEqual(stable_document_id(row), stable_document_id(dict(row)))
|
| 96 |
+
changed = dict(row, speaker="Inny poseł")
|
| 97 |
+
self.assertNotEqual(stable_document_id(row), stable_document_id(changed))
|
| 98 |
+
self.assertTrue(stable_document_id(row).startswith("sejm_api_"))
|
| 99 |
+
|
| 100 |
+
def test_exact_duplicate_fingerprint_depends_on_text_only(self) -> None:
|
| 101 |
+
left = sample_row(1)
|
| 102 |
+
right = dict(left, speaker="Inny mówca", date="2025-01-01")
|
| 103 |
+
self.assertEqual(text_fingerprint(str(left["text"])), text_fingerprint(str(right["text"])))
|
| 104 |
+
|
| 105 |
+
def test_missing_speaker_rejected(self) -> None:
|
| 106 |
+
with self.assertRaisesRegex(ContributionError, "speaker"):
|
| 107 |
+
normalize_source_row(
|
| 108 |
+
dict(sample_row(1), speaker=""), start_date=START_DATE,
|
| 109 |
+
added_date="2026-08-22", encoder=FakeEncoder()
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
def test_nonofficial_source_url_rejected(self) -> None:
|
| 113 |
+
with self.assertRaisesRegex(ContributionError, "source URL"):
|
| 114 |
+
normalize_source_row(
|
| 115 |
+
dict(sample_row(1), source_url="https://example.com/speech"),
|
| 116 |
+
start_date=START_DATE, added_date="2026-08-22", encoder=FakeEncoder()
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
def test_temporal_novelty_against_both_registered_sources(self) -> None:
|
| 120 |
+
self.assertEqual(assert_temporal_novelty(REGISTRY, START_DATE), {
|
| 121 |
+
"parliamentary": "2019-12-31",
|
| 122 |
+
"parlamint_pl": "2022-12-31",
|
| 123 |
+
})
|
| 124 |
+
|
| 125 |
+
def test_overlap_with_registered_parlamint_fails_closed(self) -> None:
|
| 126 |
+
with self.assertRaisesRegex(ContributionError, "overlaps"):
|
| 127 |
+
assert_temporal_novelty(REGISTRY, "2022-01-01")
|
| 128 |
+
|
| 129 |
+
def test_registry_entry_is_valid_and_preserves_existing_sources(self) -> None:
|
| 130 |
+
updated = insert_source_registry_entry(REGISTRY, end_date="2026-07-03")
|
| 131 |
+
ast.parse(updated)
|
| 132 |
+
self.assertIn('"sejm_api": {', updated)
|
| 133 |
+
self.assertIn('"parlamint_pl": {', updated)
|
| 134 |
+
self.assertIn('"created": "2023-01-01, 2026-07-03"', updated)
|
| 135 |
+
|
| 136 |
+
def test_legal_evidence_contains_official_sources_and_no_fake_cc(self) -> None:
|
| 137 |
+
evidence = legal_evidence(source_revision="a" * 40, target_revision="b" * 40)
|
| 138 |
+
self.assertEqual(evidence["dataset_record_license"], SOURCE_LICENSE)
|
| 139 |
+
self.assertEqual(evidence["copyright_basis"]["article"], "4(2)")
|
| 140 |
+
self.assertIn("no upstream Creative Commons grant is asserted", evidence["limitations"])
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
class DynawordParquetIntegrationTests(unittest.TestCase):
|
| 144 |
+
def test_end_to_end_candidate_preserves_ontology_and_attribution(self) -> None:
|
| 145 |
+
try:
|
| 146 |
+
import pyarrow as pa
|
| 147 |
+
import pyarrow.parquet as pq
|
| 148 |
+
import tiktoken # noqa: F401
|
| 149 |
+
except ImportError:
|
| 150 |
+
self.skipTest("pyarrow and tiktoken are installed on the release runner")
|
| 151 |
+
|
| 152 |
+
with tempfile.TemporaryDirectory() as temporary:
|
| 153 |
+
root = pathlib.Path(temporary)
|
| 154 |
+
source_dir = root / "source" / "data"
|
| 155 |
+
source_dir.mkdir(parents=True)
|
| 156 |
+
duplicate = sample_row(1)
|
| 157 |
+
train_rows = [
|
| 158 |
+
sample_row(0, date="2022-12-31"),
|
| 159 |
+
duplicate,
|
| 160 |
+
sample_row(2, date="2025-06-10"),
|
| 161 |
+
]
|
| 162 |
+
validation_rows = [dict(duplicate, speaker="Duplikat mówcy")]
|
| 163 |
+
for name, rows in (("train", train_rows), ("validation", validation_rows)):
|
| 164 |
+
pq.write_table(pa.Table.from_pylist(rows), source_dir / f"{name}.parquet")
|
| 165 |
+
registry = root / "sources.py"
|
| 166 |
+
registry.write_text(REGISTRY, encoding="utf-8")
|
| 167 |
+
output = root / "result"
|
| 168 |
+
result = build_contribution(
|
| 169 |
+
root / "source", registry, output,
|
| 170 |
+
source_revision="a" * 40, target_revision="b" * 40,
|
| 171 |
+
added_date="2026-08-22", actor="github:PiotrStyla",
|
| 172 |
+
run_id="github-actions:1", git_commit="c" * 40,
|
| 173 |
+
tests_file=pathlib.Path(__file__),
|
| 174 |
+
)
|
| 175 |
+
self.assertEqual(result["stats"]["read"], 4)
|
| 176 |
+
self.assertEqual(result["stats"]["drop_before_start"], 1)
|
| 177 |
+
self.assertEqual(result["stats"]["drop_dup"], 1)
|
| 178 |
+
self.assertEqual(result["stats"]["kept"], 2)
|
| 179 |
+
self.assertEqual(result["stats"]["authors_with_value"], 2)
|
| 180 |
+
parquet = pq.read_table(output / "data" / "sejm_api" / "sejm_api.parquet")
|
| 181 |
+
self.assertEqual(tuple(parquet.column_names), EXPECTED_FIELDS)
|
| 182 |
+
self.assertEqual(parquet.num_rows, 2)
|
| 183 |
+
manifest = json.loads(
|
| 184 |
+
(output / "artifacts" / "sejm_api_ontology_manifest.json").read_text()
|
| 185 |
+
)
|
| 186 |
+
self.assertEqual(len(manifest["claims"]), 3)
|
| 187 |
+
self.assertEqual(len(manifest["evidence"]), 5)
|
| 188 |
+
self.assertTrue((output / "src" / "fetch_sejm_api.py").is_file())
|
| 189 |
+
self.assertTrue((output / "src" / "test_sejm_api_contract.py").is_file())
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
if __name__ == "__main__":
|
| 193 |
+
unittest.main()
|