ppuzio Claude Opus 5.5 commited on
Commit
2d732f7
·
1 Parent(s): ec01c58

verify_paper_claims: read the v0.2.6 paper draft (v2#61)

Browse files

- PAPER_NAMES: the 15 display names v0.2.6 adds.
- tab:additions: a minus typeset as $-$ is a negative cell, and a
"Net change" row is the totals row of a release that also removes sources.
- norm_license: a LicenseRef compares by its name, so "EU reuse policy"
matches LicenseRef-EU-Reuse-Policy (the eurlex FAIL).
- released_at: a source stops counting from its `removed` release. The three
withdrawn sources (wikisource, wikiquote, european_hplt_v3_pl) get
removed="0.2.6"; AGENTS.md and the source-rights-review skill say to set it.

Left for the release commit: v0.2.6 in src/plot_version_growth.py,
`release` on the 15 new sources (after NERGAL), the CHANGELOG section.

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

.agents/skills/source-rights-review/SKILL.md CHANGED
@@ -207,7 +207,8 @@ As done for HPLT (Hub commits 23e883a, 1802420, bade8e7):
207
 
208
  1. Remove `data/<key>/` data files from main.
209
  2. Keep the `SOURCES` entry for history; add a `legal_note` with the reason and the clause URL. Keep its old
210
- `release` value (`european_hplt_v3_pl` still says `"0.2.3"`).
 
211
  3. Write a decision record (`status: excluded`, or `held_for_review` while a human decides).
212
  4. Run `python3 src/verify_paper_claims.py --tex ../polish-dynaword-v2/main.tex --ref worktree`. Its FAILs
213
  are the paper's token, document and source counts that the removal breaks.
 
207
 
208
  1. Remove `data/<key>/` data files from main.
209
  2. Keep the `SOURCES` entry for history; add a `legal_note` with the reason and the clause URL. Keep its old
210
+ `release` value and set `removed` to the first release without it (`european_hplt_v3_pl`: `"0.2.3"` and
211
+ `"0.2.6"`). `verify_paper_claims.py` stops counting the source from `removed` on.
212
  3. Write a decision record (`status: excluded`, or `held_for_review` while a human decides).
213
  4. Run `python3 src/verify_paper_claims.py --tex ../polish-dynaword-v2/main.tex --ref worktree`. Its FAILs
214
  are the paper's token, document and source counts that the removal breaks.
AGENTS.md CHANGED
@@ -208,7 +208,8 @@ Two rules about all of the above:
208
  ## Cut the release (maintainer, one commit after the source PRs merge)
209
 
210
  0. In `src/sources.py`, set `release` on each merged source this release ships
211
- (check its shard went through NERGAL first). A source is not released until
 
212
  its rights review is recorded (see "Rights review").
213
  1. In `src/make_docs.py`: bump `VERSION` and `RELEASE_DATE`. Add a row for the new
214
  version to the version table and a row for each new contributor to the
 
208
  ## Cut the release (maintainer, one commit after the source PRs merge)
209
 
210
  0. In `src/sources.py`, set `release` on each merged source this release ships
211
+ (check its shard went through NERGAL first), and `removed` on each source it
212
+ drops. A source is not released until
213
  its rights review is recorded (see "Rights review").
214
  1. In `src/make_docs.py`: bump `VERSION` and `RELEASE_DATE`. Add a row for the new
215
  version to the version table and a row for each new contributor to the
src/sources.py CHANGED
@@ -158,6 +158,7 @@ SOURCES = {
158
  "wikisource": {
159
  "added": "2026-06-15",
160
  "release": "0.2.0",
 
161
  "speakleash_key": "plwikisource",
162
  "pretty": "Polish Wikisource",
163
  "license": "CC-BY-SA-3.0",
@@ -580,6 +581,7 @@ SOURCES = {
580
  "wikiquote": {
581
  "added": "2026-06-15",
582
  "release": "0.2.0",
 
583
  "file_key": "plwikiquote",
584
  "pretty": "Polish Wikiquote (quotations)",
585
  "license": "CC-BY-SA-3.0",
@@ -916,6 +918,7 @@ SOURCES = {
916
  "european_hplt_v3_pl": {
917
  "added": "2026-07-14",
918
  "release": "0.2.3",
 
919
  "file_key": "european_hplt_v3_pl",
920
  "pretty": "HPLT v3.0 Polish (web, top WDS bins 10-5)",
921
  "license": "CC0-1.0",
 
158
  "wikisource": {
159
  "added": "2026-06-15",
160
  "release": "0.2.0",
161
+ "removed": "0.2.6",
162
  "speakleash_key": "plwikisource",
163
  "pretty": "Polish Wikisource",
164
  "license": "CC-BY-SA-3.0",
 
581
  "wikiquote": {
582
  "added": "2026-06-15",
583
  "release": "0.2.0",
584
+ "removed": "0.2.6",
585
  "file_key": "plwikiquote",
586
  "pretty": "Polish Wikiquote (quotations)",
587
  "license": "CC-BY-SA-3.0",
 
918
  "european_hplt_v3_pl": {
919
  "added": "2026-07-14",
920
  "release": "0.2.3",
921
+ "removed": "0.2.6",
922
  "file_key": "european_hplt_v3_pl",
923
  "pretty": "HPLT v3.0 Polish (web, top WDS bins 10-5)",
924
  "license": "CC0-1.0",
src/test_verify_paper_claims.py CHANGED
@@ -2,6 +2,7 @@
2
 
3
  import json
4
  from pathlib import Path
 
5
  import subprocess
6
 
7
  import pytest
@@ -182,6 +183,53 @@ def test_unreleased_source_is_left_out(repo, capsys):
182
  assert any("totals over ALL sources" in line for line in lines(out, vpc.WARN))
183
 
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  def test_dual_licence_warns(repo, capsys):
186
  edit(repo / "src" / "sources.py", '"license_spdx": "CC0-1.0"', '"license_spdx": "CC-BY-4.0"')
187
  code, out = run(repo, capsys)
@@ -246,6 +294,8 @@ def test_printed_precision_sets_the_tolerance(raw, actual, ok):
246
  ("CC BY 3.0", "CC-BY-4.0", False),
247
  ("CC BY", "CC-BY-SA-4.0", False),
248
  ("mixed CC BY/BY-SA/PD", "per-record upstream license", True),
 
 
249
  ])
250
  def test_licence_comparison(paper, registry, ok):
251
  assert vpc.compatible(vpc.norm_license(paper), vpc.norm_license(registry)) is ok
 
2
 
3
  import json
4
  from pathlib import Path
5
+ import shutil
6
  import subprocess
7
 
8
  import pytest
 
183
  assert any("totals over ALL sources" in line for line in lines(out, vpc.WARN))
184
 
185
 
186
+ def remove_dziennik(root: Path) -> None:
187
+ """v0.1.2 removes dziennik_ustaw: the data goes, the registry marks it, the tables follow."""
188
+ shutil.rmtree(root / "data" / "dziennik_ustaw")
189
+ edit(root / "src" / "sources.py", '"release": "0.1.0"}', '"release": "0.1.0", "removed": "0.1.2"}')
190
+ edit(root / "src" / "plot_version_growth.py", '"v0.1.1"]', '"v0.1.1", "v0.1.2"]')
191
+ edit(root / "src" / "plot_version_growth.py", "300_000]", "300_000, 100_000]")
192
+ edit(root / "src" / "plot_version_growth.py", "3_000_000_000]", "3_000_000_000, 1_000_000_000]")
193
+ edit(root / "CHANGELOG.md", "# Changelog\n", "# Changelog\n\n## v0.1.2 (2026-01-03)\n\n- Removed `dziennik_ustaw`: 1 source.\n")
194
+ tex = root / "main.tex"
195
+ edit(tex, "v0.1.1 & 2 & 300,000 & 3.000\\\\\n", "v0.1.1 & 2 & 300,000 & 3.000\\\\\nv0.1.2 & 1 & 100,000 & 1.000\\\\\n")
196
+ edit(tex, " & Total added & 100,000 & 1,000,000,000\\\\\n",
197
+ " & Total added & 100,000 & 1,000,000,000\\\\\n"
198
+ "v0.1.2 & Dziennik Ustaw & $-$200,000 & $-$2,000,000,000\\\\\n"
199
+ " & Net change & $-$200,000 & $-$2,000,000,000\\\\\n")
200
+ edit(tex, "Dziennik Ustaw & 200,000 & 2,000.0 & 969 & legal & v0.1.0 & official records; Art.~4 basis & none & dropped\\\\\n", "")
201
+ edit(tex, "Total & 300,000 & 3,000.0 & & & & 2 sources", "Total & 100,000 & 1,000.0 & & & & 1 sources")
202
+
203
+
204
+ def test_removal_release_passes(repo, capsys):
205
+ remove_dziennik(repo)
206
+ code, out = run(repo, capsys)
207
+ assert (code, lines(out, vpc.FAIL)) == (0, [])
208
+ assert any("] v0.1.2 Net change documents " in line for line in lines(out, vpc.OK))
209
+ assert any("] v0.1.2 source count " in line for line in lines(out, vpc.OK))
210
+ assert any("] v0.1.0 source count " in line for line in lines(out, vpc.OK)) # removal is not retroactive
211
+
212
+
213
+ @pytest.mark.parametrize("mutate, label", [
214
+ (in_file("src/sources.py", ', "removed": "0.1.2"', ""), "v0.1.2 source count"),
215
+ (in_file("main.tex", "Net change & $-$200,000", "Net change & $-$199,000"), "v0.1.2 Net change documents"),
216
+ (in_file("main.tex", "Dziennik Ustaw & $-$200,000", "Dziennik Ustaw & 200,000"),
217
+ "v0.1.2 additions sum to the documents change"),
218
+ ], ids=["registry keeps the removed source", "Net change", "removal printed as an addition"])
219
+ def test_wrong_removal_claim_fails(repo, capsys, mutate, label):
220
+ remove_dziennik(repo)
221
+ mutate(repo)
222
+ code, out = run(repo, capsys)
223
+ assert code == 1
224
+ assert any(f"] {label} " in line for line in lines(out, vpc.FAIL)), out
225
+
226
+
227
+ def test_paper_names_are_registry_sources():
228
+ registry = vpc.load_registry(vpc.ROOT, "worktree")
229
+ assert sorted(set(vpc.PAPER_NAMES.values()) - set(registry)) == []
230
+ assert len(set(vpc.PAPER_NAMES.values())) == len(vpc.PAPER_NAMES)
231
+
232
+
233
  def test_dual_licence_warns(repo, capsys):
234
  edit(repo / "src" / "sources.py", '"license_spdx": "CC0-1.0"', '"license_spdx": "CC-BY-4.0"')
235
  code, out = run(repo, capsys)
 
294
  ("CC BY 3.0", "CC-BY-4.0", False),
295
  ("CC BY", "CC-BY-SA-4.0", False),
296
  ("mixed CC BY/BY-SA/PD", "per-record upstream license", True),
297
+ ("EU reuse policy", "LicenseRef-EU-Reuse-Policy", True),
298
+ ("EU reuse policy", "LicenseRef-TED-Notice-Reuse", False),
299
  ])
300
  def test_licence_comparison(paper, registry, ok):
301
  assert vpc.compatible(vpc.norm_license(paper), vpc.norm_license(registry)) is ok
src/verify_paper_claims.py CHANGED
@@ -8,7 +8,8 @@ a tagged release is checked against that release and not against later commits.
8
  1. Release trajectory (`tab:releases`, `tab:additions`): documents, tokens and
9
  source counts per release, and the additions that reconcile consecutive totals.
10
  Ground truth: the VERSIONS/DOCUMENTS/TOKENS literals in src/plot_version_growth.py,
11
- the `release` field in src/sources.py, and the CHANGELOG.md source counts.
 
12
 
13
  2. Corpus composition (`tab:sources` and the prose): per-source documents, tokens
14
  and first release, the source set, and the totals of the latest release.
@@ -67,6 +68,22 @@ PAPER_NAMES = {
67
  "Global Voices": "global_voices",
68
  "NKJP1M": "nkjp1m",
69
  "Wiktionary examples": "wiktionary_examples",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  # Prose claims about the whole corpus: what they count, the printed unit, the pattern.
@@ -80,7 +97,9 @@ CLAIMS = (
80
 
81
  UNITS = {1: "", 1e6: "M", 1e9: "B"}
82
 
83
- NUMBER = re.compile(r"\d[\d,]*(?:\.\d+)?")
 
 
84
  VERSION = re.compile(r"v\d+\.\d+\.\d+")
85
  TABLE = re.compile(r"\\begin\{(table\*?)\}.*?\\end\{\1\}", re.S)
86
 
@@ -152,7 +171,8 @@ def _rows(tex: str, label: str, columns: tuple[str, ...]) -> list[dict[str, str]
152
  for line in _table_body(tex, label).splitlines():
153
  line = line.strip()
154
  if line.endswith("\\\\"):
155
- cells = [cell.strip() for cell in re.split(r"(?<!\\)&", line[:-2])]
 
156
  if len(cells) == len(columns):
157
  rows.append(dict(zip(columns, cells)))
158
  return rows
@@ -165,9 +185,10 @@ def parse_releases(tex: str) -> dict[str, dict[str, str]]:
165
 
166
 
167
  def parse_additions(tex: str) -> tuple[dict[str, list[dict]], dict[str, dict]]:
168
- """tab:additions: version -> its addition rows, and version -> its "Total added" row.
169
 
170
- A row with an empty release cell continues the release above it.
 
171
  """
172
  additions: dict[str, list[dict]] = {}
173
  totals: dict[str, dict] = {}
@@ -176,7 +197,7 @@ def parse_additions(tex: str) -> tuple[dict[str, list[dict]], dict[str, dict]]:
176
  if not (NUMBER.fullmatch(row["documents"]) and NUMBER.fullmatch(row["tokens"])):
177
  continue # header
178
  release = row["release"] or release
179
- if row["addition"] == "Total added":
180
  totals[release] = row
181
  else:
182
  additions.setdefault(release, []).append(row)
@@ -264,10 +285,11 @@ def load_registry(root: Path, ref: str) -> dict[str, dict]:
264
 
265
 
266
  def released_at(registry: dict[str, dict], version: str) -> set[str]:
267
- """Sources whose `release` is at or before `version`."""
268
  ceiling = _version_key(version)
269
  return {name for name, cfg in registry.items()
270
- if cfg.get("release") and _version_key(cfg["release"]) <= ceiling}
 
271
 
272
 
273
  def _version_key(version: str) -> tuple[int, ...]:
@@ -350,7 +372,7 @@ def check_trajectory(report: Report, tex: str, root: Path, ref: str) -> None:
350
  added = sum(int(_number(row[what])[0]) for row in rows)
351
  report.num(f"{version} additions sum to the {what} change", added, change)
352
  if version in totals:
353
- report.printed(f"{version} Total added {what}", totals[version][what], change)
354
 
355
 
356
  def check_composition(report: Report, tex: str, root: Path, ref: str) -> None:
@@ -449,7 +471,8 @@ def norm_license(text: str) -> tuple[str, str | None]:
449
  match = re.search(r"CC[- ]BY(?:[- ](SA))?(?:[- ](\d+\.\d+))?", t)
450
  if match:
451
  return ("CC-BY-SA" if match.group(1) else "CC-BY", match.group(2))
452
- return (t.strip(), None)
 
453
 
454
 
455
  def compatible(a: tuple[str, str | None], b: tuple[str, str | None]) -> bool:
 
8
  1. Release trajectory (`tab:releases`, `tab:additions`): documents, tokens and
9
  source counts per release, and the additions that reconcile consecutive totals.
10
  Ground truth: the VERSIONS/DOCUMENTS/TOKENS literals in src/plot_version_growth.py,
11
+ the `release` and `removed` fields in src/sources.py, and the CHANGELOG.md
12
+ source counts.
13
 
14
  2. Corpus composition (`tab:sources` and the prose): per-source documents, tokens
15
  and first release, the source set, and the totals of the latest release.
 
68
  "Global Voices": "global_voices",
69
  "NKJP1M": "nkjp1m",
70
  "Wiktionary examples": "wiktionary_examples",
71
+ # Added in v0.2.6.
72
+ "UZP rulings": "uzp_orzeczenia_pl",
73
+ "Wikipedia user talk": "plwiki_user_talk",
74
+ "Sejm committee transcripts": "sejm_committee_transcripts",
75
+ "Wikipedia talk": "plwiki_talk",
76
+ "TED notices": "ted_pl",
77
+ "Sejm speeches 2011--2022": "sejm_api_2011_2022",
78
+ "Sejm interpellations": "sejm_interpellations",
79
+ "Nonsensopedia": "nonsa",
80
+ "OPEN ICM": "open_icm_pl",
81
+ "Studia BAS": "studia_bas",
82
+ "Wiadomo\\'sci Statystyczne": "wiadomosci_statystyczne_pl",
83
+ "ROCK Politechnika Lubelska": "rock_pollub_pl",
84
+ "Edukacja Medialna": "edukacja_medialna_pl",
85
+ "Open AGH chemistry": "open_agh_chemistry_pl",
86
+ "Kultura bez Barier": "kultura_bez_barier_pl",
87
  }
88
 
89
  # Prose claims about the whole corpus: what they count, the printed unit, the pattern.
 
97
 
98
  UNITS = {1: "", 1e6: "M", 1e9: "B"}
99
 
100
+ TOTAL_ROWS = ("Total added", "Net change")
101
+
102
+ NUMBER = re.compile(r"-?\d[\d,]*(?:\.\d+)?")
103
  VERSION = re.compile(r"v\d+\.\d+\.\d+")
104
  TABLE = re.compile(r"\\begin\{(table\*?)\}.*?\\end\{\1\}", re.S)
105
 
 
171
  for line in _table_body(tex, label).splitlines():
172
  line = line.strip()
173
  if line.endswith("\\\\"):
174
+ # A minus sign is typeset as $-$.
175
+ cells = [cell.strip().replace("$-$", "-") for cell in re.split(r"(?<!\\)&", line[:-2])]
176
  if len(cells) == len(columns):
177
  rows.append(dict(zip(columns, cells)))
178
  return rows
 
185
 
186
 
187
  def parse_additions(tex: str) -> tuple[dict[str, list[dict]], dict[str, dict]]:
188
+ """tab:additions: version -> its addition rows, and version -> its totals row.
189
 
190
+ A row with an empty release cell continues the release above it. The totals row
191
+ is "Total added", or "Net change" for a release that also removes or shrinks sources.
192
  """
193
  additions: dict[str, list[dict]] = {}
194
  totals: dict[str, dict] = {}
 
197
  if not (NUMBER.fullmatch(row["documents"]) and NUMBER.fullmatch(row["tokens"])):
198
  continue # header
199
  release = row["release"] or release
200
+ if row["addition"] in TOTAL_ROWS:
201
  totals[release] = row
202
  else:
203
  additions.setdefault(release, []).append(row)
 
285
 
286
 
287
  def released_at(registry: dict[str, dict], version: str) -> set[str]:
288
+ """Sources whose `release` is at or before `version` and whose `removed`, if any, is after it."""
289
  ceiling = _version_key(version)
290
  return {name for name, cfg in registry.items()
291
+ if cfg.get("release") and _version_key(cfg["release"]) <= ceiling
292
+ and not (cfg.get("removed") and _version_key(cfg["removed"]) <= ceiling)}
293
 
294
 
295
  def _version_key(version: str) -> tuple[int, ...]:
 
372
  added = sum(int(_number(row[what])[0]) for row in rows)
373
  report.num(f"{version} additions sum to the {what} change", added, change)
374
  if version in totals:
375
+ report.printed(f"{version} {totals[version]['addition']} {what}", totals[version][what], change)
376
 
377
 
378
  def check_composition(report: Report, tex: str, root: Path, ref: str) -> None:
 
471
  match = re.search(r"CC[- ]BY(?:[- ](SA))?(?:[- ](\d+\.\d+))?", t)
472
  if match:
473
  return ("CC-BY-SA" if match.group(1) else "CC-BY", match.group(2))
474
+ # A LicenseRef spells a licence's name: LicenseRef-EU-Reuse-Policy is "EU reuse policy".
475
+ return (re.sub(r"^LICENSEREF-", "", t.strip()).replace("-", " "), None)
476
 
477
 
478
  def compatible(a: tuple[str, str | None], b: tuple[str, str | None]) -> bool: