ppuzio commited on
Commit
64b093f
·
1 Parent(s): 0d26aa9

1000_novels: keep only the public-domain texts (#49)

Browse files

- 1000_novels: keep only the public-domain texts (503158a3db9904581faaef1a2d98355cb19b980b)

artifacts/source_findings.md CHANGED
@@ -1008,3 +1008,33 @@ quoted third-party passages.
1008
  spot-check noisy sources, a "0 residual" pattern count is not evidence; (2)
1009
  CAPTCHA-gated origins are reproducible only via pinned checksums, not re-fetch -
1010
  say so in the datasheet instead of pretending a before/after can be regenerated.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1008
  spot-check noisy sources, a "0 residual" pattern count is not evidence; (2)
1009
  CAPTCHA-gated origins are reproducible only via pinned checksums, not re-fetch -
1010
  say so in the datasheet instead of pretending a before/after can be regenerated.
1011
+
1012
+ ## `1000_novels` rebuilt as its public-domain subset
1013
+
1014
+ **Investigated:** 2026-10-05
1015
+ **Verdict:** keep 837 of 1,000 texts as `public-domain`; drop 17 in copyright and 146 unresolved.
1016
+
1017
+ ### Verified
1018
+
1019
+ - CLARIN-PL (email reply, 2026-10-05): handle `11321/312` holds metadata only;
1020
+ CLARIN-PL does not distribute the texts and holds no documentation of rights in
1021
+ them. The record's CC BY 4.0 therefore licenses nothing at the text level.
1022
+ - Per-text screen (`polish-dynaword-v2/evidence/1000_novels_rights_screen.csv`):
1023
+ 825 public domain by term, 12 by the retained Wolne Lektury footer, 17 in
1024
+ copyright, 146 unresolved.
1025
+ - Header credit lines beat names found elsewhere in the text. Four rows changed
1026
+ status (0221, 0292, 0294, 0450). `1000_novels_0981` is Seneca's letter to
1027
+ Lucilius filed under Żuławski, headed "PRZEKŁAD" with no translator named,
1028
+ so it now fails closed.
1029
+ - `src/clean_1000_novels.py` writes per-row author (with translator), title, death
1030
+ year and basis to `1000_novels.attribution.jsonl`. Titles: 790 match the CLARIN
1031
+ file name, 32 are read by position (Inferred), 15 are read by hand.
1032
+
1033
+ ### Not established
1034
+
1035
+ - Edition rights (Art. 99¹–99²).
1036
+ - The 12 Wolne Lektury rows rest on WL's statement (Inferred).
1037
+ - No dedup yet against `wolne_lektury` / `eltec_pol`.
1038
+
1039
+ **Lesson:** a file name is metadata, not evidence. Two texts did not match the
1040
+ work their file name gives, and 4 translator credits were wrong.
data/1000_novels/1000_novels.attribution.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5519bac2b956db503b3c80312a9adbeaf77bc6e762a57a725a10a288c14eaa46
3
+ size 304759
data/1000_novels/1000_novels.license-evidence.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checked_at": "2026-10-05",
3
+ "upstream": "https://clarin-pl.eu/dspace/handle/11321/312",
4
+ "upstream_record_license": "CC BY 4.0 (compilation; record read 2026-09-30)",
5
+ "upstream_rights_statement": "CLARIN-PL (Tomasz Naskręt), email reply received 2026-10-05: the handle currently contains metadata only and does not provide the corpus files for download or redistribution; CLARIN-PL does not distribute the individual novels or translations and does not hold documentation concerning the rights to the individual texts.",
6
+ "text_license": "public-domain",
7
+ "test": "Polish law (Art. 36): the author and every credited translator died in 1955 or earlier; a credited name without a curated death year fails closed. 12 rows rely on the retained Wolne Lektury footer stating no economic copyright (Inferred: Wolne Lektury's claim, not re-derived).",
8
+ "not_assessed": "Edition and critical-edition rights (Art. 99^1-99^2).",
9
+ "screen": "polish-dynaword-v2/evidence/1000_novels_rights_screen.csv",
10
+ "screen_script": "polish-dynaword-v2/scripts/novels_rights_screen.py",
11
+ "release_scope": {
12
+ "screened": 1000,
13
+ "kept": 837,
14
+ "pd_by_term": 825,
15
+ "pd_per_wolne_lektury": 12,
16
+ "dropped_in_copyright": 17,
17
+ "dropped_unresolved": 146
18
+ }
19
+ }
data/1000_novels/1000_novels.md CHANGED
@@ -1,60 +1,63 @@
1
  # 1000_novels
