From 7a41ffa669fe6fd85863afcadf57c86804f309b3 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 19:08:39 -0800 Subject: [PATCH 1/2] Join a Latin bound given name past the first word with the name word after it (#1464) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit abd, abdel, abdal and abou carry `completes_any` on their bound_given reading, and abdul `long_names_only` beside it: rules/P12 joins the bound word with a plain name word after it past the first name word, abdul only in a name of four name words or more, and position places the pair (family where it ends the name, one middle name inside it). `Tariq Abdel Aziz` gives family 'Abdel Aziz'; `Tariq Abdul Aziz` keeps middle 'Abdul'; `Haddad, Nadia Abd Karim` no longer reads ABD. abu and Arabic-script عبد are unchanged. The four-word count runs after classify's H9 phrase test, part by part: each part's leading title run counts as none, and after the pair only a plain word, a bound given name or a pair of initials up to the next comma, a numeral written other than in Title case not counting. Two properties compile into BOUND_COMPLETES_ANY and BOUND_LONG_NAMES_ONLY; the build refuses long_names_only alone. Rules P12, P5, O6 and S8 amended; decisions/P12 records the three routes measured, the three-word split by population and what is still wrong. Snapshot, rules corpus and CLDR agreement re-recorded. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- docs/customize.rst | 27 +- ...ven-name-and-the-word-that-completes-it.md | 37 ++- docs/design/rules/O6-two-family-names.md | 4 +- ...ven-name-and-the-word-that-completes-it.md | 25 +- docs/design/rules/P5-bound-given-names.md | 3 +- docs/design/rules/README.md | 2 +- .../rules/S8-credentials-trailing-run.md | 2 +- docs/migrate.rst | 25 ++ docs/release_log.rst | 1 + nameparser/AGENTS.md | 2 +- nameparser/_lexicon.py | 9 +- nameparser/_pipeline/_classify.py | 135 +++++++-- nameparser/_pipeline/_group.py | 8 +- nameparser/_pipeline/_state.py | 11 +- nameparser/_reading_index.py | 20 +- nameparser/config/_compiled.py | 12 + nameparser/config/_index.py | 10 +- nameparser/vocab/README.md | 2 + nameparser/vocab/ar.toml | 15 +- tests/v2/cases.py | 274 +++++++++++++++++- tests/v2/pipeline/test_group.py | 9 +- tests/v2/pipeline/test_post_rules.py | 20 +- tests/v2/test_cases.py | 14 +- tests/v2/test_layering.py | 6 +- tests/v2/test_lexicon.py | 37 ++- tests/v2/test_reading_index.py | 3 +- tests/v2/test_regex_sync.py | 4 + tests/v2/test_types.py | 4 +- tests/v2/test_vocab.py | 10 + tools/differential/cldr_agreement.json | 6 +- tools/differential/corpus_rules.jsonl | 13 +- tools/differential/snapshot.jsonl | 17 +- tools/vocab/build.py | 17 +- 34 files changed, 687 insertions(+), 99 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 22cb0b70f..f8cae1e6f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -272,7 +272,7 @@ The compiled sets, read by `Lexicon` (mostly as the `_sets` field of the same na - titles — `TITLES` (every title reading; prenominals), `GIVEN_NAME_TITLES` (the readings with `addresses = "given"`, e.g. "Sir", which treat the following name as given, not family — a subset of the title readings by construction, though not of `TITLES`: a word that may also be a given name, such as `king` or `sheikh`, compiles to `TITLES_AMBIGUOUS` instead) and `AFTER_GIVEN_TITLES` (the salutation readings with `after_given = true`, read as the title where one ends the given part after a family comma, rules/H8, #835 — a subset by construction); `TITLE_ABBREVIATIONS` (the title readings with `abbreviation = true`, `maj`, which rules/H5's trailing chain takes with its period where the word is in `TITLES_AMBIGUOUS`, and on a style rules/H9 gives the article before it as a partner, #999; private, like the kind sets 3.0 added); `DOTTED_TITLES` (the title readings with `dotted = true`, `us`, `uk`, `pd`, the titles abbreviating several words that a run of single letters joined by full stops spells, which rules/H10 reads as the title at the head of a name where a title the run keeps follows it, #490; private); `GLUED_TITLES` (the title readings with `attached = { side = "before" }`, Thai `นาย`, `นางสาว`, `อาจารย์`, which rules/W6's front peel splits off the start of the name's first word they are glued to, #317; private); `TITLES_AMBIGUOUS` (a title reading beside a `given` one, derived, compiled INSTEAD of into `TITLES`: a title only inside a title phrase, rules/H9, #752 phase 2i), `TITLE_MODIFIERS` and `TITLE_STYLES` (by kind) and `TITLE_PHRASES` (the two-word phrases `attaches` makes) - suffixes — `SUFFIX_ACRONYMS` (suffix readings with `acronym = true`, matched with every period removed, e.g. "M.D.") and `SUFFIX_WORDS` (the rest, e.g. "Jr."), disjoint because a word has one suffix kind; `SUFFIX_ACRONYMS_AMBIGUOUS` (an acronym reading on a word with a `given` or `family` reading, derived since 2026-10-25: the build refuses the phase 1 flag `may_be_name`; a `given` reading carrying `same_as`, a name written short, marks no clash with a suffix reading since #1383 (`ReadingProperties.marks_a_clash`), so `md`, Muhammad written short, stays an unambiguous credential); `SUFFIX_WORDS_AMBIGUOUS` (its word twin, a generation or agnomen reading, or a credential written as a word, on a word with a name reading, `fils`, `junior`, `júnior`, the agnomens and `kc`, `pc` and `dl`, gated by the count, rules/S11, since 2026-10-25, the credentials since 2026-10-30, #965, Junior since #1039) with `AGNOMENS` inside it (the `agnomen` kind) and `TITLE_CASE_NAME_WORDS` beside it (the readings written `title_case_is_name`, `fils`, `père`, `kc`, `pc`, `dl`, whose writing leans, Title case to the name; any other gated word's writing never leans, #1039); and `GLUED_HONORIFICS` (#308, `attached`), the subset of `SUFFIX_WORDS` the peel may split off the END of a name token — a separate, harsher bar, since the glued position has no writer-drawn boundary to lean on, and each word refused it carries `excluded = { attached = … }` - particles — `PARTICLES` (family-name particles, e.g. "de", "van") and `NON_GIVEN_NAME_PARTICLES`, the curated subset that is *never* a standalone given name (the particles whose word has no `given` reading, each stating `may_be_given = false`; a `given` reading on the word is what makes a particle possibly given, the phase 1 flag `may_be_given = true` refused since 2026-10-25). What the subset licenses is rules/P1's fold in `post_rules` (the "rule 1b" of older issue comments — decisions/legacy-rule-numbers maps the old numbers), and the fold has ONE site: the piece that OPENS the name. A lone never-given particle there, with at least one more name word behind it, starts the family. Titles do not move the opening position (rules/P4), so `Sir de Mesnil` reads family `de Mesnil` under every `name_order`, as `de Mesnil` does. How far the fold reaches depends on the order the name was read under: by default it takes the rest of the name (`de Mesnil Jean` → family `de Mesnil Jean`); under either family-first order it takes the particle run plus ONE name unit and lays the rest out by the order (`de Mesnil Jean` → family `de Mesnil`, given `Jean`); after a family comma it takes the rest of that part whatever the order (`Smith, de Mesnil Jean` → family `Smith de Mesnil Jean`). The leading particle stays a lone piece for the fold to find — `group` does not chain it forward, and the fold walks the particles after it itself — so `de la Vega` reads family `de la Vega` under all three orders. Behind a title-particle (`St`, `Freiherr`, P4's Except) it does chain, and under a family-first order the fold cuts that chain as it cuts a run (`St de Mesnil Jean` → family `de Mesnil`, given `Jean`, #828). The GIVEN position is not a site. It was a second one until #467, which removed it because under a family-first order that slot holds what the caller DECLARED to be the given name: `Mesnil de` under `FAMILY_FIRST` or `FAMILY_FIRST_GIVEN_LAST` reads given `de`, family `Mesnil`. Nor is a particle inside the name: `Juan de la Vega` under a family-first order reads family `Juan`, given `de la Vega`, with no ambiguity recorded — what the vocabulary forbids is the bare particle as a given name, not a name part that begins with one. A bare `de` has nothing to fold into and is placed like any one-word name, by `Policy.lone_name_word` (rules/O5, #1111): given `de` by default under every order, family `de` where the caller sets the switch to family. A leading particle OUTSIDE the set is left to position — `Van Gogh` is given `Van`, family `Gogh` by default and family `Van`, given `Gogh` under both family-first orders — and records a `PARTICLE_OR_GIVEN` ambiguity under all three, save one written in lower case in a mixed-case name under a family-first order, which the fold takes and which records none (`van Gogh` → family `van Gogh`, rules/P11, #670); a never-given particle opening the name records none (`de Mesnil`), and neither does an ambiguous one inside it (`Vincent van Gogh`). The internal `Lexicon._sets.particles_ambiguous`, the particles holding a `given` reading, is its complement within `PARTICLES`, so the two mark OPPOSITE sets — see the flip warning in `docs/migrate.rst` before translating either -- bound given names — `BOUND_GIVEN_NAMES` (`bound_given` readings, e.g. "abdul", "abu"; one that is also a particle needs a `given` reading, a build check); a group-stage rule joins the first non-title piece to its following piece before roles are assigned, reserving a family word unless a family comma has already fixed it or a given-name title stands ahead (#369, rules/P5) (ported from v1's `_join_bound_first_name`), and `BOUND_PHRASES` (#694, rules/P12, the two-word given names a bound word's `completed_by` lists, Arabic `عبد` before the names of God), each pair joined past the first name word, where P5's join does not reach +- bound given names — `BOUND_GIVEN_NAMES` (`bound_given` readings, e.g. "abdul", "abu"; one that is also a particle needs a `given` reading, a build check); a group-stage rule joins the first non-title piece to its following piece before roles are assigned, reserving a family word unless a family comma has already fixed it or a given-name title stands ahead (#369, rules/P5) (ported from v1's `_join_bound_first_name`), and `BOUND_PHRASES` (#694, rules/P12, the two-word given names a bound word's `completed_by` lists, Arabic `عبد` before the names of God), each pair joined past the first name word, where P5's join does not reach, and `BOUND_COMPLETES_ANY` (#1464, the `completes_any` readings, the Latin `abdul`, `abd`, `abdel`, `abdal`, `abou`) with `BOUND_LONG_NAMES_ONLY` inside it (`long_names_only`, `abdul`), the bound words P12 joins with any plain name word after them, the second only in a name of four name words or more, both private - given names written short — `GIVEN_NAME_ABBREVIATIONS` (#789, a `given` reading carrying `same_as`, the full name: "chas", "wm", Filipino "ma", `md`), the given names written short that rules/H2's shape yields to, and that rules/C13's given-name Except reads where one is also a credential opening the part after a family comma (#1393, classify's `vocab:given-abbreviation` tag), and that rules/S8's run declines for in a name written wholly in one case with a name word behind it (#1394, `SITI NORA MD YUSRI`); nothing else reads it - names a given name's second half reads — `PARTICLE_GIVEN_NAMES` (#704, a `given` reading written `after_particle`: "carmen", "ángeles", "lurdes", "graças", the Spanish and Portuguese words a compound given name writes behind a particle, which rules/P10 reads as a middle name in `María del Carmen García`, by default, and "piedade" only under a Portuguese choice, #1118, #1122), `SAINT_PARTICLES` (the `saint` kind, `san`, `santa`, `st`, `ste`, `sta`, `sto`, whose run P10 refuses, `Santa María` being a surname) and `SHARED_NAMES` (#704, a name reading written `shared`: Sikh "kaur", "singh", which rules/O6 and O7 neither take nor complete and P10 does not complete, `Kaur del Carmen García`), private; each is read through classify's tags or the lexicon in `_post_rules` - conjunctions — `CONJUNCTIONS` (e.g. "and", "of") used to chain multi-word titles and to join name parts (rules/P3), plus `CONJUNCTIONS_AMBIGUOUS` (#383/#479, rules/P8, `may_be_initial`, refused by the build on anything but a cased single letter), the subset of single cased letters that read as an INITIAL in a name written wholly in one case — a marker set diff --git a/docs/customize.rst b/docs/customize.rst index fef2a131c..b0faf749c 100644 --- a/docs/customize.rst +++ b/docs/customize.rst @@ -1156,19 +1156,34 @@ entirely: >>> Parser(lexicon=off).parse("abdul salam ahmed salem").given 'abdul' -Past the first name word, a bound word joins only a word its reading -lists in ``completed_by``. Arabic-script ``عبد`` lists the names of God -and the devotional names it completes, so the pair is one name wherever -it stands, while the Latin ``abdul`` lists none: +Past the first name word, a bound word joins a word its reading lists +in ``completed_by``, or, where its reading is written ``completes_any``, +any name word after it with no vocabulary reading and no initial's +shape. Arabic-script ``عبد`` +lists the names of God and the devotional names it completes, so the +pair is one name wherever it stands. The Latin spellings name no word +after them and complete with any, ``abdul`` only in a name of four +words or more, titles and suffixes not counted (``long_names_only``), +its three-word names being split +both ways by the people who write them: .. doctest:: >>> parse("طارق عبد العزيز").family 'عبد العزيز' + >>> parse("Tariq Abdel Aziz").family + 'Abdel Aziz' >>> parse("Tariq Abdul Aziz").family 'Aziz' - >>> lex = Lexicon.default().add("abdul", kind="bound_given", - ... completed_by=["aziz"]) + +Where your names are Malaysian, which write a three-word ``X Abdul Y`` +with the pair as the family, state ``abdul``'s reading without +``long_names_only``: + +.. doctest:: + + >>> lex = (Lexicon.default().remove("abdul", kind="bound_given") + ... .add("abdul", kind="bound_given", completes_any=True)) >>> Parser(lexicon=lex).parse("Tariq Abdul Aziz").family 'Abdul Aziz' diff --git a/docs/design/decisions/P12-bound-given-name-and-the-word-that-completes-it.md b/docs/design/decisions/P12-bound-given-name-and-the-word-that-completes-it.md index e3d2e7d98..a2bfd12db 100644 --- a/docs/design/decisions/P12-bound-given-name-and-the-word-that-completes-it.md +++ b/docs/design/decisions/P12-bound-given-name-and-the-word-that-completes-it.md @@ -3,18 +3,47 @@ ## Standing - A bound given-name word past the first name word joins the word after it where its reading lists that word in `completed_by`, the pair one name unit that position places: `طارق عبد العزيز` gives family 'عبد العزيز' — 2026-11-04 #694. -- The license is a closed list on the bound word's reading, not a shape of the word after it: Arabic-script `عبد` lists 217 spellings of 139 words, the 97 one-word names of God, `الله`, 27 other divine epithets and 14 devotional completions, each with its hamza-less and Persian spellings, and `الله` with the Urdu heh too — 2026-11-04 #694. -- The Latin `abdul`, `abdel` and `abdal` list no word, so a non-leading one stays apart (`Tariq Abdul Aziz` → middle 'Abdul') — 2026-11-04 #694. -- A pair P12 joined counts as one family word for rules/O6 (two family names): under `two_family_names` `سعيد حسن عبد الله` gives family 'حسن عبد الله'; P5's pair at the start and a pair a particle chain took count as two, as the Latin `abdul rahman` does — 2026-11-04 #694. +- For Arabic-script `عبد` the license is a closed list on the bound word's reading, not a shape of the word after it: `عبد` lists 217 spellings of 139 words, the 97 one-word names of God, `الله`, 27 other divine epithets and 14 devotional completions, each with its hamza-less and Persian spellings, and `الله` with the Urdu heh too — 2026-11-04 #694. +- The Latin `abd`, `abdel`, `abdal` and `abou` are written `completes_any`: past the first name word each joins any plain name word after it, one the vocabulary reads no other way, the pair placed by position, the family where it ends the name and one middle name inside it (`Tariq Abdel Aziz` → family 'Abdel Aziz') — 2026-11-19 #1464, reversing 2026-11-04 #694's decline. +- `abdul` is written `long_names_only` beside it, joining only in a name of four name words or more, counted part by part before a maiden clause: a word with no letter and each part's leading title run (a listed title, a title phrase H9 reads with the word its connective joins, a dotted title, a title by H2's shape) counting as none, and after the pair only a plain word, a bound given name or a pair of initials in a script with case up to the next comma, a numeral `VI` to `X` written other than in Title case counting as none (`Tariq Abdul Aziz` → middle 'Abdul'; `Nadia Ali Abdul Rahim` → family 'Abdul Rahim'): the writers of a three-word `X Abdul Y` split it both ways by population — 2026-11-19 #1464. +- `abu` keeps its particle and teknonymic readings and no `completes_any`; Arabic-script `عبد` keeps its list — 2026-11-19 #1464. +- A pair P12 joined counts as one family word for rules/O6 (two family names): under `two_family_names` `سعيد حسن عبد الله` gives family 'حسن عبد الله'; P5's pair at the start and a pair a particle chain took count as two — 2026-11-04 #694; a Latin pair the join makes past the first name word counts as one, as the Arabic-script pair does (`Ana abdul Rahman López` under `two_family_names` gives family 'abdul Rahman López'), where one at the start still counts as two — 2026-11-19 #1464. + +Open: a Malay choice could turn `abdul`'s three-word join on, its Malaysian writers filing the pair as the family 183 times to 2 in ORCID; the Malay choice is #1179's question (2026-11-19 #1464). Open: the second elements that join the word BEFORE them (`الدين`, `الله`, `الغنى` in `جميل عز الدين`, `هالة شكر الله`, `عائشة ذو الغنى`), the other three Arabic-script names `wikidata_native_agreement.json` held on the shape, want a mechanism of their own and are not decided here. ## Log -- 2026-11-04 #694 (Derek) — A BOUND WORD JOINS A LISTED WORD AFTER IT PAST THE FIRST NAME WORD. `طارق عبد العزيز` read middle 'عبد', family 'العزيز' in 1.4.0 through 2.8.1, where Wikidata's family is 'عبد العزيز'; of the ten Arabic-script names `wikidata_native_agreement.json` recorded on master `fad581a4` (seven `ar`, two `ur`, one `fa`), four were this shape and now agree. rules/P5's join reads only the first name word, and keeps its reserve there; this is a rule of its own because it reads a signal P5 does not, the word after the bound word, and it is that word's listing, not its shape, that licenses the join. +- 2026-11-04 #694 (Derek) (its decline of the Latin spellings superseded by 2026-11-19 #1464) — A BOUND WORD JOINS A LISTED WORD AFTER IT PAST THE FIRST NAME WORD. `طارق عبد العزيز` read middle 'عبد', family 'العزيز' in 1.4.0 through 2.8.1, where Wikidata's family is 'عبد العزيز'; of the ten Arabic-script names `wikidata_native_agreement.json` recorded on master `fad581a4` (seven `ar`, two `ur`, one `fa`), four were this shape and now agree. rules/P5's join reads only the first name word, and keeps its reserve there; this is a rule of its own because it reads a signal P5 does not, the word after the bound word, and it is that word's listing, not its shape, that licenses the join. - **The first build and the article test.** Joining `عبد` to any word after it (the first build, never committed) was right where the next word opened with the article `ال` and wrong where it did not, `عبد` standing alone there as a short given name (`نوال عبد هاشم`, family box 'هاشم'): ORCID's family boxes, scored by the recipe under Measured, read 2 records right that did not and 6 the reverse among its moves with no article after `عبد`. The second build kept only the article case, a test on a word's first two letters, and scored 65 and 5, with 20 neither and 11 with no family box (commit `44c65f62` against `fad581a4`). The design-docs review refused it as a statistical reading wearing the script's clothes (root AGENTS.md's three cases of a script-conditional rule): the article opens a nisba surname too, and most of the 5 it broke were one filed as the family alone (`فواز علي عبد القريشي`, family box 'القريشي'), and it would read Persian `الهام` (Elham) as a completion and miss the pointed and wasla spellings. Decided in chat: list the words instead, which the vocabulary can do because the set is closed, the names of God and a handful of devotional names. - **The list.** The 97 one-word names of the asmāʾ al-ḥusnā (the 99 less `مالك الملك` and `ذو الجلال والإكرام`, two words each) and `الله`; 27 other epithets (`الإله`, `القدير`, `المنعم`, `الناصر`) and 14 devotional completions (`المطلب`, `النبي`, `الرسول`, `المسيح`, the Imams' names `الحسين`, `الرضا`, `الكاظم` and their kin) found after `عبد` in the corpora; each with hamza folded (`الامير` beside `الأمير`, `الباري` beside `البارئ`) and with keheh and Farsi yeh for kaf, yeh and alef maqsura (`الکریم` beside `الكريم`, `المولی` beside `المولى`), and `اللہ` with the Urdu heh. Left out: the nisba surnames and words no name takes (`القريشي`, `المحمدي`, `اللاوي`, `الدعمي`, `السادة`, `المرضى`) and misspellings (`الطيف`, `الغاني`). Counted 2026-11-04 by splitting on whitespace each ORCID `raw.jsonl` record's `name` (the 2026-10-27 fetch) and each JRC-Names `corpus.jsonl` line, and taking the word after every `عبد`: 1,239 pairs over 185 words, 1,095 of them a listed word, and 47 more a listed word with punctuation glued to it in the text (`الله،`), which the tokenizer strips, so those join too. - **Why not the Latin spellings.** Simulated on 2026-11-04, the same join for a non-leading `abdul`, `abdel` or `abdal` (the pair one unit, placed by position) reads the family box right in 1,248 of ORCID's 1,590 records holding one with a word after it, against 348 today, but in 1,461 of the UK PSC register's 1,921 against 1,572 today, and 787 of its 1,033 British filers against 903: British South Asian filers write `Mohammed Abdul Khan`, Abdul a middle name of its own. The particle reading the issue weighed chains to the end of the name (`Mohamed abdel hakim Harkat` → family 'abdel hakim Harkat') and reads 1,184 and 1,192 right, below the join in both. Declined for the default; a Latin list under a language choice is not decided. The simulated view was built by hand from the default parse of master `c6207549`: where the middle's last word is `abdul`, `abdel` or `abdal` and the family one word, family 'Abdul X', scored by whether the family equals the family box (ORCID's `raw.jsonl` of the 2026-10-27 fetch; the PSC register's `surname` box, British by its nationality field). - **Measured** 2026-11-04 at `8ba37fae`, `config_diff.py diff --local all --committed --match 'عبد' 'expr:Parser(lexicon=Lexicon.default().remove("عبد", kind="bound_given").add("عبد", kind="bound_given"))' default`, the comparator being the default with `عبد`'s reading written without its list: of 2,448 names holding the word (this change's case rows among them), 309 move, 194 of JRC-Names' 1,362, 110 of ORCID's 1,063 and 7 of the committed 27; every move is middle to family, save one Persian name under a family-first order (`سید عبد الکریم عبد الحمید ایم پی` → given 'عبد الکریم'). Scored against ORCID's family boxes (`raw.jsonl` of the 2026-10-27 fetch joined by name to `config_diff.py --readings` output, which 93 of the 110 moved names match, a record moving where its title, given, middle or family differs, right where its family equals the box with whitespace collapsed): 62 records read right that did not, 0 the reverse, 20 neither, 11 with no family box. The 20 are boxes holding the father's name with the pair (`رؤى لؤي عبد الله`, box 'لؤي عبد الله'), the nasab no default reads. - **O6.** rules/O6 counts the family's words to decide whether a two-family-name policy has a second surname to take; a pair P12 joined counts as one, as a hyphenated word does, so under `two_family_names` `سعيد حسن عبد الله` gives family 'حسن عبد الله', where counted as two words the pair left `حسن` a middle name. Group leaves the tag only on the bound word of a pair it joined, so P5's pair at the start still counts as two (`عبد الله حسن سعيد` under `FAMILY_FIRST` and `two_family_names` gives given 'حسن', middle 'سعيد', family 'عبد الله', as on `fad581a4`), and so does a pair a particle chain took (`سعيد محمد بن عبد الله` keeps middle 'محمد'); the code review found both moving when the count read classify's tag alone. - Frames: the phrase test is a plain loop in classify, gated on the name holding a bound word, and the join is called only where a token carries the tag, so a name with no bound word pays no frame. The join builds its pieces in one pass, a run of pairs shifting nothing (tests/v2/test_benchmark.py). +- 2026-11-19 #1464 — THE LATIN SPELLINGS COMPLETE WITH ANY PLAIN NAME WORD, `abdul` ONLY IN A NAME OF FOUR WORDS OR MORE. SUPERSEDES: the 2026-11-04 #694 entry's decline of the Latin spellings (its "Why not the Latin spellings" bullet). `abd`, `abdel`, `abdal`, `abou` and `abdul` carry `completes_any` on their `bound_given` reading, and `abdul` `long_names_only` too; classify tags the bound word with the phrase tag where the word after it carries no vocabulary tag, and group's P12 join pairs them as it pairs a listed phrase. No new vocabulary kind and no API beyond the two properties a caller may state with `add`. + - **Three routes, measured side by side.** Each scored against filers' boxes by one recipe: every record of `orcid-researchers` (the 2026-10-27 fetch), `psc-individuals` and `patentsview-inventors` whose `name` holds one of the five words as a word, parsed, and counted right where given and middle together equal the given box (PSC: forename and middle-name boxes) and the family equals the family box, lower-cased, commas dropped, whitespace collapsed; fixed and broken are the records right on one tree and wrong on the other, against master `12b568f8` (the shipped build against `1ca93b25`, which reads every such record as `12b568f8` does). ORCID 5,420 records, PSC 2,573, PatentsView 663. + + | fixed / broken | particle reading (a `given` beside a generic particle) | the join, all five words in every name | the join, `abdul` declined in a three-word name (shipped) | + |---|--:|--:|--:| + | ORCID, every country | 1,944 / 324 | 1,671 / 122 | 1,243 / 30 | + | Malaysia | 636 / 14 | 625 / 7 | 445 / 5 | + | Egypt | 398 / 31 | 301 / 1 | 298 / 1 | + | Iraq | 167 / 43 | 92 / 10 | 63 / 9 | + | Bangladesh | 11 / 72 | 11 / 51 | 1 / 2 | + | Pakistan | 44 / 19 | 43 / 9 | 8 / 1 | + | PSC, every nationality | 301 / 643 | 270 / 346 | 166 / 76 | + | British | 126 / 385 | 113 / 215 | 70 / 44 | + | Pakistani | 35 / 50 | 33 / 30 | 6 / 2 | + | Indian | 35 / 47 | 32 / 24 | 22 / 3 | + | PatentsView, every country | 95 / 170 | 83 / 91 | 66 / 51 | + | Saudi Arabia | 9 / 48 | 7 / 22 | 5 / 12 | + + The third column was first measured on a scratch prototype by holding each three-word `X Abdul Y` record (titles `Mr`, `Mrs`, `Ms`, `Miss`, `Dr`, `Mx` dropped from PSC's) at master's reading, which gave ORCID 1,243 / 30 and PSC 166 / 82; the shipped build counts name words as rules/P12 states (a title with its period, a title phrase and a suffix after the pair counting as none), and the shipped column is measured on the branch's final tree: the same ORCID figures, and in PSC 6 fewer broken than the prototype. + - **Why the particle reading was dropped.** It scored lowest in PSC and PatentsView, and it cost two shapes the join does not: a two-word name before a credential comma lost its given name, the particle opening the name taking the whole name into the family (`Abd Karim, MD`, 49 ClinicalTrials.gov names), and a `bin` chain with a word before the bound word was cut there, the particle starting a chain of its own (`Ali bin Hj Abdul Karim` → middle and patronymic 'bin Hj', family 'Abdul Karim', where master and the join read family and patronymic 'bin Hj Abdul Karim'); and rules/R4 then lower-cased the word as a particle, some 900 case-repair moves. The join reads none of these: the word after it must carry no vocabulary, so a `bin`, a title or a credential is never taken, and the bound word keeps its case. + - **The three-word split.** How filers box `X W Y` where W is one of the five words, by the record's boxes (family 'W Y' against family 'Y'): ORCID Malaysia 258 to 3, Egypt 250 to 0, Lebanon 128 to 0, Bangladesh 11 to 60; PSC British 66 to 185. For `abdul` alone: ORCID Malaysia 183 to 2, Pakistan 35 to 14, Iraq 31 to 1, Bangladesh 10 to 60; PSC British 43 to 172, Pakistani 27 to 29, Indian 10 to 21, Bangladeshi 1 to 21; PatentsView Malaysia 8 to 9, Saudi Arabia 2 to 11. Egypt's three-word names are mostly `abd` and `abdel` (128 and 94, `abdul` 3 to 0), Lebanon's `abou` (101, `abdul` 13 to 0), so the populations that split the other way write `abdul`, and declining `abdul` alone there is the variant that breaks the fewest records in every population measured and is net positive in each corpus's total, Saudi Arabia (PatentsView 5 / 12) and Bangladesh (ORCID 1 / 2) breaking more than it fixes. The counts are on `abdul`'s entry in `ar.toml`, so the next word declined is a data change. Recipe: each record's boxes split at whitespace, lower-cased, kept where they hold three words with the bound word second (`tools`-free; the scratch script reads the three raw files). + - **What is still wrong.** PSC's British filers of a four-word name who put `Abdul` alone in the middle-name box (`Nadia Ali Abdul Rahim`, family box 'Rahim'): the join reads family 'Abdul Rahim' (most of PSC's 76). Pakistani compound shapes where the bound word ends a compound written as one family (`X Abdul Y Z` boxed family 'Y Z'). Bangladesh's `Md Abdel Y` read family 'Abdel Y' where its filers box 'Y'; its `Md Abdul Y` is three words and declined. Two shapes nobody writes on purpose, left as they read: a word after a numeral counted though the trailing run takes it (`Ali Abdul Rahim VI Hassan` → family 'Abdul Rahim', suffix 'VI Hassan'), and a modifier H9 reads out of a trailing bare phrase joined (`Ali Abdel Crown Prince` under `FAMILY_FIRST` → given 'Abdel Crown'). + - **Measured** 2026-11-19 with `tools/differential/measure.py --base` against master `1ca93b25`, on the branch's final code (`3940a393`). Moves: ORCID 1,586 names, ClinicalTrials.gov officials 399 and contacts 249, JRC-Names 592, PSC 265, PatentsView 126, TSE donors 37, `my-candidates` 24, the parliaments 9, the committed snapshot 2; every other local corpus, CLDR and GND unmoved. Each move is a middle word joining the family or middle name after it, save one shape: `Abd` opening a word pair after a family comma, which the given part had read as the credential ABD, now joins (`Haddad, Nadia Abd Karim` → middle 'Abd Karim', where 1.4.0 through 3.1.0 read suffix 'Abd'). Scored against the boxes (`local_agreement.py`, its own count, which compares every record and not only those holding a word): ORCID 1,247 records read right that did not and 31 the reverse, PSC 148 and 73, PatentsView 68 and 56; JRC-Names 61 persons whose spellings now read alike and 89 now apart (the prototype of the join in every name: 63 and 111). + - **O6.** A pair this join makes counts as one family word, as `abu Bakr` does, so under `two_family_names` `Ana abdul Rahman López` gives family 'abdul Rahman López' (rules/O6's case row moved to `Umm Kulthum`, whose bound word P12 does not join past the first word, `umm` completing nothing). + - **Frames.** The reference row (`Dr. Juan0001 de la Vega III`) stays 196 and `Smith, John` 98; a name whose bound word opens it pays nothing (`Abdul Rahman Ali` 132), one holding one past the first word pays two frames for the four-word count where it asks one (`Tariq Abdul Aziz` 127 → 129, the count and H2's shape test of the leading word) and 8 to 11 where the pair joins (`Tariq Abdel Aziz` 127 → 135, `Nadia Ali Abdul Rahim` 143 → 154), counted with `sys.setprofile` over 20 parses each on py3.11, 2026-11-19, on the branch's final tree. diff --git a/docs/design/rules/O6-two-family-names.md b/docs/design/rules/O6-two-family-names.md index 35a45ec73..b0037375f 100644 --- a/docs/design/rules/O6-two-family-names.md +++ b/docs/design/rules/O6-two-family-names.md @@ -92,7 +92,7 @@ ``` ", Ana García López" two_family_names → family="" ``` -- **What is taken must be one name word a family name could be**: a bound given-name pair (P5) written as two words stays where it is, and so do an initial written alone, which writes a given name, and a mark or number with no letter in it. A particle chain (P2) is split only where the family-first bullet cuts it and otherwise moves whole, and where taking it would leave no given name the rule declines. A listed given name stays where it is too, under either order, and so does a hyphenated word every part of which is one or an initial, and a list written without accents matches the word written with them, and the shipped lists hold each word written with ñ spelled with n too, where that spelling is still mostly a given name, as data without the letter writes it, never the reverse: the caller's vocabulary names it a word only a given name is, so the name holds one family name. A listed word behind a particle is a surname unit, taken as before, unless the vocabulary marks it a given name written there (below). +- **What is taken must be one name word a family name could be**: a bound given-name pair (P5) written as two words stays where it is, unless P12 made it one name, and so do an initial written alone, which writes a given name, and a mark or number with no letter in it. A particle chain (P2) is split only where the family-first bullet cuts it and otherwise moves whole, and where taking it would leave no given name the rule declines. A listed given name stays where it is too, under either order, and so does a hyphenated word every part of which is one or an initial, and a list written without accents matches the word written with them, and the shipped lists hold each word written with ñ spelled with n too, where that spelling is still mostly a given name, as data without the letter writes it, never the reverse: the caller's vocabulary names it a word only a given name is, so the name holds one family name. A listed word behind a particle is a surname unit, taken as before, unless the vocabulary marks it a given name written there (below). ``` "José Luis Pérez" two_family_names+es_given_names → family="Pérez" "Jose Luis Perez" two_family_names+es_given_names → middle="Luis" @@ -103,7 +103,7 @@ "Ana María-José López" two_family_names+es_given_names → family="López" "Ana M.-J. López" two_family_names → family="López" "Ana M.-José López" two_family_names+es_given_names → family="López" - "Ana abdul Rahman López" two_family_names → family="López" + "Ana Umm Kulthum López" two_family_names → family="López" "Ana M. García" two_family_names → family="García" "Ana María García - López" two_family_names → family="López" "Ana María 3 López" two_family_names → family="López" diff --git a/docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md b/docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md index a2bd2e3d0..32c2d43fb 100644 --- a/docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md +++ b/docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md @@ -1,6 +1,6 @@ # P12 — a bound given name and the word that completes it -**When:** a bound given-name word stands past the first name word, and the word after it is one the vocabulary lists as completing it, as in "طارق عبد العزيز". +**When:** a bound given-name word stands past the first name word, and the word after it is one the vocabulary lists as completing it, as in "طارق عبد العزيز", or a plain name word after a bound word whose reading completes with any name. **Then:** the two words are one name unit past the first name word, a unit that position places. @@ -17,8 +17,16 @@ "نوال عبد هاشم" → family="هاشم" · boundary "محمد عبد القريشي" → family="القريشي" · boundary ``` +- **A Latin spelling completes with any plain name word** (`completes_any` on the bound word's reading): `abdul`, `abd`, `abdel`, `abdal` and `abou` write the bound word without the name it serves, so no list can say which word follows it, and a word the vocabulary reads otherwise, a particle among them, or an initial completes nothing. + ``` + "Tariq Abdel Aziz" → family="Abdel Aziz" + "Nadia Ali Abdul Rahim" → family="Abdul Rahim" + "Nadia Abdul Rahim Ali" → middle="Abdul Rahim" + "Ahmad Abdel bin Omar" → middle="Abdel" · boundary + "Ahmad Abdel K." → middle="Abdel" · boundary + ``` -**Because:** Arabic script writes a theophoric given name as two words, `عبد` (servant of) and the name of God it serves, `عبد الله`, so a name holding two of them, or one behind a given name, puts the second word where a family name would stand alone. Which words complete `عبد` is a closed set, the names of God and a few devotional names, so the vocabulary can list them, and a list is certain where a shape is not: the article `ال` opens a nisba surname as readily as a name of God. Researchers who split such a name into boxes put the pair in the family box together. +**Because:** Arabic script writes a theophoric given name as two words, `عبد` (servant of) and the name of God it serves, `عبد الله`, so a name holding two of them, or one behind a given name, puts the second word where a family name would stand alone. In Arabic script the words that complete `عبد` are a closed set, the names of God and a few devotional names, so the vocabulary can list them, and a list is certain where a shape is not (the article `ال` opens a nisba surname as readily as a name of God), while a Latin spelling drops the article and names no word, leaving a name word's place as the only signal. Researchers who split such a name into boxes put the pair in the family box together. **Except:** @@ -26,17 +34,26 @@ ``` "عبد الله" → given="عبد" ``` -- **A bound word listing nothing joins only at the start**: the Latin spellings `abdul`, `abdel` and `abdal` list no word, the pair standing behind a given name as a middle name about as often as a family. +- **A bound word with neither joins only at the start**: a word whose reading neither lists a completion nor completes with any name is P5's alone. + ``` + "Tariq Umm Aziz" → middle="Umm" + ``` +- **`abdul` in a name of three words stays apart** (`long_names_only` on its reading): the writers of `X Abdul Y` split it both ways by population, the pair the family in Malaysia and a middle name of its own in Bangladesh and in Britain, and the pair is joined only in a name of four name words or more, a title run at the head of a part counting as none, and after the pair only a plain name word, a bound given name or a pair of initials up to the next comma, a numeral written other than in Title case being no name word. ``` "Tariq Abdul Aziz" → middle="Abdul" + "Mr Tariq Abdul Aziz" → middle="Abdul" + "Tariq Abdul Aziz Jr." → middle="Abdul" + "The Rt Hon Nadia Abdul Rahim" → middle="Abdul" + "Nadia Abdul Rahim, MA" → middle="Abdul" ``` **Accepted:** - A completing word written with its vowel points or with the alef wasla (`ٱلله`, `اَلله`) is not listed, and keeps its words apart; one JRC-Names spelling held one after `عبد` on 2026-11-04 (`عبد ِالعزيز`). - A connective's join takes the word after it first (P3), so a pair behind a connective stays apart: `طارق عبد الله و عبد الرحمن` reads middle 'عبد الله و عبد', family 'الرحمن'. +- A writer who counts `Abdul` a middle name of its own in a name of four words reads the pair joined all the same: `Nadia Ali Abdul Rahim` gives family 'Abdul Rahim' where such a writer would have the family 'Rahim'. - A kunya opening the name is P5's join of its two bound words, and the word completing the second is left to position (`أبو عبد الله محمد` reads given 'أبو عبد', middle 'الله'), as before this rule; behind a given name the kunya is the family (`محمد أبو عبد الله`). --- -**Signal:** neighbor: a bound given-name word and the word after it, which its reading lists +**Signal:** neighbor: a bound given-name word and the word after it, which its reading lists, or which carries no vocabulary after one that completes any, `abdul` only in a name of four name words or more **history:** decisions/P12 · **implemented:** nameparser/_pipeline/_classify.py, nameparser/_pipeline/_group.py, nameparser/_pipeline/_post_rules.py diff --git a/docs/design/rules/P5-bound-given-names.md b/docs/design/rules/P5-bound-given-names.md index 764032d8b..5a3f08035 100644 --- a/docs/design/rules/P5-bound-given-names.md +++ b/docs/design/rules/P5-bound-given-names.md @@ -76,10 +76,11 @@ "Sir Abu Bakar" → given="Abu Bakar" "Abu Bakar Salim" → given="Abu Bakar" ``` -- **A word that is BOTH bound-given and suffix vocabulary** ("abd Allah Smith", "Smith, Abd"): position decides and both readings survive: leading, it is the bound word; trailing, it is the suffix (S2). In the given slot after a family comma the suffix reading wins. +- **A word that is BOTH bound-given and suffix vocabulary** ("abd Allah Smith", "Smith, Abd"): position decides and both readings survive: leading, it is the bound word; trailing, it is the suffix (S2). In the given slot after a family comma the suffix reading wins, save before a plain name word, which P12 joins it with. ``` "abd Allah Smith" → given="abd Allah" "Smith, Abd" → suffix="Abd" + "Haddad, Nadia Abd Karim" → middle="Abd Karim" ``` - **A trailing particle after a family comma** ("Berg, abdul van"): the join runs before the trailing particle's attachment (P6) sees the name. diff --git a/docs/design/rules/README.md b/docs/design/rules/README.md index 55d887a8f..509fd4b0a 100644 --- a/docs/design/rules/README.md +++ b/docs/design/rules/README.md @@ -95,7 +95,7 @@ The marker's unit is the whole rule, so a clause that reaches past the tolerated Terms the rules use without defining them each time, each with the rule that defines or counts it. -- **name word** — a word of the person's name itself: titles, suffixes, nicknames and particles acting as particles are not name words (R3). How name words are COUNTED is each rule's own, and there is no single count: C3, counting the words before a comma, takes a particle run and the one name word it attaches to as one word (P1's reach, not P2's whole chain), counts a connective join and a bound given-name pair as their words, and counts a suffix word opening the part as a name word where one follows it; S8 counts P2's whole chain as one name word; P1's family-first fold takes one unit, a particle chain (P2), a conjunction join (P3) or a bound given-name pair (P5) whole; O6 counts a family's words by P1's reach, a connective join and a hyphenated word counting as their words. +- **name word** — a word of the person's name itself: titles, suffixes, nicknames and particles acting as particles are not name words (R3). How name words are COUNTED is each rule's own, and there is no single count: C3, counting the words before a comma, takes a particle run and the one name word it attaches to as one word (P1's reach, not P2's whole chain), counts a connective join and a bound given-name pair as their words, and counts a suffix word opening the part as a name word where one follows it; S8 counts P2's whole chain as one name word; P1's family-first fold takes one unit, a particle chain (P2), a conjunction join (P3) or a bound given-name pair (P5) whole; O6 counts a family's words by P1's reach, a connective join and a hyphenated word counting as their words. P12's four-word gate counts the name's words before a maiden clause part by part, a word with no letter and each part's leading title run counting as none, and after the pair only a plain word, a bound given name or a pair of initials up to the next comma, a numeral written other than in Title case not counting. - **words to spare** — enough name words that reading one as a suffix still leaves the name its family word. As the second of two name words a bare ambiguous acronym has none to spare and stays the family name (S4); S10's one-letter numeral needs the same. - **credential run** — a run of words read as post-nominals: a comma part made wholly of suffix words (C1, C8), or the run an unambiguous credential starts after the name core, taking every later word of its part (S8). - **listing form** — the family name, a comma, then the given name, as in "Smith, John" (C1). diff --git a/docs/design/rules/S8-credentials-trailing-run.md b/docs/design/rules/S8-credentials-trailing-run.md index 5657cdce7..8e9ce60eb 100644 --- a/docs/design/rules/S8-credentials-trailing-run.md +++ b/docs/design/rules/S8-credentials-trailing-run.md @@ -29,7 +29,7 @@ ``` "Mary Jane Pope Smith" → family="Smith" "Josep Carod i Rovira" → family="Carod i Rovira" - "Mohamed Ali Abd Allah" → family="Allah" + "Mohamed Ali Abd Allah" → family="Abd Allah" "John Smith Ma Jones" → family="Jones" "JOHN SMITH MA JONES" → family="JONES" "John Smith DO Jones" → family="DO Jones" diff --git a/docs/migrate.rst b/docs/migrate.rst index 5df809e84..2384c9001 100644 --- a/docs/migrate.rst +++ b/docs/migrate.rst @@ -2298,3 +2298,28 @@ unlisted pair of capitals does there: ('ZIA UD', 'DIN', '') >>> parse("Anke Vissering, UD").given 'UD' + +A Latin bound given name past the first word +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``Abdel``, ``Abd``, ``Abdal`` and ``Abou`` past the first word of a +name now join the name word after them, and ``Abdul`` does too in a name +of four words or more. Position places the pair: the family name where +it ends the name, one middle name inside it. 1.4 through 3.1 read the +bound word as a middle name of its own, or, for ``Abd`` in the given +part after a family comma, as the credential ABD, and the word after it +apart. In a name of three words ``Abdul`` still stays apart: + +.. doctest:: + + >>> tariq = parse("Tariq Abdel Aziz") + >>> tariq.middle, tariq.family + ('', 'Abdel Aziz') + >>> nadia = parse("Nadia Ali Abdul Rahim") + >>> nadia.middle, nadia.family + ('Ali', 'Abdul Rahim') + >>> parse("Tariq Abdul Aziz").middle + 'Abdul' + >>> haddad = parse("Haddad, Nadia Abd Karim") + >>> haddad.middle, haddad.suffix + ('Abd Karim', '') diff --git a/docs/release_log.rst b/docs/release_log.rst index 90ac27379..5b115d2d0 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,6 +4,7 @@ Release Log nameparser 3.2 is under development. + - **Fix Abdel, Abd and Abou past the first word of a name, which read as a middle name of their own.** ``parse("Tariq Abdel Aziz")`` gives family ``Abdel Aziz``, where 1.4.0 through 3.1.0 gave middle ``Abdel``, family ``Aziz``. ``Abdul`` joins only in a name of four words or more, titles and suffixes not counted, so ``Tariq Abdul Aziz`` keeps middle ``Abdul``; and after a family comma ``Abd`` before a name word is no longer the credential ABD. :issue:`1464` - **Change Parser.suggest() to read where a Russian-style patronymic stands as a vote on the order, and add Signal.PATRONYMIC_POSITION, the signal that casts it.** ``Parser().suggest(["Sidorov Ivan Petrovich", "Volkov Pavel Sergeevich", "Orlova Anna Ivanovna", "Zaitsev Oleg Nikolaevich", "Belova Vera Andreevna"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=...)``, where 3.1.0 gave the rule with the given-first order, which misread any name of two words in such a list (``Sidorov Ivan`` gave family ``Ivan``); a patronymic in the middle votes given-first. :issue:`1447` - **Fix ud inside a South Asian compound name, which read as a credential and took the rest of the name.** ``parse("NADIR ZIA UD DIN")`` gives middle ``ZIA UD``, family ``DIN``, as 1.4.0 through 2.3.0 did, where 2.4.0 through 3.1.0 gave family ``ZIA``, suffix ``UD DIN``; ``UD`` alone after a name and a comma now reads as initials (``Anke Vissering, UD`` gives given ``UD``, family ``Anke Vissering``, where 1.4.0 through 3.1.0 gave suffix ``UD``). ``bt`` stays a credential: for Malay names remove it, as :doc:`customize` shows. :issue:`1467` - **Fix the surname1 and surname2 views, which left a family of two surnames whole before a family comma, opening with a particle, or behind a given name a particle completes.** Under ``two_family_names``, as ``locales.ES``, ``ES_AR``, ``CS``, ``SK``, ``PT_BR`` and ``PT_PT`` turn it on, ``parser_for(locales.ES).parse("García Márquez, Gabriel")`` gives surname1 ``García``, surname2 ``Márquez``, as ``Gabriel García Márquez`` does, where 3.0.0 through 3.1.0 gave surname1 ``García Márquez``, surname2 ``''``. No field moves; a family joined by ``y`` or written as one hyphenated word stays whole, and so, where 3.0.0 through 3.1.0 divided them, do a lone particle and the word after it under a family-first order (``Van Gogh``) and a Turkic father's name with its marker; with ``capitals_as_family`` on too, the family the capitals name is divided. :issue:`1456`, :issue:`1479` diff --git a/nameparser/AGENTS.md b/nameparser/AGENTS.md index 594dd2d8c..c7d29e81d 100644 --- a/nameparser/AGENTS.md +++ b/nameparser/AGENTS.md @@ -12,7 +12,7 @@ A view the parse marks must read the same for the comma writing of a name, and a ### Counting the one-word path -Count the one-word path the way C3 counts, which is neither tokens nor pieces: a particle run and the one word it attaches to are one word (#575), a connective join and a bound given-name pair count as their words (#613, so `Ortega y Gasset, Dr.` is a whole name), and a suffix beside the surname counts as no name word at all -- a numeral of two or more letters (`VI` to `IX`) the trailing fork reads as the generation included, as a listed one is (#893: `Dumas VI, Jr.` lost its family where `Dumas III, Jr.` kept it). #603's review found the suffix half (`Vega y Lopez Jr., PhD Jones` lost its family where `Vega y Lopez, PhD Jones` kept it); #613 then reversed the connective half, and both now read given 'Vega', middle 'y', family 'Lopez' — so test a particle surname, a connective surname and a surname with a suffix, each before a comma. The same holds for any count INSIDE a part, not only the comma's: #886's numeral site in the family part counted pieces, and an unjoined particle there is a piece of its own, so `Smith van der V, John` and `SMITH VD V, JOHN` read suffix 'V' from 2.7.0 until #1080, the particles counted as words to spare; put a particle run in front of the word being counted, and one opening the part (`de Mesnil V, Jean`, which #1080's first fix still counted), in the grid of every count -- and a single-letter connective, which P3 leaves unjoined where the name has fewer than four root words and is a piece the same way: `Smith y V, John` read suffix 'V' until #1093. #1080's test review found it, though that fix's grid held `y`: but a grid read for what a change MOVES shows nothing about a shape it leaves wrong, so read the unmoved rows of a count's grid too. And write the connective in one case too, but don't assume what it is there: only the marked subset (`may_be_initial`, rules/P8) reads as an initial in a one-case name, while `Y` and `И` keep their connective tag, so `JOHN SMITH Y V` moved with its mixed-case twin under #1097 and #1098, after a decision had been asked on the premise that it could not. A suffix word OPENING the part is the other half, and counts as a name word where one follows it: from 2.4.0 the counts passed over it, so `JP Clancy, MD` lost its given name to initials that spell a credential and `Cem Akin, MD` to a given name a credential spells, until #1017, while `Md Rahman, PhD` had read title 'Md' or family 'Md Rahman' in every release. No comma grid had put a listed suffix word at the head, and real heads are full of them, so open a head with initials (`JP`, `A.M.`), a given name a credential spells (`Cem`, `Md`), a title/suffix dual (`Sr.`) and a split credential's member (`MB ChB`), behind a title too, and put a title behind the opening word (`Md Prof., PhD`): the first build counted it as the name word there in one count and not in the other, found by review. A bound given-name pair is the same trap from the other side: a count that passes over particles reads `Abu Bakr` as ONE word, `abu` being a particle and a bound word both, where `abdul Rahman` counts two, so a rule asking whether the given name already holds two words needs a bound pair of each spelling in its grid; #1057's grid held only `abdul` until its test review found O7 completing `Abu Bakr` (`_post_rules._one_given_word` counts it now). And C3's one name word is not one word as written: it passes over a title word (`Ashley Knight`) and reads a capitalized particle with its surname as one (`Bin Zhang`), so a rule keyed to a one-word head reads more two-word heads than it means to -- #1238's first build read `Bin Zhang, M.D.` and `Ashley Knight, M.S. BME` as initials, found by its grid and the ClinicalTrials.gov measurement; put a title-word surname and a capitalized particle head in the grid of any one-word-head rule, beside the lower-case Dutch particle (`de Waart`) it may mean to admit. A run of letters is a spelling too: `_LETTER` matches a Hangul syllable (`J.씨`, a glued honorific) and a decomposed accent's base, so a test that every letter is a capital needs a mark-free, cased letter in its grid and the NFD spelling beside it. +Count the one-word path the way C3 counts, which is neither tokens nor pieces: a particle run and the one word it attaches to are one word (#575), a connective join and a bound given-name pair count as their words (#613, so `Ortega y Gasset, Dr.` is a whole name), and a suffix beside the surname counts as no name word at all -- a numeral of two or more letters (`VI` to `IX`) the trailing fork reads as the generation included, as a listed one is (#893: `Dumas VI, Jr.` lost its family where `Dumas III, Jr.` kept it). #603's review found the suffix half (`Vega y Lopez Jr., PhD Jones` lost its family where `Vega y Lopez, PhD Jones` kept it); #613 then reversed the connective half, and both now read given 'Vega', middle 'y', family 'Lopez' — so test a particle surname, a connective surname and a surname with a suffix, each before a comma. The same holds for any count INSIDE a part, not only the comma's: #886's numeral site in the family part counted pieces, and an unjoined particle there is a piece of its own, so `Smith van der V, John` and `SMITH VD V, JOHN` read suffix 'V' from 2.7.0 until #1080, the particles counted as words to spare; put a particle run in front of the word being counted, and one opening the part (`de Mesnil V, Jean`, which #1080's first fix still counted), in the grid of every count -- and a single-letter connective, which P3 leaves unjoined where the name has fewer than four root words and is a piece the same way: `Smith y V, John` read suffix 'V' until #1093. #1080's test review found it, though that fix's grid held `y`: but a grid read for what a change MOVES shows nothing about a shape it leaves wrong, so read the unmoved rows of a count's grid too. And write the connective in one case too, but don't assume what it is there: only the marked subset (`may_be_initial`, rules/P8) reads as an initial in a one-case name, while `Y` and `И` keep their connective tag, so `JOHN SMITH Y V` moved with its mixed-case twin under #1097 and #1098, after a decision had been asked on the premise that it could not. A suffix word OPENING the part is the other half, and counts as a name word where one follows it: from 2.4.0 the counts passed over it, so `JP Clancy, MD` lost its given name to initials that spell a credential and `Cem Akin, MD` to a given name a credential spells, until #1017, while `Md Rahman, PhD` had read title 'Md' or family 'Md Rahman' in every release. No comma grid had put a listed suffix word at the head, and real heads are full of them, so open a head with initials (`JP`, `A.M.`), a given name a credential spells (`Cem`, `Md`), a title/suffix dual (`Sr.`) and a split credential's member (`MB ChB`), behind a title too, and put a title behind the opening word (`Md Prof., PhD`): the first build counted it as the name word there in one count and not in the other, found by review. A bound given-name pair is the same trap from the other side: a count that passes over particles reads `Abu Bakr` as ONE word, `abu` being a particle and a bound word both, where `abdul Rahman` counts two, so a rule asking whether the given name already holds two words needs a bound pair of each spelling in its grid; #1057's grid held only `abdul` until its test review found O7 completing `Abu Bakr` (`_post_rules._one_given_word` counts it now). And C3's one name word is not one word as written: it passes over a title word (`Ashley Knight`) and reads a capitalized particle with its surname as one (`Bin Zhang`), so a rule keyed to a one-word head reads more two-word heads than it means to -- #1238's first build read `Bin Zhang, M.D.` and `Ashley Knight, M.S. BME` as initials, found by its grid and the ClinicalTrials.gov measurement; put a title-word surname and a capitalized particle head in the grid of any one-word-head rule, beside the lower-case Dutch particle (`de Waart`) it may mean to admit. A run of letters is a spelling too: `_LETTER` matches a Hangul syllable (`J.씨`, a glued honorific) and a decomposed accent's base, so a test that every letter is a capital needs a mark-free, cased letter in its grid and the NFD spelling beside it. And a count of the whole name's words leaves the maiden clause out (rules/M2): #1464's four-word count for `abdul` first counted `née Haddad` as two name words, so `Tariq Abdul Aziz née Haddad` joined where `Tariq Abdul Aziz` did not, found by `test_a_maiden_clause_changes_nothing_else` and not by the change's own grid, which put a clause only behind `abdel`, a word the count does not gate: put the clause behind the word a count decides for. Its code review found two more of the same: a suffix written without a comma (`Tariq Abdul Aziz Jr.`, where the grid held only `Tariq Abdul Aziz, MD`) and a title read by its shape (`Insp.`) each counted as a name word, so put a suffix with and without its comma, and a listed and a shape title, around the word a count decides for. The review of that fix found five more: a title phrase H9 reads (`Associate Dean`, `The Rt Hon`, `Dean of Students`) and a dotted title (`U.S. Senator`), tagged only later in classify, so the count moved below the H9 phrase test; an ambiguous credential (`, MA`) and a numeral `VI` to `X`, which carry another tag or none; and a pair of initials (`B.K.`), which an exclusion by the acronym's shape tag dropped though #864 reads it as the family. A count of name words reads every kind of non-name word the parse knows, and runs where the stage has tagged them all. Moving the test later then narrowed it twice, found by the next review: the join's "plain word after it" test now saw the tag H9 leaves on a contested title it reads as a name (`Ali Abdel Mahdi`), and the leading title run took a particle after a title for a title's object (`Dr Abu Bakar Abdul Rahim`); when a test moves to read more tags, re-check every test beside it that reads tags too. ### Orders diff --git a/nameparser/_lexicon.py b/nameparser/_lexicon.py index b61096402..de396e5b3 100644 --- a/nameparser/_lexicon.py +++ b/nameparser/_lexicon.py @@ -596,6 +596,11 @@ class _LexiconSets: #: the two-word given names a bound word's `completed_by` lists #: ('عبد الله'), which rules/P12 joins past the first name word (#694) bound_phrases: frozenset[str] + #: the bound given names that complete with any plain name word + #: after them past the first name word, and the ones of those that + #: do so only in a name of four words or more (rules/P12, #1464) + bound_completes_any: frozenset[str] + bound_long_names_only: frozenset[str] #: Lexicon field -> the compiled constant it is read from, for every @@ -637,6 +642,8 @@ class _LexiconSets: "dotted_titles": "DOTTED_TITLES", "glued_titles": "GLUED_TITLES", "bound_phrases": "BOUND_PHRASES", + "bound_completes_any": "BOUND_COMPLETES_ANY", + "bound_long_names_only": "BOUND_LONG_NAMES_ONLY", } #: What the 2.x sets do not record: the kinds the views read (rules/R8, @@ -876,7 +883,7 @@ def _default_compiled() -> _Compiled: _FLAG_PROPS = frozenset({ "abbreviation", "acronym", "after_given", "may_be_initial", "title_case_is_name", "shared", "after_particle", "capital_opening", - "dotted"}) + "dotted", "completes_any", "long_names_only"}) class _Edit(NamedTuple): diff --git a/nameparser/_pipeline/_classify.py b/nameparser/_pipeline/_classify.py index 25e17f1f2..f4cc5ec6e 100644 --- a/nameparser/_pipeline/_classify.py +++ b/nameparser/_pipeline/_classify.py @@ -28,9 +28,11 @@ community gives every member (shared_names) and the given names written behind a particle (particle_given_names, #704) and the two-word given names a bound word completes into (bound_phrases, -#694) and the titles a run of single letters may spell -(dotted_titles, rules/H10, #490) and the saint particles a word glued -at its full stop is cut behind (saint_particles, through +#694) and the bound words that complete with any plain name word, in +any name or only in one of four name words or more +(bound_completes_any, bound_long_names_only, #1464) and the titles a +run of single letters may spell (dotted_titles, rules/H10, #490) and +the saint particles a word glued at its full stop is cut behind (saint_particles, through `_vocab.glued_saint_cut`); and, since 2.4, Policy.unlisted_dotted_suffixes and Policy.unlisted_caps_suffixes, which decide whether an UNLISTED dotted or all-caps token joins the @@ -95,7 +97,9 @@ class (rules/S12). """ from __future__ import annotations +import re import unicodedata +from collections.abc import Sequence from nameparser._lexicon import _normalize, _spells_an_initial from nameparser._policy import CapsSuffixes @@ -111,10 +115,10 @@ class (rules/S12). ) from nameparser._types import AmbiguityKind, ReadingKind, ReadingSource from nameparser._pipeline._vocab import ( - BUILTIN_GLUED_DELIMITERS, SPLIT_CHUNK, SPLIT_PAIR_OPENS, _INITIAL, _JOINED_WORD, + BUILTIN_GLUED_DELIMITERS, SPLIT_CHUNK, SPLIT_PAIR_OPENS, _INITIAL, _JOINED_WORD, _ROMAN, _TRAILING_TITLE_SHAPE, caps_shape_candidate, composed_len, glued_cores, glued_stem, is_cased_paired_initials, - is_dotted_title, is_initial, is_one_case, + is_dotted_title, is_initial, is_one_case, is_title_shaped, period_joined_title, period_joined_vocab, split_pair, suffix_as_written, tag_marker_runs, title_readings, @@ -122,6 +126,71 @@ class (rules/S12). from nameparser._pipeline._pieces import own_words +def _name_words(tokens: Sequence[WorkToken], state: ParseState, + clause_at: int, partner: int) -> int: + """How many name words the name holds, for rules/P12's + `long_names_only`, part by part (the comma parts, before a maiden + clause, which changes nothing else in the name): words carrying no + role and holding a letter, save each part's leading title run (a + listed title, a title phrase H9 read, a dotted title, one H2's shape + reads, and a connective inside the run with the word it joins) and, + after `partner`, the word the bound word would join, anything but a + plain word, a bound given name or a pair of initials in a script + with case (a suffix, listed, by its shape or a numeral VI to X + written other than in Title case), and nothing past the next comma. + A plain loop, a generator costing a frame per word.""" + count = 0 + for seg in state.segments: + if seg and seg[0] > partner: + break + leading = True + held = 0 + titled = False + for i in seg: + if i >= clause_at: + break + t = tokens[i] + if t.role is not None or not _HAS_LETTER.search(t.text): + continue + tags = t.tags + if i > partner: + stem = t.text.rstrip(".") + if ((not tags - _BOUND_TAGS + or is_cased_paired_initials(t.text)) + and not (stem and not stem.istitle() + and _ROMAN.match(stem))): + count += 1 + continue + if leading: + if (_LEADING_TITLE_TAGS & tags + or is_title_shaped(t.text, state.lexicon)): + held = 0 + titled = True + continue + if "conjunction" in tags: + held += 1 + continue + if titled and held: + # the word a title's connective joins into the run + # ('Dean of Students') + held = 0 + continue + leading = False + count += held + count += 1 + return count + + +#: The tag H9 leaves on a contested title it read as a name word. +_CONTESTED_TAGS = frozenset({TITLE_AMBIGUOUS_TAG}) +#: A bound given name's own tags: one after the pair is a name word. +_BOUND_TAGS = frozenset({"vocab:bound-given"}) +#: The tags that mark a word of the leading title run: a title, listed +#: or read in its phrase (H9), and a dotted title (H10). +_LEADING_TITLE_TAGS = frozenset({"vocab:title", DOTTED_TITLE_TAG}) +#: A letter (a decomposed accent's base included): a search, not a +#: loop over the word, so the test costs no frame. +_HAS_LETTER = re.compile(r"[^\W\d_]") # rules/S2: "a trailing word of the suffix vocabulary reads as a @@ -538,25 +607,6 @@ def classify(state: ParseState) -> ParseState: tokens = tuple( copy_with(t, tags=t.tags - _JOINING_TAGS) if i in stemmed else t for i, t in enumerate(tokens)) - # rules/P12: "the two words are one name unit past the first name word" - # -- the phrase test over each word and the word after it, asked - # only of a name holding a bound word, in a plain loop, so that no - # other name pays a frame; the tag goes on the bound word, and - # group joins the pair (decisions/P12, #694) - phrases = state.lexicon._sets.bound_phrases - if phrases and not state.lexicon._sets.bound_given_names.isdisjoint( - folded): - heads = set() - for i in range(len(folded) - 1): - # rules/C10: "no join, maiden clause or connective reaches - # across it", so a delimiter glued to the bound word ends it - if (f"{folded[i]} {folded[i + 1]}" in phrases - and i not in stemmed): - heads.add(i) - if heads: - tokens = tuple( - copy_with(t, tags=t.tags | {BOUND_PHRASE_TAG}) - if i in heads else t for i, t in enumerate(tokens)) # rules/H9: "the word is a title only inside a title phrase, and # elsewhere a name word" -- the phrase test (_vocab.title_readings) # asked per part, of the words carrying no role, and only of a part @@ -606,6 +656,43 @@ def classify(state: ParseState) -> ParseState: if tags != written[i].tags: written[i] = copy_with(written[i], tags=tags) tokens = tuple(written) + # rules/P12: "the two words are one name unit past the first name word" + # -- the phrase test over each word and the word after it, asked + # only of a name holding a bound word, in a plain loop, so that no + # other name pays a frame; the tag goes on the bound word, and + # group joins the pair (decisions/P12, #694). A bound word written + # `completes_any` pairs with a plain word, one carrying no tag (no + # vocabulary reading, not initial-shaped) and holding a letter, and + # one written `long_names_only` only in a name of four name words + # or more (decisions/P12, #1464) + sets = state.lexicon._sets + phrases = sets.bound_phrases + open_bound = sets.bound_completes_any + if ((phrases or open_bound) + and not sets.bound_given_names.isdisjoint(folded)): + heads = set() + for i in range(len(folded) - 1): + # rules/C10: "no join, maiden clause or connective reaches + # across it", so a delimiter glued to the bound word ends it + if i in stemmed: + continue + if f"{folded[i]} {folded[i + 1]}" in phrases: + heads.add(i) + # the first word is P5's, which this join never reads + # a contested title H9 read out of a title phrase is a name word + elif (i and folded[i] in open_bound + and not tokens[i + 1].tags - _CONTESTED_TAGS + and _HAS_LETTER.search(tokens[i + 1].text)): + # counted per pair, the count reading which words stand + # after the word it would join + if (folded[i] in sets.bound_long_names_only + and _name_words(tokens, state, clause_at, i + 1) < 4): + continue + heads.add(i) + if heads: + tokens = tuple( + copy_with(t, tags=t.tags | {BOUND_PHRASE_TAG}) + if i in heads else t for i, t in enumerate(tokens)) # rules/S12: "a credential written split across a space reads as one # word" -- each adjacent pair of a segment asked once, here, and # the answer written on its first word for group's merge and the diff --git a/nameparser/_pipeline/_group.py b/nameparser/_pipeline/_group.py index b58283047..8bdc94e4b 100644 --- a/nameparser/_pipeline/_group.py +++ b/nameparser/_pipeline/_group.py @@ -26,7 +26,8 @@ ONCE, after P3's connective joins and before the particle chain and the bound-given join, and split off so neither reaches it (#614), which assign places and reports rather than peeling again; and, -last in each part, P12's join of a listed pair past the start, the +last in each part, P12's join past the start of a listed pair, or of a +`completes_any` bound word and the plain word after it (#1464), the classify tag left only on the bound word of a pair it joined (#694). Reads: token tags (from classify), Lexicon.given_name_titles (the P5 licence, #369), Policy.name_order (rules/P13's joins at the end @@ -720,7 +721,8 @@ def _settle_splits(pieces: list[Piece], ptags: list[set[str]]) -> None: # rules/P12: "the two words are one name unit past the first name word" # -- past the piece P5's leading join reads, which this leaves as it # was, its reserve included; classify's tag says the word and the -# token after it are a listed phrase (history: decisions/P12, #694) +# token after it are a listed phrase, or a `completes_any` bound word +# before a plain word (history: decisions/P12, #694, #1464) def _join_bound_phrases(pieces: list[Piece], ptags: list[set[str]], tokens: Sequence[WorkToken], joined_heads: set[int]) -> None: @@ -1610,7 +1612,7 @@ def group(state: ParseState) -> ParseState: ptags = [] seg_reads: list[TailRead | None] = [] for part in parts: - # a plain loop, no frame: a name with no listed pair pays + # a plain loop, no frame: a name with no tagged pair pays # nothing (rules/P12) heads: set[int] | None = None for i in part: diff --git a/nameparser/_pipeline/_state.py b/nameparser/_pipeline/_state.py index a7ce92ae4..8e76324a3 100644 --- a/nameparser/_pipeline/_state.py +++ b/nameparser/_pipeline/_state.py @@ -257,10 +257,13 @@ def reported_suffix_fork(ambiguities: Sequence[PendingAmbiguity], PARTICLE_GIVEN_TAG = "vocab:particle-given" #: On a bound given name whose word and the word after it are a phrase -#: of `Lexicon.bound_phrases` ('عبد' before 'الله'), which rules/P12 -#: joins past the first name word (`_group._join_bound_phrases`), and -#: group leaves it only on a pair it joined. Dropped -#: from the published token like the kind tags above (#694). +#: of `Lexicon.bound_phrases` ('عبد' before 'الله'), or one of +#: `Lexicon.bound_completes_any` before a plain name word, one of +#: `Lexicon.bound_long_names_only` only in a name of four name words or +#: more (#1464), which rules/P12 joins past the first name word +#: (`_group._join_bound_phrases`), and group leaves it only on a pair +#: it joined. Dropped from the published token like the kind tags +#: above (#694). BOUND_PHRASE_TAG = "vocab:bound-phrase" #: rules/O9 ("the capitals settle the field"): a word in capitals that #: Policy.capitals_as_family read as the family, written by post_rules, diff --git a/nameparser/_reading_index.py b/nameparser/_reading_index.py index 44469b430..50599e5b1 100644 --- a/nameparser/_reading_index.py +++ b/nameparser/_reading_index.py @@ -122,7 +122,8 @@ "title_case_is_name"}), "particle": frozenset({"capital_opening", "cased", "default"}), "conjunction": frozenset({"may_be_initial", "cased", "default"}), - "bound_given": frozenset({"completed_by", "cased", "default"}), + "bound_given": frozenset({"completed_by", "completes_any", "cased", + "default", "long_names_only"}), "relation": frozenset({"cased", "default"}), "name": frozenset({"after_particle", "cased", "default", "shared"}), "familiar": frozenset({"default"}), @@ -246,7 +247,8 @@ def on_by_default(self) -> bool: def flag(self, prop: str) -> bool: """A `may_be_*` flag, `after_given`, `abbreviation`, `title_case_is_name`, `shared`, `after_particle`, - `capital_opening` or `dotted`: unwritten, false.""" + `capital_opening`, `dotted`, `completes_any` or + `long_names_only`: unwritten, false.""" return bool(self.props.get(prop, False)) @property @@ -663,6 +665,8 @@ class Compiled(TypedDict): DOTTED_TITLES: frozenset[str] GLUED_TITLES: frozenset[str] BOUND_PHRASES: frozenset[str] + BOUND_COMPLETES_ANY: frozenset[str] + BOUND_LONG_NAMES_ONLY: frozenset[str] SAME_AS: dict[str, dict[str, tuple[str, ...]]] SAME_AS_NAMED: dict[str, frozenset[str]] FAMILIAR: dict[str, tuple[str, ...]] @@ -718,6 +722,8 @@ def compile_readings(readings: Iterable[ReadingProperties]) -> Compiled: shared: set[str] = set() after_particle: set[str] = set() bound_phrases: set[str] = set() + completes_any: set[str] = set() + long_names_only: set[str] = set() cased: dict[str, str] = {} same_as: dict[str, dict[str, set[str]]] = { g: {} for g in SAME_AS_GROUPS.values()} @@ -802,6 +808,10 @@ def compile_readings(readings: Iterable[ReadingProperties]) -> Compiled: bound.add(t) bound_phrases.update(f"{t} {w}" for w in p.get("completed_by", ())) + if r.flag("completes_any"): + completes_any.add(t) + if r.flag("long_names_only"): + long_names_only.add(t) elif category == "relation": markers.add(t) contested = titles & given - particles @@ -903,6 +913,12 @@ def compile_readings(readings: Iterable[ReadingProperties]) -> Compiled: # the bound word and each word that completes it ('عبد الله'), # which rules/P12 joins wherever they stand (#694) BOUND_PHRASES=frozenset(bound_phrases), + # the bound given names written `completes_any`, which rules/P12 + # joins with any plain name word after them past the first name + # word, and of those the ones written `long_names_only`, joined + # only in a name of four words or more (#1464) + BOUND_COMPLETES_ANY=frozenset(completes_any), + BOUND_LONG_NAMES_ONLY=frozenset(long_names_only), # every reading's `same_as` in the group of its kind: the words # it is a listed spelling of (`wm` of `william` among given # names, `junior` of `jr` among suffixes, `sr` of both `señor` diff --git a/nameparser/config/_compiled.py b/nameparser/config/_compiled.py index 5547e2320..0f01d63fc 100644 --- a/nameparser/config/_compiled.py +++ b/nameparser/config/_compiled.py @@ -4627,6 +4627,18 @@ 'عبد الکریم', }) +BOUND_COMPLETES_ANY: frozenset[str] = frozenset({ + 'abd', + 'abdal', + 'abdel', + 'abdul', + 'abou', +}) + +BOUND_LONG_NAMES_ONLY: frozenset[str] = frozenset({ + 'abdul', +}) + SAME_AS: dict[str, dict[str, tuple[str, ...]]] = { 'family': { 'ad-': ('al-',), diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 2f70eab50..40baf0733 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -49,16 +49,16 @@ ('abbot', (('en', 'religious', ()),)), ('abby', (('en', 'familiar', (('short_for', ('abigail',)),)), ('mul', 'familiar', (('short_for', ('abigale',)),)))), ('abc', (('en', 'credential', ()),)), - ('abd', (('ar', 'bound_given', ()), ('en', 'credential', ()))), - ('abdal', (('ar', 'bound_given', (('same_as', 'abdul'),)),)), - ('abdel', (('ar', 'bound_given', (('same_as', 'abdul'),)),)), - ('abdul', (('ar', 'bound_given', ()),)), + ('abd', (('ar', 'bound_given', (('completes_any', True),)), ('en', 'credential', ()))), + ('abdal', (('ar', 'bound_given', (('completes_any', True), ('same_as', 'abdul'))),)), + ('abdel', (('ar', 'bound_given', (('completes_any', True), ('same_as', 'abdul'))),)), + ('abdul', (('ar', 'bound_given', (('completes_any', True), ('long_names_only', True))),)), ('abdullah', (('ar', 'spelling', (('spelling_of', ('abdallah',)),)),)), ('abe', (('en', 'familiar', (('short_for', ('abraham',)),)),)), ('abhi', (('en', 'familiar', (('short_for', ('abhishek',)),)),)), ('abi', (('en', 'familiar', (('short_for', ('abigail',)),)),)), ('abolitionist', (('en', 'occupation', ()),)), - ('abou', (('ar', 'bound_given', (('same_as', 'abu'),)),)), + ('abou', (('ar', 'bound_given', (('completes_any', True), ('same_as', 'abu'))),)), ('abpp', (('en', 'credential', ()),)), ('abr', (('en', 'credential', ()),)), ('abu', (('ar', 'teknonymic', ()), ('ar', 'bound_given', ()), ('ar', 'given', ()))), diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index 9fe60c84e..88c3144bb 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -192,6 +192,8 @@ A property is **behavioral** when it compiles into a set and so changes how name | `shared` | behavioral | `name` | false | `SHARED_NAMES`: a name a community gives every member, written after the personal name and before a family name where there is one (Sikh `kaur` and `singh`), no personal or family name of the bearer's own: two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) and two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) neither take it nor complete one with it, so `Harpreet Kaur Dhillon` keeps middle `Kaur` under either, and a given name a particle completes ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md)) is never one, so `Kaur del Carmen García` keeps family `del Carmen García` by default (#704) | | `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `carmo`, `conceição`, `luz`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share before #1189 (decisions/P10, #704, #1118, #1122) | | `completed_by` | behavioral | `bound_given` | none | `BOUND_PHRASES`: the words that complete the bound given name into one name unit past the first name word, a list (`completed_by = ["الله", "الرحمن"]` on `عبد`), each one word written folded: `سعيد عبد الله` reads family `عبد الله` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md), a bound given name and the word that completes it), while a word left off the list after it is a name of its own, as in `نوال عبد هاشم` (#694) | +| `completes_any` | behavioral | `bound_given` | false | `BOUND_COMPLETES_ANY`: the bound given name completes with any plain name word after it past the first name word, one with no vocabulary reading and no initial's shape, the pair one name unit that position places, family where it ends the name and one middle name inside it: `Tariq Abdel Aziz` reads family `Abdel Aziz` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md)), written on the Latin spellings, which name no word after them (#1464) | +| `long_names_only` | behavioral | `bound_given` | false | `BOUND_LONG_NAMES_ONLY`, a subset of `BOUND_COMPLETES_ANY`: narrows `completes_any`, which it needs beside it (the build refuses it alone; a caller's `add` of it alone is inert), to a name of four name words or more, a title and a suffix word counting as none, so a three-word name keeps the bound word apart: `Tariq Abdul Aziz` reads middle `Abdul` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md)), written on `abdul`, whose three-word names are split both ways by population (#1464) | | `dotted` | behavioral | `title` | false | `DOTTED_TITLES`: the title abbreviates several words and is written with a full stop after each letter (`us`, `uk`, German `pd`), so a run of single letters joined by full stops that spells it is that title at the head of a name where a title the name keeps follows it, as in `U.S. District Judge Marc Treadwell`, and the initials it is written as otherwise (`U.S. Grant`) ([rules/H10](../../docs/design/rules/H10-title-written-as-a-run-of-letters.md), a title written as a run of letters). A title abbreviating one word (`dr`, `mr`, `lt`) is left unmarked, since two initials spell it (`D.R. Judge Smith` reads given 'D.', middle 'R. Judge', its given names 'D.R. Judge', no title) | | `capital_opening` | behavioral | `particle` | false | `CAPITAL_OPENING_PARTICLES`: the particle is written with a capital where the word before it in the family name is no particle, nor, where it opens the family name, the word written right before it in any role (`Van der Walt` keeps its lowercase `der`), as the Armenian priestly prefix is (`ter` and `der`: `LEVON TER PETROSYAN` repairs to `Levon Ter Petrosyan`), and keeps its lowercase after one (`Jan van der Berg`) ([rules/R12](../../docs/design/rules/R12-particle-opening-the-family-name-with-a-capital.md), a particle opening the family name with a capital); it moves no parse. A Dutch surname opened by `ter` takes the capital too (`Gerard Ter Borch`), a cost accepted in decisions/R12 | | `may_be_given` | stated | `particle` | none: required where the word has no `given` reading | `false` is required where the word has no `given` reading in any file, and that absence, not the property, is what puts the word in `NON_GIVEN_NAME_PARTICLES`: a particle opening the name starts the family name ([rules/P1](../../docs/design/rules/P1-lone-particle-fold.md), the lone particle fold). `true` is refused, naming the `given` reading to write instead (check 11) | diff --git a/nameparser/vocab/ar.toml b/nameparser/vocab/ar.toml index eb536ec14..8fee72628 100644 --- a/nameparser/vocab/ar.toml +++ b/nameparser/vocab/ar.toml @@ -565,23 +565,28 @@ note = "formal script attaches و to the following word (وفاطمة), so a sta text = "abd" [word.bound_given] expands = "servant of" -note = "the bare transliteration, which abdul/abdel/abdal do not match: 'abd Allah Smith' and 'Abd al-Rahman Smith' read given 'abd Allah' and 'Abd al-Rahman'; the three-token 'abd al rahman smith' is not joined, al being a particle that chains forward. Also the credential ABD in en.toml; position decides at the two ends but not in a family comma's given slot (decisions/P5)" +completes_any = true +note = "the bare transliteration, which abdul/abdel/abdal do not match: 'abd Allah Smith' and 'Abd al-Rahman Smith' read given 'abd Allah' and 'Abd al-Rahman'; the three-token 'abd al rahman smith' is not joined, al being a particle that chains forward. Also the credential ABD in en.toml; position decides at the two ends but not in a family comma's given slot (decisions/P5), save before a plain name word there, which it completes ('Haddad, Nadia Abd Karim' reads middle 'Abd Karim'). completes_any: joined with any plain name word after it past the first name word, the pair placed by position (rules/P12, #1464)" [[word]] text = "abdul" -bound_given = { expands = "servant of the" } +[word.bound_given] +expands = "servant of the" +completes_any = true +long_names_only = true +note = "completes_any: joined with any plain name word after it past the first name word, the pair placed by position (rules/P12, #1464). long_names_only: only in a name of four name words or more, for the filers of a three-word X Abdul Y split it both ways, by the boxes filed for abdul between two words in the three-word names of each population (2026-11-19): family 'Abdul Y' against family 'Y', ORCID Malaysia 183 to 2, Pakistan 35 to 14, Iraq 31 to 1, Bangladesh 10 to 60; PSC British 43 to 172, Pakistani 27 to 29, Indian 10 to 21, Bangladeshi 1 to 21; PatentsView Malaysia 8 to 9, Saudi Arabia 2 to 11 (decisions/P12)" [[word]] text = "abdal" -bound_given = { expands = "servant of the", same_as = "abdul" } +bound_given = { expands = "servant of the", same_as = "abdul", completes_any = true } [[word]] text = "abdel" -bound_given = { expands = "servant of the", same_as = "abdul" } +bound_given = { expands = "servant of the", same_as = "abdul", completes_any = true } [[word]] text = "abou" -bound_given = { expands = "father of", same_as = "abu" } +bound_given = { expands = "father of", same_as = "abu", completes_any = true } [[word]] text = "umm" diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 5b9e6b267..aeb1cdb99 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -678,10 +678,21 @@ def _check_cjk_shape_purity(self) -> None: notes="hyphenated initials write given names, as an initial " "written alone does (#959)"), Case("two_family_names_leaves_a_bound_given_pair_before_the_family", - "Ana abdul Rahman López", - {"given": "Ana", "middle": "abdul Rahman", "family": "López"}, + "Ana Umm Kulthum López", + {"given": "Ana", "middle": "Umm Kulthum", "family": "López"}, policy=_TWO, classification="parity", - notes="#754 review: a P5 pair is one GIVEN name"), + notes="#754 review: a bound word P12 does not join past the " + "first word (umm completes nothing) leaves two words, which " + "O6 does not take; written with 'abdul Rahman' until #1464 " + "made that pair one name (rules/P12), which O6 takes as a " + "family word"), + Case("two_family_names_takes_a_latin_bound_pair_p12_joined", + "Ana abdul Rahman López", + {"given": "Ana", "family": "abdul Rahman López"}, + policy=_TWO, classification="fix(#1464)", + notes="rules/P12 joins the pair past the first name word, so O6 " + "counts it one word, as it counts 'abu Bakr'; read middle " + "'abdul Rahman', family 'López' through 3.1.0"), Case("two_family_names_counts_an_en_dash_as_a_hyphen", "Ana María García–López", {"given": "Ana", "middle": "María", "family": "García–López"}, @@ -3059,10 +3070,12 @@ def _check_cjk_shape_purity(self) -> None: "title half only; the sweep test over `trailing_candidates` " "found this one"), Case("a_bound_given_word_is_no_run", "Mohamed Ali Abd Allah", - {"given": "Mohamed", "middle": "Ali Abd", "family": "Allah"}, + {"given": "Mohamed", "middle": "Ali", "family": "Abd Allah"}, + classification="fix(#1464)", notes="'abd' is in the credential list (ABD) and heads 'Abd " "Allah'; a word another vocabulary claims as a name never " - "starts the run"), + "starts the run. rules/P12 joins the pair since #1464; " + "middle 'Ali Abd', family 'Allah' through 3.1.0"), Case("one_name_word_is_no_core", "John PhD Smith", {"given": "John", "middle": "PhD", "family": "Smith"}, notes="with no comma two name words must stand in front of the " @@ -21668,4 +21681,255 @@ def _check_cjk_shape_purity(self) -> None: "(1.4.0 through 2.3.0 read middle 'Aina bt', family " "'Rosli'); a caller with Malay names removes it " "(docs/customize.rst)"), + # #1464: a Latin bound given name (abdul, abd, abdel, abdal, abou) + # completes with a plain name word after it past the first name + # word (rules/P12), abdul only in a name of four name words or more. + Case("abdel_past_the_first_word_completes_with_the_word_after_it", + "Tariq Abdel Aziz", + {"given": "Tariq", "family": "Abdel Aziz"}, + classification="fix(#1464)", + notes="the pair ends the name, so it is the family; read middle " + "'Abdel', family 'Aziz' 1.4.0 through 3.1.0"), + Case("abdul_ending_a_four_word_name_is_the_family", + "Nadia Ali Abdul Rahim", + {"given": "Nadia", "middle": "Ali", "family": "Abdul Rahim"}, + classification="fix(#1464)", + notes="read middle 'Ali Abdul', family 'Rahim' 1.4.0 through " + "3.1.0"), + Case("abdul_inside_a_four_word_name_is_one_middle_name", + "Nadia Abdul Rahim Ali", + {"given": "Nadia", "middle": "Abdul Rahim", "family": "Ali"}, + notes="boundary: the pair stands inside the name, so position " + "makes it one middle name, the field it already filled"), + Case("abdul_in_a_three_word_name_stays_apart", + "Tariq Abdul Aziz", + {"given": "Tariq", "middle": "Abdul", "family": "Aziz"}, + notes="boundary: abdul's reading is written long_names_only, the " + "writers of a three-word name splitting it both ways by " + "population (decisions/P12, #1464)"), + Case("abdul_in_a_three_word_name_with_a_title_stays_apart", + "Mr Tariq Abdul Aziz", + {"title": "Mr", "given": "Tariq", "middle": "Abdul", + "family": "Aziz"}, + notes="boundary: a title is no name word in the count"), + Case("abdul_in_a_three_word_name_with_a_credential_stays_apart", + "Tariq Abdul Aziz, MD", + {"given": "Tariq", "middle": "Abdul", "family": "Aziz", + "suffix": "MD"}, + notes="boundary: a credential after a comma is no name word in " + "the count"), + Case("abdul_in_a_three_word_name_in_capitals_stays_apart", + "TARIQ ABDUL AZIZ", + {"given": "TARIQ", "middle": "ABDUL", "family": "AZIZ"}, + notes="boundary: the spelling twin of the three-word row"), + Case("abdel_in_capitals_completes_with_the_word_after_it", + "NADIA ABDEL RAHIM", + {"given": "NADIA", "family": "ABDEL RAHIM"}, + classification="fix(#1464)", + notes="read middle 'ABDEL', family 'RAHIM' 1.4.0 through 3.1.0"), + Case("abou_completes_with_the_word_after_it", + "Ahmad Abou Zeid", + {"given": "Ahmad", "family": "Abou Zeid"}, + classification="fix(#1464)", + notes="abou is abu's spelling; abu keeps its particle reading " + "and is not changed. Read middle 'Abou', family 'Zeid' " + "1.4.0 through 3.1.0"), + Case("abd_past_the_first_word_completes_before_a_credential", + "Nadia Abd Karim, MD", + {"given": "Nadia", "family": "Abd Karim", "suffix": "MD"}, + classification="fix(#1464)", + notes="read middle 'Abd', family 'Karim' 1.4.0 through 3.1.0"), + Case("abd_opening_a_two_word_name_keeps_its_given_name", + "Abd Karim, MD", + {"given": "Abd", "family": "Karim", "suffix": "MD"}, + notes="boundary: the opening word is P5's, which leaves a " + "two-word name its family; the particle reading weighed in " + "decisions/P12 (#1464) would have read the whole name into " + "the family and left no given name"), + Case("a_latin_bound_word_completes_no_particle", + "Ahmad Abdel bin Omar", + {"given": "Ahmad", "middle": "Abdel", "family": "bin Omar"}, + notes="boundary: a word the vocabulary reads otherwise completes " + "nothing, so the bin chain keeps its family"), + Case("a_latin_bound_pair_before_a_bin_chain_is_a_middle_name", + "Ahmad Abdul Rahim bin Omar", + {"given": "Ahmad", "middle": "Abdul Rahim", "family": "bin Omar"}, + notes="boundary: the pair joins inside the name and the chain is " + "not cut"), + Case("a_latin_bound_word_completes_no_initial", + "Ahmad Abdel K.", + {"given": "Ahmad", "middle": "Abdel", "family": "K."}, + notes="boundary: an initial is no plain name word"), + Case("a_latin_bound_pair_after_a_family_comma_is_a_middle_name", + "Rahim, Nadia Abdel Karim", + {"given": "Nadia", "middle": "Abdel Karim", "family": "Rahim"}, + notes="boundary: the pair stands inside the given part"), + Case("a_latin_bound_pair_under_family_first_is_the_given_name", + "Rahim Nadia Abdel Karim", + {"given": "Abdel Karim", "middle": "Nadia", "family": "Rahim"}, + policy=Policy(name_order=FAMILY_FIRST_GIVEN_LAST), + classification="fix(#1464)", + notes="position places the pair: with the given name declared " + "last, the pair is it; read given 'Karim', middle 'Nadia " + "Abdel' through 3.1.0"), + Case("a_latin_bound_pair_under_family_first_is_a_middle_name", + "Rahim Nadia Abdel Karim", + {"given": "Nadia", "middle": "Abdel Karim", "family": "Rahim"}, + policy=Policy(name_order=FAMILY_FIRST), + notes="boundary: the given name declared second, the pair is " + "the middle name it was"), + Case("abd_after_a_family_comma_completes_rather_than_reads_as_abd", + "Haddad, Nadia Abd Karim", + {"given": "Nadia", "middle": "Abd Karim", "family": "Haddad"}, + classification="fix(#1464)", + notes="the join keeps 'Abd' a name word where the given part " + "read it as the credential ABD (All But Dissertation); " + "read middle 'Karim', suffix 'Abd' 1.4.0 through 3.1.0"), + Case("abdul_in_a_three_word_name_with_a_generation_stays_apart", + "Tariq Abdul Aziz Jr.", + {"given": "Tariq", "middle": "Abdul", "family": "Aziz", + "suffix": "Jr."}, + notes="boundary: a suffix word after the pair is no name word in " + "the count, with no comma before it as with one (code " + "review)"), + Case("abdul_in_a_three_word_name_with_a_credential_and_no_comma", + "Tariq Abdul Aziz MD", + {"given": "Tariq", "middle": "Abdul", "family": "Aziz", + "suffix": "MD"}, + notes="boundary: the comma-less twin of the credential row"), + Case("abdul_in_a_three_word_name_with_a_shape_title_stays_apart", + "Insp. Tariq Abdul Aziz", + {"title": "Insp.", "given": "Tariq", "middle": "Abdul", + "family": "Aziz"}, + notes="boundary: a title read by its shape (rules/H2) is no name " + "word in the count, as a listed one is not"), + Case("a_latin_bound_word_completes_no_lone_mark", + "Tariq Abdel - Smith", + {"given": "Abdel", "middle": "- Smith", "family": "Tariq"}, + policy=Policy(name_order=FAMILY_FIRST), + notes="boundary: a mark with no letter is no name word to join " + "(code review)"), + Case("abdul_in_a_three_word_name_with_a_nickname_stays_apart", + "Tariq (Zizo) Abdul Aziz", + {"given": "Tariq", "middle": "Abdul", "family": "Aziz", + "nickname": "Zizo"}, + notes="boundary: a nickname is no name word in the count (test " + "review)"), + Case("abdul_in_a_three_word_name_with_a_quoted_nickname_stays_apart", + 'Tariq "Zizo" Abdul Aziz', + {"given": "Tariq", "middle": "Abdul", "family": "Aziz", + "nickname": "Zizo"}, + notes="boundary: the quoted twin of the nickname row"), + Case("a_nickname_between_the_bound_word_and_its_partner_parts_them", + "Nadia Abdel (Zizo) Rahim", + {"given": "Nadia", "middle": "Abdel", "family": "Rahim", + "nickname": "Zizo"}, + notes="boundary: the join pairs the bound word with the word " + "written right after it, and a clause between ends it"), + Case("abdul_inside_a_four_word_name_under_family_first", + "Nadia Abdul Rahim Ali", + {"given": "Abdul Rahim", "middle": "Ali", "family": "Nadia"}, + policy=Policy(name_order=FAMILY_FIRST), + classification="fix(#1464)", + notes="the pair joins in a four-word name and the order places " + "it: given 'Abdul', middle 'Rahim Ali' through 3.1.0"), + Case("abdul_in_a_three_word_name_under_family_first_given_last", + "Rahim Abdul Aziz", + {"given": "Aziz", "middle": "Abdul", "family": "Rahim"}, + policy=Policy(name_order=FAMILY_FIRST_GIVEN_LAST), + notes="boundary: three words stay apart under every order"), + Case("a_latin_bound_pair_before_a_bin_chain_under_family_first", + "Ahmad Abdul Rahim bin Omar", + {"given": "Abdul Rahim", "middle": "bin Omar", "family": "Ahmad"}, + policy=Policy(name_order=FAMILY_FIRST), + classification="fix(#1464)", + notes="the pair joins and the chain stays whole: given 'Abdul', " + "middle 'Rahim bin Omar' through 3.1.0"), + Case("a_latin_bound_pair_after_an_empty_head_is_a_middle_name", + ", Tariq Abdel Aziz", + {"given": "Tariq", "middle": "Abdel Aziz"}, + notes="boundary: nothing before the comma names no family (C15), " + "and the pair stays one middle name"), + Case("a_latin_bound_pair_in_lower_case_completes", + "tariq abdel aziz", + {"given": "tariq", "family": "abdel aziz"}, + classification="fix(#1464)", + notes="the lower-case twin; read middle 'abdel', family 'aziz' " + "1.4.0 through 3.1.0"), + Case('abdul_after_a_title_phrase_stays_apart', + 'Associate Dean Nadia Abdul Rahim', + {'title': 'Associate Dean', 'given': 'Nadia', 'middle': 'Abdul', 'family': 'Rahim'}, + classification='feat(#752)', + notes='boundary: a title phrase (rules/H9) is no name word in the count (fix-commit review)'), + Case('abdul_after_a_title_phrase_with_a_connective_stays_apart', + 'Dean of Students Nadia Abdul Rahim', + {'title': 'Dean of Students', 'given': 'Nadia', 'middle': 'Abdul', 'family': 'Rahim'}, + classification='feat(#752)', + notes="boundary: the word a title's connective joins is the title's"), + Case('abdul_after_an_article_and_titles_stays_apart', + 'The Rt Hon Nadia Abdul Rahim', + {'title': 'The Rt Hon', 'given': 'Nadia', 'middle': 'Abdul', 'family': 'Rahim'}, + notes='boundary: a connective inside the leading title run is no name word'), + Case('abdul_after_a_dotted_title_stays_apart', + 'U.S. Senator Nadia Abdul Rahim', + {'title': 'U.S. Senator', 'given': 'Nadia', 'middle': 'Abdul', 'family': 'Rahim'}, + classification='fix(#490)', + notes='boundary: a dotted title (rules/H10) is no name word'), + Case('abdul_before_an_ambiguous_credential_after_a_comma_stays_apart', + 'Nadia Abdul Rahim, MA', + {'given': 'Nadia', 'middle': 'Abdul', 'family': 'Rahim', 'suffix': 'MA'}, + notes='boundary: after the pair only a plain word counts'), + Case('abdul_before_a_numeral_stays_apart', + 'Ali Abdul Rahim VI', + {'given': 'Ali', 'middle': 'Abdul', 'family': 'Rahim', 'suffix': 'VI'}, + ambiguities=("suffix-or-name",), + notes='boundary: a numeral VI to X, which no tag marks, is no name word'), + Case("abdul_before_paired_initials_under_family_first", + "Ram Abdul Bahadur B.K.", + {"given": "Abdul Bahadur", "middle": "B.K.", "family": "Ram"}, + ambiguities=("suffix-or-name",), + policy=Policy(name_order=FAMILY_FIRST), + classification="fix(#1464)", + notes="paired initials in a script with case may be a family " + "name (#864), so they count; given 'Abdul', middle 'Bahadur " + "B.K.' through 3.1.0"), + Case("a_second_abdul_after_p5s_pair_completes", + "Mr Abdul Rahim Abdul Karim", + {"title": "Mr", "given": "Abdul Rahim", "family": "Abdul Karim"}, + classification="fix(#1464)", + notes="the four-word count is taken per pair, and a bound word " + "after the pair is a name word (fix-commit review: P5's " + "pair's count once stood in for the second); read middle " + "'Abdul', family 'Karim' 1.4.0 through 3.1.0"), + Case("abdul_after_a_title_and_a_bound_pair_completes", + "Dr Abu Bakar Abdul Rahim", + {"title": "Dr", "given": "Abu Bakar", "family": "Abdul Rahim"}, + classification="fix(#1464)", + notes="a particle after a title opens the name and is no title " + "object; four name words, as without the title (second " + "fix-commit review); 1.4.0 and 2.0.0 read family 'Abu " + "Bakar Abdul Rahim', 3.1.0 middle 'Abdul', family 'Rahim'"), + Case("abdul_after_a_title_and_a_particle_completes", + "Dr. Al Amin Abdul Rahman", + {"title": "Dr.", "given": "Al", "middle": "Amin", + "family": "Abdul Rahman"}, + ambiguities=("particle-or-given",), + classification="fix(#1464)", + notes="the untitled twin reads the same; 1.4.0 and 2.0.0 read " + "family 'Al Amin Abdul Rahman', 3.1.0 middle 'Amin Abdul', " + "family 'Rahman'"), + Case("abdel_completes_with_a_contested_title_read_as_a_name", + "Ali Abdel Mahdi", + {"given": "Ali", "family": "Abdel Mahdi"}, + classification="fix(#1464)", + notes="H9 reads 'Mahdi' out of any title phrase, a name word " + "(rules/H9), so it is plain to the join; read middle " + "'Abdel', family 'Mahdi' 1.4.0 through 3.1.0"), + Case("abdul_before_a_lower_case_numeral_stays_apart", + "Ali Abdul Rahim vi", + {"given": "Ali", "middle": "Abdul", "family": "Rahim", + "suffix": "vi"}, + notes="boundary: a numeral in lower case reads as the " + "generation (rules/S10), so it is no name word in the " + "count"), ) diff --git a/tests/v2/pipeline/test_group.py b/tests/v2/pipeline/test_group.py index f17bdf82c..9d990af68 100644 --- a/tests/v2/pipeline/test_group.py +++ b/tests/v2/pipeline/test_group.py @@ -234,11 +234,14 @@ def test_a_caller_lists_the_words_that_complete_a_bound_word() -> None: def test_a_delimiter_glued_to_the_bound_word_ends_the_pair() -> None: # a delimiter glued to the bound word parts the pair, as a comma - # would (the C10 rule); one glued to the word after it does not - for text in ("حسن, سعيد عبد; الله", "حسن, سعيد عبد الله; حسين"): + # would (the C10 rule); one glued to the word after it does not -- + # for a listed phrase and for a Latin word completing any (#1464) + for text in ("حسن, سعيد عبد; الله", "حسن, سعيد عبد الله; حسين", + "Haddad, Said Abdel; Karim", "Haddad, Said Abdel Karim; Omar"): state = _grouped(text, lexicon=Lexicon.default()) joined = [p for seg in state.pieces for p in seg if len(p) > 1] - assert joined == ([] if "عبد;" in text else [(2, 3)]), (text, joined) + glued = "عبد;" in text or "Abdel;" in text + assert joined == ([] if glued else [(2, 3)]), (text, joined) def test_the_phrase_tag_stays_only_on_a_pair_p12_joined() -> None: diff --git a/tests/v2/pipeline/test_post_rules.py b/tests/v2/pipeline/test_post_rules.py index f0184b873..2c5224cc5 100644 --- a/tests/v2/pipeline/test_post_rules.py +++ b/tests/v2/pipeline/test_post_rules.py @@ -66,7 +66,8 @@ # María'), which rules/O7 reads (#704) .add("maría", "maria", kind="given", after_particle=True) .add("y", kind="conjunction") - .add("abdul", kind="bound_given") + .add("abdul", kind="bound_given", completes_any=True, + long_names_only=True) ) @@ -1196,15 +1197,17 @@ def test_a_surviving_name_word_parts_two_entries() -> None: test alone cannot reach: a name word standing between two post-nominals parts their entries. `abd` is suffix vocabulary that starts no credential run (it is bound given-name vocabulary too, - rules/S8), so `Jones` behind it survives as a name word before - the credential. Drop the conjunct and this renders 'abd PhD'. + rules/S8), so `de Jones` behind it survives as a name word before + the credential. Drop the conjunct and this renders 'abd PhD'. The + particle keeps `abd` from completing with the word after it + (rules/P12, #1464), which 'abd Jones' does. The fixture was 'Smith, MD - PhD - FACS' until #602, whose dashes stood as name words between the post-nominals; a credential now starts a run to the end of the part, taking them in.""" for policy in (Policy(), Policy(extra_suffix_delimiters=frozenset({" | "}))): - assert _entry_tags("Smith, Jane abd Jones PhD", policy) == [ + assert _entry_tags("Smith, Jane abd de Jones PhD", policy) == [ ("abd", False), ("PhD", False)] @@ -2871,9 +2874,12 @@ def _division_disagreements(readings: Sequence[_DivisionReading], #: tree that added the division (#1456, #1479); on 6560abde, before #: it, the same grid disagreed in 941 pairs, the comma-less side of a #: particle-led and a P10 family undivided too (a dated figure). Re-take -#: the first two when the grid moves. -_DIVISION_SAME_FAMILY = 1659 -_DIVISION_UNGUARDED = 1241 +#: the first two when the grid moves. 1659 and 1241 until #1464, whose +#: Latin bound pair joined past the first name word (rules/P12) read 18 +#: more pairs' two writings one family, each divided where the comma +#: divides it. +_DIVISION_SAME_FAMILY = 1677 +_DIVISION_UNGUARDED = 1259 def test_both_writings_of_one_family_read_the_same_units() -> None: diff --git a/tests/v2/test_cases.py b/tests/v2/test_cases.py index c9b285153..51ea4f76a 100644 --- a/tests/v2/test_cases.py +++ b/tests/v2/test_cases.py @@ -503,9 +503,13 @@ def test_the_field_sweep_sees_the_claims_it_checks() -> None: # Smith' reporting title-or-name under three orders; 2195 -> 2198 the # same day, #1457's 'Mr Masters' reporting title-or-name under three # orders; 2198 -> 2201 the same day, #1467's 'Nur Aina bt Rosli' - # reporting suffix-or-name under three orders. - assert claims == 2201, ( - f"the field sweep checks {claims} claims, recorded as 2201 on " + # reporting suffix-or-name under three orders; 2201 -> 2205 the same + # day, #1464's 'Ali Abdul Rahim VI' under three orders and 'Ram Abdul + # Bahadur B.K.' under its declared policy, each reporting + # suffix-or-name; 2205 -> 2208 the same day, #1464's 'Dr. Al Amin + # Abdul Rahman' reporting particle-or-given. + assert claims == 2208, ( + f"the field sweep checks {claims} claims, recorded as 2208 on " f"2026-11-19") @@ -989,7 +993,9 @@ def test_the_alternative_sweep_sees_the_fields_it_checks() -> None: # FAMILY_FIRST row of that name; 494 -> 497 the same day, #1467's # 'Nur Aina bt Rosli' under the three orders, its suffix-or-name # reports all skipped - assert (checked, skipped) == (605, 497), (checked, skipped) + # 605 -> 608 the same day, from #1464's two suffix-or-name rows + # ('Ali Abdul Rahim VI', 'Ram Abdul Bahadur B.K.') + assert (checked, skipped) == (608, 497), (checked, skipped) def test_every_case_name_is_unique() -> None: diff --git a/tests/v2/test_layering.py b/tests/v2/test_layering.py index 8935b824e..50f5b3ece 100644 --- a/tests/v2/test_layering.py +++ b/tests/v2/test_layering.py @@ -899,7 +899,9 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: a listed title, its `sets =` binding and the two title sets it #: reads, 200 -> 203; the 3.1 simplify pass folding T8's two copies #: of the unambiguous title-or-suffix test after a glued stop into -#: `_vocab._claimed_after_the_stop`, 203 -> 198); +#: `_vocab._claimed_after_the_stop`, 203 -> 198; #1464's P12 test +#: in classify reading the bound sets through a `sets =` binding, +#: 198 -> 199); #: the tools' first 20 are 18 #: attribute loads, every tool scanned, and config_diff.py's #: `sets =` binding and the roster `getattr` through it (its @@ -926,7 +928,7 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: `_lexicon._fields_of` from 4i-b until 4i-c retired it. #: A reader added through `_sets` moves these, and they are re-taken #: then: they count what the check would refuse with the move undone. -_UNGUARDED_READS = {"library": 198, "tools": 35} +_UNGUARDED_READS = {"library": 199, "tools": 35} def test_the_check_refuses_every_read_4i_a_moved() -> None: diff --git a/tests/v2/test_lexicon.py b/tests/v2/test_lexicon.py index 579e146a8..8affcb0ff 100644 --- a/tests/v2/test_lexicon.py +++ b/tests/v2/test_lexicon.py @@ -1007,6 +1007,40 @@ def test_dotted_is_rule_h10s_switch_both_ways() -> None: assert Parser().parse("U.S. Senator John Smith").title == "U.S. Senator" +def test_completes_any_and_long_names_only_are_rule_p12s_switches_both_ways() -> None: + # a caller's completes_any reaches the parse as a file's does, False + # turns a shipped one off, and long_names_only narrows it to a name + # of four name words or more either way (rules/P12, #1464) + def family(lex: Lexicon, text: str) -> str: + return Parser(lexicon=lex).parse(text).family + default = Lexicon.default() + assert family(default, "Tariq Abdou Aziz") == "Aziz" + assert family(default.add("abdou", kind="bound_given", completes_any=True), + "Tariq Abdou Aziz") == "Abdou Aziz" + assert family(default, "Tariq Abdel Aziz") == "Abdel Aziz" + assert family(default.add("abdel", kind="bound_given", completes_any=False), + "Tariq Abdel Aziz") == "Aziz" + assert family(default, "Tariq Abdul Aziz") == "Aziz" + assert family(default.add("abdul", kind="bound_given", long_names_only=False), + "Tariq Abdul Aziz") == "Abdul Aziz" + long_only = default.add("abdel", kind="bound_given", long_names_only=True) + assert family(long_only, "Tariq Abdel Aziz") == "Aziz" + assert family(long_only, "Nadia Ali Abdel Rahim") == "Abdel Rahim" + # alone it narrows nothing, so it is inert rather than refused (the + # build, which refuses it, holds the shipped files to more): an + # inert entry misparses nothing (AGENTS.md, invariants guard harm) + alone = default.add("abdou", kind="bound_given", long_names_only=True) + assert family(alone, "Nadia Ali Abdou Rahim") == "Rahim" + + +@pytest.mark.parametrize("flag", ["completes_any", "long_names_only"]) +def test_p12s_switches_refuse_a_non_bool_and_another_kind(flag: str) -> None: + with pytest.raises(TypeError, match=flag): + Lexicon.default().add("abdou", kind="bound_given", **{flag: 1}) + with pytest.raises(ValueError, match=flag): + Lexicon.default().add("abdou", kind="given", **{flag: True}) + + def test_a_dotted_title_reads_as_listed_in_its_language() -> None: # assemble counts classify's dotted tag as a listed title's # (rules/H10), so the reading names the vocabulary and its file @@ -1885,7 +1919,8 @@ def test_migrate_s_table_covers_every_compiled_constant() -> None: "SHARED_NAMES", "PARTICLE_GIVEN_NAMES", "SAINT_PARTICLES", "CAPITALIZED_PARTICLES", "CAPITAL_OPENING_PARTICLES", "DOTTED_TITLES", "GLUED_TITLES", - "BOUND_PHRASES", "SAME_AS", "SAME_AS_NAMED", "FAMILIAR", + "BOUND_PHRASES", "BOUND_COMPLETES_ANY", "BOUND_LONG_NAMES_ONLY", + "SAME_AS", "SAME_AS_NAMED", "FAMILIAR", "ALTERNATE_SPELLINGS"} assert public_in_2x <= named assert len(_migrate_constant_rows()) >= 20 # the rows with code diff --git a/tests/v2/test_reading_index.py b/tests/v2/test_reading_index.py index 9b1b02ce9..94690a7b4 100644 --- a/tests/v2/test_reading_index.py +++ b/tests/v2/test_reading_index.py @@ -65,7 +65,8 @@ def test_the_index_compiled_with_no_choice_is_the_committed_module() -> None: "may_be_initial": True, "title_case_is_name": True, "shared": True, "after_particle": True, "capital_opening": True, "dotted": True, - "completed_by": ["zzq"]} + "completed_by": ["zzq"], "completes_any": True, + "long_names_only": True} def _probe_readings() -> list[Any]: diff --git a/tests/v2/test_regex_sync.py b/tests/v2/test_regex_sync.py index 0eaaf0258..08d432205 100644 --- a/tests/v2/test_regex_sync.py +++ b/tests/v2/test_regex_sync.py @@ -166,6 +166,10 @@ def test_dotted_initial_is_the_period_alternative_of_initial() -> None: ("_render", "_INITIAL"): ("_vocab", "_INITIAL"), # SAME object, imported for the one-case letter initial (#723) ("_classify", "_INITIAL"): ("_vocab", "_INITIAL"), + # SAME object, imported for rules/P12's four-word count (#1464) + ("_classify", "_ROMAN"): ("_vocab", "_ROMAN"), + # rules/P12's letter test (#1464), its own only copy + ("_classify", "_HAS_LETTER"): None, # Deliberately NOT a straight copy -- _INITIAL's period # alternative, pinned by the dedicated test above: ("_render", "_DOTTED_INITIAL"): None, diff --git a/tests/v2/test_types.py b/tests/v2/test_types.py index 6d94e3784..0e499e573 100644 --- a/tests/v2/test_types.py +++ b/tests/v2/test_types.py @@ -1454,7 +1454,9 @@ def test_a_patronymic_parsedname_pickled_by_2_8_0_loads_equal() -> None: # O6's other declines ("Ana García", _GF, False, ""), ("Ana M.-J. López", _GF, False, ""), - ("Ana abdul Rahman López", _GF, False, ""), + ("Ana Umm Kulthum López", _GF, False, ""), + # a Latin bound pair P12 joined is one unit O6 takes (#1464) + ("Ana abdul Rahman López", _GF, False, "López"), ("Ana M. García", _GF, False, ""), ("Pérez de la Vega", _FF, False, ""), ("王 小 明", _GF, False, ""), diff --git a/tests/v2/test_vocab.py b/tests/v2/test_vocab.py index 24fa12f0d..e47d200e1 100644 --- a/tests/v2/test_vocab.py +++ b/tests/v2/test_vocab.py @@ -688,6 +688,12 @@ def _w(body: str) -> str: # (BEHAVIORAL), so any other refuses it as unknown ("dotted-not-true", {"en.toml": _w('[[word]]\ntext = "us"\nmodifier = { dotted = false }')}, "dotted must be true, or left unwritten"), ("dotted-on-a-suffix-reading", {"en.toml": _w('[[word]]\ntext = "zzq"\ncredential = { dotted = true }')}, "dotted"), + # rules/P12's completes_any and long_names_only: true or unwritten, + # and long_names_only only beside completes_any, which it narrows + # (#1464) + ("completes-any-not-true", {"ar.toml": _w('[[word]]\ntext = "zzq"\nbound_given = { completes_any = false }')}, "completes_any must be true, or left unwritten"), + ("long-names-only-not-true", {"ar.toml": _w('[[word]]\ntext = "zzq"\nbound_given = { completes_any = true, long_names_only = 1 }')}, "long_names_only must be true, or left unwritten"), + ("long-names-only-alone", {"ar.toml": _w('[[word]]\ntext = "zzq"\nbound_given = { long_names_only = true }')}, "long_names_only narrows completes_any"), ] @@ -1300,6 +1306,10 @@ def _sets_fed(kind: str, props: str = "{}", text: str = "zzq", "capital_opening": ("preposition", "{ capital_opening = true }", "zzq"), "dotted": ("modifier", "{ dotted = true }", "zzq"), "completed_by": ("bound_given", '{ completed_by = ["zzr"] }', "zzq"), + "completes_any": ("bound_given", "{ completes_any = true }", "zzq"), + "long_names_only": ("bound_given", + "{ completes_any = true, long_names_only = true }", + "zzq"), # a phrase needs the head it attaches to: a second title word "attaches": ("office", '{ attaches = ["occupation"] }', "zzq", '\n\n[[word]]\ntext = "zzr"\noccupation = {}'), diff --git a/tools/differential/cldr_agreement.json b/tools/differential/cldr_agreement.json index ffe60e4d4..0a2d015c5 100644 --- a/tools/differential/cldr_agreement.json +++ b/tools/differential/cldr_agreement.json @@ -5613,11 +5613,7 @@ }, "given_names": { "expected": "Syed Abd Aziz", - "got": "Syed Aziz Syed A" - }, - "suffix": { - "expected": "", - "got": "Abd" + "got": "Syed Abd Aziz Syed A" }, "surname1_particles": { "expected": "Syed A", diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index 653a872cc..a78ca647f 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -90,6 +90,8 @@ "Abu Bakr Carlos García" "Abu Bakr del Carmen García" "Abu El Hassan Haddou" +"Ahmad Abdel K." +"Ahmad Abdel bin Omar" "Ahmad al-ʿAbbas" "Ahmad bin Abd Rahman" "Ahmad bin Abdul Rahman" @@ -150,7 +152,7 @@ "Ana Neto" "Ana Ruiz, JO, MD" "Ana SB" -"Ana abdul Rahman López" +"Ana Umm Kulthum López" "Ana de María Pérez" "Ana de Miguel de la Vega" "Ana de la Torre Ugarte" @@ -467,6 +469,7 @@ "Guy Andre Junior Francois" "Gyani Zail Singh" "Gülcan B.TURAN" +"Haddad, Nadia Abd Karim" "Hans Meier Priv.-Doz." "Hans „Erster“ und “Zweiter” Müller" "Harpreet Kaur Dhillon" @@ -1359,6 +1362,7 @@ "Mr Sailor Vinod" "Mr Shaikh Ahmed" "Mr Smith" +"Mr Tariq Abdul Aziz" "Mr Wing Lau" "Mr and Mrs St.Clair" "Mr. Jack Jill" @@ -1378,6 +1382,9 @@ "Ménil Christophe de" "Ménil de" "NOLEN, MAJ MAUREEN" +"Nadia Abdul Rahim Ali" +"Nadia Abdul Rahim, MA" +"Nadia Ali Abdul Rahim" "Nadir Qassoumi, Medical Doctor" "Nguyen Thi Van" "Nguyen Van Anh" @@ -1744,7 +1751,10 @@ "TER HORST, JAN VAN" "TER PETROSYAN, LEVON" "THE ROCK Mary" +"Tariq Abdel Aziz" "Tariq Abdul Aziz" +"Tariq Abdul Aziz Jr." +"Tariq Umm Aziz" "Teresa da Conceição Sousa Pinto" "The Hon. Justice Mary Smith" "The Hon. Wing Lau" @@ -1753,6 +1763,7 @@ "The Marquis of Tavistock" "The Rev. Deacon John Smith" "The Right Hon. the President of the Queen's Bench Division" +"The Rt Hon Nadia Abdul Rahim" "The Saint Thomas More" "Tom N/A Reed" "Torres Sánchez-Cid Andrés" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 96406fb07..f3bdb3d30 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -171,6 +171,8 @@ {"name": "Aguado y García, Dionisio", "given": "Dionisio", "family": "Aguado y García", "initials": "D. A. G."} {"name": "Agustín Gómez Campos", "given": "Agustín", "middle": "Gómez", "family": "Campos", "initials": "A. G. C."} {"name": "Agustín Yáñez y Girona", "given": "Agustín", "family": "Yáñez y Girona", "initials": "A. Y. G."} +{"name": "Ahmad Abdel K.", "given": "Ahmad", "middle": "Abdel", "family": "K.", "initials": "A. A. K."} +{"name": "Ahmad Abdel bin Omar", "given": "Ahmad", "middle": "Abdel", "family": "bin Omar", "initials": "A. A. O.", "patronymic": "bin Omar"} {"name": "Ahmad Al-Hadi", "given": "Ahmad", "family": "Al-Hadi", "initials": "A. A."} {"name": "Ahmad Albar bin Akbar", "given": "Ahmad", "middle": "Albar", "family": "bin Akbar", "initials": "A. A. A.", "patronymic": "bin Akbar"} {"name": "Ahmad Jayadi, CHA", "given": "Ahmad", "family": "Jayadi", "suffix": "CHA", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as given (position)"], "initials": "A. J."} @@ -304,7 +306,7 @@ {"name": "Ana Ruiz, JO, MD", "given": "Ana", "family": "Ruiz", "suffix": "JO, MD", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as given (position)"], "initials": "A. R."} {"name": "Ana SB", "given": "Ana", "family": "SB", "initials": "A. S.", "capitalized_force": "Ana Sb"} {"name": "Ana Torres", "given": "Ana", "family": "Torres", "initials": "A. T."} -{"name": "Ana abdul Rahman López", "given": "Ana", "middle": "abdul Rahman", "family": "López", "initials": "A. a. R. L.", "capitalized_force": "Ana Abdul Rahman López"} +{"name": "Ana Umm Kulthum López", "given": "Ana", "middle": "Umm Kulthum", "family": "López", "initials": "A. U. K. L."} {"name": "Ana de María Pérez", "given": "Ana", "middle": "de María", "family": "Pérez", "initials": "A. M. P."} {"name": "Ana de Miguel de la Vega", "given": "Ana", "middle": "de Miguel", "family": "de la Vega", "initials": "A. M. V."} {"name": "Ana de la Torre Ugarte", "given": "Ana", "family": "de la Torre Ugarte", "initials": "A. T. U."} @@ -1437,6 +1439,7 @@ {"name": "Gülcan B.TURAN", "given": "Gülcan", "middle": "B.", "family": "TURAN", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (shape)"], "initials": "G. B. T.", "capitalized_force": "Gülcan B.Turan"} {"name": "H. Budi Santoso", "given": "H.", "middle": "Budi", "family": "Santoso", "initials": "H. B. S."} {"name": "Habib Pacha es-Saad", "given": "Habib", "middle": "Pacha", "family": "es-Saad", "initials": "H. P. e.", "capitalized_force": "Habib Pacha Es-Saad"} +{"name": "Haddad, Nadia Abd Karim", "given": "Nadia", "middle": "Abd Karim", "family": "Haddad", "initials": "N. A. K. H."} {"name": "Hafis al-Assad", "given": "Hafis", "family": "al-Assad", "initials": "H. a.", "capitalized_force": "Hafis Al-Assad"} {"name": "Hagen, Hermann von", "given": "Hermann", "family": "von Hagen", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: name as middle (declared)"], "initials": "H. H."} {"name": "Haider Hān ʿAmū-ūġlī", "given": "Haider", "middle": "Hān", "family": "ʿAmū-ūġlī", "initials": "H. H. ʿ.", "capitalized_force": "Haider Hān ʿAmū-Ūġlī"} @@ -1610,7 +1613,7 @@ {"name": "Ismail Abdul Rahman", "given": "Ismail", "middle": "Abdul", "family": "Rahman", "initials": "I. A. R."} {"name": "Ismail I.", "given": "Ismail", "family": "I.", "ambiguities": ["ORDER"], "initials": "I. I."} {"name": "Ismail Nasiruddin Shah", "given": "Ismail", "middle": "Nasiruddin", "family": "Shah", "initials": "I. N. S."} -{"name": "Ismail, Syed Abd Aziz Syed A", "given": "Syed", "middle": "Aziz Syed A", "family": "Ismail", "suffix": "Abd", "initials": "S. A. S. A. I.", "capitalized_force": "Syed Aziz Syed A Ismail ABD"} +{"name": "Ismail, Syed Abd Aziz Syed A", "given": "Syed", "middle": "Abd Aziz Syed A", "family": "Ismail", "initials": "S. A. A. S. A. I."} {"name": "Isseu Awa", "given": "Isseu", "family": "Awa", "initials": "I. A."} {"name": "Iu Alavedra i Ferrer", "given": "Iu", "family": "Alavedra i Ferrer", "initials": "I. A. F."} {"name": "Iustinus II.", "given": "Iustinus", "suffix": "II.", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "I.", "generation": "II."} @@ -3286,7 +3289,7 @@ {"name": "Mohamad Zein El Dine", "given": "Mohamad", "middle": "Zein", "family": "El Dine", "initials": "M. Z. D."} {"name": "Mohamad Zeineddine", "given": "Mohamad", "family": "Zeineddine", "initials": "M. Z."} {"name": "Mohamad, Mahathir bin", "given": "Mahathir", "family": "bin Mohamad", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: name as middle (declared)"], "initials": "M. M.", "patronymic": "bin Mohamad"} -{"name": "Mohamed Ali Abd Allah", "given": "Mohamed", "middle": "Ali Abd", "family": "Allah", "initials": "M. A. A. A."} +{"name": "Mohamed Ali Abd Allah", "given": "Mohamed", "middle": "Ali", "family": "Abd Allah", "initials": "M. A. A. A."} {"name": "Mohamed Khir Johari", "given": "Mohamed", "middle": "Khir", "family": "Johari", "initials": "M. K. J."} {"name": "Mohamed bin Hamzah", "given": "Mohamed", "family": "bin Hamzah", "initials": "M. H.", "patronymic": "bin Hamzah"} {"name": "Mohd Najib bin Abdul Razak", "given": "Mohd", "middle": "Najib", "family": "bin Abdul Razak", "initials": "M. N. A. R.", "patronymic": "bin Abdul Razak"} @@ -3315,6 +3318,7 @@ {"name": "Mr Sailor Vinod", "title": "Mr", "given": "Sailor", "family": "Vinod", "initials": "S. V."} {"name": "Mr Shaikh Ahmed", "title": "Mr", "given": "Shaikh", "family": "Ahmed", "initials": "S. A."} {"name": "Mr Smith", "title": "Mr", "family": "Smith", "initials": "S."} +{"name": "Mr Tariq Abdul Aziz", "title": "Mr", "given": "Tariq", "middle": "Abdul", "family": "Aziz", "initials": "T. A. A."} {"name": "Mr Wing Lau", "title": "Mr", "given": "Wing", "family": "Lau", "initials": "W. L."} {"name": "Mr XXX", "title": "Mr", "family": "XXX", "initials": "X.", "capitalized_force": "Mr Xxx"} {"name": "Mr and Mrs St.Clair", "title": "Mr and Mrs", "family": "St.Clair", "initials": "S."} @@ -3394,6 +3398,9 @@ {"name": "Mūsā al-Kāẓīm", "given": "Mūsā", "family": "al-Kāẓīm", "initials": "M. a.", "capitalized_force": "Mūsā Al-Kāẓīm"} {"name": "NASCIMENTO, EDSON ARANTES DO", "given": "EDSON", "middle": "ARANTES", "family": "DO NASCIMENTO", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: name as middle (declared)"], "initials": "E. A. N.", "capitalized": "Edson Arantes do Nascimento"} {"name": "NOLEN, MAJ MAUREEN", "given": "MAJ", "middle": "MAUREEN", "family": "NOLEN", "initials": "M. M. N.", "capitalized": "Maj Maureen Nolen"} +{"name": "Nadia Abdul Rahim Ali", "given": "Nadia", "middle": "Abdul Rahim", "family": "Ali", "initials": "N. A. R. A."} +{"name": "Nadia Abdul Rahim, MA", "given": "Nadia", "middle": "Abdul", "family": "Rahim", "suffix": "MA", "initials": "N. A. R."} +{"name": "Nadia Ali Abdul Rahim", "given": "Nadia", "middle": "Ali", "family": "Abdul Rahim", "initials": "N. A. A. R."} {"name": "Nadir Qassoumi, Medical Doctor", "title": "Medical Doctor", "given": "Nadir", "family": "Qassoumi", "initials": "N. Q."} {"name": "Nakae, Toju", "given": "Toju", "family": "Nakae", "initials": "T. N."} {"name": "Nakamura, Masanao", "given": "Masanao", "family": "Nakamura", "initials": "M. N."} @@ -4327,7 +4334,10 @@ {"name": "Takeyama, Michio", "given": "Michio", "family": "Takeyama", "initials": "M. T."} {"name": "Tammik hr Mari-Ann Henri Roobert parlamendiliige", "order": "FAMILY_FIRST", "given": "hr", "middle": "Mari-Ann Henri Roobert parlamendiliige", "family": "Tammik", "initials": "h. M. H. R. p. T.", "capitalized_force": "Tammik Hr Mari-Ann Henri Roobert Parlamendiliige"} {"name": "Tammik, Mari-Ann Henri Roobert, parlamendiliige", "given": "Mari-Ann", "middle": "Henri Roobert", "family": "Tammik", "suffix": "parlamendiliige", "ambiguities": ["COMMA_STRUCTURE"], "initials": "M. H. R. T.", "capitalized_force": "Mari-Ann Henri Roobert Tammik Parlamendiliige"} +{"name": "Tariq Abdel Aziz", "given": "Tariq", "family": "Abdel Aziz", "initials": "T. A. A."} {"name": "Tariq Abdul Aziz", "given": "Tariq", "middle": "Abdul", "family": "Aziz", "initials": "T. A. A."} +{"name": "Tariq Abdul Aziz Jr.", "given": "Tariq", "middle": "Abdul", "family": "Aziz", "suffix": "Jr.", "initials": "T. A. A.", "generation": "Jr."} +{"name": "Tariq Umm Aziz", "given": "Tariq", "middle": "Umm", "family": "Aziz", "initials": "T. U. A."} {"name": "Taufīq al-Ḥakīm", "given": "Taufīq", "family": "al-Ḥakīm", "initials": "T. a.", "capitalized_force": "Taufīq Al-Ḥakīm"} {"name": "Te Awanui-a-Rangi Black", "given": "Te", "middle": "Awanui-a-Rangi", "family": "Black", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: particle as family (vocabulary)"], "initials": "T. A. B.", "capitalized_force": "Te Awanui-A-Rangi Black"} {"name": "Teddy Bunn", "given": "Teddy", "family": "Bunn", "initials": "T. B."} @@ -4352,6 +4362,7 @@ {"name": "The Rt Hon", "title": "The Rt", "family": "Hon", "ambiguities": ["TITLE_OR_NAME"], "alternatives": ["TITLE_OR_NAME: title as title (vocabulary)"], "initials": "H.", "capitalized_force": "the Rt Hon"} {"name": "The Rt Hon John Jones", "title": "The Rt Hon", "given": "John", "family": "Jones", "initials": "J. J.", "capitalized_force": "the Rt Hon John Jones"} {"name": "The Rt Hon Kenneth Clarke QC MP, HMG", "title": "The Rt Hon", "given": "Kenneth", "family": "Clarke", "suffix": "QC MP, HMG", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as given (position)"], "initials": "K. C.", "capitalized_force": "the Rt Hon Kenneth Clarke QC MP, HMG"} +{"name": "The Rt Hon Nadia Abdul Rahim", "title": "The Rt Hon", "given": "Nadia", "middle": "Abdul", "family": "Rahim", "initials": "N. A. R.", "capitalized_force": "the Rt Hon Nadia Abdul Rahim"} {"name": "The Saint Thomas More", "given": "The Saint", "middle": "Thomas", "family": "More", "initials": "S. T. M.", "capitalized_force": "the Saint Thomas More"} {"name": "Theobald, Dietrich von", "given": "Dietrich", "family": "von Theobald", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: name as middle (declared)"], "initials": "D. T."} {"name": "Theodor von Schön", "given": "Theodor", "family": "von Schön", "initials": "T. S."} diff --git a/tools/vocab/build.py b/tools/vocab/build.py index 64deebd76..991316507 100644 --- a/tools/vocab/build.py +++ b/tools/vocab/build.py @@ -1011,6 +1011,18 @@ def _check_reading(r: Reading, pool: Pool) -> None: # takes one (rules/H10) raise VocabError(f"{where}: dotted must be true, or left unwritten") _check_default(where, p) + for flag in ("completes_any", "long_names_only"): + if flag in p and p[flag] is not True: + # unwritten is false, so only true says anything; keys of + # the bound_given category alone (BEHAVIORAL), so only a + # bound given name takes one (rules/P12, #1464) + raise VocabError(f"{where}: {flag} must be true, or left " + f"unwritten") + if "long_names_only" in p and "completes_any" not in p: + # it narrows where `completes_any` joins, so alone it is inert + raise VocabError(f"{where}: long_names_only narrows completes_any " + f"to a name of four words or more, so it needs " + f"completes_any = true beside it") if "completed_by" in p: # the words that complete a bound given name into one given # name past the first name word (rules/P12): each one word, written @@ -1460,7 +1472,8 @@ def _behavior(r: Reading, prop: str) -> object: return None if att is None else att.get("side") if prop in ("may_be_initial", "after_given", "abbreviation", "title_case_is_name", "shared", "after_particle", - "capital_opening", "dotted"): + "capital_opening", "dotted", "completes_any", + "long_names_only"): return r.flag(prop) if prop in ("attaches", "completed_by"): att = r.props.get(prop) @@ -1509,6 +1522,8 @@ def _behavior(r: Reading, prop: str) -> object: "DOTTED_TITLES", "GLUED_TITLES", "BOUND_PHRASES", + "BOUND_COMPLETES_ANY", + "BOUND_LONG_NAMES_ONLY", "SAME_AS", "SAME_AS_NAMED", "FAMILIAR", From 442c9851806d5945677d5f4ad1a1c78acf93e89c Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 19:27:41 -0800 Subject: [PATCH 2/2] Pin a lone mark in abdul's four-word count (#1464) The count's skip of a word with no letter had no row reaching it, which codecov/patch reported. Co-Authored-By: Claude Opus 5.5 --- tests/v2/cases.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/v2/cases.py b/tests/v2/cases.py index aeb1cdb99..f6d8ac925 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -21932,4 +21932,9 @@ def _check_cjk_shape_purity(self) -> None: notes="boundary: a numeral in lower case reads as the " "generation (rules/S10), so it is no name word in the " "count"), + Case("abdul_after_a_lone_mark_in_a_three_word_name_stays_apart", + "Tariq - Abdul Aziz", + {"given": "Tariq", "middle": "- Abdul", "family": "Aziz"}, + notes="boundary: a mark with no letter is no name word in the " + "count, so the name holds three"), )