wikipedia: record links and a citations table (v2#110)

#148
by ppuzio - opened

Adds the per-record links to wikipedia and its source citations in a separate table (v2#110, 1A, option A for the citations). Text, ids, labels and every column of wikipedia.parquet are unchanged (same LFS object).

Sidecar: each line of wikipedia.attribution.jsonl gains permalink, history_url, license_urls and conversion, as in the sibling wiki PRs. citations is not in it but in its own table (option A), and there is no source_notes (no source-note templates are defined for Wikipedia).

Citations table: data/wikipedia/citations/wikipedia.citations.parquet (542 MB, zstd), columns id and citations (list of strings), one row per released row in the same order and row groups. Each list holds the page's non-empty <ref> bodies, then the Cytuj.../Cite... templates outside them, as wikitext, in page order without repeats (page_sources, the same as the other wiki sources). 1,165,616 of 1,468,647 rows have any; 7,476,723 citations in all. They are read from the 7 plwiki-20260901-pages-meta-current shards (sha1-checked against dumpstatus.json), and every released row's revision id and timestamp match the dump's, so the citations belong to the shipped text. build.json citations records the shards, counts and sha256.

It is in a folder of its own because data/*/*.parquet (the README's dataset config, make_training_mix, the takedown default, test_uniform_schema) would read a parquet next to wikipedia.parquet as documents.

Card: the citations paragraph (generated by citations_text from build.json), the quotation paragraph (Art. 29) before Evidence, the link fields, a pointer from Provenance's "removing <ref> bodies" to the table, and two Not-checked lines reworded (Art. 29; personal data in the text and the citations).

Personal data: the citations are not redacted, like the Wikipedia text; the NERGAL pass before release has to cover this table too (v2#60).

Code:

  • fetch_wikipedia.py: a citations step (--out = the shards' dir) that stops on a missing page, a page in two shards or twice in one, a sha1 mismatch, or a row whose revision or timestamp differs from the dump's; withhold refuses to run after it (its output would have to be filtered). citations_text writes the card paragraph.
  • fetch_wikimedia.py: citations_sentence, split out of sources_text (the other cards' text is unchanged); page_sources no longer needs a SOURCE_NOTE_TEMPLATES entry.
  • takedown.py apply also drops blocked rows from the <k>.*.parquet tables in a folder next to a shard; PROCEDURE.md step 4.3 says so (step 4.1's git lfs pull --include "data/<k>/*" already pulls nested files). test_takedown covers it, and a new test checks that no such table holds a row its shard lacks. As with attribution_sha256, a takedown leaves build.json citations stale until the step reruns; the contract test flags it.

Tests: test_wikipedia_contract passes, including the new unit tests and test_citations_table_matches_the_release; test_takedown passes. The full suite has 2 failures, both on main already: test_studia_bas_artifacts (relative path) and test_wikinews_contract (waits for #146). test_every_row_is_labelled_by_contribution, failing on main, passes here. README, CHANGELOG and totals are left to v2#80.

🤖 Generated with Claude Code

ppuzio changed pull request status to open
ppuzio changed pull request status to merged
ppuzio deleted the refs/pr/148 ref

Sign up or log in to comment