Skip to content

Read a bound pair from its listed second word too (#1072) - #1500

Merged
derek73 merged 4 commits into
masterfrom
fix/issue-1072-backward-pairs
Nov 20, 2026
Merged

derek73 merged 4 commits into
masterfrom
fix/issue-1072-backward-pairs

Conversation

@derek73

@derek73 derek73 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Closes #1072

As decided on the issue: a bound pair is read from its listed second word too, an amendment to rules/P12 (a bound given name and the word that completes it). In Arabic script, الدين and الله join the plain word before them: Persian الدین and اله and Urdu اللہ too. The pair is the given name where it opens the name and the family where it ends it, under the default order. ذو joins الغنى and الفقار.

نور الدين سامر حداد   → given 'نور الدين', middle 'سامر'   (1.4.0–3.1.0: given 'نور', middle 'الدين سامر')
سامر عز الدين         → family 'عز الدين'                  (1.4.0–3.1.0: middle 'عز', family 'الدين')
ليلى شكر الله          → family 'شكر الله'                  (1.4.0–3.1.0: middle 'شكر', family 'الله')
سامر نور الدين حداد   → middle 'نور الدين'                  (unchanged: inside the name)
عز الدين              → given 'عز', family 'الدين'          (unchanged: a name of two name words)
Dr. عز الدين          → given 'عز', family 'الدين'          (unchanged: a title is no name word)

What it adds

  • A new vocabulary kind, bound_second, for the word a pair writes second. Lexicon.add accepts it (add("x", kind="bound_second")), with one list property, completes=[...], naming the only first words it joins behind.
    • Compiled sets: BOUND_SECONDS, BOUND_SECOND_PHRASES and BOUND_SECONDS_LISTED.
    • It is listed everywhere a kind is listed: _reading_index's tables, the build's checks and their mutations, Lexicon.add's docs, the vocabulary README, customize.rst's kind and property tables.
    • No other API.
  • The rule:
    • Classify tags the plain word before a listed second word: a word carrying no vocabulary and holding a letter, the second word carrying none but H9's contested-title tag.
    • Group's P12 join pairs them, at the name's first word too.
    • A name of two name words keeps the pair apart. That is asked of the parse once roles are settled: post_rules splits a pair that holds every name word the parse read, unless it stands after a family comma or behind a given-name title, where P5 joins عبد الله too. A later word's report then names the field it would take beside two names.
  • Shared readers: the unit readers (P1's family-first fold, O6's take and division) read the new tag as they read the forward pair's, so the pair stays one unit there.
  • rules/P12, amended, not split: one rule about a bound pair, read from whichever word is listed.
    • P5 keeps a bound word at the first name word.
    • A pair read from its second word joins there too, its first word being no bound word for P5.
    • Where a bound word opens the name, P5's join wins and the pair is split (a new Precedence bullet: أبو نور الدين سامر → given 'أبو نور').
    • The Signal line names the second signal with +, so the split-candidate grep sees it.
  • Left out, as Open lines in decisions/P12:
    • The Latin spellings. Uddin: PSC 25 fixed / 432 broken, ORCID Bangladesh 15 / 99. Without the u- forms: ORCID 155 / 0, but PSC 16 / 11 and PatentsView 6 / 8.
    • آية الله as a title. The vocabulary can't express it: a title phrase's partner must be a title word, and a title reading on الله would break the pairs read from it. The shape is 16 spaced JRC-Names spellings plus 7 written joined. It is pinned as the accepted reading: given 'آية الله', where 3.1.0 read given 'آية', wrong both ways.
  • Should د. and the Iraqi academic abbreviations read as titles? (د. أحمد علي حسن gives given 'د.') #1149 (PR Read Arabic titles written short, and give Arabic script no initials (#1149) #1497, merged into this branch): the two share no word. Read Arabic titles written short, and give Arabic script no initials (#1149) #1497 adds Arabic titles (أ.د, د, الاستاذ, اللواء, ...) and does not touch آية الله, الدين, الله or the join's code. A title of it before a pair is read as a title and the pair joins after it (د. نور الدين سامر حداد → title 'د.', given 'نور الدين'). Its د. addresses the given name as الدكتور does, so a two-word pair behind it stays joined, P5's exception (د. عز الدين → given 'عز الدين', a row). The shared files (ar.toml, the compiled vocabulary, the snapshot and rules corpus, cases.py, migrate.rst) merged with both sides kept and the generated ones rebuilt.

Measured

The prototype was scored against master 34771e2d on three variants; the shipped build reads the 857 corpus names holding a second word as variant A does, save one two-word name the prototype mishandled.

A (shipped): second words behind any plain word B: closed list of pairs C: الله behind listed words only
ORCID, Arabic-script boxes (178 records) fixed / broken 33 / 0 26 / 0 26 / 0
Wikidata native: the 3 names the record held 3 now agree 3 3
Egypt's House: 25 pairs wrong on master 25 right 25 25
JRC-Names opening الدين / الله, 3+ words, pair kept in one field 33 of 33 / 60 of 60 23 / 18 33 / 18

Changes

  • Code: _classify.py, _group.py, _vocab.py (unit_ends), _post_rules.py (O6's division), _assemble.py, _state.py, _reading_index.py, _lexicon.py, tools/vocab/build.py.
  • Vocabulary: entries in ar.toml, fa.toml and ur.toml; compiled modules rebuilt.
  • Records: the snapshot, the rules corpus and the Wikidata native agreement record are re-recorded. The record's 3 names of this shape now agree; no other record moves.
  • Docs:
    • rules/P12 and P5; decisions/P12, with a dated entry: the three variants, the three questions answered, the recipe, what A gets wrong, the alike moves and the Persian count.
    • mechanisms.md's UNIT-PARTITION and the rules README glossary.
    • customize.rst, a migrate.rst entry and one release-log bullet.
    • The vocab README; root, nameparser/ and nameparser/vocab/ AGENTS.md lessons.
  • Tests:
    • cases.py rows across comma shapes, the three orders, titles and particles before the pair, maiden clauses, nicknames, marks, Persian and Urdu spellings, and the guard's edges. parity_check.py reports 0 of 690 parity rows differing from 1.4.0; the fix(...) notes were checked against the 1.4.0, 2.x and 3.1.0 wheels.
    • Build-check mutations, a caller's add/remove both ways, the refusals, and the tags kept off published tokens.

Reviews

  • Round one: code, tests with mutations, comments, and design docs.
  • What they found:
    • a title or suffix beside a two-word pair joined it into the whole name;
    • O6 and P1's family-first fold cut the pair;
    • three rule examples quoted real Wikidata records;
    • a wrong reason for آية الله;
    • an unreproducible JRC-Names row;
    • a missing recipe and precedence;
    • surviving mutants.
  • Then: all fixed with rows, and the fix commits reviewed, four more rounds.
  • The guard's form: the first three tried to count name words in classify, before the trailing run is read. Each round found the count narrowing somewhere new:
    • a title or suffix counted;
    • a bare trailing title not counted;
    • a word the run then left a middle name made to stop the count.
  • Where it settled: post_rules, which reads the parse's own roles. The last review found one stale report alternative under FAMILY_FIRST, now fixed and pinned.

measure.py --base against e0f698c8: 30 steps, none failed; moves only in the jrc-names, parliaments and orcid steps. Frames re-taken on the merged tree are unchanged from the table.

Full suite, -m serial, mypy, ruff, Sphinx doctest, README doctest, build.py --check, familiar.py --check and parity_check.py all pass.

🤖 Generated with Claude Code

A new vocabulary kind, bound_second, for the word an Arabic-script pair
writes second: الدين and الله (Persian الدین and اله, Urdu اللہ) join
the plain word before them, at the first name word too, the pair placed
by position (under the default order the given name where it opens the
name, the family where it ends it); الغنى and الفقار are written
`completes = ["ذو"]`, joining behind ذو alone. Lexicon.add accepts the
new kind.

A pair holding every name word the parse read is split back once roles
are settled, as P5's reserve keeps a bound word's, save after a family
comma and behind a given-name title, where P5 joins too. The pair is
one unit for P1's family-first fold and O6's take and division, before
a family comma too. One rule, rules/P12, read from whichever word is
listed. Latin spellings and آية الله as a title stay out, recorded as
Open lines in decisions/P12 with the counts. Snapshot, rules corpus and
the Wikidata native agreement record re-recorded (the three names #1072
named now agree).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73 derek73 added this to the 3.2 milestone Nov 20, 2026
@derek73 derek73 added vocabulary Fixed by a word-list entry: per-word vocabulary and language packs non-latin-script Names written in a script other than Latin (rules/W) particles Particles and surname prefixes (rules/P) labels Nov 20, 2026
@derek73 derek73 self-assigned this Nov 20, 2026
derek73 and others added 3 commits November 19, 2026 22:09
The split's own adjacency check could not be reached once the caller had
tested the tag, which codecov/patch reported; the caller now tests both,
and the split reads the pair it was handed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both sides added a migrate.rst section and cases.py rows; both kept.
The compiled index, rules corpus and snapshot are regenerated. A row
pins that #1149's short title, which addresses the given name, keeps
a two-word pair joined behind it, as الدكتور does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The release log kept both sides' bullets; the compiled vocabulary, rules
corpus and snapshot were regenerated and did not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

non-latin-script Names written in a script other than Latin (rules/W) particles Particles and surname prefixes (rules/P) vocabulary Fixed by a word-list entry: per-word vocabulary and language packs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should جميل عز الدين read family عز الدين, the الدين joining the word before it?

1 participant