2
 
3
- 1000 Novels Corpus (CLARIN-PL)
4
 
5
  ## Dataset description
6
  - **Source (upstream):** https://clarin-pl.eu/dspace/handle/11321/312
7
  - **Domain:** literature
8
  - **Language:** Polish (pl)
9
- - **License:** `CC-BY-4.0`
10
  - **Created (range):** unknown
11
- - **Added:** 2026-07-02
12
 
13
  ## Licensing — traceable basis
14
- The 1000 Novels Corpus is released under Creative Commons Attribution 4.0 International by CLARIN-PL / Wrocław University of Technology, with attribution to the corpus authors and maintainers.
15
-
16
- ## Rights note (per-text screen, September 2026)
17
- The CC-BY-4.0 licence covers the corpus as compiled by CLARIN-PL. It cannot license
18
- third-party rights in the individual novels and translations. A per-text screen of
19
- the released file found:
20
-
21
- | status | texts |
22
- |---|---:|
23
- | public domain in Poland by term (author and any translator died by 1955) | 830 |
24
- | marked public domain by Wolne Lektury | 10 |
25
- | in copyright; published by Wolne Lektury under CC BY-SA 3.0 | 17 |
26
- | author or translator could not be verified | 143 |
27
-
28
- Releases up to v0.2.5 label all 1,000 texts `CC-BY-4.0`. Before the next release, the
29
- 17 in-copyright texts should be relabelled `CC-BY-SA-3.0` with Wolne Lektury
30
- attribution or removed, and the 143 unverified texts withheld until their rights are
31
- established.
 
 
 
 
 
 
 
32
 
33
  ## Provenance
34
- Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key `1000_novels_corpus_CLARIN-PL`) of the upstream CLARIN-PL source. SpeakLeash credited as intermediate aggregator; upstream license/attribution preserved.
 
 
 
35
 
36
  ## Statistics
37
  | documents | characters | tokens (tiktoken proxy) |
38
  |---:|---:|---:|
39
- | 1,000 | 151,610,758 | 60,517,363 |
40
-
41
 
42
  ## Per-document license metadata
43
  | license | documents |
44
  |---|---:|
45
- | `CC-BY-4.0` | 1,000 |
46
-
47
- Author metadata present for **0** documents. Empty values mean the upstream record did not expose a machine-readable author field.
48
 
49
- Statistics were recomputed directly from the released parquet file.
50
 
51
- ## Filters applied (build_dynaword.py)
52
- Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
53
- - drop documents < 200 chars: **0**
54
- - drop non-Polish (diacritic ratio): **0**
55
- - exact cross-source dedup (sha1): **0**
56
- - OCR alpha-ratio < 0.70 (OCR sources only): **0**
57
- - read 1,000 → kept 1,000
58
 
59
  Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
60
  Llama-3 count is computed at release.
 
1
  # 1000_novels
2
 
3
+ 1000 Novels Corpus (CLARIN-PL), public-domain subset
4
 
5
  ## Dataset description
6
  - **Source (upstream):** https://clarin-pl.eu/dspace/handle/11321/312
7
  - **Domain:** literature
8
  - **Language:** Polish (pl)
9
+ - **License:** `public-domain` (public domain in Poland; per-row basis in `1000_novels.attribution.jsonl`)
10
  - **Created (range):** unknown
11
+ - **Added:** 2026-07-02; rebuilt 2026-10-05 as the public-domain subset
12
 
13
  ## Licensing — traceable basis
