ppuzio Claude Opus 5.5 commited on
Commit
a989518
·
2 Parent(s): f9e9eee4e5009e

Merge main (#62) into govpl: keep both source_findings entries

Browse files
artifacts/source_findings.md CHANGED
@@ -1261,6 +1261,36 @@ References: `rights_audit_2026-10/reports/citations.md` L10;
1261
  from the official dump with page ids and licence templates, so each page can be
1262
  screened and labelled.
1263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1264
  ## govpl — PAP reprints dropped (2026-10-06)
1265
 
1266
  **Verdict** — `kept`, minus 188 PAP reprints (slayerlabs/polish-dynaword-v2#51).
 
1261
  from the official dump with page ids and licence templates, so each page can be
1262
  screened and labelled.
1263
 
1264
+ ## biblioteka_nauki — public-domain-label records dropped (2026-10-06)
1265
+
1266
+ **Verdict** — `added`, kept for v0.2.6 minus 3 records (polish-dynaword-v2#52). 42,071 →
1267
+ 42,068 documents, 673,488,831 → 673,112,676 tokens (−376,155), 1,748,333,935 →
1268
+ 1,747,387,478 characters. `src/clean_biblioteka_nauki.py` filters the v0.2.5 Parquet
1269
+ (pinned by SHA-256): it keeps `cc-by`, `cc-by-sa` and `cc0`, drops `public-domain`, and
1270
+ fails on any other value. `recover_attribution.py` no longer counts `public-domain` as clean.
1271
+
1272
+ **Reason** — the 3 rows (`books_2142716`, `books_2147851`, `articles_2097363`) carry the
1273
+ platform's "Domena publiczna" label. Verified 2026-10-06 against
1274
+ `bibliotekanauki.pl/api/{type}/{id}`: licence id 22, `creativeCommons: false`, URL
1275
+ `creativecommons.org/publicdomain/mark/1.0/`. Creative Commons describes the Mark as "a tag
1276
+ or a label" for works already free of copyright; it grants nothing. All three are original
1277
+ texts (`reprintPublication` and `translationPublication` false) first published 2019, 2021
1278
+ and 2022 by named authors (Jerzy Zając, Witold Rakowski, Beata Michalec), so life+70 has
1279
+ not run out. The 2019 book's own colophon reads "Copyright by Jerzy Zając 2019 / Copyright
1280
+ by Muzeum Niepodległości w Warszawie 2019". That the authors are alive is inferred.
1281
+
1282
+ **Not done here** — the licence version is still collapsed: rows say `cc-by`/`cc-by-sa`,
1283
+ the card and `stats.json` say 4.0. A live re-check (seed 20261006, 24 rows) found 4 of 12
1284
+ `cc-by` rows under 3.0 PL or 3.0 Unported; all 12 `cc-by-sa` rows were 4.0. Fixing it needs
1285
+ a per-record API re-fetch of name and version (tracked under polish-dynaword-v2#57). The
1286
+ card still names SpeakLeash while `src/sources.py` says direct rebuild; `licenses.jsonl`,
1287
+ `index.jsonl` and `build_parquet.py` are not in the repo. 128 kept rows (88 `cc-by`, 40
1288
+ `cc-by-sa`; 1.56% of tokens) contain "Wszelkie prawa zastrzeżone" or "All rights
1289
+ reserved" in their text (publication years 2010-2021); regex count only, not reviewed.
1290
+
1291
+ **Lesson** — a platform's "public domain" label can be the PD Mark. Check the URL behind
1292
+ the label, and check the date: a 2019 work cannot be public domain by term in Poland.
1293
+
1294
  ## govpl — PAP reprints dropped (2026-10-06)
1295
 
1296
  **Verdict** — `kept`, minus 188 PAP reprints (slayerlabs/polish-dynaword-v2#51).
data/biblioteka_nauki/biblioteka_nauki.md CHANGED
@@ -6,7 +6,7 @@ Biblioteka Nauki — Polish open-access scholarly corpus (scientific articles, b
6
  - **Source (upstream):** https://bibliotekanauki.pl (operated by ICM, University of Warsaw — Centrum Otwartej Nauki)
7
  - **Domain:** academic (scientific articles, books, chapters)
8
  - **Language:** Polish (pl)
9
- - **License:** per-document — CC BY 4.0 28,335 · CC BY-SA 4.0 13,733 · Public Domain 3
10
  - **Created (range):** per-document publication year, from each item's bibliotekanauki.pl metadata
11
  - **Added:** 2026-06-27
12
 
@@ -20,10 +20,16 @@ items are kept; all-rights-reserved and unknown items are gated out. Recovery yi
20
  |---|---:|
21
  | CC BY 4.0 | 28,335 |
22
  | CC BY-SA 4.0 | 13,733 |
23
- | Public Domain | 3 |
24
 
25
  The per-document license is carried in the parquet `license` column.
26
 
 
 
 
 
 
 
 
27
  ## Attribution
28
  Per-document attribution (author · year · title · publisher) was re-fetched 1:1 from
29
  bibliotekanauki.pl (43,576 / 43,576 ok) and is carried in the parquet `attribution` column,
@@ -37,7 +43,7 @@ attribution recovered per document and preserved.
37
  ## Statistics
38
  | documents | characters | tokens (tiktoken proxy) |
39
  |---:|---:|---:|
40
- | 42,071 | 1,748,333,935 | 673,488,831 |
41
 
42
  ## Filters applied (build_dynaword.py)
43
  Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
@@ -45,7 +51,8 @@ Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
45
  - drop non-Polish (diacritic ratio): **925**
46
  - exact cross-source dedup (sha1): **180**
47
  - OCR alpha-ratio < 0.70 (OCR source): **400**
48
- - read 43,576 → kept 42,071
 
49
 
50
  Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
51
  Llama-3 count is computed at release.
 
6
  - **Source (upstream):** https://bibliotekanauki.pl (operated by ICM, University of Warsaw — Centrum Otwartej Nauki)
7
  - **Domain:** academic (scientific articles, books, chapters)
8
  - **Language:** Polish (pl)
9
+ - **License:** per-document — CC BY 4.0 28,335 · CC BY-SA 4.0 13,733
10
  - **Created (range):** per-document publication year, from each item's bibliotekanauki.pl metadata
11
  - **Added:** 2026-06-27
12
 
 
20
  |---|---:|
21
  | CC BY 4.0 | 28,335 |
22
  | CC BY-SA 4.0 | 13,733 |
 
23
 
24
  The per-document license is carried in the parquet `license` column.
25
 
26
+ Three items labelled "Domena publiczna" were dropped for v0.2.6 (`src/clean_biblioteka_nauki.py`,
27
+ polish-dynaword-v2#52): `books_2142716`, `books_2147851`, `articles_2097363` (376,155 tokens).
28
+ Biblioteka Nauki gives them API licence id 22, the CC Public Domain Mark 1.0, which is a label, not a
29
+ waiver or a licence. They are original works first published 2019-2022, so the Polish life+70 term has
30
+ not run out, and `books_2147851` itself prints "Copyright by Jerzy Zając 2019". Only CC BY, CC BY-SA
31
+ and CC0 values are kept; any other value fails the script.
32
+
33
  ## Attribution
34
  Per-document attribution (author · year · title · publisher) was re-fetched 1:1 from
35
  bibliotekanauki.pl (43,576 / 43,576 ok) and is carried in the parquet `attribution` column,
 
43
  ## Statistics
44
  | documents | characters | tokens (tiktoken proxy) |
45
  |---:|---:|---:|
46
+ | 42,068 | 1,747,387,478 | 673,112,676 |
47
 
48
  ## Filters applied (build_dynaword.py)
49
  Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
 
51
  - drop non-Polish (diacritic ratio): **925**
52
  - exact cross-source dedup (sha1): **180**
53
  - OCR alpha-ratio < 0.70 (OCR source): **400**
54
+ - licence not an established grant, CC Public Domain Mark (`src/clean_biblioteka_nauki.py`): **3**
55
+ - read 43,576 → kept 42,068
56
 
57
  Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
58
  Llama-3 count is computed at release.
data/biblioteka_nauki/biblioteka_nauki.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26
3
- size 1076638904
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b57b8eec198c9899198a73cea1af372df09b43783a49474a856ccbf83c97da4
3
+ size 1075953966
data/biblioteka_nauki/biblioteka_nauki.stats.json CHANGED
@@ -1,12 +1,18 @@
1
  {
2
  "read": 43576,
3
- "kept": 42071,
4
  "drop_short": 0,
5
  "drop_lang": 925,
6
  "drop_dup": 180,
7
  "drop_ocr": 400,
8
- "chars": 1748333935,
9
- "tokens": 673488831,
10
  "secs": 484.1,
11
- "license": "CC-BY-4.0 / CC-BY-SA-4.0"
 
 
 
 
 
 
12
  }
 
1
  {
2
  "read": 43576,
3
+ "kept": 42068,
4
  "drop_short": 0,
5
  "drop_lang": 925,
6
  "drop_dup": 180,
7
  "drop_ocr": 400,
8
+ "chars": 1747387478,
9
+ "tokens": 673112676,
10
  "secs": 484.1,
11
+ "license": "CC-BY-4.0 / CC-BY-SA-4.0",
12
+ "drop_rights": 3,
13
+ "licenses": {
14
+ "cc-by": 28335,
15
+ "cc-by-sa": 13733
16
+ },
17
+ "input_sha256": "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26"
18
  }
data/biblioteka_nauki/recover_attribution.py CHANGED
@@ -1,5 +1,5 @@
1
  #!/usr/bin/env python3
2
- """Targeted attribution pass for the CLEAN (CC-BY/CC-BY-SA/PD) Biblioteka Nauki ids ONLY.
3
  The first recovery pass stored the license correctly but parsed the wrong attribution fields.
4
  CC-BY/CC-BY-SA legally REQUIRE attribution, so re-fetch just the ~43.6k clean ids and extract:
5
  authors = contributors[role=AUTHOR] firstName+lastName ; year = dates[PUBLISHED].date.year ;
@@ -16,7 +16,10 @@ HERE = os.path.dirname(os.path.abspath(__file__))
16
  LIC = os.path.join(HERE, "licenses.jsonl")
17
  OUT = os.path.join(HERE, "attribution.jsonl")
18
  PROG = os.path.join(HERE, "attribution_progress.txt")
19
- CLEAN = {"cc-by", "cc-by-sa", "cc0", "public-domain"}
 
 
 
20
  WORKERS = 8
21
  UA = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
22
  "(KHTML, like Gecko) Chrome/124 Safari/537.36")
 
1
  #!/usr/bin/env python3
2
+ """Targeted attribution pass for the CLEAN (CC-BY/CC-BY-SA/CC0) Biblioteka Nauki ids ONLY.
3
  The first recovery pass stored the license correctly but parsed the wrong attribution fields.
4
  CC-BY/CC-BY-SA legally REQUIRE attribution, so re-fetch just the ~43.6k clean ids and extract:
5
  authors = contributors[role=AUTHOR] firstName+lastName ; year = dates[PUBLISHED].date.year ;
 
16
  LIC = os.path.join(HERE, "licenses.jsonl")
17
  OUT = os.path.join(HERE, "attribution.jsonl")
18
  PROG = os.path.join(HERE, "attribution_progress.txt")
19
+ # The v0.2.4 run also kept "public-domain": the CC Public Domain Mark, a label rather than a grant
20
+ # (polish-dynaword-v2#52). src/clean_biblioteka_nauki.py drops it from the shipped Parquet; its KEEP
21
+ # set must equal this one.
22
+ CLEAN = {"cc-by", "cc-by-sa", "cc0"}
23
  WORKERS = 8
24
  UA = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
25
  "(KHTML, like Gecko) Chrome/124 Safari/537.36")
src/clean_biblioteka_nauki.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Drop Biblioteka Nauki rows whose licence is not an established grant.
3
+
4
+ Kept: `cc-by`, `cc-by-sa` and `cc0` (none in v0.2.5), the per-item Creative Commons licence read from
5
+ bibliotekanauki.pl/api/{type}/{id} (`license.iconId`) by data/biblioteka_nauki/recover_licenses.py.
6
+ Dropped: `public-domain`. The platform shows it for items tagged with the CC Public Domain Mark 1.0
7
+ (API licence id 22, https://creativecommons.org/publicdomain/mark/1.0/). The Mark is a label, not
8
+ a waiver or a licence, and the 3 tagged items are original works first published 2019-2022, so
9
+ the Polish life+70 term cannot have run out (polish-dynaword-v2#52,
10
+ artifacts/rights_audit_2026-10/reports/academic.md). Any other licence value fails the run.
11
+
12
+ The v0.2.4 assembly script (build_parquet.py) was never committed, so this filters the shipped
13
+ v0.2.5 Parquet, pinned by SHA-256, and updates the stats file in place. Rerun:
14
+ git checkout v0.2.5 -- data/biblioteka_nauki/biblioteka_nauki.parquet
15
+ python3 src/clean_biblioteka_nauki.py
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import argparse
20
+ import hashlib
21
+ import json
22
+ import os
23
+ from collections import Counter
24
+ from pathlib import Path
25
+
26
+ import pyarrow as pa
27
+ import pyarrow.compute as pc
28
+ import pyarrow.parquet as pq
29
+
30
+ SOURCE = "biblioteka_nauki"
31
+ DATA = Path(__file__).resolve().parents[1] / "data" / SOURCE
32
+ INPUT_SHA256 = "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26" # v0.2.5
33
+ KEEP = {"cc-by", "cc-by-sa", "cc0"} # = CLEAN in data/biblioteka_nauki/recover_attribution.py
34
+ DROP = {"public-domain"} # CC Public Domain Mark: a label, not a grant (see docstring)
35
+
36
+
37
+ def filter_table(table: pa.Table) -> pa.Table:
38
+ """Rows whose `license` is in KEEP. Fails on any value in neither KEEP nor DROP."""
39
+ if unknown := set(table.column("license").unique().to_pylist()) - KEEP - DROP:
40
+ raise SystemExit(f"unexpected license values: {sorted(unknown, key=str)}")
41
+ return table.filter(pc.is_in(table.column("license"), pa.array(sorted(KEEP))))
42
+
43
+
44
+ def build(input_path: Path, out_dir: Path) -> dict:
45
+ with input_path.open("rb") as stream:
46
+ if hashlib.file_digest(stream, "sha256").hexdigest() != INPUT_SHA256:
47
+ raise SystemExit(f"{input_path} is not the v0.2.5 Parquet; restore it with "
48
+ f"`git checkout v0.2.5 -- data/{SOURCE}/{SOURCE}.parquet`")
49
+ table = pq.read_table(input_path)
50
+ kept = filter_table(table)
51
+ dropped = sorted(set(table.column("id").to_pylist()) - set(kept.column("id").to_pylist()))
52
+
53
+ stats_path = out_dir / f"{SOURCE}.stats.json"
54
+ stats = json.loads(stats_path.read_text(encoding="utf-8")) # keeps build_dynaword's read/drop_* counts
55
+ stats.update(
56
+ kept=kept.num_rows,
57
+ drop_rights=table.num_rows - kept.num_rows,
58
+ chars=pc.sum(pc.utf8_length(kept.column("text"))).as_py(),
59
+ tokens=pc.sum(kept.column("token_count")).as_py(),
60
+ licenses=dict(sorted(Counter(kept.column("license").to_pylist()).items())),
61
+ input_sha256=INPUT_SHA256,
62
+ )
63
+ parquet_tmp = out_dir / f"{SOURCE}.parquet.tmp"
64
+ stats_tmp = out_dir / f"{SOURCE}.stats.json.tmp"
65
+ pq.write_table(kept, parquet_tmp)
66
+ stats_tmp.write_text(json.dumps(stats, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
67
+ os.replace(parquet_tmp, out_dir / f"{SOURCE}.parquet")
68
+ os.replace(stats_tmp, stats_path)
69
+ return {**stats, "dropped_ids": dropped}
70
+
71
+
72
+ def main() -> None:
73
+ parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
74
+ parser.add_argument("--input", type=Path, default=DATA / f"{SOURCE}.parquet")
75
+ parser.add_argument("--out", type=Path, default=DATA)
76
+ args = parser.parse_args()
77
+ print(json.dumps(build(args.input, args.out), indent=2, ensure_ascii=False))
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()
src/test_biblioteka_nauki_contract.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract checks for biblioteka_nauki after the public-domain drop (src/clean_biblioteka_nauki.py)."""
2
+
3
+ import importlib.util
4
+ import json
5
+ import sys
6
+ from collections import Counter
7
+ from pathlib import Path
8
+
9
+ import pyarrow as pa
10
+ import pyarrow.compute as pc
11
+ import pyarrow.parquet as pq
12
+ import pytest
13
+
14
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
15
+
16
+ from clean_biblioteka_nauki import DATA, KEEP, filter_table
17
+
18
+ PUBLIC_DOMAIN_MARK_IDS = {
19
+ "biblioteka_nauki_books_2142716",
20
+ "biblioteka_nauki_books_2147851",
21
+ "biblioteka_nauki_articles_2097363",
22
+ }
23
+
24
+
25
+ def test_shard_has_no_public_domain_rows_and_matches_stats():
26
+ stats = json.loads((DATA / "biblioteka_nauki.stats.json").read_text(encoding="utf-8"))
27
+ path = DATA / "biblioteka_nauki.parquet"
28
+ assert pq.read_schema(path).names == [
29
+ "id", "text", "source", "added", "created", "token_count", "license", "attribution"]
30
+ table = pq.read_table(path, columns=["id", "source", "token_count", "license", "attribution"])
31
+ ids = table.column("id").to_pylist()
32
+ licenses = Counter(table.column("license").to_pylist())
33
+
34
+ assert table.num_rows == stats["kept"] == 42_068
35
+ assert len(set(ids)) == len(ids)
36
+ assert not PUBLIC_DOMAIN_MARK_IDS & set(ids)
37
+ assert "public-domain" not in licenses
38
+ assert licenses == stats["licenses"] == {"cc-by": 28_335, "cc-by-sa": 13_733}
39
+ assert set(table.column("source").to_pylist()) == {"biblioteka_nauki"}
40
+ assert pc.sum(table.column("token_count")).as_py() == stats["tokens"]
41
+ assert pc.min(table.column("token_count")).as_py() > 0
42
+ assert all(a and a.strip() for a in table.column("attribution").to_pylist())
43
+ drops = ("drop_short", "drop_lang", "drop_dup", "drop_ocr", "drop_rights")
44
+ assert stats["read"] - sum(stats[k] for k in drops) == stats["kept"]
45
+ assert stats["drop_rights"] == 3
46
+
47
+
48
+ def test_datasheet_counts_match_stats():
49
+ stats = json.loads((DATA / "biblioteka_nauki.stats.json").read_text(encoding="utf-8"))
50
+ card = (DATA / "biblioteka_nauki.md").read_text(encoding="utf-8")
51
+ assert f"| {stats['kept']:,} | {stats['chars']:,} | {stats['tokens']:,} |" in card
52
+ for license, docs in stats["licenses"].items():
53
+ assert f"{docs:,}" in card, license
54
+ assert "| Public Domain |" not in card
55
+
56
+
57
+ def test_filter_drops_public_domain_and_fails_closed():
58
+ table = pa.table({"id": ["a", "b", "c", "d"], "license": ["cc-by", "public-domain", "cc-by-sa", "cc0"]})
59
+ assert filter_table(table).column("id").to_pylist() == ["a", "c", "d"]
60
+ for bad in ("cc-by-nc", "cc-by-nd", "all-rights-reserved", None):
61
+ with pytest.raises(SystemExit):
62
+ filter_table(pa.table({"license": ["cc-by", bad]}))
63
+
64
+
65
+ def test_upstream_gate_matches_filter():
66
+ spec = importlib.util.spec_from_file_location("recover_attribution", DATA / "recover_attribution.py")
67
+ module = importlib.util.module_from_spec(spec)
68
+ spec.loader.exec_module(module)
69
+ assert module.CLEAN == KEEP