ppuzio Claude Opus 5.5 commited on
Commit
d705fa1
·
2 Parent(s): ead9e97a8792dc

Merge origin/main (samorzad_gov_pl #64, global_voices) into v026-1000_novels

Browse files

Conflict in artifacts/source_findings.md resolved by keeping every entry:
main's samorzad_gov_pl and global_voices sections, then the 1000_novels section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

artifacts/source_findings.md CHANGED
@@ -1322,6 +1322,118 @@ https://www.gov.pl/web/gov/prawa-autorskie (read 2026-10-06).
1322
  **Lesson** — an open-licence footer covers the publisher's own text. On a news-style
1323
  site, check source lines for agency copy before taking the footer at face value.
1324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1325
  ## `1000_novels` rescreened: unknown authors fail closed, translator death years cited
1326
 
1327
  **Investigated:** 2026-10-06
 
1322
  **Lesson** — an open-licence footer covers the publisher's own text. On a news-style
1323
  site, check source lines for agency copy before taking the footer at face value.
1324
 
1325
+ ## samorzad_gov_pl — third-party slices dropped (2026-10-06)
1326
+
1327
+ **Verdict** — kept, relabelled, 144 rows dropped: 72,472 → 72,328 documents,
1328
+ 40,011,099 → 39,890,244 tokens (baseline: main after #46, not the v0.2.5 tag's
1329
+ 72,771). The basis is now called an operator-declared platform licence. A question
1330
+ to KPRM is pending (polish-dynaword-v2 #49); its answer may still change the
1331
+ source's status. The drops are in `src/clean_samorzad_gov_pl.py`
1332
+ (`third_party_drop`, applied by `--refilter-release` to the pinned release):
1333
+ - 69 "Piątek z poezją" posts (all Powiat Sokołowski): poems credited to their
1334
+ authors. All 69 hand-checked.
1335
+ - 9 IMGW-PIB notices carrying "Opracowanie niniejsze i jego format…", which forbids
1336
+ changes and requires naming IMGW-PIB. All 9 hand-checked.
1337
+ - 66 articles whose `Źródło:` line credits a non-governmental source (Wikipedia,
1338
+ media, associations including volunteer fire brigades, foundations, clubs, rural
1339
+ housewives' circles, companies, named books or brochures), unless a photo or film
1340
+ marker precedes it on the line. All 66 hand-checked as third-party text. The rule
1341
+ was revised on the same matches (first pass 61 of 67 correct), so precision is
1342
+ in-sample and recall is unknown; one known miss is a Fundacja Santander credit.
1343
+ Part of the regex lists work titles found in that review.
1344
+ - Not dropped: contest entries. The issue's 112 is not reproducible; the closest
1345
+ regex (awarded/winning/distinguished works) gives 111 documents, and a 40-document
1346
+ sample (seed 49) contains no entry text: they are results announcements. Only 3
1347
+ documents publishing entries were found; most entries are images, not text.
1348
+
1349
+ **Reason** — gov.pl's copyright page says the service also carries third-party works
1350
+ whose use requires the owners' consent; the footer licence cannot cover them.
1351
+ Credits matter here: 810 documents have an `Źródło:` line, but in 405 every credit is
1352
+ only a de-identified `<URL>`, so their sources cannot be classified; 231 documents
1353
+ mention IMGW without the verbatim notice and were not reviewed.
1354
+
1355
+ References: polish-dynaword-v2 #49;
1356
+ `rights_audit_2026-10/reports/govweb.md` L8-15; `reports/citations/samorzad_nonsa.md`
1357
+ S1, S8, C4; <https://www.gov.pl/web/gov/prawa-autorskie> (read 2026-10-05).
1358
+
1359
+ **Lesson** — de-identification that replaces URLs also removes the provenance needed
1360
+ to screen reposts. Record the credited domain before masking URLs.
1361
+
1362
+ ## global_voices — partner republications dropped (2026-10-06)
1363
+
1364
+ **Verdict** — `admitted` with 114 posts withheld (polish-dynaword-v2 #50). The source
1365
+ goes from 2,040 docs / 10,073,628 chars / 3,715,020 tokens to 1,926 / 9,358,071 /
1366
+ 3,453,918. The posts come from 51 outlets. The new `src/clean_global_voices.py` filters
1367
+ the v0.2.5 Parquet and sidecar, pinned by SHA-256. `src/test_global_voices_contract.py`
1368
+ checks that no shipped row matches the rule.
1369
+
1370
+ **Reason** — Global Voices licenses "content created by Global Voices" under CC BY 3.0.
1371
+ A post that republishes a partner's article under a content-sharing agreement or with
1372
+ permission stays the partner's work.
1373
+ - **Where the rule looks.** It reads only the first 700 and last 350 characters, where
1374
+ the editorial note sits. A rule fires only on a sentence about the post itself that
1375
+ does not name Global Voices, so news reporting ("raport opublikowany przez UNESCO")
1376
+ and GV's own projects do not count. Sentences whose subject is an image are skipped
1377
+ too.
1378
+ - **Rule counts** (a post can match several):
1379
+ - originally: 69
1380
+ - agreement: 56
1381
+ - published_by: 51
1382
+ - partnership: 11
1383
+ - permission: 5
1384
+ - republished: 5
1385
+ - written_for: 3
1386
+ - non_commercial: 3
1387
+ - listed by hand: 3 (21466, 27005, 32352)
1388
+ - **Hand check.**
1389
+ - Every one of the 114 drops was read, and the English original was consulted where
1390
+ the note was unclear.
1391
+ - 25 rule matches are kept by hand with a stated reason:
1392
+ - 12 cross-posts from the author's own blog;
1393
+ - 7 posts GV wrote for the ISN blog;
1394
+ - 3210, a GV post that another outlet republished;
1395
+ - 2 notes dating GV's own English original;
1396
+ - 3 news mentions.
1397
+ - All 43 posts where the gating removed a raw match were checked. They are image
1398
+ credits, news and GV projects.
1399
+ - 15 partner-organisation accounts with no republication note (e.g. 350.org 22567,
1400
+ Metamorphosis 33071) were checked against the English page and kept.
1401
+ - **Outlets.**
1402
+ - PRI/The World 21
1403
+ - The Stand News 8
1404
+ - Hong Kong Free Press 7
1405
+ - Agência Pública 6
1406
+ - Metamorphosis/Meta.mk 5
1407
+ - 350.org 5
1408
+ - Eurasianet 3
1409
+ - Freemuse 3
1410
+ - The Irrawaddy 3
1411
+ - 2 each: Balkan Diskurs, Ensia, Kurtural, Loa, MigraMundo, NACLA, Nepali
1412
+ Times/Himalkhabar, Premium Times, Syria Untold, Teplitsa, Transitions
1413
+ - 1 each: 88 Bar, APC.org, Afroféminas, Azerbaijan Internet Watch, Baynana, Bumaga,
1414
+ CHRI, Cari-Bois, Chaikhana, Common Dreams, Connectas, Doha News, Fundación MEPI,
1415
+ GCHR, Hive-Mind/EJO, Iran Voices, New America Media, OC Media, Periodismo de
1416
+ Barrio, Promundo, Russia Post, Sin Embargo, Syria Deeply, TJournal, Tea After
1417
+ Twelve, The Isaan Record, The Moscow Times, VideoVolunteers, WITNESS,
1418
+ inmediahk.net, openDemocracy.
1419
+ - **Delta against the audit's 64.** The audit used outlet names plus an agreement
1420
+ regex, and it recorded neither the list nor the script. Its "17 PRI" is an
1421
+ undercount: all 21 posts credited to PRI/PRX's The World carry a republication note.
1422
+ Most of the remaining difference is outlets the audit's name list did not cover,
1423
+ such as The Stand News (8) and Agência Pública (6). The Hub PR has per-document
1424
+ evidence.
1425
+ - **Borderline; dropped and flagged for review.**
1426
+ - Freemuse ×3: the note allows republication "by non-commercial media" only.
1427
+ - Bumaga 30003: a shorter version of the author's article for Bumaga.
1428
+ - Hive-Mind/EJO 34820.
1429
+ - openDemocracy 29544: "under a Creative Commons licence", version not stated.
1430
+ - Transitions 34277: "powstał dzięki umowie partnerskiej", possibly a co-production.
1431
+ - 32352: built on two Meta.mk texts.
1432
+
1433
+ **Lesson** — the licence covers what the publisher created. A per-post editorial note
1434
+ is the only signal of a partner's work, so the filter has to read the note and not only
1435
+ the byline.
1436
+
1437
  ## `1000_novels` rescreened: unknown authors fail closed, translator death years cited
1438
 
1439
  **Investigated:** 2026-10-06
data/global_voices/NOTICE.md CHANGED
@@ -6,6 +6,8 @@ original authors and translators under Creative Commons Attribution 3.0.
6
  Source: https://pl.globalvoices.org/
7
  License: https://creativecommons.org/licenses/by/3.0/
8
 
9
- Per-record contributor attribution is stored in the `author` column. The accompanying `global_voices.attribution.jsonl` sidecar additionally preserves each released article's title, canonical URL, license URL and modification notice. Twelve historical records had no machine-readable contributor field; full-text review recovered Didem Tali and Khalid Ibrahim for two of them. Ten records without an identifiable contributor use the explicitly organizational attribution `Global Voices`; this must not be interpreted as a known individual author.
 
 
10
 
11
  Binary media files are not included. Articles may nevertheless contain captions, URLs, social-media posts and quotations from third-party works; rights in those materials may remain with their respective authors. Article-level CC BY 3.0 is not asserted independently for photographs, videos, embeds or separately quoted works.
 
6
  Source: https://pl.globalvoices.org/
7
  License: https://creativecommons.org/licenses/by/3.0/
8
 
9
+ Per-record contributor attribution is stored in the `author` column. The accompanying `global_voices.attribution.jsonl` sidecar additionally preserves each released article's title, canonical URL, license URL and modification notice. Eleven released records had no machine-readable contributor field; full-text review recovered Khalid Ibrahim for one of them. Ten records without an identifiable contributor use the explicitly organizational attribution `Global Voices`; this must not be interpreted as a known individual author.
10
+
11
+ Posts that Global Voices republished from partner outlets (for example PRI's The World, Hong Kong Free Press, The Stand News, Meta.mk and 350.org) are not included. Their text remains the partner's work, and the Global Voices CC BY 3.0 grant does not demonstrably cover it.
12
 
13
  Binary media files are not included. Articles may nevertheless contain captions, URLs, social-media posts and quotations from third-party works; rights in those materials may remain with their respective authors. Article-level CC BY 3.0 is not asserted independently for photographs, videos, embeds or separately quoted works.
data/global_voices/global_voices.attribution.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ab8ad393c4453524c4f3d7fe89157bfca1d9f66f2a735815f3b1ebd405c8fa13
3
- size 1146354
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4709fcc9a53bb5d7d1a90eb29d2b6e8f398c28bfb842f9be0710353e9a4e691
3
+ size 1078938
data/global_voices/global_voices.md CHANGED
@@ -17,7 +17,7 @@ Global Voices describes its Lingua translations as human-made work performed by
17
 
18
  | documents | characters | tokens (`cl100k_base` proxy) |
19
  |---:|---:|---:|
20
- | 2,040 | 10,073,628 | 3,715,020 |
21
 
22
  The Parquet schema matches DynaWord:
23
 
@@ -34,7 +34,7 @@ Published files:
34
 
35
  Articles were acquired directly from the Polish Global Voices website through its official publication interfaces, rather than from a third-party corpus. Each released ID is linked to the corresponding canonical article URL in `global_voices.attribution.jsonl`.
36
 
37
- The source release contained 2,044 records. Four records below the minimum quality and length requirements were excluded, leaving 2,040 documents. The final source contains no exact duplicate documents.
38
 
39
  ## Cleaning
40
 
@@ -46,7 +46,19 @@ The cleaning process did not use machine translation or automatic speech transcr
46
 
47
  CC BY 3.0 was verified from the article-level license link published with each retained Global Voices article. Each released record carries `CC-BY-3.0` metadata. Contributor roles are preserved in the `author` column where available, distinguishing original authors from Polish translators.
48
 
49
- Because the fixed DynaWord schema does not contain article titles or URLs, the attribution sidecar maps every released `id` to its title, canonical URL, contributor attribution, license URL and modification notice. It contains one unique URL-bearing record for each of the 2,040 Parquet documents.
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  Recommended attribution:
52
 
 
17
 
18
  | documents | characters | tokens (`cl100k_base` proxy) |
19
  |---:|---:|---:|
20
+ | 1,926 | 9,358,071 | 3,453,918 |
21
 
22
  The Parquet schema matches DynaWord:
23
 
 
34
 
35
  Articles were acquired directly from the Polish Global Voices website through its official publication interfaces, rather than from a third-party corpus. Each released ID is linked to the corresponding canonical article URL in `global_voices.attribution.jsonl`.
36
 
37
+ The source release contained 2,044 records. Four records below the minimum quality and length requirements were excluded, leaving 2,040 documents. A later rights review excluded 114 posts that Global Voices republished from partner outlets (see below), leaving 1,926 documents. The final source contains no exact duplicate documents.
38
 
39
  ## Cleaning
40
 
 
46
 
47
  CC BY 3.0 was verified from the article-level license link published with each retained Global Voices article. Each released record carries `CC-BY-3.0` metadata. Contributor roles are preserved in the `author` column where available, distinguishing original authors from Polish translators.
48
 
49
+ Because the fixed DynaWord schema does not contain article titles or URLs, the attribution sidecar maps every released `id` to its title, canonical URL, contributor attribution, license URL and modification notice. It contains one unique URL-bearing record for each of the 1,926 Parquet documents.
50
+
51
+ ### Partner republications (excluded)
52
+
53
+ Global Voices licenses the content it creates under CC BY 3.0. Some posts instead republish an article that a partner outlet published first, under a content-sharing agreement or with the outlet's permission. That text remains the partner's work, so the release excludes it. `src/clean_global_voices.py` finds the editorial note such posts carry in their opening or closing lines (for example "pierwotnie ukazał się na portalu PRI.org … w ramach umowy o wymianie treści"). It also excludes three posts whose note the rules miss and keeps 25 look-alike notes, each with a stated reason. Every match was checked by hand.
54
+
55
+ The rule excluded 114 posts from 51 outlets. The largest groups are PRI/The World (21), The Stand News (8), Hong Kong Free Press (7), Agência Pública (6), Metamorphosis/Meta.mk (5) and 350.org (5). Three Freemuse co-commissions are excluded because their note allows republication only by non-commercial media.
56
+
57
+ The following posts are kept:
58
+ - posts that Global Voices contributors cross-posted from their own blogs;
59
+ - posts Global Voices wrote for the ISN blog;
60
+ - posts that partner organisations wrote directly for Global Voices without a republication note;
61
+ - photo-only permission credits.
62
 
63
  Recommended attribution:
64
 
data/global_voices/global_voices.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1ca02fdb6bad32b20757ddcd9b9f072056ff35b68c487143138cc7912b3a45c3
3
- size 5253559
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd33133703e9ea375060cf2f83c2aec915d9786db5fd7d4b34fc2f3643c9c7ba
3
+ size 4907377
data/global_voices/global_voices.stats.json CHANGED
@@ -1,15 +1,34 @@
1
  {
2
  "read": 2044,
3
- "kept": 2040,
4
  "drop_short": 4,
5
  "drop_lang": 0,
6
  "drop_dup": 0,
7
  "drop_ocr": 0,
8
- "chars": 10073628,
9
- "tokens": 3715020,
 
10
  "licenses": {
11
- "CC-BY-3.0": 2040
12
  },
13
- "authors_with_value": 2040,
14
- "stats_recomputed_from_parquet": true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
 
1
  {
2
  "read": 2044,
3
+ "kept": 1926,
4
  "drop_short": 4,
5
  "drop_lang": 0,
6
  "drop_dup": 0,
7
  "drop_ocr": 0,
8
+ "drop_partner_republication": 114,
9
+ "chars": 9358071,
10
+ "tokens": 3453918,
11
  "licenses": {
12
+ "CC-BY-3.0": 1926
13
  },
14
+ "authors_with_value": 1926,
15
+ "stats_recomputed_from_parquet": true,
16
+ "partner_republication": {
17
+ "by_rule": {
18
+ "agreement": 56,
19
+ "non_commercial": 3,
20
+ "originally": 69,
21
+ "partnership": 11,
22
+ "permission": 5,
23
+ "published_by": 51,
24
+ "republished": 5,
25
+ "written_for": 3
26
+ },
27
+ "listed": 3,
28
+ "kept_by_hand": 25
29
+ },
30
+ "input_sha256": {
31
+ "global_voices.parquet": "1ca02fdb6bad32b20757ddcd9b9f072056ff35b68c487143138cc7912b3a45c3",
32
+ "global_voices.attribution.jsonl": "ab8ad393c4453524c4f3d7fe89157bfca1d9f66f2a735815f3b1ebd405c8fa13"
33
+ }
34
  }
data/samorzad_gov_pl/NOTICE.md CHANGED
@@ -4,11 +4,25 @@ The `samorzad_gov_pl` source contains textual articles collected from public
4
  pages hosted on the shared [samorzad.gov.pl](https://samorzad.gov.pl/)
5
  platform.
6
 
7
- The platform footer states that textual content published in the service,
8
- excluding audiovisual content, is available under the [Creative Commons
 
9
  Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)
10
  license (`CC-BY-SA-4.0`). Every page in the published v0.2 source dataset belongs
11
- to the v0.1 source set for which the shared footer reference was verified.
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  For every released DynaWord document:
14
 
@@ -17,8 +31,8 @@ For every released DynaWord document:
17
  fetched `final_url`, recommended `attribution_url`, article title,
18
  institution, tenant identifier, license URL and modification notice;
19
  - article text was extracted from source HTML and de-identified upstream;
20
- - this contribution normalizes metadata and excludes short, non-Polish or
21
- duplicate records.
22
 
23
  When redistributing or adapting these texts, retain the source attribution,
24
  indicate changes and distribute adaptations under compatible
 
4
  pages hosted on the shared [samorzad.gov.pl](https://samorzad.gov.pl/)
5
  platform.
6
 
7
+ The licence basis is an operator-declared platform licence: the platform
8
+ footer states that textual content published in the service, excluding
9
+ audiovisual content, is available under the [Creative Commons
10
  Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)
11
  license (`CC-BY-SA-4.0`). Every page in the published v0.2 source dataset belongs
12
+ to the v0.1 source set for which the shared footer reference was verified. The
13
+ agreements between the platform operator and the publishing institutions are
14
+ not published, and no per-institution grant was found. A question to the
15
+ operator (KPRM) is pending
16
+ ([slayerlabs/polish-dynaword-v2#49](https://github.com/slayerlabs/polish-dynaword-v2/issues/49));
17
+ its answer may change this source's status.
18
+
19
+ gov.pl's copyright page states that the service also carries works whose
20
+ copyright belongs to third parties and that their use requires the owners'
21
+ consent (<https://www.gov.pl/web/gov/prawa-autorskie>, read 2026-10-05). The
22
+ platform licence does not cover such works. Rows identified as third-party
23
+ works (Friday poetry posts, IMGW-PIB notices, text credited to a
24
+ non-governmental source) are excluded; third-party text that is not detectable
25
+ from the article text may remain.
26
 
27
  For every released DynaWord document:
28
 
 
31
  fetched `final_url`, recommended `attribution_url`, article title,
32
  institution, tenant identifier, license URL and modification notice;
33
  - article text was extracted from source HTML and de-identified upstream;
34
+ - this contribution normalizes metadata and excludes short, non-Polish,
35
+ duplicate or third-party records.
36
 
37
  When redistributing or adapting these texts, retain the source attribution,
38
  indicate changes and distribute adaptations under compatible
data/samorzad_gov_pl/samorzad_gov_pl.attribution.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2def7488c34e749204842bcf21d33149738b34de2515115e3f79401f7eb271c4
3
- size 72438302
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9c7dc3d049a26fc17fab86ab96b271e94a29159f38cb57ace373dcfef1fab80
3
+ size 73230755
data/samorzad_gov_pl/samorzad_gov_pl.md CHANGED
@@ -13,7 +13,8 @@ institutions and other public bodies.
13
  - **Original platform:** https://samorzad.gov.pl/
14
  - **Domain:** local government, education, social services and culture
15
  - **Language:** Polish (`pl`)
16
- - **License:** `CC-BY-SA-4.0`
 
17
  - **Created:** 2020–2026 for dated records; most source records do not expose a date
18
  - **Added:** 2026-08-14
19
 
@@ -21,7 +22,7 @@ institutions and other public bodies.
21
 
22
  | read | kept | characters | tokens (`cl100k_base` proxy) | publishers |
23
  |---:|---:|---:|---:|---:|
24
- | 81,418 | 72,472 | 107,130,266 | 40,011,099 | 247 |
25
 
26
  The released Parquet uses the canonical DynaWord schema:
27
 
@@ -56,14 +57,24 @@ release gates passed.
56
 
57
  `src/clean_samorzad_gov_pl.py` verifies and converts the v0.2 Parquets into the
58
  DynaWord schema, applies the common minimum-length and Polish-language checks,
59
- removes exact duplicate text and counts tokens with `cl100k_base`. Retained text
60
- is otherwise unchanged after upstream de-identification.
61
-
62
- ## Licensing — traceable basis and attribution
63
-
64
- The platform's shared footer states that textual content published in the
65
- service, excluding audiovisual content, is available under CC BY-SA 4.0. A
66
- release-time audit verified the live shared footer script for all 81,422 pages
 
 
 
 
 
 
 
 
 
 
67
  in the v0.1 source set. The four records omitted from v0.2 were a subset of that
68
  audited set, so every v0.2 article remains covered by the same evidence. The
69
  evidence URL, byte count and SHA-256 digest are recorded in
@@ -76,6 +87,15 @@ publishing institution, platform tenant, license URL and modification notice.
76
  For 688 retained records the discovered and final URLs differ because the
77
  platform redirected the request; `attribution_url` uses the fetched final URL.
78
 
 
 
 
 
 
 
 
 
 
79
  Recommended attribution:
80
 
81
  > Publishing institution listed in the `author` column; article title and
@@ -96,12 +116,37 @@ not redistribute those files.
96
  | shorter than 200 characters | 6,932 |
97
  | below the Polish-language heuristic | 34 |
98
  | exact duplicate text | 1,980 |
99
- | retained | 72,472 |
 
 
 
100
 
101
  Exact duplicate removal is performed after short-text and language checks.
102
  Existing DynaWord sources take priority when the same text is already present
103
  elsewhere in the corpus.
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  ## Limitations and recommended use
106
 
107
  - Automated de-identification reduces but cannot guarantee removal of every
@@ -109,8 +154,11 @@ elsewhere in the corpus.
109
  their use case.
110
  - The collection is not a complete historical archive of samorzad.gov.pl. It
111
  contains the pages found and successfully extracted during one crawl.
112
- - After filtering, 51,964 retained records have an empty `created` value; no
113
  date is inferred for them.
 
 
 
114
  - The source text can contain spelling errors, extraction remnants or captions.
115
  - Very short source records are excluded by DynaWord's 200-character minimum.
116
  - Institution names describe the publishing body, not necessarily the person
@@ -152,6 +200,19 @@ uv run --with pyarrow --with tiktoken python src/clean_samorzad_gov_pl.py \
152
  --added 2026-08-14
153
  ```
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  Use `--refresh-publishers` only when intentionally updating the frozen
156
  institution-name manifest from live tenant homepages. Review any changed name
157
  before publishing a new release.
 
13
  - **Original platform:** https://samorzad.gov.pl/
14
  - **Domain:** local government, education, social services and culture
15
  - **Language:** Polish (`pl`)
16
+ - **License:** `CC-BY-SA-4.0`, an operator-declared platform licence (see
17
+ [Licensing](#licensing--operator-declared-platform-licence))
18
  - **Created:** 2020–2026 for dated records; most source records do not expose a date
19
  - **Added:** 2026-08-14
20
 
 
22
 
23
  | read | kept | characters | tokens (`cl100k_base` proxy) | publishers |
24
  |---:|---:|---:|---:|---:|
25
+ | 81,418 | 72,328 | 106,816,031 | 39,890,244 | 247 |
26
 
27
  The released Parquet uses the canonical DynaWord schema:
28
 
 
57
 
58
  `src/clean_samorzad_gov_pl.py` verifies and converts the v0.2 Parquets into the
59
  DynaWord schema, applies the common minimum-length and Polish-language checks,
60
+ removes exact duplicate text, drops three third-party slices (see
61
+ [Filters applied](#filters-applied)) and counts tokens with `cl100k_base`.
62
+ Retained text is otherwise unchanged after upstream de-identification.
63
+
64
+ ## Licensing — operator-declared platform licence
65
+
66
+ The licence is declared by the platform operator, not by the authors. The
67
+ shared footer of the platform, injected by a template script of the gov.pl
68
+ platform operator (KPRM; formerly Ministry of Digital Affairs), states that
69
+ textual content published in the service, excluding audiovisual content, is
70
+ available under CC BY-SA 4.0. The articles are written by the 247 publishing
71
+ institutions. The agreements those institutions sign with the operator are not
72
+ published, and no document granting the operator a licence from them was found.
73
+ The maintainer has asked KPRM whether the institutions authorise the footer
74
+ licence ([slayerlabs/polish-dynaword-v2#49](https://github.com/slayerlabs/polish-dynaword-v2/issues/49)).
75
+ That answer is pending and may change this source's status.
76
+
77
+ A release-time audit verified the live shared footer script for all 81,422 pages
78
  in the v0.1 source set. The four records omitted from v0.2 were a subset of that
79
  audited set, so every v0.2 article remains covered by the same evidence. The
80
  evidence URL, byte count and SHA-256 digest are recorded in
 
87
  For 688 retained records the discovered and final URLs differ because the
88
  platform redirected the request; `attribution_url` uses the fetched final URL.
89
 
90
+ **Third-party works.** gov.pl's copyright page states that the service also
91
+ carries works whose copyright belongs to third parties and that their use
92
+ requires the owners' consent (https://www.gov.pl/web/gov/prawa-autorskie, read
93
+ 2026-10-05). The platform licence does not reach those works. This release drops
94
+ the third-party slices that a committed rule can identify (see
95
+ [Filters applied](#filters-applied)). Third-party text can remain where nothing
96
+ in the record marks it, e.g. contest entries by pupils or reposts whose source
97
+ line was reduced to a `<URL>` placeholder by de-identification.
98
+
99
  Recommended attribution:
100
 
101
  > Publishing institution listed in the `author` column; article title and
 
116
  | shorter than 200 characters | 6,932 |
117
  | below the Polish-language heuristic | 34 |
118
  | exact duplicate text | 1,980 |
119
+ | third party: "Piątek z poezją" poems | 69 |
120
+ | third party: IMGW-PIB notices | 9 |
121
+ | third party: non-governmental "Źródło:" credit | 66 |
122
+ | retained | 72,328 |
123
 
124
  Exact duplicate removal is performed after short-text and language checks.
125
  Existing DynaWord sources take priority when the same text is already present
126
  elsewhere in the corpus.
127
 
128
+ The third-party drops run after deduplication and are defined by
129
+ `third_party_drop()` in `src/clean_samorzad_gov_pl.py`. Every dropped document
130
+ was read by hand before release.
131
+
132
+ - **"Piątek z poezją" poems:** the title contains `Piątek z poezją`. All 69 are
133
+ from Powiat Sokołowski and reprint poems credited to named authors.
134
+ - **IMGW-PIB notices:** the text contains `Opracowanie niniejsze i jego format`.
135
+ These meteorological warnings allow further sharing only verbatim with
136
+ IMGW-PIB named, which CC BY-SA's permission to adapt cannot honour
137
+ (9 documents from Gmina Bodzechów, Gmina Ciężkowice and Gmina Leżajsk).
138
+ - **Non-governmental "Źródło:" credit:** a line's first `Źródło:` ("Source:")
139
+ credits a non-public author: Wikipedia, newspapers, radio and television,
140
+ associations (including volunteer fire brigades), foundations, clubs, rural
141
+ housewives' circles, companies, or a named book, memoir or brochure. A credit
142
+ preceded on the same line by a photo, illustration or film marker (`Fot.`,
143
+ `Ilustracja`, `film`) credits the image, not the text, and is not matched.
144
+ Credits to public bodies, including associations of local governments, are
145
+ not matched. 810 documents have an `Źródło:` line: in 405 every credit is
146
+ only a de-identified `<URL>` placeholder, which cannot be classified; 66 of
147
+ the 405 with a named credit are dropped. The 339 kept named credits were not
148
+ individually reviewed.
149
+
150
  ## Limitations and recommended use
151
 
152
  - Automated de-identification reduces but cannot guarantee removal of every
 
154
  their use case.
155
  - The collection is not a complete historical archive of samorzad.gov.pl. It
156
  contains the pages found and successfully extracted during one crawl.
157
+ - After filtering, 51,834 retained records have an empty `created` value; no
158
  date is inferred for them.
159
+ - Third-party text that carries no title, notice or source line naming its
160
+ author is not detected. This includes most contest entries and reposts whose
161
+ `Źródło:` line holds only a `<URL>` placeholder.
162
  - The source text can contain spelling errors, extraction remnants or captions.
163
  - Very short source records are excluded by DynaWord's 200-character minimum.
164
  - Institution names describe the publishing body, not necessarily the person
 
200
  --added 2026-08-14
201
  ```
202
 
203
+ The third-party drops were applied to the release above in place with:
204
+
205
+ ```bash
206
+ uv run --with pyarrow python src/clean_samorzad_gov_pl.py --refilter-release
207
+ ```
208
+
209
+ `--refilter-release` refuses to run unless the Parquet and sidecar in
210
+ `data/samorzad_gov_pl/` match the SHA-256 values of the pre-carve-out release
211
+ (`PRE_CARVE_OUT_SHA256`). It drops the matching rows, recomputes the row-derived
212
+ statistics and writes through the same staged, validated replacement as a full
213
+ build. A full build applies the same `third_party_drop()` at the same point,
214
+ after deduplication.
215
+
216
  Use `--refresh-publishers` only when intentionally updating the frozen
217
  institution-name manifest from live tenant homepages. Review any changed name
218
  before publishing a new release.
data/samorzad_gov_pl/samorzad_gov_pl.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3a683b4220b9b70698d7c524637d9ea5c1d72630b8f92ea7a871642a719cf2c0
3
- size 49612214
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9a43a5d6f2407033e95af132ef4d6996ae98ab73f553b9261b6f18a734ae4db
3
+ size 49498053
data/samorzad_gov_pl/samorzad_gov_pl.stats.json CHANGED
@@ -1,22 +1,27 @@
1
  {
2
- "authors_with_value": 72472,
3
  "central_tenant_count": 1,
4
- "chars": 107130266,
5
  "cross_source_hashes_loaded": 4255011,
6
  "drop_dup": 1980,
7
  "drop_lang": 34,
8
  "drop_ocr": 0,
9
  "drop_short": 6932,
10
- "kept": 72472,
 
 
 
 
 
11
  "license": "CC-BY-SA-4.0",
12
  "licenses": {
13
- "CC-BY-SA-4.0": 72472
14
  },
15
  "local_public_tenant_count": 246,
16
  "publisher_count": 247,
17
  "read": 81418,
18
  "redirected_urls": 688,
19
- "tokens": 40011099,
20
  "upstream_artifact_count": 10,
21
  "upstream_dataset": "dawidmajewski/samorzad-gov-pl-articles",
22
  "upstream_deidentification_model": "ArkadiuszPawlak/fastpdn-ner-polish-pii",
 
1
  {
2
+ "authors_with_value": 72328,
3
  "central_tenant_count": 1,
4
+ "chars": 106816031,
5
  "cross_source_hashes_loaded": 4255011,
6
  "drop_dup": 1980,
7
  "drop_lang": 34,
8
  "drop_ocr": 0,
9
  "drop_short": 6932,
10
+ "drop_third_party": {
11
+ "imgw_notice": 9,
12
+ "nongov_source": 66,
13
+ "poetry_friday": 69
14
+ },
15
+ "kept": 72328,
16
  "license": "CC-BY-SA-4.0",
17
  "licenses": {
18
+ "CC-BY-SA-4.0": 72328
19
  },
20
  "local_public_tenant_count": 246,
21
  "publisher_count": 247,
22
  "read": 81418,
23
  "redirected_urls": 688,
24
+ "tokens": 39890244,
25
  "upstream_artifact_count": 10,
26
  "upstream_dataset": "dawidmajewski/samorzad-gov-pl-articles",
27
  "upstream_deidentification_model": "ArkadiuszPawlak/fastpdn-ner-polish-pii",
src/clean_global_voices.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Drop Global Voices posts republished from partner outlets (slayerlabs/polish-dynaword-v2#50).
3
+
4
+ Global Voices licenses "content created by Global Voices" under CC BY 3.0. Posts it republished
5
+ from partner outlets (PRI's The World, Hong Kong Free Press, The Stand News, Meta.mk, 350.org,
6
+ The Irrawaddy, ...) under content-sharing agreements or with permission stay the partner's work,
7
+ so the CC BY grant does not demonstrably cover them. Each such post carries an editorial note in
8
+ its first or last lines, e.g. "Ten artykuł ... pierwotnie ukazał się na portalu PRI.org ... i jest
9
+ publikowany ponownie w ramach umowy o wymianie treści". `note_rules()` finds those notes.
10
+
11
+ Kept on purpose: posts that GV contributors cross-posted from their own blogs, posts GV wrote for
12
+ the ISN partnership, partner organisations writing directly for GV with no republication note,
13
+ and photo-only permission credits ("Zdjęcie ..., użyte za pozwoleniem").
14
+
15
+ The input is the Parquet and sidecar as of v0.2.5 (the Parquet is unchanged since), pinned by
16
+ SHA-256. Restore them before a rerun:
17
+ git checkout 92b36dc -- data/global_voices/global_voices.parquet data/global_voices/global_voices.attribution.jsonl
18
+ python3 src/clean_global_voices.py
19
+ """
20
+ from __future__ import annotations
21
+
22
+ import argparse
23
+ import hashlib
24
+ import json
25
+ import os
26
+ import re
27
+ from collections import Counter
28
+ from pathlib import Path
29
+
30
+ import pyarrow.parquet as pq
31
+
32
+ SOURCE = "global_voices"
33
+ ROOT = Path(__file__).resolve().parents[1]
34
+ DATA = ROOT / "data" / SOURCE
35
+ INPUT_SHA256 = {
36
+ f"{SOURCE}.parquet": "1ca02fdb6bad32b20757ddcd9b9f072056ff35b68c487143138cc7912b3a45c3",
37
+ f"{SOURCE}.attribution.jsonl": "ab8ad393c4453524c4f3d7fe89157bfca1d9f66f2a735815f3b1ebd405c8fa13",
38
+ }
39
+
40
+ # The contributed release (PR #7) read 2,044 records and dropped 4 short ones before the v0.2.5 input.
41
+ READ, DROP_SHORT = 2044, 4
42
+ # Editorial notes sit in the lede or the closing lines; the body quotes and reports on
43
+ # agreements, first publications and permissions far too often to search it.
44
+ HEAD, TAIL = 700, 350
45
+ # Sentence ends before an upper-case start or at a paragraph break, so "umowy dot. współdzielenia" holds.
46
+ SENTENCE = re.compile(r"(?<=[.!?])\s+(?=[^\sa-ząćęłńóśźż])|\s*\n+\s*")
47
+ PUB = r"(?:opublik|publik|ukaza|ukazuj|pojawi|przedruk|zamieszcz|udostępni|reprodukow|wydan)\w*"
48
+ FIRST = r"(?:pierwotnie|oryginalnie|orginalnie|po\s+raz\s+pierwszy|pierwszy\s+raz|początkowo|uprzednio|wcześniej|najpierw|w\s+oryginale)"
49
+ NOT_GV = r"(?!Global\s*Voices|GV\b|globalvoices|ramach|naszym|niniejszym|tym\b)"
50
+ # A note speaks about the post itself: "Ten artykuł ...", "Poniżej publikujemy zredagowaną wersję artykułu ...",
51
+ # "Jest to trzecia odsłona historii ...", "Opublikowano za zgodą PRI".
52
+ SELF = re.compile(
53
+ r"^\W*(?:\S+\s+){0,2}?(?:artykuł|tekst|post|wpis|histori|reportaż|wywiad|wiadomoś|wersj|seri|częś|materiał|opowieś|esej|treś)\w{0,3}\b"
54
+ rf"|^\W*(?:Jest|Są)\s+to\b|^\W*(?:\S+\s+)?{PUB}", re.I)
55
+ GV = re.compile(r"\bGV\b|Global\s*Voices|Rising\s*Voices", re.I)
56
+ # Photo, art and video credits ("Zdjęcie: ... Opublikowano za zgodą.") are not text republications;
57
+ # their sentences do not open with a text noun, and a bare permission line right after one belongs to it.
58
+ IMAGE = r"zdj[eę]ci|zdjęć|fotograf|\bfot\.|ilustracj|obraz|grafik|wideo|\bfilm|nagrani|plakat|rysun|karykatur|okład|zrzut|\bmap"
59
+ CREDIT = re.compile(rf"^\W*(?:\S+\s+)?\S*?(?:{IMAGE})", re.I) # an image is the subject
60
+
61
+ RULES = {
62
+ # "w ramach umowy o wymianie treści", "na mocy porozumienia o dzieleniu się treściami",
63
+ # "umowy partnerskiej", "porozumienie z Global Voices"
64
+ "agreement": re.compile(
65
+ r"\b(?:umow|porozumie)\w*\s+(?:\w+\s+){0,3}?(?:o\s+|dot\.\s*|dotycząc\w*\s+|w\s+sprawie\s+)?"
66
+ r"(?:wymian|udostępn|dzieleni|współdziel|podzia|rozpowszechn|partnersk|partnerstw)\w*"
67
+ r"|\bporozumieni\w*\s+z\s+Global\s+Voices", re.I),
68
+ # "w ramach partnerstwa pomiędzy PRI i Global Voices", "w ramach naszej współpracy z Syria Deeply",
69
+ # "post partnerski ze strony EurasiaNet.org"
70
+ "partnership": re.compile(
71
+ r"(?:w\s+ramach|na\s+mocy|na\s+podstawie|jako\s+część)\s+(?:\w+\s+){0,2}?(?:partnerstw|współprac)\w*\s+"
72
+ r"(?:\w+\s+){0,3}?(?:z|pomiędzy|między)\s"
73
+ r"|\bpost\w*\s+partnersk\w*|\bpartnersk\w*\s+post\w*", re.I),
74
+ # "pierwotnie ukazał się na portalu PRI.org", "pojawił się po raz pierwszy na stronie CHRI",
75
+ # "Oryginalny tekst [ru] dostępny na stronie Teplicy"
76
+ "originally": re.compile(
77
+ rf"{FIRST}\s+(?:\S+\s+){{0,6}}?(?:{PUB}|ujrzał\w*)|{PUB}\s+(?:\S+\s+){{0,2}}?{FIRST}"
78
+ r"|oryginaln\w*\s+(?:\[\w+\]\s+)?(?:wersj|tekst|artykuł|publikacj)\w*", re.I),
79
+ # "Ta republikacja", "jest tutaj reprodukowany", "poniższa reedycja"
80
+ "republished": re.compile(r"\brepublikacj\w*|reprodukowan\w*|przedrukowan\w*|reedycj\w*", re.I),
81
+ # "napisany przez Fentona Lutunatabua dla 350.org", "artykułu napisanego przez Irinę Illa Pueyo dla Afroféminas"
82
+ "written_for": re.compile(rf"napisan\w*\s+(?:\S+\s+){{0,6}}?dla\s+{NOT_GV}", re.I),
83
+ # "Artykuł został opublikowany na stronie internetowej Agência Pública", "część artykułu opublikowanego na łamach The Stand News"
84
+ "published_by": re.compile(
85
+ rf"(?:artykuł|tekst|post|wpis|histori|reportaż|wywiad|wiadomoś|wersj|seri)\w*\s+(?:\S+\s+){{0,8}}?"
86
+ rf"(?:opublikowan|publikowan|ukazał|pojawił)\w*\s+(?:\S+\s+){{0,3}}?"
87
+ rf"(?:na\s+stronie|na\s+łamach|na\s+portalu|w\s+serwisie|na\s+blogu|przez|w)\s+{NOT_GV}", re.I),
88
+ # "Opublikowano za zgodą PRI", "Opublikowany za pozwoleniem." (the author's or artist's own consent is not a partner's)
89
+ "permission": re.compile(
90
+ rf"{PUB}\s+(?:\S+\s+){{0,6}}?(?:za|ze|z)\s+(?:\S+\s+)?(?:zgodą|pozwoleniem|przyzwoleniem)(?!\s+(?:autor|artyst))", re.I),
91
+ # Freemuse co-commissions: "may be republished by non-commercial media" conflicts with CC BY
92
+ "non_commercial": re.compile(r"niekomercyjn\w*\s+medi|non-commercial\s+media", re.I),
93
+ }
94
+ # Rules that fire only on a sentence about the post itself that does not name Global Voices,
95
+ # so news reporting ("raport opublikowany przez UNESCO") and GV's own projects do not count.
96
+ SELF_RULES = {"originally", "republished", "written_for", "published_by", "permission"}
97
+
98
+ # Notes a rule matches that are not partner republications, checked by hand against the text
99
+ # and, where unclear, the English original on globalvoices.org.
100
+ OWN_BLOG = "the GV author's cross-post from their own blog"
101
+ ISN = "written by GV for the ISN blog under the GV-ISN partnership"
102
+ KEEP = {
103
+ **{f"global_voices_{n}": OWN_BLOG + " (Juan Arellano, Globalizado)"
104
+ for n in (7749, 11971, 18309, 20340, 21612, 22399, 25101)},
105
+ "global_voices_1420": OWN_BLOG + " (Georgia Popplewell, Caribbean Free Radio)",
106
+ "global_voices_23554": OWN_BLOG + " (Elia Ayoub, Hummus For Thought)",
107
+ "global_voices_28150": OWN_BLOG + " (Jillian C. York)",
108
+ "global_voices_28814": OWN_BLOG + " (Anca Matioc, Medium)",
109
+ "global_voices_29905": OWN_BLOG + " (Derek Lackaff, r12n)",
110
+ **{f"global_voices_{n}": ISN for n in (13370, 14712, 14881, 14946, 15662, 17435, 18724)},
111
+ "global_voices_3210": "a GV post that Ezhednevny Zhurnal republished, not the reverse",
112
+ "global_voices_15986": "dates GV's own English original",
113
+ "global_voices_22228": "dates GV's own English original",
114
+ "global_voices_8": "news about an AOL partnership deal",
115
+ "global_voices_14503": "news: a quoted blogger's posts also ran in The Guardian",
116
+ "global_voices_15837": "news: interviews published on the Mujeres Mundi blog",
117
+ }
118
+ # Partner republications whose note no rule matches.
119
+ DROP = {
120
+ "global_voices_21466": "Agência Pública; a long quoted title splits the note",
121
+ "global_voices_27005": "inmediahk.net; the note follows a 1,000-character lede",
122
+ "global_voices_32352": "based on two Meta.mk / CriThink.mk (Metamorphosis Foundation) texts",
123
+ }
124
+
125
+
126
+ def sha256(path: Path) -> str:
127
+ digest = hashlib.sha256()
128
+ with path.open("rb") as stream:
129
+ for chunk in iter(lambda: stream.read(1 << 20), b""):
130
+ digest.update(chunk)
131
+ return digest.hexdigest()
132
+
133
+
134
+ def note_zone(text: str) -> str:
135
+ return text if len(text) <= HEAD + TAIL else text[:HEAD] + "\n" + text[-TAIL:]
136
+
137
+
138
+ def note_rules(text: str) -> list[str]:
139
+ """Names of the rules whose pattern matches a sentence in the post's opening or closing lines."""
140
+ hits = []
141
+ previous = ""
142
+ for sentence in SENTENCE.split(note_zone(text)):
143
+ about_post = SELF.search(sentence) and not GV.search(sentence) and not CREDIT.search(sentence)
144
+ for name, rule in RULES.items():
145
+ if name in hits or (name in SELF_RULES and not about_post):
146
+ continue
147
+ if name == "permission" and re.search(IMAGE, previous, re.I):
148
+ continue
149
+ if rule.search(sentence):
150
+ hits.append(name)
151
+ previous = sentence
152
+ return hits
153
+
154
+
155
+ def reason(doc_id: str, text: str) -> str | None:
156
+ """Why a row is dropped (rule names, or the DROP note), or None to keep it."""
157
+ if doc_id in DROP:
158
+ return "listed: " + DROP[doc_id]
159
+ if doc_id in KEEP:
160
+ return None
161
+ hits = note_rules(text)
162
+ return "+".join(hits) if hits else None
163
+
164
+
165
+
166
+ def build(input_dir: Path, out_dir: Path) -> dict:
167
+ parquet, sidecar = (input_dir / name for name in INPUT_SHA256)
168
+ for path, expected in zip((parquet, sidecar), INPUT_SHA256.values()):
169
+ if sha256(path) != expected:
170
+ raise SystemExit(f"{path} is not the v0.2.5 input; restore it with the command in this script's docstring")
171
+ table = pq.read_table(parquet)
172
+ lines = sidecar.read_text(encoding="utf-8").splitlines(keepends=True)
173
+ ids = table.column("id").to_pylist()
174
+ sidecar_ids = [json.loads(line)["id"] for line in lines]
175
+ if len(set(ids)) != len(ids) or set(ids) != set(sidecar_ids) or len(sidecar_ids) != len(ids):
176
+ raise SystemExit("Parquet and attribution sidecar do not cover the same ids")
177
+ if stale := (KEEP.keys() | DROP.keys()) - set(ids):
178
+ raise SystemExit(f"KEEP/DROP name ids that are not in the input: {sorted(stale)}")
179
+
180
+ rows = table.to_pylist()
181
+ dropped = {row["id"]: why for row in rows if (why := reason(row["id"], row["text"]))}
182
+ kept = [row for row in rows if row["id"] not in dropped]
183
+ rules = Counter(name for why in dropped.values() if not why.startswith("listed: ") for name in why.split("+"))
184
+ stats = {
185
+ "read": READ, "kept": len(kept),
186
+ "drop_short": DROP_SHORT, "drop_lang": 0, "drop_dup": 0, "drop_ocr": 0,
187
+ "drop_partner_republication": len(dropped),
188
+ "chars": sum(len(r["text"]) for r in kept), "tokens": sum(r["token_count"] for r in kept),
189
+ "licenses": dict(Counter(r["license"] for r in kept)), "authors_with_value": sum(bool(r["author"]) for r in kept),
190
+ "stats_recomputed_from_parquet": True,
191
+ "partner_republication": {
192
+ "by_rule": dict(sorted(rules.items())),
193
+ "listed": sum(why.startswith("listed: ") for why in dropped.values()),
194
+ "kept_by_hand": len(KEEP),
195
+ },
196
+ "input_sha256": INPUT_SHA256,
197
+ }
198
+ staged = {
199
+ out_dir / f"{SOURCE}.parquet.tmp": lambda p: pq.write_table(
200
+ table.from_pylist(kept, schema=table.schema), p, compression="zstd"),
201
+ out_dir / f"{SOURCE}.attribution.jsonl.tmp": lambda p: p.write_text(
202
+ "".join(line for line, i in zip(lines, sidecar_ids) if i not in dropped), encoding="utf-8"),
203
+ out_dir / f"{SOURCE}.stats.json.tmp": lambda p: p.write_text(
204
+ json.dumps(stats, indent=2, ensure_ascii=False) + "\n", encoding="utf-8"),
205
+ }
206
+ for path, write in staged.items():
207
+ write(path)
208
+ for path in staged:
209
+ os.replace(path, path.with_suffix(""))
210
+ return {**stats, "dropped": dropped}
211
+
212
+
213
+ def main() -> None:
214
+ parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
215
+ parser.add_argument("--input", type=Path, default=DATA, help="directory holding the v0.2.5 Parquet and sidecar")
216
+ parser.add_argument("--out", type=Path, default=DATA)
217
+ args = parser.parse_args()
218
+ print(json.dumps(build(args.input, args.out), indent=2, ensure_ascii=False))
219
+
220
+
221
+ if __name__ == "__main__":
222
+ main()
src/clean_samorzad_gov_pl.py CHANGED
@@ -48,6 +48,58 @@ _SITE_NAME_RE = re.compile(
48
  re.IGNORECASE | re.DOTALL,
49
  )
50
  _TITLE_RE = re.compile(r"<title\b[^>]*>(.*?)</title>", re.IGNORECASE | re.DOTALL)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  DYNAWORD_SCHEMA = pa.schema(
52
  [
53
  ("id", pa.string()),
@@ -250,16 +302,25 @@ def normalize_record(
250
  "license": LICENSE,
251
  "license_url": LICENSE_URL,
252
  "modified": True,
253
- "modification_notice": (
254
- "Article text was extracted from the source HTML and de-identified "
255
- "upstream. This DynaWord release normalizes metadata and may exclude "
256
- "short, non-Polish or duplicate records; retained text is otherwise "
257
- "unchanged after upstream de-identification."
258
- ),
259
  }
260
  return row, attribution
261
 
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  def _polish_ratio(text: str) -> float:
264
  letters = ALPHA_RE.findall(text)
265
  return len(POLISH_RE.findall(text)) / len(letters) if letters else 0.0
@@ -403,10 +464,7 @@ def build(
403
  "drop_lang": 0,
404
  "drop_dup": 0,
405
  "drop_ocr": 0,
406
- "chars": 0,
407
- "tokens": 0,
408
- "licenses": {LICENSE: 0},
409
- "authors_with_value": 0,
410
  "publisher_count": len(publishers),
411
  "local_public_tenant_count": sum(
412
  publisher_type != "central" for publisher_type in tenant_types.values()
@@ -414,7 +472,6 @@ def build(
414
  "central_tenant_count": sum(
415
  publisher_type == "central" for publisher_type in tenant_types.values()
416
  ),
417
- "redirected_urls": 0,
418
  "cross_source_hashes_loaded": len(prior_hashes),
419
  "license": LICENSE,
420
  "upstream_dataset": UPSTREAM_DATASET,
@@ -444,6 +501,12 @@ def build(
444
  stats["drop_dup"] += 1
445
  continue
446
  seen.add(digest)
 
 
 
 
 
 
447
  record["text"] = text
448
  candidates.append(record)
449
 
@@ -462,16 +525,26 @@ def build(
462
  row, attribution = normalize_record(source_row, publishers, token_count, added)
463
  rows.append(row)
464
  attribution_rows.append(attribution)
465
- stats["kept"] += 1
466
- stats["chars"] += len(row["text"])
467
- stats["tokens"] += token_count
468
- stats["licenses"][LICENSE] += 1
469
- stats["authors_with_value"] += int(bool(row["author"]))
470
- stats["redirected_urls"] += int(
471
- attribution["source_url"] != attribution["final_url"]
472
- )
473
 
474
  table = pa.Table.from_pylist(rows, schema=DYNAWORD_SCHEMA)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  with tempfile.TemporaryDirectory(prefix=f".{SOURCE}-", dir=output_dir) as temp:
476
  staged_dir = Path(temp)
477
  staged_parquet = staged_dir / f"{SOURCE}.parquet"
@@ -492,12 +565,38 @@ def build(
492
  )
493
  _validate_staged_release(staged_dir)
494
  _replace_release(staged_dir, output_dir)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  return stats
496
 
497
 
498
  def main() -> None:
499
  parser = argparse.ArgumentParser()
500
- parser.add_argument("--input", type=Path, required=True, help="directory containing source Parquet shards")
501
  parser.add_argument(
502
  "--manifest",
503
  type=Path,
@@ -505,17 +604,27 @@ def main() -> None:
505
  )
506
  parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
507
  parser.add_argument("--publishers", type=Path, default=Path(__file__).with_name("samorzad_gov_pl_publishers.json"))
508
- parser.add_argument("--added", required=True)
509
  parser.add_argument("--refresh-publishers", action="store_true")
510
- args = parser.parse_args()
511
- stats = build(
512
- input_path=args.input,
513
- manifest_path=args.manifest or args.input.parent / "manifest.json",
514
- repo_root=args.repo_root.resolve(),
515
- publishers_path=args.publishers,
516
- added=args.added,
517
- refresh=args.refresh_publishers,
518
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  print(json.dumps(stats, ensure_ascii=False, indent=2))
520
 
521
 
 
48
  re.IGNORECASE | re.DOTALL,
49
  )
50
  _TITLE_RE = re.compile(r"<title\b[^>]*>(.*?)</title>", re.IGNORECASE | re.DOTALL)
51
+
52
+ # Third-party carve-out (slayerlabs/polish-dynaword-v2#49). gov.pl's copyright
53
+ # page says the service also carries works whose rights belong to third parties
54
+ # and whose use needs the owners' consent, so the operator-declared platform
55
+ # licence does not reach them. Each rule below is one hand-checked slice.
56
+ THIRD_PARTY_DROPS = ("poetry_friday", "imgw_notice", "nongov_source")
57
+ # Powiat Sokołowski's "Piątek z poezją" series reprints poems by named authors.
58
+ _POETRY_FRIDAY_TITLE_RE = re.compile(r"piątek z poezją", re.IGNORECASE)
59
+ # IMGW-PIB warnings carry a notice allowing reuse only in verbatim form.
60
+ _IMGW_NOTICE = "Opracowanie niniejsze i jego format"
61
+ # First "Źródło:" on a line: the text before it and up to 200 credited chars.
62
+ _SOURCE_LINE_RE = re.compile(
63
+ r"^(?P<before>[^\n]*?)\bźr[óo]d[łl]o\s*:\s*(?P<credit>[^\n]{0,200})",
64
+ re.IGNORECASE | re.MULTILINE,
65
+ )
66
+ # "Fot. X, źródło: Y" credits a photo, illustration or film, not the text.
67
+ _MEDIA_CREDIT_RE = re.compile(
68
+ r"^\W*(?:fot|ilustracj|film)|\b(?:fot|ilustracj|film)\w*[^\n]{0,20}$",
69
+ re.IGNORECASE,
70
+ )
71
+ # Credits naming a non-governmental author: media, encyclopedias, NGOs (OSP
72
+ # units are associations), companies, and authored works. Associations of
73
+ # local governments (Stowarzyszenie Łódzki Obszar Metropolitalny) are public.
74
+ _NONGOV_CREDIT_RE = re.compile(
75
+ r"""
76
+ wikipedi | wikimedia | telewizja | \btvp\b | \bradio\s
77
+ | serwis\s+samorządowy\s+pap | redakcj[ai]\s+(?:życia|tygodnika)
78
+ | podlasie\s?24 | jasło112 | tymbark\.in | polskiobserwator | it\s+w\s+administracji
79
+ | stowarzyszeni[ea](?!\s+łódzki\s+obszar) | fundacj[ia] | \bkgw\b | \bskgw\b
80
+ | ^koło\s+gospodyń | \bklub\b | \bmlks\b | junis | amazonki | izba\s+(?:lotnicza|gospodarcza)
81
+ | \bosp\b | \bzosp\b | związku\s+ochotniczych\s+straży | polskiego\s+związku\s+łowieckiego
82
+ | lokalna\s+grupa\s+działania
83
+ | sp\.\s*z\s*o\.\s*o | \bpge\b | edp\s+renewables | grupa\s+nowy\s+szpital | carrefour
84
+ | \bautor(?:\s+tekstu)?\s*: | broszura | wspomnienia | monografia
85
+ | rodzinne\s+gniazdo | historia\s+i\s+teraźniejszość | historia\s+włókniarza
86
+ | jubiläumsschrift | bio\s+artystki | domowe\s+historie
87
+ """,
88
+ re.IGNORECASE | re.VERBOSE,
89
+ )
90
+ MODIFICATION_NOTICE = (
91
+ "Article text was extracted from the source HTML and de-identified "
92
+ "upstream. This DynaWord release normalizes metadata and may exclude "
93
+ "short, non-Polish, duplicate or third-party records; retained text is "
94
+ "otherwise unchanged after upstream de-identification."
95
+ )
96
+ # The release on main 92b36dc before the third-party drops. refilter_release()
97
+ # starts from it because a full build() also needs every other source's
98
+ # Parquet for cross-source dedup.
99
+ PRE_CARVE_OUT_SHA256 = {
100
+ f"{SOURCE}.parquet": "3a683b4220b9b70698d7c524637d9ea5c1d72630b8f92ea7a871642a719cf2c0",
101
+ f"{SOURCE}.attribution.jsonl": "2def7488c34e749204842bcf21d33149738b34de2515115e3f79401f7eb271c4",
102
+ }
103
  DYNAWORD_SCHEMA = pa.schema(
104
  [
105
  ("id", pa.string()),
 
302
  "license": LICENSE,
303
  "license_url": LICENSE_URL,
304
  "modified": True,
305
+ "modification_notice": MODIFICATION_NOTICE,
 
 
 
 
 
306
  }
307
  return row, attribution
308
 
309
 
310
+ def third_party_drop(title: str, text: str) -> str | None:
311
+ """Return the THIRD_PARTY_DROPS slice a record belongs to, or None."""
312
+ if _POETRY_FRIDAY_TITLE_RE.search(title):
313
+ return "poetry_friday"
314
+ if _IMGW_NOTICE in text:
315
+ return "imgw_notice"
316
+ for line in _SOURCE_LINE_RE.finditer(text):
317
+ if _NONGOV_CREDIT_RE.search(line["credit"]) and not _MEDIA_CREDIT_RE.search(
318
+ line["before"]
319
+ ):
320
+ return "nongov_source"
321
+ return None
322
+
323
+
324
  def _polish_ratio(text: str) -> float:
325
  letters = ALPHA_RE.findall(text)
326
  return len(POLISH_RE.findall(text)) / len(letters) if letters else 0.0
 
464
  "drop_lang": 0,
465
  "drop_dup": 0,
466
  "drop_ocr": 0,
467
+ "drop_third_party": dict.fromkeys(THIRD_PARTY_DROPS, 0),
 
 
 
468
  "publisher_count": len(publishers),
469
  "local_public_tenant_count": sum(
470
  publisher_type != "central" for publisher_type in tenant_types.values()
 
472
  "central_tenant_count": sum(
473
  publisher_type == "central" for publisher_type in tenant_types.values()
474
  ),
 
475
  "cross_source_hashes_loaded": len(prior_hashes),
476
  "license": LICENSE,
477
  "upstream_dataset": UPSTREAM_DATASET,
 
501
  stats["drop_dup"] += 1
502
  continue
503
  seen.add(digest)
504
+ # After dedup, so the dup set matches the pre-carve-out release and
505
+ # refilter_release() gives the same rows as a full build.
506
+ reason = third_party_drop(str(record.get("title") or ""), text)
507
+ if reason:
508
+ stats["drop_third_party"][reason] += 1
509
+ continue
510
  record["text"] = text
511
  candidates.append(record)
512
 
 
525
  row, attribution = normalize_record(source_row, publishers, token_count, added)
526
  rows.append(row)
527
  attribution_rows.append(attribution)
 
 
 
 
 
 
 
 
528
 
529
  table = pa.Table.from_pylist(rows, schema=DYNAWORD_SCHEMA)
530
+ _write_release(output_dir, table, attribution_rows, stats)
531
+ return stats
532
+
533
+
534
+ def _write_release(
535
+ output_dir: Path, table: pa.Table, attribution_rows: list[dict], stats: dict
536
+ ) -> None:
537
+ """Fill the row-derived stats, then stage, validate and swap in the release."""
538
+ stats.update(
539
+ kept=table.num_rows,
540
+ chars=sum(map(len, table["text"].to_pylist())),
541
+ tokens=sum(table["token_count"].to_pylist()),
542
+ licenses={LICENSE: table.num_rows},
543
+ authors_with_value=sum(map(bool, table["author"].to_pylist())),
544
+ redirected_urls=sum(
545
+ row["source_url"] != row["final_url"] for row in attribution_rows
546
+ ),
547
+ )
548
  with tempfile.TemporaryDirectory(prefix=f".{SOURCE}-", dir=output_dir) as temp:
549
  staged_dir = Path(temp)
550
  staged_parquet = staged_dir / f"{SOURCE}.parquet"
 
565
  )
566
  _validate_staged_release(staged_dir)
567
  _replace_release(staged_dir, output_dir)
568
+
569
+
570
+ def refilter_release(
571
+ output_dir: Path, expected: dict[str, str] = PRE_CARVE_OUT_SHA256
572
+ ) -> dict:
573
+ """Apply third_party_drop() to the pinned pre-carve-out release in place."""
574
+ for name, digest in expected.items():
575
+ if _file_sha256(output_dir / name) != digest:
576
+ raise ValueError(f"{name} is not the pinned pre-carve-out release")
577
+ table = pq.read_table(output_dir / f"{SOURCE}.parquet")
578
+ with (output_dir / f"{SOURCE}.attribution.jsonl").open(encoding="utf-8") as handle:
579
+ attributions = [json.loads(line) for line in handle]
580
+ stats = json.loads((output_dir / f"{SOURCE}.stats.json").read_text(encoding="utf-8"))
581
+ stats["drop_third_party"] = dict.fromkeys(THIRD_PARTY_DROPS, 0)
582
+ keep: list[bool] = []
583
+ for attribution, text in zip(attributions, table["text"].to_pylist(), strict=True):
584
+ reason = third_party_drop(attribution["title"], text)
585
+ if reason:
586
+ stats["drop_third_party"][reason] += 1
587
+ keep.append(reason is None)
588
+ kept_attributions = [
589
+ {**attribution, "modification_notice": MODIFICATION_NOTICE}
590
+ for attribution, kept in zip(attributions, keep)
591
+ if kept
592
+ ]
593
+ _write_release(output_dir, table.filter(pa.array(keep)), kept_attributions, stats)
594
  return stats
595
 
596
 
597
  def main() -> None:
598
  parser = argparse.ArgumentParser()
599
+ parser.add_argument("--input", type=Path, help="directory containing source Parquet shards")
600
  parser.add_argument(
601
  "--manifest",
602
  type=Path,
 
604
  )
605
  parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
606
  parser.add_argument("--publishers", type=Path, default=Path(__file__).with_name("samorzad_gov_pl_publishers.json"))
607
+ parser.add_argument("--added")
608
  parser.add_argument("--refresh-publishers", action="store_true")
609
+ parser.add_argument(
610
+ "--refilter-release",
611
+ action="store_true",
612
+ help="apply the third-party drops to the pinned pre-carve-out release in data/",
 
 
 
 
613
  )
614
+ args = parser.parse_args()
615
+ if args.refilter_release:
616
+ stats = refilter_release(args.repo_root.resolve() / "data" / SOURCE)
617
+ elif args.input is None or args.added is None:
618
+ parser.error("--input and --added are required unless --refilter-release")
619
+ else:
620
+ stats = build(
621
+ input_path=args.input,
622
+ manifest_path=args.manifest or args.input.parent / "manifest.json",
623
+ repo_root=args.repo_root.resolve(),
624
+ publishers_path=args.publishers,
625
+ added=args.added,
626
+ refresh=args.refresh_publishers,
627
+ )
628
  print(json.dumps(stats, ensure_ascii=False, indent=2))
629
 
630
 
src/sources.py CHANGED
@@ -511,8 +511,9 @@ SOURCES = {
511
  "pretty": "samorzad.gov.pl — Polish public-sector institutions",
512
  "license": "CC-BY-SA-4.0",
513
  "license_spdx": "CC-BY-SA-4.0",
514
- "traceable": "The shared samorzad.gov.pl platform footer publishes textual "
515
- "content under CC BY-SA 4.0. The v0.2 source release is a "
 
516
  "de-identified subset of the audited v0.1 pages, all of which "
517
  "referenced the shared footer script; audiovisual media and "
518
  "attachment bytes are not redistributed.",
@@ -525,6 +526,18 @@ SOURCES = {
525
  "from each tenant homepage's og:site_name metadata and stored "
526
  "as DynaWord author values; discovered, fetched and attribution "
527
  "URLs plus license details are preserved in the sidecar.",
 
 
 
 
 
 
 
 
 
 
 
 
528
  "domain": "local government, education, social services and culture",
529
  "created": "2020-2026 for 21,892 dated records; 59,530 source records undated",
530
  "is_ocr": False,
@@ -718,9 +731,10 @@ SOURCES = {
718
  "global_voices": {
719
  "added": "2026-07-15",
720
  "release": "0.2.3",
721
- # Data contributed directly (PR #7): no in-repo fetch/build script and a
722
- # hand-authored datasheet. Registered for the source table + release totals;
723
- # the datasheet stays contributor-owned via custom_datasheet.
 
724
  "file_key": "global_voices",
725
  "pretty": "Global Voices Polish",
726
  "license": "CC-BY-3.0",
@@ -729,6 +743,17 @@ SOURCES = {
729
  "with each retained Global Voices article; each record carries "
730
  "CC-BY-3.0 metadata and per-document author/translator attribution "
731
  "in global_voices.attribution.jsonl.",
 
 
 
 
 
 
 
 
 
 
 
732
  "upstream": "https://pl.globalvoices.org/",
733
  "domain": "civic media, news and public-interest journalism",
734
  "created": "2008-11-04, 2023-05-24",
 
511
  "pretty": "samorzad.gov.pl — Polish public-sector institutions",
512
  "license": "CC-BY-SA-4.0",
513
  "license_spdx": "CC-BY-SA-4.0",
514
+ "traceable": "Operator-declared platform licence: the shared samorzad.gov.pl "
515
+ "platform footer publishes textual content under CC BY-SA 4.0. "
516
+ "The v0.2 source release is a "
517
  "de-identified subset of the audited v0.1 pages, all of which "
518
  "referenced the shared footer script; audiovisual media and "
519
  "attachment bytes are not redistributed.",
 
526
  "from each tenant homepage's og:site_name metadata and stored "
527
  "as DynaWord author values; discovered, fetched and attribution "
528
  "URLs plus license details are preserved in the sidecar.",
529
+ "legal_note": "The licence is declared by the platform operator (KPRM) in the "
530
+ "shared footer; the operator's agreements with the publishing "
531
+ "institutions are unpublished and no per-institution grant was "
532
+ "found. A question to KPRM is pending (slayerlabs/polish-dynaword-v2#49) "
533
+ "and its answer may change this source's status. gov.pl's copyright "
534
+ "page states that the service also carries third-party works whose "
535
+ "use requires the owners' consent; the platform licence does not "
536
+ "cover them. 144 such rows are dropped by src/clean_samorzad_gov_pl.py: "
537
+ "69 Friday poetry posts, 9 IMGW-PIB notices and 66 articles credited "
538
+ "to a non-governmental source. Contest entries, reposts credited "
539
+ "only by a de-identified URL and other undetected third-party text "
540
+ "may remain.",
541
  "domain": "local government, education, social services and culture",
542
  "created": "2020-2026 for 21,892 dated records; 59,530 source records undated",
543
  "is_ocr": False,
 
731
  "global_voices": {
732
  "added": "2026-07-15",
733
  "release": "0.2.3",
734
+ # Data contributed directly (PR #7) with a hand-authored datasheet; no fetch
735
+ # script. src/clean_global_voices.py drops partner republications from it.
736
+ # Registered for the source table + release totals; the datasheet stays
737
+ # contributor-owned via custom_datasheet.
738
  "file_key": "global_voices",
739
  "pretty": "Global Voices Polish",
740
  "license": "CC-BY-3.0",
 
743
  "with each retained Global Voices article; each record carries "
744
  "CC-BY-3.0 metadata and per-document author/translator attribution "
745
  "in global_voices.attribution.jsonl.",
746
+ "provenance": "Contributed directly (PR #7) from pl.globalvoices.org. "
747
+ "src/clean_global_voices.py filters the v0.2.5 Parquet and "
748
+ "attribution sidecar (pinned by SHA-256) to drop partner "
749
+ "republications: 2,040 -> 1,926 documents.",
750
+ "legal_note": "Posts Global Voices republished from partner outlets are dropped "
751
+ "(114 posts from 51 outlets, among them PRI's The World, The Stand "
752
+ "News, Hong Kong Free Press, Agência Pública, Meta.mk and 350.org). "
753
+ "Their text is the partner's work, not content created by Global "
754
+ "Voices under its CC BY 3.0 grant. The rule matches the "
755
+ "republication note in a post's opening or closing lines; posts "
756
+ "contributors cross-posted from their own blogs are kept.",
757
  "upstream": "https://pl.globalvoices.org/",
758
  "domain": "civic media, news and public-interest journalism",
759
  "created": "2008-11-04, 2023-05-24",
src/test_global_voices_contract.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract checks for the partner-republication drop in global_voices (src/clean_global_voices.py)."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import pyarrow.parquet as pq
7
+
8
+ from clean_global_voices import DROP, KEEP, note_rules, reason
9
+
10
+ DATA = Path(__file__).resolve().parents[1] / "data" / "global_voices"
11
+ KEPT = 1926 # 2,040 in v0.2.5 minus 114 partner republications
12
+
13
+
14
+ def test_release_has_no_partner_republications():
15
+ stats = json.loads((DATA / "global_voices.stats.json").read_text(encoding="utf-8"))
16
+ table = pq.read_table(DATA / "global_voices.parquet")
17
+ rows = table.to_pylist()
18
+ sidecar = [json.loads(line) for line in (DATA / "global_voices.attribution.jsonl").read_text(encoding="utf-8").splitlines()]
19
+ ids = [r["id"] for r in rows]
20
+ assert table.column_names == ["id", "text", "source", "added", "created", "token_count", "license", "author"]
21
+ assert table.num_rows == stats["kept"] == len(sidecar) == KEPT
22
+ assert stats["read"] == stats["kept"] + stats["drop_short"] + stats["drop_partner_republication"]
23
+ assert stats["chars"] == sum(len(r["text"]) for r in rows)
24
+ assert stats["tokens"] == sum(r["token_count"] for r in rows)
25
+ assert len(set(ids)) == len(ids)
26
+ assert {a["id"] for a in sidecar} == set(ids)
27
+ assert {r["source"] for r in rows} == {"global_voices"}
28
+ assert {r["license"] for r in rows} == {a["license"] for a in sidecar} == {"CC-BY-3.0"}
29
+ assert [i for i, r in zip(ids, rows) if reason(i, r["text"])] == []
30
+ assert not DROP.keys() & set(ids)
31
+ # Every hand exception is still in the release and still needed (a rule matches it).
32
+ texts = dict(zip(ids, (r["text"] for r in rows)))
33
+ assert [i for i in KEEP if not note_rules(texts[i])] == []
34
+
35
+
36
+ def test_note_rules():
37
+ pri = "Ten artykuł autorstwa Jane Doe pierwotnie ukazał się na portalu PRI.org 5 maja 2015 r. i jest publikowany ponownie w ramach umowy o wymianie treści."
38
+ assert note_rules(pri) == ["agreement", "originally", "published_by"]
39
+ assert note_rules("Opublikowano za zgodą PRI.") == ["permission"]
40
+ assert note_rules("Artykuł, napisany przez Giorgiego Lomsadze, jest również dostępny na stronie EurasiaNet.org. Opublikowany za pozwoleniem.") == ["permission"]
41
+ assert note_rules("Ten artykuł został napisany przez Hodę Baraka dla 350.org, organizacji tworzącej ruch na rzecz klimatu.") == ["written_for"]
42
+ assert note_rules("Jest to już trzecia odsłona historii, która pierwotnie została opublikowana w języku chińskim na stronie The Stand News.") == ["originally"]
43
+ assert note_rules("Poniżej publikujemy zredagowaną wersję artykułu, który pojawił się po raz pierwszy na stronie Centrum Praw Człowieka w Iranie.") == ["originally"]
44
+ # Notes are searched only in the opening and closing lines.
45
+ assert note_rules("x " * 1000 + "\nTen artykuł pierwotnie ukazał się na PRI.org.") == ["originally"]
46
+ assert note_rules("x " * 400 + "\nTen artykuł pierwotnie ukazał się na PRI.org.\n" + "y " * 400) == []
47
+ # Photo credits, the author's own consent, news reporting, GV's own projects and look-alike words.
48
+ for text in (
49
+ "Więzienie w Monte Cristo. Zdjęcie: Luiz Silveira, Agence CNJ. Opublikowano za zgodą.",
50
+ "Zdjęcie opublikowane za zgodą Tunisia Live",
51
+ "Ilustracja opublikowana pierwotnie w magazynie Puck 25 stycznia 1899 roku.",
52
+ "Sami Shah. Opublikowane za zgodą autora.",
53
+ "Według raportu opublikowanego przez Amnesty International, 13 tys. osób zginęło.",
54
+ "Artykuł ten został napisany i opublikowany przez Rezwana w ramach projektu Rising Voices",
55
+ "Inicjatywa I Can Help U podsumowuje to wszystko udostępniając zdjęcie poniżej:",
56
+ "Dekret ogranicza naukę rdzennych języków w republikach narodowych Federacji Rosyjskiej.",
57
+ "Tunezyjski blog Nawaat, we współpracy z Ministerstwem Młodzieży, rozpoczął nowy projekt.",
58
+ ):
59
+ assert note_rules(text) == [], text
60
+
61
+
62
+ def test_reason_lists():
63
+ own_blog = "Ten post był pierwotnie opublikowany na blogu Juana Arellano Globalizado [es]."
64
+ assert reason("global_voices_0", own_blog) == "originally+published_by"
65
+ assert reason("global_voices_7749", own_blog) is None
66
+ assert reason("global_voices_32352", "").startswith("listed: ")
67
+ assert reason("global_voices_0", "Zwykły tekst bez noty.") is None
src/test_samorzad_gov_pl_contract.py CHANGED
@@ -18,6 +18,8 @@ from clean_samorzad_gov_pl import (
18
  _replace_release,
19
  normalize_record,
20
  publisher_name_from_html,
 
 
21
  verify_upstream_release,
22
  )
23
 
@@ -76,6 +78,86 @@ def test_normalize_record_maps_publisher_to_author_and_preserves_provenance():
76
  assert "de-identified upstream" in attribution["modification_notice"]
77
 
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  def test_verify_upstream_release_rejects_modified_shard(tmp_path):
80
  data_dir = tmp_path / "data"
81
  data_dir.mkdir()
@@ -185,7 +267,14 @@ def test_release_artifact_matches_stats_and_has_institution_authors():
185
  assert table.schema == DYNAWORD_SCHEMA
186
  assert table.num_rows == stats["kept"] == len(attributions)
187
  assert stats["read"] == 81_418
188
- assert stats["kept"] == 72_472
 
 
 
 
 
 
 
189
  assert stats["authors_with_value"] == stats["kept"]
190
  assert stats["publisher_count"] == 247
191
  assert stats["local_public_tenant_count"] == 246
@@ -218,3 +307,9 @@ def test_release_artifact_matches_stats_and_has_institution_authors():
218
  assert sum(
219
  item["source_url"] != item["final_url"] for item in attributions
220
  ) == stats["redirected_urls"]
 
 
 
 
 
 
 
18
  _replace_release,
19
  normalize_record,
20
  publisher_name_from_html,
21
+ refilter_release,
22
+ third_party_drop,
23
  verify_upstream_release,
24
  )
25
 
 
78
  assert "de-identified upstream" in attribution["modification_notice"]
79
 
80
 
81
+ @pytest.mark.parametrize(
82
+ ("title", "text", "expected"),
83
+ [
84
+ ("Piątek z poezją - wiersz", "Treść.", "poetry_friday"),
85
+ ("Ostrzeżenie", "Opracowanie niniejsze i jego format, jako ...", "imgw_notice"),
86
+ ("Historia", "Tekst.\nŹródło: Wikipedia, wolna encyklopedia", "nongov_source"),
87
+ ("Zebranie", "Tekst.\nŹródło: OSP Dąbrówka", "nongov_source"),
88
+ ("Pomoc", "Tekst.\nzdjęcie i źródło: Radio Kielce", "nongov_source"),
89
+ ("Koncert", "singiel promujący film „Miłość na pierwszą stronę” (źródło: oficjalne BIO Artystki)", "nongov_source"),
90
+ # photo, illustration and film credits are not text credits
91
+ ("Szlak", "Fot. Roland Mielnicki, źródło: tymbark.in", None),
92
+ ("Praga", "Ilustracja przedstawia obraz Canaletta, źródło: Wikimedia Commons.", None),
93
+ ("Dożynki", "Poniżej film z wydarzenia (źródło: Małopolskie Stowarzyszenie Sołtysów).", None),
94
+ # public-sector credits and article titles that only mention an NGO
95
+ ("Komunikat", "Tekst.\nŹródło: Urząd Gminy Raba Wyżna", None),
96
+ ("ŁOM", "Źródło: Stowarzyszenie Łódzki Obszar Metropolitalny", None),
97
+ ("Lasy", "Źródło: Koła Gospodyń Wiejskich promują zdrową żywność — Lasy Państwowe", None),
98
+ ("Konkurs", "Wyniki konkursu poezji. Nagrodzone prace zostaną wystawione.", None),
99
+ ],
100
+ )
101
+ def test_third_party_drop_rules(title, text, expected):
102
+ assert third_party_drop(title, text) == expected
103
+
104
+
105
+ def test_refilter_release_drops_third_party_rows_and_recomputes_stats(tmp_path):
106
+ texts = ["Zwykły komunikat gminy.", "Źródło: Fundacja Przykład", "Wiersz."]
107
+ titles = ["Komunikat", "Artykuł", "Piątek z poezją"]
108
+ table = pa.Table.from_pylist(
109
+ [
110
+ {
111
+ "id": f"samorzad_gov_pl_{index}", "text": text, "source": "samorzad_gov_pl",
112
+ "added": "2026-08-14", "created": "", "token_count": index + 1,
113
+ "license": "CC-BY-SA-4.0", "author": "Gmina",
114
+ }
115
+ for index, text in enumerate(texts)
116
+ ],
117
+ schema=DYNAWORD_SCHEMA,
118
+ )
119
+ pq.write_table(table, tmp_path / "samorzad_gov_pl.parquet")
120
+ (tmp_path / "samorzad_gov_pl.attribution.jsonl").write_text(
121
+ "".join(
122
+ json.dumps(
123
+ {
124
+ "id": f"samorzad_gov_pl_{index}", "title": title, "publisher": "Gmina",
125
+ "source_url": "u", "final_url": "u" if index else "v",
126
+ "attribution_url": "u" if index else "v", "modification_notice": "old",
127
+ }
128
+ )
129
+ + "\n"
130
+ for index, title in enumerate(titles)
131
+ ),
132
+ encoding="utf-8",
133
+ )
134
+ (tmp_path / "samorzad_gov_pl.stats.json").write_text(
135
+ json.dumps({"read": 3, "kept": 3, "drop_dup": 0}), encoding="utf-8"
136
+ )
137
+ pins = {
138
+ name: hashlib.sha256((tmp_path / name).read_bytes()).hexdigest()
139
+ for name in ("samorzad_gov_pl.parquet", "samorzad_gov_pl.attribution.jsonl")
140
+ }
141
+
142
+ stats = refilter_release(tmp_path, pins)
143
+
144
+ out = pq.read_table(tmp_path / "samorzad_gov_pl.parquet")
145
+ sidecar = [
146
+ json.loads(line)
147
+ for line in (tmp_path / "samorzad_gov_pl.attribution.jsonl").open(encoding="utf-8")
148
+ ]
149
+ assert out["id"].to_pylist() == ["samorzad_gov_pl_0"]
150
+ assert [row["id"] for row in sidecar] == ["samorzad_gov_pl_0"]
151
+ assert "third-party" in sidecar[0]["modification_notice"]
152
+ assert stats["drop_third_party"] == {
153
+ "poetry_friday": 1, "imgw_notice": 0, "nongov_source": 1,
154
+ }
155
+ assert (stats["read"], stats["kept"], stats["tokens"], stats["redirected_urls"]) == (3, 1, 1, 1)
156
+ assert stats["chars"] == len(texts[0])
157
+ with pytest.raises(ValueError, match="not the pinned pre-carve-out release"):
158
+ refilter_release(tmp_path, pins)
159
+
160
+
161
  def test_verify_upstream_release_rejects_modified_shard(tmp_path):
162
  data_dir = tmp_path / "data"
163
  data_dir.mkdir()
 
267
  assert table.schema == DYNAWORD_SCHEMA
268
  assert table.num_rows == stats["kept"] == len(attributions)
269
  assert stats["read"] == 81_418
270
+ assert stats["kept"] == 72_328
271
+ assert stats["drop_third_party"] == {
272
+ "poetry_friday": 69,
273
+ "imgw_notice": 9,
274
+ "nongov_source": 66,
275
+ }
276
+ assert stats["chars"] == 106_816_031
277
+ assert stats["tokens"] == 39_890_244
278
  assert stats["authors_with_value"] == stats["kept"]
279
  assert stats["publisher_count"] == 247
280
  assert stats["local_public_tenant_count"] == 246
 
307
  assert sum(
308
  item["source_url"] != item["final_url"] for item in attributions
309
  ) == stats["redirected_urls"]
310
+ # slayerlabs/polish-dynaword-v2#49: no third-party slice survives.
311
+ assert [
312
+ item["id"]
313
+ for item, text in zip(attributions, texts, strict=True)
314
+ if third_party_drop(item["title"], text)
315
+ ] == []