14
+ The CLARIN-PL record licenses the corpus under CC BY 4.0 as a compiled resource. That
15
+ licence cannot cover third-party rights in the individual novels and translations.
16
+ CLARIN-PL confirmed on 2026-10-05 that the handle holds metadata only and that it holds
17
+ no documentation of rights in the individual texts.
18
+
19
+ The release therefore keeps only the texts that are in the public domain in Poland,
20
+ from a per-text screen (`polish-dynaword-v2/evidence/1000_novels_rights_screen.csv`,
21
+ script `polish-dynaword-v2/scripts/novels_rights_screen.py`):
22
+
23
+ | status | texts | released |
24
+ |---|---:|---|
25
+ | public domain by term: the author and every credited translator died in 1955 or earlier (Art. 36) | 825 | yes |
26
+ | marked public domain by Wolne Lektury in the retained footer | 12 | yes |
27
+ | in copyright; published by Wolne Lektury under CC BY-SA 3.0 | 17 | no |
28
+ | author or translator not verified, or the text does not match its file | 146 | no |
29
+
30
+ The 12 Wolne Lektury rows rely on Wolne Lektury's statement, not on a death year we
31
+ verified. Edition and critical-edition rights (Art. 99¹–99²) are not assessed.
32
+
33
+ ## Attribution
34
+ The `author` column credits the author and, for translations, the translator:
35
+ `Hans Christian Andersen (tłum. Cecylia Niewiadomska)`. `1000_novels.attribution.jsonl`
36
+ has, per row: author, author's death year, translator, title, how the title was read
37
+ (`file`: header text matching the CLARIN file name, 790; `position`: the line beside the
38
+ author line, 32; `manual`: read by hand, 15), CLARIN file name, screen status and basis.
39
 
40
  ## Provenance
41
+ Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key
42
+ `1000_novels_corpus_CLARIN-PL`) of the CLARIN-PL corpus; row *i* matches the *i*-th file
43
+ of the CLARIN listing. Rebuilt by `src/clean_1000_novels.py` from the v0.2.5 Parquet
44
+ (SHA-256 pinned in the script). Text, `added`, `created` and `token_count` are unchanged.
45
 
46
  ## Statistics
47
  | documents | characters | tokens (tiktoken proxy) |
48
  |---:|---:|---:|
49
+ | 837 | 129,722,658 | 51,765,528 |
 
50
 
51
  ## Per-document license metadata
52
  | license | documents |
53
  |---|---:|
54
+ | `public-domain` | 837 |
 
 
55
 
56
+ Author metadata present for **837** documents.
57
 
58
+ ## Filters applied
59
+ - rights screen: read 1,000 → kept 837 (dropped 17 in copyright, 146 unresolved)
60
+ - no length, language, deduplication or OCR filters in this rebuild
 
 
 
 
61
 
62
  Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
63
  Llama-3 count is computed at release.
