Repository navigation
Add a native-script Wikidata corpus: real names in their own scripts - #693
Merged
Merged
Conversation
Every real-name corpus was Latin script apart from Wikidata's Russian patronymics, and CLDR's native-script names are invented, so the script-conditional rules (family-first Han, Hangul and kana, Korean segmentation, the honorific peel) had met no real name. build_wikidata_native_corpus.py samples public figures by country and language (20 strata, 910 names: Hangul, Han, kana, Arabic, Persian, Hebrew, Georgian, Armenian, Greek, Serbian, Bulgarian, Ukrainian, Kazakh, Bengali, Devanagari, Thai), reusing build_wikidata_corpus.py's alignment. It adds a script filter, character alignment for unspaced text with nothing inferred, per-language feminine surnames, and no shape where the script decides the order. --lc-check compares the splits with the Library of Congress's native-script variants: 96 of the 99 it can split agree, and the other three are suspect P244 links. cldr_agreement.py scores the source (wikidata_native_agreement.json) and its locale view now reads a row's own `pack`, so the Han and kana names are scored under ZH and JA too (wikidata_native_agreement_ locales.json). The other records do not move; the snapshot gains 904 names, none moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ths mutations missed A katakana-only name written unspaced keeps its family-first shape, and only Han, kana and Hangul are aligned by character. A pool shorter than its size stops the build unless the stratum is marked as its whole population. The LC check counts an LCCN LC no longer has. The locale summary still checks a pack with no renderings left, and reports a row naming a pack no view measures. New tests cover each of these, the query matching nothing, a missing pooled person, the languages filter, the LC cache, every locale record being read, and the carry-over of an unmeasured pack's entries. The rebuilt corpus is byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Second review of the fixes: the Hebrew-point row was all Hebrew, so it passed with the mark check deleted; the pool comment still called a short pool the whole population; the whole-strata test only restated the table. The README's Adding-a-source paragraph records both lessons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI's 3.14 and 3.15 jobs failed the two LC error tests on an unraisable ResourceWarning: an HTTPError holds its response until closed. The 404 path in lc_variants closes it, which a real run needed too, and the 503 test closes the one it catches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #693 +/- ##
=======================================
Coverage 99.03% 99.03%
=======================================
Files 46 46
Lines 4541 4541
=======================================
Hits 4497 4497
Misses 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…t on The full PR review (code, comments, tests, types) found no correctness bug. It did find that the corpus was said to test the CJK honorific peel, which it cannot: no text holds an honorific, so AGENTS.md would have sent a peel change to a record blind to it. The builder docstring, README and AGENTS.md now say so. Also corrected: Arabic nasab chains fail because `بن` is no connective in Arabic script, not for want of a family name; which strata have lowered floors and why; the Japanese blind spot; `--lc-check` runs after the build; 907 corpus lines, 904 new to the snapshot. Code: a stratum marked whole=True whose pool fills stops the build, since the mark is then stale; entities() reads `languages` once; unmapped() takes the rows it needs; --record reuses the loaded rows. Tests for each mutation that survived the second pass: feminine forms added, not substituted; a given name required; the LC tallies; the Arabic comma, same-order and spaced-text branches of lc_split; texts in a variant language, and not in another; given-first unspaced order; each locale view's own default count. Every one fails its mutation. The offline rebuild is byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/simplify (reuse, simplification, efficiency, altitude): - The locale view reads each source's pack from its own rendering key (LocaleSource: CLDR's file through LOCALE_FILES, the native source's stratum through the new NATIVE_LABELS), so the builder no longer writes a `pack` field. That removes row_pack, the fallback for a rendering that is gone, the rows argument to unmapped, and the stray- pack check. NATIVE_LABELS sits beside LOCALE_FILES; the strata it must cover live in the builder, so a test ties the two both ways (the second review found a new zh or ja stratum would otherwise go unscored under its pack). The fields file loses `pack` on its 140 Han and kana rows and nothing else; no record moves. - build_wikidata_corpus.claim() and by_field() hold the alignment rule once; align() and align_chars() find spans and call them. - renderings() orders both branches with _order(), and script_orders() names the script-decides-the-order rule its test used to restate. A test now pins the scripts it names against Policy().script_orders. - lc_split reads both commas in one partition. - The two summary tests share one main([]) run, and the summary no longer scores a pack twice: the four test modules run in 3.6 s, from 4.6 s. Skipped: a shared build/pool driver for both Wikidata builders and a shared fetch helper (they reach into the parent builder and GND/CLDR; a follow-up if the builders grow), lazy pool fetching (changes every cache key; only --refresh pays), moving the test helpers to the shared fixtures, and corpus_lines's re-export, which test_corpus_build reads. Each of 13 mutations of the refactored code fails a test; the offline rebuild differs from the committed file only by the dropped `pack`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 17, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every real-name corpus in
tools/differential/was Latin script, apart from Wikidata's Russian patronymics. CLDR covers native scripts, but its names are invented. So the parser's script-conditional readings had never been checked against a real name: family-first order for Han, Hangul and kana, and Korean surname segmentation. No text holds an honorific, so the corpus does not exercise the CJK honorific peel; it only shows the peel leaves plain names alone. This PR adds 910 real names written in 16 scripts and languages, sampled in 20 strata by country and language.What it adds
build_wikidata_native_corpus.pyreusesbuild_wikidata_corpus.py's fetches and token alignment throughcorpus_build.py, and adds:mullabels are Latin, so without thisAnushka Sharmapassed as a Hindi name.--lc-check, which compares each split with the native-script variants of the person's Library of Congress record. It is a report only: it runs after the build, and adds nothing to the output files and filters nothing.cldr_agreement.pyscores the source intowikidata_native_agreement.json. Its locale view now maps each source's rendering key to a pack (NATIVE_LABELSfor the native strata), so real Han and kana names are scored underZHandJAtoo, intowikidata_native_agreement_locales.json.What it found (2026-10-16)
عبد العزيز,عز الدين,شكر الله,ذو الغنى), where the parser reads the first word as a middle name;ZH, which misses the surnames詹,卫,柯,茅,华and文. 59/60 underJA.Wikidata's labels encode a convention in places, and the README records where: an Arabic nisba is entered as P734.
Left out
Cost
Measured locally without coverage, 2026-10-16:
Records
The snapshot gains 904 names and moves none. The CLDR, GND, Wikidata, conventions and CLDR locale records do not move. The JA rows were recorded with the
jaextra installed. The suite passes both with and withoutnamedivider.Reviews
HTTPErrorfails the run; the 404 path now closes it (2bfd5cd).wholeguard added, and tests for every mutation a second 35-mutation pass left alive (b54bb32)./simplify(reuse, simplification, efficiency, altitude): the locale view reads each source's pack from its own rendering key (NATIVE_LABELSbesideLOCALE_FILES), so the fields rows no longer carrypack; one shared alignment rule (claim) and one order rule (script_orders, pinned againstPolicy().script_orders); the agreement tests share one summary run (3.6 s, from 4.6 s). Its second review found a new zh/ja stratum could go unscored; a test now ties the two tables (428148f).Follow-ups (not filed; drafts on request)
عبدand similar first words bind to the word after them in native script?ZHsurname coverage: six surnames missed on real names.🤖 Generated with Claude Code