wolne_lektury: restore author and translator notes (v2#109)

#188
by ppuzio - opened
Commit history is no longer available for this pull request.
Fabryka AI org
•
edited 8 days ago

wolne_lektury: restore author and translator notes (v2#109)

On main cab2c22 (after 184 and 187). SpeakLeash's export of Wolne Lektury (WL) has no footnotes; WL's book XML does. Per the maintainer's decision of 2026-10-20, the author's notes (<pa>) and translator's notes (<pt>) are added at the end of the 460 texts whose book has them. WL's editorial notes (<pe>, <pr>) are not restored, and the glosses WL's editors added inside the restored notes are stripped, and so are the 2 such glosses in the main text (below). The other 5,614 texts are byte-identical to main.

Format, after the existing text (paragraphs are separated by a blank line, as elsewhere in the corpus; numbering restarts at 1 in each section, in document order):

Przypisy autora

1. <note>

2. <note>

Przypisy tłumacza

1. <note>

A real tail (wolne_lektury_2372314): ...Życzę im tego. / Przypisy autora / 1. z tego letargu, w którym [Francja] leży uśpiona przez dwadzieścia lat władzy osobistej --- Podróż ta pisana przed ostatnią wojną. / Przypisy tłumacza / 1. Charenton --- szpital wariatów w Paryżu. A note is the text of its element with whitespace collapsed; nested pe/pr/extra/uwaga text is left out, and so are WL's glosses.

Rows Notes
changed rows 460 18,938
author's notes (Przypisy autora) 337 8,100
translator's notes (Przypisy tłumacza) 168 10,838
left out: empty 2 2
left out: the export kept the note in the text 2 3
left out: translator's notes of a public-domain row with no WL public-domain date 0 0
left out: nothing but WL's glosses after the word (wl_gloss_only) 0 0

45 rows have both kinds. The notes add 3,909,520 chars and 1,497,180 tokens; with the 2 main-text glosses stripped (below), chars go from 230,761,977 to 234,671,405 (+3,909,428) and tokens from 90,653,913 to 92,151,055 (+1,497,142). token_count of the 462 changed rows is recounted with the dataset's tokenizer (tiktoken cl100k_base). No text still ends with a WL footer, so no notes had to go before one.

WL's glosses are stripped (decided 2026-10-20)

WL's editors added glosses in square brackets inside author's and translator's notes, e.g. dotis --- miara zbliżona do polskiego łokcia [czyli ok. 60 cm; red. W.L.]. (wolne_lektury_2371955), restored as dotis --- miara zbliżona do polskiego łokcia. strip_glosses() in src/wolne_lektury_notes.py removes every bracket whose own text carries WL's signature (\bW\.?L\b: "red. WL", "Red. WL", "red WL", "przyp. WL", "W.L.", a bare "WL"), one level of nesting deep, and tidies the punctuation left around the cut (no ;., ,., (), ( x).

Notes Rows Glosses Characters
glosses stripped 632 131 668 77,065

The characters are the glosses'; with the spaces and punctuation around them the text is 77,867 characters and 30,961 tokens shorter than with the glosses.

  • A print editor's bracket with a WL gloss nested in it (signed "J. U.", in wolne_lektury_2375317) keeps its own text; only the inner WL bracket is cut.
  • Unsigned brackets are kept: translations, references, the print editions' own brackets, 126 "[pominięto tłum. …]" in wolne_lektury_2374372 (kept as decided on 2026-10-20; a 127th there is signed and is stripped), 37 bibliographic "[red.]" in wolne_lektury_2373909, 71 "[Komentarz autora z Uwag.]" in wolne_lektury_2374243.
  • No restored note is left with nothing after its word, so wl_gloss_only is 0. A release test checks that no restored section still carries WL's signature.
  • footnote_check.wl_glosses_stripped in the evidence file lists each note's row, kind, position and number of glosses. The sidecar note of the 131 rows says the glosses are not included; the other 329 restored rows keep the plain wording.

WL's glosses in the main text are stripped too (decided 2026-10-20)

The export's main text carries 2 glosses of WL's editors, one in each of 2 rows (90 characters):

  • "Profesor Butrym" (Jerzy Żuławski, wolne_lektury_2372131): …wyjrzało złote i uśmiechnięte [słońce – przyp. WL] i przeglądało się… becomes …wyjrzało złote i uśmiechnięte i przeglądało się….
  • "Intryga i miłość" (Fryderyk Schiller, tr. Michał Budzyński, wolne_lektury_2377006): ŻONA / / [mówi jednocześnie z dalszymi kwestiami Millera i Ferdynanda — Red.WL] załamując ręce / becomes ŻONA / / załamując ręce /.

TEXT_GLOSSES in src/wolne_lektury_notes.py lists the 2 rows and their glosses. strip_text_glosses() runs strip_glosses() on each line of every row before the notes are added and stops the build if the glosses it finds are not exactly that list; a second digest pin (the text with the glosses stripped, before the notes) stops it if anything else changed. Each row is 1 space plus its gloss shorter: −92 characters and −38 tokens in all. The sidecar modification_note of the 2 rows quotes the gloss removed, wl_glosses_in_main_text in the evidence file lists them, and a release test checks that no released text, notes included, still has a gloss signed by WL and that the 2 passages read as above.

How it is reproducible

  • data/wolne_lektury/wolne_lektury.notes.jsonl (4.2 MB, plain git, pinned by SHA-256) holds, for each of the 460 rows, the slug, the SHA-256 of its XML file, dc:date.pd and the notes. python3 -I src/wolne_lektury_notes.py write|check <directory with the XML> rebuilds or verifies it (DOCTYPE and ENTITY are refused; the files are parsed, never run). It was checked against the 6,064 downloaded files: they give the committed file.
  • src/clean_wolne_lektury.py reads only that committed file. It adds the notes after the ELTeC dedup, so the dedup scores the texts without them and wolne_lektury.eltec_pairs.tsv is unchanged. A pin on the text digest before the notes stops the step if the input is not the text it was written for.
  • src/build_wolne_lektury_attribution.py then fills author and writes the sidecar; text_sha1 is of the final text. The docstring of clean_wolne_lektury.py gives the whole chain: git checkout v0.2.5 -- data/wolne_lektury/wolne_lektury.parquet data/eltec_pol/eltec_pol.parquet, python3 src/clean_wolne_lektury.py, python3 src/build_wolne_lektury_attribution.py --cache ~/speakleash/wolne_lektury_meta, then the ELTeC builder again (or git checkout HEAD -- data/eltec_pol/eltec_pol.parquet).
  • The sidecar modification_note of the 460 rows says the notes were restored from WL's book XML as sections at the end and that WL's editorial notes (and, in 131 rows, its glosses) are not included. The note of the 2 main-text-gloss rows quotes the gloss removed. The other rows' records are unchanged. footnote_check in the evidence file now states what was restored, what was left out, the glosses stripped and the notes file's SHA-256. The card and artifacts/source_findings.md are updated.

Checks

  • The Parquet on main and this one compared row by row (one-off local run): 5,614 rows are identical, 460 are their old text plus the sections, and the 2 glossed rows are their old text less 1 space and the gloss; every other column is unchanged. The release test strips the sections and checks the digest of the text before the notes, with the 2 glosses stripped.
  • Before appending, each note was checked against its row's text: 3 author's notes were already in the text (wolne_lektury_2371978 note 701, wolne_lektury_2376761 notes 5 and 6) and are not appended, the other notes of wolne_lektury_2376761 (Lithuanian glosses) appear in the text only as paraphrases and are restored.
  • Counts of nested cases: 1 author's note nested inside another (kept in the outer note and as its own); 0 pe/pr inside a note (one-off scan of the XML); 4 notes contain extra/uwaga text, which is dropped.
  • Release tests: file pin and format, per-row section numbering and counts parsed independently from the Parquet, notes agree with wl_date_pd, token recount, stats sums, sidecar notes, evidence counts, no gloss signed by WL left in any text. Unit tests on synthetic XML and tables. Full suite from the repository root, on this commit on main cab2c22: 1992 passed, 9 skipped, 138 subtests passed.

Edition review (2026-10-20): the evidence file records, under edition_review.reviewed, that 98 rows were read (58 critical, 10 with a "Komentarz" heading, 30 public-domain without a WL public-domain date) and no row was cut or dropped. A release test pins 98 = 58 + 10 + 30 by recomputing the three groups from the evidence and the sidecar.

Open points

  • Notes keep WL's markup: --- for the dash, ,," quotes, / for verse breaks.
  • Not checked: the Korczak row (WL serves no XML, 404) and the second book of wolne_lektury_2375260.
  • The restored notes add to text_checks: 1 WL URL (wolne_lektury_2373987, a translator's note citing WL's Montaigne), 5 rows with a [przypis marker (the author's or translator's own, e.g. "[Przypis autora]"; 2 more were WL's signed labels, e.g. "[przypis zweryfikowany i poprawiony przez Red. WL]", and are stripped), 1 period-spelling row (wolne_lektury_2374500; now 239) and 4 soft hyphens (now 9,300). They are content of the notes.

Files

  • data/wolne_lektury/wolne_lektury.{parquet,notes.jsonl,attribution.jsonl,license-evidence.json,md,stats.json}
  • src/wolne_lektury_notes.py (new), src/clean_wolne_lektury.py, src/build_wolne_lektury_attribution.py, src/wolne_lektury_licences.py (read_licences), src/sources.py
  • Tests: src/test_wolne_lektury_notes.py (new), src/test_wolne_lektury_attribution.py, src/test_attribution_release.py
  • artifacts/source_findings.md: WL section

Not in this PR: the README row (v2#80), the 98-row edition decisions beyond recording them, and eltec_pol.

🤖 Generated with Claude Code

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

Sign up or log in to comment