data/1000_novels/1000_novels.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:27be09e5e2347dcf1a83e94b6c210ca26bdd89365bc3563e88ea5af9846990ea
3
- size 73419435
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2947b057afa57204f3cc2d29752dfc2b2eb1a9482d9449716d849c5b172621d2
3
+ size 63085970
data/1000_novels/1000_novels.stats.json CHANGED
@@ -1,16 +1,29 @@
1
  {
2
  "read": 1000,
3
- "kept": 1000,
 
4
  "drop_short": 0,
5
  "drop_lang": 0,
6
  "drop_dup": 0,
7
  "drop_ocr": 0,
8
- "chars": 151610758,
9
- "tokens": 60517363,
10
  "licenses": {
11
- "CC-BY-4.0": 1000
12
  },
13
- "authors_with_value": 0,
14
- "license": "CC-BY-4.0",
15
- "stats_recomputed_from_parquet": true
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
 
1
  {
2
  "read": 1000,
3
+ "kept": 837,
4
+ "drop_rights": 163,
5
  "drop_short": 0,
6
  "drop_lang": 0,
7
  "drop_dup": 0,
8
  "drop_ocr": 0,
9
+ "chars": 129722658,
10
+ "tokens": 51765528,
11
  "licenses": {
12
+ "public-domain": 837
13
  },
14
+ "authors_with_value": 837,
15
+ "license": "public-domain",
16
+ "screen": {
17
+ "pd_by_term": 825,
18
+ "unresolved": 146,
19
+ "in_copyright": 17,
20
+ "pd_per_wolne_lektury": 12
21
+ },
22
+ "titles": {
23
+ "file": 790,
24
+ "position": 32,
25
+ "manual": 15
26
+ },
27
+ "input_sha256": "27be09e5e2347dcf1a83e94b6c210ca26bdd89365bc3563e88ea5af9846990ea",
28
+ "screen_sha256": "f5a68656f8ac7ff5c2a7a284094f944983ad8d33383e3d86cc40a1f31b9f2880"
29
  }
src/clean_1000_novels.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Rebuild `1000_novels` as its public-domain subset with per-row attribution.
3
+
4
+ CLARIN-PL replied (October 2026) that handle 11321/312 holds metadata only: CLARIN does not
5
+ distribute the texts and holds no rights documentation, so no licence covers them. A row is
6
+ kept only when the per-text rights screen finds it public domain in Poland:
7
+ polish-dynaword-v2/evidence/1000_novels_rights_screen.csv
8
+ (written by polish-dynaword-v2/scripts/novels_rights_screen.py)
9
+ Kept rows are labelled `public-domain`, and `author` credits the author and any translator.
10
+ Title, death year, screen basis and CLARIN file name go to `1000_novels.attribution.jsonl`.
11
+
12
+ The input is the v0.2.5 Parquet, pinned by SHA-256. Restore it before a rerun:
13
+ git checkout v0.2.5 -- data/1000_novels/1000_novels.parquet
14
+ python3 src/clean_1000_novels.py --screen ../polish-dynaword-v2/evidence/1000_novels_rights_screen.csv
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import argparse
19
+ import csv
20
+ import hashlib
21
+ import json
22
+ import os
23
+ import re
24
+ import unicodedata
25
+ from collections import Counter
26
+ from pathlib import Path
27
+
28
+ import pyarrow.parquet as pq
29
+
30
+ SOURCE = "1000_novels"
31
+ ROOT = Path(__file__).resolve().parents[1]
32
+ DATA = ROOT / "data" / SOURCE
33
+ INPUT_SHA256 = "27be09e5e2347dcf1a83e94b6c210ca26bdd89365bc3563e88ea5af9846990ea" # v0.2.5
34
+ UPSTREAM = "https://clarin-pl.eu/dspace/handle/11321/312"
35
+ LICENSE = "public-domain"
36
+ KEEP = {"pd_by_term", "pd_per_wolne_lektury"}
37
+ SCREENS = KEEP | {"in_copyright", "unresolved"}
38
+ # Read off each text's header by hand where the rules below fail: no header, a dedication
39
+ # ("H. K. T."), a series title (Proust), a title broken over lines, or a misspelt file name.
40
+ TITLES = {
41
+ "conrad_murzyn-z-zalogi-narcyza_1923.txt": "Murzyn z załogi „Narcyza”",
42
+ "orzeszkowa_pan-graba_czesc1_1872.txt": "Pan Graba",
43
+ "proust_w-cieniu-zakwitajacych-dziewczat_tom-I_1937.txt": "W cieniu zakwitających dziewcząt",
44
+ "proust_w-cieniu-zakwitajacych-dziewczat_tom-II_1937.txt": "W cieniu zakwitających dziewcząt",
45
+ "proust_w-cieniu-zakwitajacych-dziewczat_tom-III_1937.txt": "W cieniu zakwitających dziewcząt",
46
+ "prus_co-sie-z-wielkiej-idei-zrobilo-w-malym-miasteczku.txt": "Co się z wielkiej idei zrobiło w małem miasteczku",
47
+ "prus_piesn-swiata_1935.txt": "Pleśń świata",
48
+ "reymont_wampir.txt": "Wampir",
49
+ "sienkiewicz_bajka1.txt": "Bajka",
50
+ "sienkiewicz_bajka3.txt": "Bajka",
51
+ "sienkiewicz_jako-sie-pan-lubomirski-nawrocil-kosciol-w-tarnowie-zbudowal_1931.txt":
52
+ "Jako się pan Lubomirski nawrócił i kościół w Tarnawie zbudował",
53
+ "verne_przygody-trzech-rosjan-i-trzech-anglikow-w-poludniowej-afryce_1883.txt":
54
+ "Przygody trzech Rossyan i trzech Anglików w południowej Afryce",
55
+ "zapolska_papuzia_1958.txt": "Papuzia",
56
+ "zeromski_popioly.txt": "Popioły",
57
+ "zulawski_z-domu-ojcow_1897.txt": "Z domu ojców",
58
+ }
59
+ NOT_A_TITLE = re.compile(r"^(tłum|tłumacz|przekład|rozdział|tom|księga|[IVXLC]+\.?$|\d+\.?$)", re.I)
60
+
61
+
62
+ def sha256(path: Path) -> str:
63
+ digest = hashlib.sha256()
64
+ with path.open("rb") as stream:
65
+ for chunk in iter(lambda: stream.read(1 << 20), b""):
66
+ digest.update(chunk)
67
+ return digest.hexdigest()
68
+
69
+
70
+ def fold(text: str) -> str:
71
+ """ASCII slug as in CLARIN file names: `Śpiewak spod strzechy` -> `spiewak-spod-strzechy`."""
72
+ text = text.replace("ł", "l").replace("Ł", "L")
73
+ text = unicodedata.normalize("NFKD", text).encode("ascii", "ignore").decode().lower()
74
+ return re.sub(r"[^a-z0-9]+", "-", text).strip("-")
75
+
76
+
77
+ def file_slug(clarin_file: str) -> str:
78
+ """`sienkiewicz_krzyzacy_tom-II_1900.txt` -> `krzyzacy_tom-II` folded."""
79
+ parts = clarin_file.removesuffix(".txt").split("_")[1:]
80
+ if parts and re.fullmatch(r"\d{4}", parts[-1]):
81
+ parts = parts[:-1]
82
+ return fold(" ".join(parts))
83
+
84
+
85
+ def header_lines(text: str, limit: int = 8) -> list[str]:
86
+ lines = []
87
+ for line in re.split(r"[\r\n]+", text[:3000]):
88
+ line = line.strip().lstrip("<").strip()
89
+ if line:
90
+ lines.append(line)
91
+ if len(lines) == limit:
92
+ break
93
+ return lines
94
+
95
+
96
+ def tidy(title: str) -> str:
97
+ return re.sub(r"\s+", " ", title).strip(" .\t")
98
+
99
+
100
+ def title_of(text: str, clarin_file: str, author: str) -> tuple[str, str]:
101
+ """(title, how): `manual` = TITLES; `file` = header words that fold to the file-name slug
102
+ (V against the file name); `position` = the line next to the author line (I); `none`."""
103
+ if clarin_file in TITLES:
104
+ return TITLES[clarin_file], "manual"
105
+ slug = file_slug(clarin_file)
106
+ lines = header_lines(text)
107
+ for i in range(len(lines)):
108
+ for span in (1, 2, 3): # titles broken over lines: "...kościół w Tarnawie" / "zbudował"
109
+ if fold(" ".join(lines[i:i + span])) == slug:
110
+ return tidy(" ".join(lines[i:i + span])), "file"
111
+ words = lines[i].split() # "Kalosze szczęścia (tłum. Mirandola)/1. Początek"
112
+ for n in range(1, len(words)):
113
+ if fold(" ".join(words[:n])) == slug:
114
+ return tidy(" ".join(words[:n])), "file"
115
+ keys = {fold(clarin_file.split("_")[0]), fold(author.split()[-1])}
116
+
117
+ def is_author(line: str) -> bool:
118
+ return len(line.split()) <= 6 and any(k and k in fold(line) for k in keys)
119
+
120
+ if len(lines) > 1:
121
+ for author_at, title_at in ((0, 1), (1, 0)):
122
+ candidate = lines[title_at]
123
+ if is_author(lines[author_at]) and not is_author(candidate) and not NOT_A_TITLE.match(candidate):
124
+ return tidy(candidate), "position"
125
+ return "", "none"
126
+
127
+
128
+ def credit(author: str, translator: str) -> str:
129
+ return f"{author} (tłum. {translator})" if translator else author
130
+
131
+
132
+ def build(input_path: Path, screen_path: Path, out_dir: Path) -> dict:
133
+ if sha256(input_path) != INPUT_SHA256:
134
+ raise SystemExit(f"{input_path} is not the v0.2.5 Parquet; restore it with "
135
+ "`git checkout v0.2.5 -- data/1000_novels/1000_novels.parquet`")
136
+ table = pq.read_table(input_path)
137
+ with screen_path.open(encoding="utf-8", newline="") as stream:
138
+ screen = {row["id"]: row for row in csv.DictReader(stream)}
139
+ ids = table.column("id").to_pylist()
140
+ if set(ids) != set(screen) or len(ids) != len(set(ids)):
141
+ raise SystemExit("rights screen and Parquet do not cover the same ids")
142
+ if unknown := {row["screen"] for row in screen.values()} - SCREENS:
143
+ raise SystemExit(f"unknown screen values: {unknown}")
144
+
145
+ kept, attribution = [], []
146
+ for row in table.to_pylist():
147
+ rights = screen[row["id"]]
148
+ if rights["screen"] not in KEEP:
149
+ continue
150
+ title, how = title_of(row["text"], rights["clarin_file"], rights["author"])
151
+ kept.append({**row, "license": LICENSE, "author": credit(rights["author"], rights["translator"])})
152
+ attribution.append({
153
+ "id": row["id"], "author": rights["author"], "author_died": rights["author_died"],
154
+ "translator": rights["translator"], "title": title, "title_from": how,
155
+ "clarin_file": rights["clarin_file"], "upstream": UPSTREAM,
156
+ "license": LICENSE, "screen": rights["screen"], "basis": rights["basis"],
157
+ })
158
+ if stale := TITLES.keys() - {a["clarin_file"] for a in attribution}:
159
+ raise SystemExit(f"TITLES names files that are not kept: {sorted(stale)}")
160
+
161
+ stats = {
162
+ "read": len(ids), "kept": len(kept), "drop_rights": len(ids) - len(kept),
163
+ "drop_short": 0, "drop_lang": 0, "drop_dup": 0, "drop_ocr": 0,
164
+ "chars": sum(len(r["text"]) for r in kept), "tokens": sum(r["token_count"] for r in kept),
165
+ "licenses": {LICENSE: len(kept)}, "authors_with_value": sum(bool(r["author"]) for r in kept),
166
+ "license": LICENSE, "screen": dict(Counter(r["screen"] for r in screen.values())),
167
+ "titles": dict(Counter(a["title_from"] for a in attribution)),
168
+ "input_sha256": INPUT_SHA256, "screen_sha256": sha256(screen_path),
169
+ }
170
+ staged = {
171
+ out_dir / f"{SOURCE}.parquet.tmp": lambda p: pq.write_table(
172
+ table.from_pylist(kept, schema=table.schema), p, compression="zstd"),
173
+ out_dir / f"{SOURCE}.attribution.jsonl.tmp": lambda p: p.write_text(
174
+ "".join(json.dumps(a, ensure_ascii=False) + "\n" for a in attribution), encoding="utf-8"),
175
+ out_dir / f"{SOURCE}.stats.json.tmp": lambda p: p.write_text(
176
+ json.dumps(stats, indent=2, ensure_ascii=False) + "\n", encoding="utf-8"),
177
+ }
178
+ for path, write in staged.items():
179
+ write(path)
180
+ for path in staged:
181
+ os.replace(path, path.with_suffix(""))
182
+ return stats
183
+
184
+
185
+ def main() -> None:
186
+ parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
187
+ parser.add_argument("--input", type=Path, default=DATA / f"{SOURCE}.parquet")
188
+ parser.add_argument("--screen", type=Path, required=True, help="1000_novels_rights_screen.csv")
189
+ parser.add_argument("--out", type=Path, default=DATA)
190
+ args = parser.parse_args()
191
+ print(json.dumps(build(args.input, args.screen, args.out), indent=2, ensure_ascii=False))
192
+
193
+
194
+ if __name__ == "__main__":
195
+ main()
src/sources.py CHANGED
@@ -703,12 +703,23 @@ SOURCES = {
703
  "release": "0.2.1",
704
  "speakleash_key": "1000_novels_corpus_CLARIN-PL",
705
  "pretty": "1000 Novels Corpus (CLARIN-PL)",
706
- "license": "CC-BY-4.0",
707
- "license_spdx": "CC-BY-4.0",
708
- "traceable": "The 1000 Novels Corpus is released under Creative Commons "
709
- "Attribution 4.0 International by CLARIN-PL / Wrocław University "
710
- "of Technology, with attribution to the corpus authors and "
711
- "maintainers.",
 
 
 
 
 
 
 
 
 
 
 
712
  "upstream": "https://clarin-pl.eu/dspace/handle/11321/312",
713
  "domain": "literature",
714
  "created": "unknown",
 
703
  "release": "0.2.1",
704
  "speakleash_key": "1000_novels_corpus_CLARIN-PL",
705
  "pretty": "1000 Novels Corpus (CLARIN-PL)",
706
+ "provenance": "SpeakLeash redistribution (key 1000_novels_corpus_CLARIN-PL) of "
707
+ "the CLARIN-PL corpus; row i is the i-th file of the CLARIN listing. "
708
+ "Reduced by src/clean_1000_novels.py to the public-domain texts of the "
709
+ "per-text rights screen; text unchanged.",
710
+ "legal_note": "Public domain in Poland only (Art. 36, life + 70); status in other "
711
+ "jurisdictions not assessed. 12 rows rely on Wolne Lektury's "
712
+ "public-domain footer. Edition rights (Art. 99^1-99^2) not assessed.",
713
+ "license": "public-domain",
714
+ "license_spdx": "LicenseRef-Public-Domain-PL",
715
+ "traceable": "Only texts in the public domain in Poland are kept: the author and "
716
+ "every credited translator died in 1955 or earlier (Art. 36), or the "
717
+ "retained Wolne Lektury footer states no economic copyright. Per-text "
718
+ "screen: polish-dynaword-v2/evidence/1000_novels_rights_screen.csv; "
719
+ "author, translator, title and basis per row in "
720
+ "1000_novels.attribution.jsonl. The CLARIN-PL CC BY 4.0 record covers "
721
+ "the compilation only; CLARIN-PL holds no rights documentation for the "
722
+ "individual texts (reply received 2026-10-05).",
723
  "upstream": "https://clarin-pl.eu/dspace/handle/11321/312",
724
  "domain": "literature",
725
  "created": "unknown",
src/test_1000_novels_contract.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract checks for the public-domain rebuild of 1000_novels (src/clean_1000_novels.py)."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import pyarrow.parquet as pq
7
+
8
+ from clean_1000_novels import credit, file_slug, title_of
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ DATA = ROOT / "data" / "1000_novels"
12
+
13
+
14
+ def test_schema_counts_and_attribution():
15
+ stats = json.loads((DATA / "1000_novels.stats.json").read_text(encoding="utf-8"))
16
+ table = pq.read_table(DATA / "1000_novels.parquet")
17
+ rows = table.select(["id", "source", "license", "author"]).to_pylist()
18
+ sidecar = [json.loads(line) for line in (DATA / "1000_novels.attribution.jsonl").read_text(encoding="utf-8").splitlines()]
19
+ assert table.column_names == ["id", "text", "source", "added", "created", "token_count", "license", "author"]
20
+ assert table.num_rows == stats["kept"] == len(sidecar) == stats["screen"]["pd_by_term"] + stats["screen"]["pd_per_wolne_lektury"]
21
+ assert len({r["id"] for r in rows}) == table.num_rows
22
+ assert {r["source"] for r in rows} == {"1000_novels"}
23
+ assert {r["license"] for r in rows} == {a["license"] for a in sidecar} == {"public-domain"}
24
+ assert {a["screen"] for a in sidecar} <= {"pd_by_term", "pd_per_wolne_lektury"}
25
+ scope = json.loads((DATA / "1000_novels.license-evidence.json").read_text(encoding="utf-8"))["release_scope"]
26
+ assert scope == {"screened": stats["read"], "kept": stats["kept"], "pd_by_term": stats["screen"]["pd_by_term"],
27
+ "pd_per_wolne_lektury": stats["screen"]["pd_per_wolne_lektury"],
28
+ "dropped_in_copyright": stats["screen"]["in_copyright"], "dropped_unresolved": stats["screen"]["unresolved"]}
29
+ by_id = {a["id"]: a for a in sidecar}
30
+ assert by_id.keys() == {r["id"] for r in rows}
31
+ for row in rows:
32
+ a = by_id[row["id"]]
33
+ assert a["author"] and a["basis"] and a["clarin_file"]
34
+ assert row["author"] == credit(a["author"], a["translator"])
35
+ assert bool(a["title"]) == (a["title_from"] != "none")
36
+
37
+
38
+ def test_title_rules():
39
+ assert file_slug("sienkiewicz_krzyzacy_tom-II_1900.txt") == "krzyzacy-tom-ii"
40
+ assert title_of("Henryk Sienkiewicz\nKrzyżacy\nTom II\n", "sienkiewicz_krzyzacy_tom-II_1900.txt", "Henryk Sienkiewicz") == ("Krzyżacy Tom II", "file")
41
+ assert title_of("<Stara baśń\n<Józef Ignacy Kraszewski\n", "kraszewski_stara-basn-tom-I_1876.txt", "Józef Ignacy Kraszewski") == ("Stara baśń", "position")
42
+ assert title_of("I\nWszystkie światła pogasły.\n", "reymont_wampir.txt", "Władysław Reymont") == ("Wampir", "manual")
43
+ assert title_of("I\nDługi akapit bez tytułu.\n", "reymont_inne.txt", "Władysław Reymont") == ("", "none")
44
+ assert credit("Hans Christian Andersen", "Cecylia Niewiadomska") == "Hans Christian Andersen (tłum. Cecylia Niewiadomska)"
45
+ assert credit("Bolesław Prus", "") == "Bolesław Prus"