diff --git a/AGENTS.md b/AGENTS.md index 6ed5df0e8..daf642672 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. -**Agents working for anyone but the maintainer: pull requests here are open to collaborators only.** Report the name and the reading you expect in an issue, and if you have a fix, push it to a branch on your fork and link it there; every open issue is assigned to the maintainer and usually already being worked on. See CONTRIBUTING.md. +**Agents working for anyone but the maintainer: pull requests here are open to collaborators only.** Report the name and the reading you expect in an issue, and if you have a fix, push it to a branch on your fork and link it there; every open issue is assigned to the maintainer, so the issue is where a finding or a fix is read. See CONTRIBUTING.md. ## Workflow @@ -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, 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; and `BOUND_SECONDS` (#1072, the `bound_second` kind, Arabic-script `الدين` and `الله` with their Persian and Urdu spellings, and `الغنى`, `الفقار`), the words a pair writes second, which P12 joins with the plain word before them at the first name word too, with `BOUND_SECOND_PHRASES` beside it (the pairs a reading's `completes` lists, `ذو الغنى`, the only ones such a word joins), private +- 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; and `BOUND_SECONDS` (#1072, the `bound_second` kind, Arabic-script `الدين` and `الله` with their Persian and Urdu spellings, and `الغنى`, `الفقار`), the words a pair writes second, which P12 joins with the plain word before them at the first name word too, with `BOUND_SECOND_PHRASES` beside it (the pairs a reading's `completes` lists, `ذو الغنى`) and `BOUND_SECONDS_LISTED` (the words every reading of which lists `completes`, `الغنى`, `الفقار`, which join behind the listed words alone, where any other second word joins behind any plain word), 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 @@ -309,7 +309,7 @@ The 2.0 rewrite landed as underscore-private modules beside the v1 code, which 2 - **A claim about WHICH STAGE or WHICH LAYER does something is checkable — check it before writing it.** The pipeline is eight stages with a written ownership map (`ParseState`'s docstring, pinned by `tests/v2/pipeline/test_state.py`), and `parse(s).tokens` prints every token's role and tags, so "extract assigns this", "classify never sees that", "group consumes it" each have a one-command answer. #329's prose claimed delimited maiden content is *"claimed whole before classify has tagged anything inside it"*; measured, `classify` tags the marker fine and only the CONSUMING is missing, because `_group`'s rule walks `pieces` and a token that already carries a role is not in `pieces`. Two different mechanisms, one plausible sentence covering both. That single claim then shipped SIX times across three correction rounds, which is the part worth internalizing: **when a mechanism claim turns out wrong, sweep for where else you wrote it, and sweep again at the END of the change over the words the change itself just added.** Prose density here means one idea lives in a docstring, a case note, a release-log entry and this file at once; the implementer working against a wrong mechanism is the person most likely to restate it; and rewriting a mechanism claim is writing one, so the correction earns the same one-command check as the original — two of the six instances were fresh errors introduced by the sentence fixing the previous one. **Adjacency is the trap.** The claim that feels already-known is the one about the neighbouring stage or the neighbouring layer: one comment block in the 2.x `tests/v2/test_facade_cases.py` got the exception type, the raising layer, the skip mechanism, the count of skipped rows, and which row was blocked all wrong at once — every one a claim about `_config_shim` versus real 1.4.0, written from reasoning, in the file whose whole job is translating between them. What finally held was not better prose but moving the claim into a test (`_CORE_ONLY_IDS`, deleted with the facade in 3.0), which cannot be wrong the way a sentence can. - **Typing/docs**: `from __future__ import annotations`; `frozen=True, slots=True` on every public dataclass; strict-profile mypy flags via per-module overrides in pyproject (`strict = true` itself is not valid per-module). Docstrings state contracts in prose with **no doctest blocks** — `--doctest-modules` makes every example a test; behavior examples go to unit tests per the lean-docs rule. **Document the positive direction of a partial property**: "a non-empty `ambiguities` is a signal to act on" is checkable, while "an empty one means no fork occurred" is a universal negative needing exhaustive verification -- that claim was written twice and falsified twice, at sites the author had not audited. - **The segmenter contract**: the optional `Parser(segmenter=...)` hook is parse-totality's ONE exception (locales spec section 4). Everything inside that exception is a bug in USER CODE, never a fact about the name, so it is surfaced rather than absorbed: the segmenter's own exceptions propagate, and the two protocol violations the stage can detect for itself — an answer of the wrong type, and one cutting at or past the end of the token it was handed — raise `TypeError`/`ValueError` from `_script_segment` for the same reason. The line to hold when adding a check there: a protocol violation by the segmenter's AUTHOR raises, while an adapter's defense against its own third-party library (`locales/ja.py`'s repertoire, length, kanji, reconstruction and score guards) declines with `None`, because what those catch is a fact about the content. -- **Pickling**: v2 types must round-trip (`Parser` is picklable by construction, and it holds a `Lexicon`; the one qualifier is that a `Parser` pickles iff its segmenter does — see the segmenter bullet above). Every frozen type assigns `_guarded_getstate`/`_guarded_setstate` (`_types.py`) in its class body (`@dataclass(slots=True)` would override inherited pickle methods) — unpickling fails at the LOAD site on field-layout skew, with one widening: a field added after its type shipped carries `metadata={_types.ADDED_IN: ""}` and a default, and an older pickle missing it loads with the default (`Ambiguity.alternative`, 2.7; `Token.reading`, `Reading.languages`, `Reading.second_surname`, `Reading.first_surname`, `ParsedName.order`, `Policy.two_given_names`, `PolicyPatch.two_given_names`, `Policy.lone_name_word`, `PolicyPatch.lone_name_word` and `Locale.languages`, 3.0.0; `Policy.initials_as_family`, `PolicyPatch.initials_as_family`, `Policy.capitals_as_family` and `PolicyPatch.capitals_as_family`, 3.1.0) -- a missing field without the marker, default or not, an unknown field and a renamed one are still refused, each a row in `tests/v2/test_types.py::_REFUSED_SKEWS`, so a new field on a pickled type takes the marker or breaks every older pickle; the shared guard deliberately does NOT re-validate values (pickle is not a security boundary; canonical state comes from a validated instance). `Lexicon` and `LexiconReading` keep their own copy of the guard (layering); a new unpicklable slot type needs the same treatment plus a round-trip test. Since 3.0's 4i-b a `Lexicon` pickles its lists, its masks, its edit log, its choice of languages (`_languages` and `_strict`, 4i-c, marked `ADDED_IN` so a 4i-b pickle loads choosing nothing) and its base as a SNAPSHOT of the reading index's rows, so a pickle parses as it did where it was written, a snapshot equal to the running release's index loading as the by-reference default again (decisions/vocabulary-model, 2026-11-02 #754, item 5); its private `_sets`, `_cap_map`, `_same_as`, `_same_as_named`, `_familiar`, `_chosen` and `_files` fields are built at construction and never pickled. `Lexicon`'s copy of the guard admits the `ADDED_IN` marker, read under `_lexicon._ADDED_IN`, the same string, since layering keeps `_lexicon` from importing `_types` (`test_lexicon_marks_an_added_field_with_the_shared_key` holds the two equal), so a new `Lexicon` field takes the marker and a default or breaks older pickles. A 2.x state holds the compiled sets instead, and is refused since 3.1 with a `ValueError` (`_lexicon._refused_2x`) that tells the layout 3.0 loaded, 2.7's and 2.8's, to re-pickle under 3.0, and any older one to rebuild — that layout a frozen record (`_LAYOUT_3_0_LOADED`), never `_VOCAB_FIELDS`, which a new field joins and every 2.8 pickle would then lack, the translation 3.0 loaded it by being deleted (decisions/vocabulary-model, 2026-11-08 #1003); the 2.8 `Lexicon`, `Parser` and locale-pack pickles in `tests/v2/data/lexicon_v28.pickle` are the refusal test's input. And unlike the shared guard it DOES re-validate: a load goes through the constructor, which checks the base, refuses an edit not in canonical form, and refuses a list or mask entry that is not already normalized, because a foreign blob would otherwise load a different lexicon in silence (a snapshot base of a kind this release does not know, an edit `add` would not have written, a list entry the fold changes). +- **Pickling**: v2 types must round-trip (`Parser` is picklable by construction, and it holds a `Lexicon`; the one qualifier is that a `Parser` pickles iff its segmenter does — see the segmenter bullet above). Every frozen type assigns `_guarded_getstate`/`_guarded_setstate` (`_types.py`) in its class body (`@dataclass(slots=True)` would override inherited pickle methods) — unpickling fails at the LOAD site on field-layout skew, with one widening: a field added after its type shipped carries `metadata={_types.ADDED_IN: ""}` and a default, and an older pickle missing it loads with the default (`Ambiguity.alternative`, 2.7; `Token.reading`, `Reading.languages`, `Reading.second_surname`, `Reading.first_surname`, `ParsedName.order`, `Policy.two_given_names`, `PolicyPatch.two_given_names`, `Policy.lone_name_word`, `PolicyPatch.lone_name_word` and `Locale.languages`, 3.0.0; `Policy.initials_as_family`, `PolicyPatch.initials_as_family`, `Policy.capitals_as_family`, `PolicyPatch.capitals_as_family` and `NameEvidence.family_in_capitals`, 3.1.0) -- a missing field without the marker, default or not, an unknown field and a renamed one are still refused, each a row in `tests/v2/test_types.py::_REFUSED_SKEWS`, so a new field on a pickled type takes the marker or breaks every older pickle; the shared guard deliberately does NOT re-validate values (pickle is not a security boundary; canonical state comes from a validated instance). `Lexicon` and `LexiconReading` keep their own copy of the guard (layering); a new unpicklable slot type needs the same treatment plus a round-trip test. Since 3.0's 4i-b a `Lexicon` pickles its lists, its masks, its edit log, its choice of languages (`_languages` and `_strict`, 4i-c, marked `ADDED_IN` so a 4i-b pickle loads choosing nothing) and its base as a SNAPSHOT of the reading index's rows, so a pickle parses as it did where it was written, a snapshot equal to the running release's index loading as the by-reference default again (decisions/vocabulary-model, 2026-11-02 #754, item 5); its private `_sets`, `_cap_map`, `_same_as`, `_same_as_named`, `_familiar`, `_chosen` and `_files` fields are built at construction and never pickled. `Lexicon`'s copy of the guard admits the `ADDED_IN` marker, read under `_lexicon._ADDED_IN`, the same string, since layering keeps `_lexicon` from importing `_types` (`test_lexicon_marks_an_added_field_with_the_shared_key` holds the two equal), so a new `Lexicon` field takes the marker and a default or breaks older pickles. A 2.x state holds the compiled sets instead, and is refused since 3.1 with a `ValueError` (`_lexicon._refused_2x`) that tells the layout 3.0 loaded, 2.7's and 2.8's, to re-pickle under 3.0, and any older one to rebuild — that layout a frozen record (`_LAYOUT_3_0_LOADED`), never `_VOCAB_FIELDS`, which a new field joins and every 2.8 pickle would then lack, the translation 3.0 loaded it by being deleted (decisions/vocabulary-model, 2026-11-08 #1003); the 2.8 `Lexicon`, `Parser` and locale-pack pickles in `tests/v2/data/lexicon_v28.pickle` are the refusal test's input. And unlike the shared guard it DOES re-validate: a load goes through the constructor, which checks the base, refuses an edit not in canonical form, and refuses a list or mask entry that is not already normalized, because a foreign blob would otherwise load a different lexicon in silence (a snapshot base of a kind this release does not know, an edit `add` would not have written, a list entry the fold changes). - **One sanctioned global**: the cached default `Parser` (`_parser._default_parser`, which `parse()` and `ParsedName.matches` use). Lazily cached FROZEN singletons (`Lexicon.default()`'s `functools.cache`, the default parser's) are constants, not state; any second piece of module-level MUTABLE state requires amending the conventions doc, on purpose, in review. - **Tests**: all v2 tests live in the `tests/v2/` package, one test module per source module plus the cross-cutting ones (`test_reprs.py`, `test_layering.py`, `test_contracts.py`, `test_properties.py`, `test_benchmark.py`, the `cases.py`/`test_cases.py` table, `test_regex_sync.py`, which pins render's hand-copied patterns to the pipeline's, `test_script_properties.py`, which checks each row of the script-property table through the readers of each column that take a word, and `test_snapshot.py`, which holds every corpus name's reading to `tools/differential/snapshot.jsonl` — sharing `_differential_fixtures.py` with `test_differential.py` and `test_corpora.py` for the handles on `tools/differential/`), names stating behavior; the 1.x suite's parsing tests stand ported to `parse()` in `tests/*.py`. Never assert `Lexicon.default()` contents; the narrow sourcing spot-checks in `test_default_sources_v1_vocabulary` that pin the v1→v2 migration contract (e.g. the flipped `particles_ambiguous` model) are the sanctioned exception. @@ -349,7 +349,7 @@ The 2.0 rewrite landed as underscore-private modules beside the v1 code, which 2 **Cyrillic suffix regexes need `re.I` even when the pattern is suffix-only** — a Latin title-cased word (`Ivanovich`) keeps its suffix lowercase, so `re.I` seemed skippable; but an irregular Cyrillic suffix can be nearly the whole word (`ильич`), so title-casing capitalizes into the suffix itself (`Ильич`). `east_slavic_patronymic_cyrillic` (v1's name for what is `_vocab._EAST_SLAVIC_CYR` since 3.0 removed `config/regexes.py`, #1008) shipped without `re.I` on the Latin reasoning and silently failed on capitalized irregular forms — don't assume Latin's title-case safety transfers to Cyrillic. (#185) -**Suffix words vs the initial veto** — single-letter roman numeral suffixes (`i`, `v`) are suffix words but also initial-shaped, so `_vocab.is_suffix_strict` (v1's `is_suffix`) vetoes them through `_vocab.is_initial`. `_vocab.is_suffix_lenient` accepts suffix words without the veto and is only safe in unambiguous positions, after a comma (#136, #144). **The veto is Latin-only since #320**: `is_initial` ANDs the bare shape test (`is_initial_shaped`) with "not in a script that writes no initials", the rows of `_policy._SCRIPT_PROPERTIES` whose `writes_initials` is false (Han, Hangul, Hiragana, Katakana, since #1256 the Myanmar and Thai scripts, since #1149 the Arabic script, whose `د.` and `م.` are titles, and since #1380 the Lao script; decisions/script-properties), so the single-character CJK suffix words (씨, 様, 氏, 군, 양, 님, 殿) written with a period read as suffixes: `"김민준 씨."` gives suffix `씨.`. `V.`/`I.` still lose to the veto and still need the lenient test. +**Suffix words vs the initial veto** — single-letter roman numeral suffixes (`i`, `v`) are suffix words but also initial-shaped, so `_vocab.is_suffix_strict` (v1's `is_suffix`) vetoes them through `_vocab.is_initial`. `_vocab.is_suffix_lenient` accepts suffix words without the veto and is only safe in unambiguous positions, after a comma (#136, #144). **The veto runs only in a script that writes initials since #320**: `is_initial` ANDs the bare shape test (`is_initial_shaped`) with "not in a script that writes no initials", the rows of `_policy._SCRIPT_PROPERTIES` whose `writes_initials` is false (Han, Hangul, Hiragana, Katakana, since #1256 the Myanmar and Thai scripts, since #1149 the Arabic script, whose `د.` and `م.` are titles, and since #1380 the Lao script; decisions/script-properties), so the single-character CJK suffix words (씨, 様, 氏, 군, 양, 님, 殿) written with a period read as suffixes: `"김민준 씨."` gives suffix `씨.`. `V.`/`I.` still lose to the veto and still need the lenient test. **Comparing against v1 needs `PYTHONSAFEPATH=1` AND a directory outside the worktree** — `uv run --isolated --no-project --with 'nameparser==1.4.0'` still puts the checkout's `nameparser/` ahead of the pinned wheel on `sys.path`, so the "v1" side silently imports the branch and every comparison reports parity. Run it as `cd && PYTHONSAFEPATH=1 uv run --isolated --no-project --with 'nameparser==1.4.0' python -c "..."`. This produces false confidence rather than an error, so it invalidates results without ever looking wrong. **A `tests/v2/cases.py` row's `parity` means 1.4.0, and no test checks it** -- the table runs every row against the tree, so a row labelled `parity` that only matches master passes for good, and `parity` is the dataclass default, so a row written with no `classification` claims it. #614 added eight such rows, compared against master; #620 found them by running the wheel this way and relabelled each with the change its reading came from, found by `git bisect run` in a scratch worktree (`git worktree add --detach`, never this one). 3.1's prose sweep found 72 more, 27 of them #1395's `md_*` rows, and the check is a kept tool since: `uv run python tools/differential/parity_check.py` reads every default-config `parity` row with the 1.4.0 wheel, hardened as `compare.py` is, and lists each row 1.4.0 reads otherwise with its fields (`--check` exits 1 on one). It needs the network or uv's cache, so no CI job runs it, and it skips the rows carrying a policy or a locale, whose `parity` stays unchecked. Run it after adding a row on the default, and relabel what it lists the way #620 did. When bisecting, run Python with `-B` and `git clean -fdx` the scratch tree at each step: two checkouts within one second leave a stale `.pyc` whose source has the same mtime and size, and in 3.1's relabel one answered for two rows, naming a commit whose parent already read them. @@ -371,7 +371,7 @@ The 2.0 rewrite landed as underscore-private modules beside the v1 code, which 2 **Expected-failure tests use `@pytest.mark.xfail`** — the test classes are plain pytest classes, not `unittest.TestCase`, so `@unittest.expectedFailure` is not honored. -**`_normalize` strips leading and trailing full stops only** — `'M.D.'` → `'m.d'`, not `'md'` (interior periods are preserved). Shipped keys in `capitalization_exceptions` are dot-free, so lookups must also try `.replace('.', '')`; whatever key matches, its value is a case mask applied to the word as written, never substituted for it (#459). +**`_normalize` strips only a word's edges** — whitespace, full stops and, in a non-ASCII word, an edge ZWNJ or ZWJ (#1335), the tatweel being deleted wherever it stands (#1151); interior periods survive, so `'M.D.'` → `'m.d'`, not `'md'`. Shipped keys in `capitalization_exceptions` are dot-free, so lookups must also try `.replace('.', '')`; whatever key matches, its value is a case mask applied to the word as written, never substituted for it (#459). **Doctests** — docstring examples in `nameparser/*.py` run under `uv run pytest` (`--doctest-modules`; `testpaths` is `tests` + `nameparser` only). The `.rst` doctests in `docs/` (every `.rst` file there) and `README.rst` are also run in CI: the `python-package.yml` workflow runs `sphinx-build -b doctest docs dist/doctest` (covers every `.rst` under `docs/`) and `python -m doctest README.rst` as separate steps after the existing `-b html` build. Both should pass with zero failures — expect a clean run, not baked-in noise. **An example needing an optional extra cannot be a doctest.** `namedivider-python` is not in the `dev` group, so it reaches only the `ja-extra` job; a `.. doctest::` requiring a segmenter passes locally, where it is incidentally installed, and fails `sphinx-build -b doctest` in all five build jobs. Use `.. code-block:: python` for those. That is why the Japanese examples in `east-asian.rst` are code-blocks while the Korean and Chinese honorific ones are live doctests — the latter go through VOCABULARY, which ships. Same rule for `README.rst`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 661de49a7..3fdd81c0e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,8 @@ want a reading often changes how it is built. Put that in an issue. A few real examples are worth more than a fix. Open issues are not a list of tasks waiting for a volunteer. Every issue is -assigned to the maintainer, and most are already being worked on. +assigned to the maintainer. Add what you found to the issue, and if you have +a fix, push it to a branch on your fork and link it there. Why the maintainer makes the changes -------------------------------------- diff --git a/docs/design/decisions/P10-given-name-a-particle-completes.md b/docs/design/decisions/P10-given-name-a-particle-completes.md index b911b968d..bfe385ec1 100644 --- a/docs/design/decisions/P10-given-name-a-particle-completes.md +++ b/docs/design/decisions/P10-given-name-a-particle-completes.md @@ -12,7 +12,7 @@ - `valle` stays on by default though it breaks more Portuguese names than it fixes (7 fixed to 32 broken, mostly `do Valle` surnames), since it passes pooled (379 to 95, 80%): the pooled reading was chosen over requiring every language's countries to pass, which would also have taken `jesús`, `rosario` and `rocio` from the default: among Spanish-speaking countries' names the four fix 4,236 and break 113, among Portuguese-speaking countries' 47 and 52, so the stricter bar would have given up about 4,100 Spanish names for a net 5 Portuguese ones — 2026-11-06 #1122, decided in chat. - A word passing in one country's names alone, scored by the bar above over that country's records in the whole ORCID extract, under the country's pack, is marked `default = false` in the country's file, read under that country's choice and not under its language's or another country's: `rosário` (with `rosario`), `carmo`, `conceição` (with `conceicao`) and `luz` in `pt-PT.toml`, under `locales.PT_PT`. Nothing is marked for Brazil — 2026-11-19 #1189. -Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `ca.toml` because the property moved nothing with the switch off; under this rule a `dels` particle beside `àngels` written `after_particle` reads middle 'dels Àngels', family 'Puig' by default, today's reading, so the reason no longer holds and the words want their own measurement — #1059. +Open: none in this file. Catalan `dels` was declined on 2026-11-20 (#1059, the Log below). ## Log @@ -68,3 +68,4 @@ Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `c Portugal's parliament (`config_diff.py diff --local opensanctions-parliaments --group pt_parliament`, 2,256 spellings): 13 move, each putting the phrase in the given part, where the issue found Portugal's deputies keep it (the 2026-11-08 count on #1189). - Recompute: the whole-extract rows, for a country, over the records of `local_orcid.extract_path()` with that `country` and both boxes filled whose `given family` holds the word behind `da`, `de`, `do`, `das`, `des` or `dos`, each kept and scored as `config_diff.score` keeps and scores one (`config_diff.kept`, `score_rows` with `local_agreement.FIELDED` for ORCID), under `plain:PT_PT` (Portugal) or `plain:PT_BR` (Brazil) and the same pack with `.add(w, kind='given', after_particle=True)` on its lexicon for each spelling of the word; the other rows with `config_diff.py score plain:PT_PT --group PT --group Portuguese --cap 20000 --min 50 --json ` (the fixed and broken of every configuration are in the JSON; the printed table names only the best), `` being `expr:parser_for(Locale(code='x', lexicon=locales.PT_PT.lexicon.add(w, kind='given', after_particle=True), policy=locales.PT_PT.policy, languages=frozenset({'pt-PT'})))` with one `.add` per spelling, the four together for the last column; each on a checkout of `1ca93b25`. +- 2026-11-20 #1059 — CATALAN `dels` STAYS UNLISTED. Decided 2026-11-20. Measured on master 0d8c6fa8: no local corpus writes `dels` as a surname particle, and ORCID's boxes hold it 10 times in 25M records, 8 of them in the given-names box as the given name `dels Àngels`, which already reads right (middle 'dels Àngels'); listing it moved 0 records fixed and 0 broken over ORCID's Spanish and Andorran researchers and PatentsView's Spanish inventors, the figures as #1059's closing comment gives them, which names no command; a reopening re-scores with `config_diff.py score` over those groups. A caller whose Catalan data writes it adds it: `Lexicon.default().add("dels", kind="article")`, with `.add("àngels", kind="given", after_particle=True)` to keep the given name whole. `ca.toml`'s `del` is a preposition, not an article as #1059 said. The Open line this closes stood above. 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 2f9a9903b..2e6d5372b 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,14 +3,14 @@ ## 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. -- For Arabic-script `عبد` the license is a closed list on the bound word's reading, not a shape of the word after it: `عبد` lists 239 spellings of 139 words (217 on 2026-11-04), 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; each word ending in `ي` with its `ى` spelling too, and `المولى` with its `ي` spelling, so `سامر عبد القوى` gives family 'عبد القوى' — 2026-11-20 #1337. +- For Arabic-script `عبد` the license is a closed list on the bound word's reading, not a shape of the word after it: `عبد` lists 239 spellings of 139 words on 2026-11-20 (217 on 2026-11-04; `readings_of('عبد')`'s `completed_by`), 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; each word ending in `ي` with its `ى` spelling too, and `المولى` with its `ي` spelling, so `سامر عبد القوى` gives family 'عبد القوى' — 2026-11-20 #1337. - 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 the parse reads as four name words or more: the words it reads as given, middle and family names that hold a letter, the two parts of a family comma counted together, so a title, a suffix, a nickname, a maiden name and a lone mark are no name words and a word the parse reads as a name is one whatever else its vocabulary says (`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; counted by the parse rather than by classify since 2026-11-22 #1531. - `abu` keeps its particle and teknonymic readings and no `completes_any`; Arabic-script `عبد` keeps its list — 2026-11-19 #1464. - A pair is read from its second word too: a `bound_second` reading (Arabic-script `الدين` and `الله`, Persian `الدین` and `اله`, Urdu `اللہ`) joins the plain word before it, one carrying no vocabulary and holding a letter, at the first name word too, the pair placed by position, under the default order the given name where it opens the name and the family where it ends it (`نور الدين سامر حداد` → given 'نور الدين'; `سامر عز الدين` → family 'عز الدين'); P5's join of a bound word opening the name wins over a pair read from the word after it (`أبو نور الدين سامر` → given 'أبو نور'); `الغنى` and `الفقار` are written `completes = ["ذو"]`, joining behind `ذو` alone; where the pair holds every name word the name is read as having it is split back into two names, as P5's reserve keeps a bound word's, save after a family comma and behind a given-name title, where P5 joins too; the pair is one unit wherever UNIT-PARTITION counts units (P1's fold, rules/O6's take and its division) — 2026-11-19 #1072. - 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: `locales.MS` (#1179) could turn `abdul`'s three-word join on, its Malaysian writers filing the pair as the family 183 times to 2 in ORCID; as shipped it reads `abdul` as the default does, and a strict choice of it reads no Latin bound word at all, `ar.toml` not being chosen (2026-11-19 #1464). +Open: `locales.MS` (shipped by #1179; no issue filed for this) could turn `abdul`'s three-word join on, its Malaysian writers filing the pair as the family 183 times to 2 in ORCID; as shipped it reads `abdul` as the default does, and a strict choice of it reads no Latin bound word at all, `ar.toml` not being chosen (2026-11-19 #1464). Open: the Latin spellings of a pair read from its second word stay out (2026-11-19 #1072): `Uddin`, the commonest, is a surname alone in South Asian names (PSC 25 records fixed and 432 broken, ORCID's Bangladesh 15 and 99, the prototype scored against the boxes on 2026-11-19), and without the `u-` forms (`Eddine`, `Eldin`, `Aldeen` and the like, and `Allah` behind a word other than `Abd`) ORCID gains 155 and loses none, but PSC 16 and 11 and PatentsView 6 and 8. diff --git a/docs/design/decisions/R9-patronymic-view.md b/docs/design/decisions/R9-patronymic-view.md index ddb5354cc..4c726db88 100644 --- a/docs/design/decisions/R9-patronymic-view.md +++ b/docs/design/decisions/R9-patronymic-view.md @@ -9,7 +9,7 @@ Elsewhere: why the view leaves `family` and `middle` as they are, and the fielded-corpora measurements behind it, decisions/vocabulary-model's 2026-10-28 #754 entry, item 3; the rotations the two ending rules are named for, decisions/O1 and decisions/O2; the `clan`/`patronymic` line in the particle kinds, decisions/vocabulary-model's 2026-10-19 #749 entry; a father's name nothing in the text marks, which fills no view, and a view that overlaps the family, decisions/family-without-an-inherited-name. -Open: the Icelandic ending rule, which an `is` pack would turn on (the RFC's work order: 3b, 4c and 4f); whether the East Slavic endings should take the Belarusian spellings (`-авіч`, `-аўна`) and the Latin `-ivna`/`-ovych` of the Ukrainian ones, which would move O1's rotation too ([#1212](https://github.com/derek73/python-nameparser/issues/1212); the Ukrainian Cyrillic endings are read since 2026-11-20, decisions/O1); and a Ukrainian ending typed with a Latin `i` in a Cyrillic word (`Петрiвна`), which is not read. Whether `a/k`, written once among Malaysia's election candidates for `anak`, and `a/l` written spaced (`A / L`), which no list measured writes, should read as `a/l` does (#1468); India's and Pakistan's `S/O`, `D/O` and `W/O`, which name a parent or a husband outside the legal name (#1165). +Open: the Icelandic ending rule, which an `is` pack would turn on (the RFC's work order: 3b, 4c and 4f); whether the East Slavic endings should take the Belarusian spellings (`-авіч`, `-аўна`) and the Latin `-ivna`/`-ovych` of the Ukrainian ones, which would move O1's rotation too ([#1212](https://github.com/derek73/python-nameparser/issues/1212); the Ukrainian Cyrillic endings are read since 2026-11-20, decisions/O1); and a Ukrainian ending typed with a Latin `i` in a Cyrillic word (`Петрiвна`), which is not read. Whether `a/k`, written once among Malaysia's election candidates for `anak`, and `a/l` written spaced (`A / L`), which no list measured writes, should read as `a/l` does (left by #1468, closed 2026-11-19; no issue filed); India's and Pakistan's `S/O`, `D/O` and `W/O`, which name a parent or a husband outside the legal name (#1165). ## Log diff --git a/docs/design/decisions/S1-bracketed-credential-is-not-a-nickname.md b/docs/design/decisions/S1-bracketed-credential-is-not-a-nickname.md index bee41ddf4..e042b74f7 100644 --- a/docs/design/decisions/S1-bracketed-credential-is-not-a-nickname.md +++ b/docs/design/decisions/S1-bracketed-credential-is-not-a-nickname.md @@ -11,7 +11,7 @@ Elsewhere: an ambiguous member alone in the brackets staying a nickname, reported, is decided under decisions/suffix-acronym-collisions (its Standing line ending 2026-09-25 #540; 2026-10-21) and decisions/ma-do's 2026-07-17 entry; a member after the name whose writing settles it reading as the suffix is decisions/S13 (2026-10-26 #810). -Open: [#1268](https://github.com/derek73/python-nameparser/issues/1268) — whether a comma glued between two words of a clause should part them; this file's 2026-11-11 entry records the two designs declined. +Open: none in this file. Whether a comma glued between two words of a clause should part them was closed as an accepted limit on 2026-11-17 ([#1268](https://github.com/derek73/python-nameparser/issues/1268)), the glued comma left in the word's text (the Standing line above; the 2026-11-11 entry records the two designs declined). ## Log diff --git a/docs/design/decisions/S8-credentials-trailing-run.md b/docs/design/decisions/S8-credentials-trailing-run.md index 3f69c08c4..f7b084b3d 100644 --- a/docs/design/decisions/S8-credentials-trailing-run.md +++ b/docs/design/decisions/S8-credentials-trailing-run.md @@ -6,7 +6,7 @@ Examples name each field as the default order reads it; under the family-first o - An unambiguous suffix word of two or more letters, in any script, standing after two name words with no comma or before a suffix comma, or after the given word in the part after a family comma, starts a run to the end of its part: every later word reads as a suffix except a title word, which reads as a title, and an absorbed name word reports `suffix-or-name` (`John Smith PhD Jones` → suffix 'PhD Jones'; `Eric H. Holder Jr. Attorney General` → suffix 'Jr.', title 'Attorney General') — 2026-10-04 #602; 2026-10-14 #679. - A roman numeral of two or more letters that reads as the generation starts the run as a listed one does (`John Smith VI Jones` → suffix 'VI Jones', as `John Smith III Jones`), its shape alone reported — 2026-10-25 #784. -- What never starts the run: a title word (`Mary Jane Pope Smith` keeps family 'Smith'), a member of the ambiguous class but a credential split across a space (below) and a listed member its capitals settle (below), a single letter, a connective (`Josep Carod i Rovira` keeps family 'Carod i Rovira'), and a word that is also particle or bound given-name vocabulary (`Mohamed Ali Abd Allah` → family 'Allah'); a title/suffix dual does start it — 2026-10-04 #602. +- What never starts the run: a title word (`Mary Jane Pope Smith` keeps family 'Smith'), a member of the ambiguous class but a credential split across a space (below) and a listed member its capitals settle (below), a single letter, a connective (`Josep Carod i Rovira` keeps family 'Carod i Rovira'), and a word that is also particle or bound given-name vocabulary (`Mohamed Ali Abd Allah` → family 'Abd Allah', no suffix, since rules/P12 joins the Latin `abd`, 2026-11-19 #1464); a title/suffix dual does start it — 2026-10-04 #602. - An honorific or generational word starts the run as a credential does, whatever its script (`राम शर्मा साहब मोहन` → suffix 'साहब मोहन'); the one-character honorifics stay out by the two-letter minimum — 2026-10-14 #679. - With no family comma, a generation word written out, a numeral aside, with a name word behind it does not start the run: the family name is the word behind it (`Guy Andre Junior Francois` → middle 'Andre Junior', family 'Francois'; `John Smith Jr. Jones` → middle 'Smith Jr.', family 'Jones', the reading of 1.4.0 through 2.3.0). A name word there is a word that is no suffix word, numeral S10 reads as the generation, initial, connective, title word or maiden marker, and is a particle or is written in Title case, in a script with no case, or in a name of one case (so a particle that is also title or suffix vocabulary is none: `John Smith Jr. Mc Donald` keeps suffix 'Jr. Mc Donald'); the family-first orders are not asked, so `Smith John Jr. Jones` under `FAMILY_FIRST` reads middle 'Jr. Jones' where `Smith, John Jr. Jones` reads suffix 'Jr. Jones'; so the run still starts before a credential (`John Smith Jr. PhD Jones`), before capitals or lower case in a name of mixed case (`John Smith Jr. CF`), before a title (`Eric H. Holder Jr. Attorney General`), and after the given word in the part after a family comma (`Smith, John Jr. Jones` → suffix 'Jr. Jones') — 2026-11-02 #1023. - A lone particle counts toward the two name words only where the credential stands right behind it (`John von PhD Jones` → family 'von', suffix 'PhD Jones', under the family-first orders given 'von'); a particle run counts once, and a particle the run took is not asked (`Freiherr von vd PhD Jones` keeps middle 'PhD') — 2026-10-10 #627. diff --git a/docs/design/decisions/T8-word-glued-to-the-next-at-its-full-stop.md b/docs/design/decisions/T8-word-glued-to-the-next-at-its-full-stop.md index 6e4664c01..9add9aed4 100644 --- a/docs/design/decisions/T8-word-glued-to-the-next-at-its-full-stop.md +++ b/docs/design/decisions/T8-word-glued-to-the-next-at-its-full-stop.md @@ -12,7 +12,7 @@ Elsewhere: which words divide at all, and what a divided word reads as, decisions/period-joined-words' 2026-11-09 #1255 entries; a run of single letters, which stays one word, decisions/T7. Open: [#1306](https://github.com/derek73/python-nameparser/issues/1306), which field a Mongolian glued initial takes under the default order or a Mongolian choice (moved from #1235, which this division closed): the pack question the spaced `Ц. Сандаг-Очир` already raises. -Open: a chunk, or a name after the stop, that writes a vowel sign other than Thai's or a mark of the Arabic script's (counted since #1149, in the gate as on both sides of the stop: `أ.محمد` and `أ.د.أحمد` divide in NFD as in NFC; a zero-width joiner or non-joiner between two letters of the name is counted too, one right after the stop is not), a name of plain letters dividing in any script (`ড.করম খান`) (`डा.राम शर्मा` keeps title 'डा.राम', where `डा. राम शर्मा` reads title 'डा.', given 'राम'; `ড.রহিম` keeps title 'ড.রহিম', the listed `ড` found but রহিম's U+09BF not, #1166): the shape's letter class counts no such mark (decisions/nfd-shapes), and #1166 added Thai's on the name side alone, so no division is found there, moved here from decisions/period-joined-words' Open line. The local corpora hold almost no such title (nepal-candidates' glued Devanagari words are runs of initials, `के.सी.`, which stay whole anyway, and `मो.`, which, with the Latin `Mo.` (10 words glued to the next in the local corpora, #1178's third comment), no issue holds once #1178 closes, answered for `Ab` and `Md`), so no issue is filed. +Open: a chunk, or a name after the stop, that writes a vowel sign other than Thai's or a mark of the Arabic script's (counted since #1149, in the gate as on both sides of the stop: `أ.محمد` and `أ.د.أحمد` divide in NFD as in NFC; a zero-width joiner or non-joiner between two letters of the name is counted too, one right after the stop is not), a name of plain letters dividing in any script (`ড.করম খান`) (`डा.राम शर्मा` keeps title 'डा.राम', where `डा. राम शर्मा` reads title 'डा.', given 'राम'; `ড.রহিম` keeps title 'ড.রহিম', the listed `ড` found but রহিম's U+09BF not, #1166): the shape's letter class counts no such mark (decisions/nfd-shapes), and #1166 added Thai's on the name side alone, so no division is found there, moved here from decisions/period-joined-words' Open line. The local corpora hold almost no such title (nepal-candidates' glued Devanagari words are runs of initials, `के.सी.`, which stay whole anyway, and `मो.`, which, with the Latin `Mo.` (10 words glued to the next in the local corpora, #1178's third comment), no issue holds since #1178 closed on 2026-11-22, answered for `Ab` and `Md`), so no issue is filed. Open: a word glued at a full stop other than the ASCII one, in Latin names, as the ideographic stop in `Wenzhao Zhong, Ph。D` (one name in the local corpora, 2026-11-10). The fullwidth stop between Han names was #1312, which rules/T3 reads as the transcription dot. Open: [#1311](https://github.com/derek73/python-nameparser/issues/1311), a glued word after a family comma, the given part the comma names (`ARTHUR, L.MICHAEL`, 111 in fec-individuals), which the division would reach only once the comma's decision is asked first. Open: [#1313](https://github.com/derek73/python-nameparser/issues/1313), a particle glued to its surname at its full stop (`Alaa A. El.Baz` reads suffix 'El.Baz'), which the division does not read as a chunk. diff --git a/docs/design/decisions/family-without-an-inherited-name.md b/docs/design/decisions/family-without-an-inherited-name.md index 22782933c..186aa548b 100644 --- a/docs/design/decisions/family-without-an-inherited-name.md +++ b/docs/design/decisions/family-without-an-inherited-name.md @@ -6,7 +6,7 @@ - The patronymic view keeps rules/R9's basis, filled only by a word or a rule that says patronymic, never by a position; it may overlap the family or be a part of it, and a father's name nothing in the text marks (Ethiopia) fills no view — 2026-11-12 #1253. - An Ethiopian or Eritrean name stays positional, its family under the default given-first order the grandfather's name where it is written and the father's where it is not; a caller matching such a list builds the matcher from a parser with `middle_as_family`, keeping the default parser for the fields (docs/matching.rst) — 2026-11-12 #1253. -Open: #1188 (Kazakh), #1155 (`بن` chain), #1231 (Burma), each a value question under the two statements; #1165 (`S/O`, `W/O`), a decision of its own. +Open: #1188 (Kazakh), #1155 (`بن` chain), each a value question under the two statements; #1165 (`S/O`, `W/O`), a decision of its own. ## Log diff --git a/docs/design/decisions/indic-honorifics.md b/docs/design/decisions/indic-honorifics.md index 3b6817571..33484f063 100644 --- a/docs/design/decisions/indic-honorifics.md +++ b/docs/design/decisions/indic-honorifics.md @@ -15,7 +15,8 @@ Closes #346, #344 and #343 as one bundle: each CLASS is decided once, and each s - An abbreviation carrying a mark is spelled with it, and the Bengali ones ship as the visarga form and the bare stem while the Devanagari ones ship as the bare stem alone, the dotted form listed in neither script — 2026-09-06 #346. - Title vocabulary beats the one-letter-plus-period initial shape, measured and pinned by rows and not a rule: `ড. মুহাম্মদ ইউনূস` reads title 'ড.' while `র. কে. নারায়ণ`, with no entry behind it, keeps its initials — 2026-09-06 #346. - An unlisted abugida honorific stays a name word, and rules/H2's executable example of it is `প্রকৌশলী. Sen`, so whoever ships প্রকৌশলী moves the example first; the Tier 4 candidates in the Indic scripts (transliterated military ranks, Advocate, Engineer, Marhum, the kinship forms, मां/माता/মা, the hafiz/syed/shahid forms) are skipped pending a corpus check and not declined — 2026-09-06 #346 (the hafiz and syed forms counted since, 2026-11-19 #1469, below). -- `qari`, `moulana`, `alhaj` and `alhajj` are titles by default, each opening a name as the title in every name counted but one surname-first byline (`Qari Ahmed Khan` → title 'Qari', given 'Ahmed'); `hafiz`, `hafez`, `haji` and the spelling `maulana`, borne as given names, stay name words by default, their title reading wanting a choice of Bengali (`locales.BN` could turn on a `default = false` reading in bn.toml) or of Urdu, which this entry writes for neither; `syed`, `mian`, `chaudhry` and `makhdoom` are name words — 2026-11-19 #1469. +- `qari`, `moulana`, `alhaj` and `alhajj` are titles by default, each opening a name as the title in every name counted but one surname-first byline (`Qari Ahmed Khan` → title 'Qari', given 'Ahmed'); `hafiz`, `hafez`, `haji` and the spelling `maulana`, borne as given names, stay name words by default, neither a Bengali nor an Urdu choice reading them as titles (declined 2026-11-21 #1469, the Log below): their title reading is left to a caller's lexicon (`Lexicon.default().add("hafiz", kind="religious")`), save `haji`'s under `locales.MS` (below); `syed`, `mian`, `chaudhry` and `makhdoom` are name words — 2026-11-19 #1469. +- `haji` is a title under `locales.MS` (ms.toml's `default = false` reading), plain or strict (`parser_for(locales.MS).parse("Haji Abdul Hadi Awang")` → title 'Haji') — 2026-11-21 #1180. - Latin `md` is a credential and no title: a leading `Md` is the given name it abbreviates (`Md Abdul Karim` → given 'Md', middle 'Abdul'; `Mr Md Karim Uddin` → title 'Mr', given 'Md', middle 'Karim'), at the accepted cost of a particle behind it starting the family (`Md Abu Sayed` → family 'Abu Sayed'), and the Bengali মোঃ/মো entries stay titles — 2026-10-23 #853. - `md` is Muhammad written short as well as the medical degree, so the period-marked `Md.` opening a name is the given name (`Md. Karim Uddin` → given 'Md.', middle 'Karim'; `Mr Md. Karim Uddin` → title 'Mr', given 'Md.'), and `Md` opening the given part after a family comma is the given name where rules/C13's given-name Except reads it so (`Uddin, Md Karim` and `Uddin, Mr Md Karim` → given 'Md', middle 'Karim'; `Rahman, Md.` → given 'Md.'), the degree elsewhere (`RAHMAN, MD`, `Smith, Md PhD`, `Uddin, Mr Md` → suffix), the conditions stated in that rule and decisions/C13's Standing line — 2026-11-14 #1383. - The romanized `pandit`, `sardar`, `kumari`, `babu`, `acharya` and `begum` are titles under no pack and no strict choice, each opening far more names as a given name or a surname than as the title (`Kumari Selja`, `Sardar Ahmad`, `Babu Joseph`), and each is an `excluded` entry carrying its counts — 2026-11-03 (Derek), #345. @@ -24,7 +25,7 @@ Closes #346, #344 and #343 as one bundle: each CLASS is decided once, and each s Elsewhere: the bundle's class-level refusals are recorded under decisions/vocabulary-exclusions, not here: the Latin forms of the Indic titles belonging to the opt-in packs of #345 (2026-09-06, #344), the native spelling shipping alone where a transliteration collides with real names (sri, sant, pandit, and shri by default, a Hindi choice turning its romanization on since decisions/vocabulary-model's 2026-11-20 #1192 entry), the ban on the spaced trailing set becoming glued honorifics, and the per-word title refusals (ঠাকুর/ठाकुर, कुमारी/কুমারী, बेगम/বেগম, শেখ/शेख, आचार्य, राजा/रानी), each an `excluded` entry (`uv run python tools/vocab/query.py --excluded title`). -Open: #514 (whether the Tibetan prefix titles Tulku, Khenpo, Geshe, Kyabje and Jetsun fold like `Lama Zopa`); #1469 (whether a choice of Bengali or Urdu reads `hafiz`, `hafez`, `haji` and `maulana` as titles; no reading is written for either). +Open: #514 (whether the Tibetan prefix titles Tulku, Khenpo, Geshe, Kyabje and Jetsun fold like `Lama Zopa`). ## Log @@ -66,7 +67,7 @@ Open: #514 (whether the Tibetan prefix titles Tulku, Khenpo, Geshe, Kyabje and J - Measured, 2026-11-14, on this branch against master 3dadc263, whose parse #1390 did not change, over every local corpus's `corpus.jsonl` (the entries holding the word `md` after a comma, `,[^,]*\bmd\b`, case-insensitive, each corpus's distinct texts): 149,226 names, 19 move (re-taken after the second review's changes, 2026-11-14: the same 149,226 and 19; with the committed corpora, which this change's rule examples and case rows join, 149,359 and 27 after the third review), 5 of them #1383's leading `Md.` (ctgov) and 14 the comma's: fec-individuals 9 (`UDDIN, MD KARIM` shapes, given 'MD'), psc-individuals 3 (the forename box holding `Md` behind a title typed in the surname box), orcid-researchers 2 (`Uddin, Md. Karim`, `Hossain, Md`), and 13 of the 14 read right. The writing behind the design: after one word and a comma, `X, MD` in capitals alone is the degree in ClinicalTrials.gov (107, `Novak, MD`, `BERGER, MD`), while FEC's 10 (a Bangladeshi surname alone, then `MD`) are likely Muhammad, which no writing tells apart; `X, Md` written with a lower-case letter was the given name in all 3 found (ORCID 1, PSC 2). Recompute: each entry of a `corpus.jsonl` under `~/.cache/nameparser-tools/local/` matching `^\s*([^\s,]+),\s*(md\.?)(?:\s+(\S.*))?\s*$`, case-insensitive, grouped by the word's case, a word after it or none, and the head in capitals or not; the moves by parsing every entry matching the first pattern in both checkouts and comparing the seven name fields. - Accepted: `MD` in capitals alone after a family comma stays the degree (`RAHMAN, MD` → suffix 'MD'), so `Md. Rahman` / `RAHMAN, MD` does not match; the degree written before a given name reads as Muhammad written short, the writing being the same (`SMITH, MD JANE` → given 'MD', 1 of FEC's 9 movers); a name in one case writes no case that tells (`rahman, md` → suffix 'md'); and `mst`, which holds no given reading, keeps the cost the 2026-11-06 #1130 entry recorded (`Begum, Mst Amina` → suffix 'Mst Amina'). A full spelling of Muhammad written with a full stop is still a title by rules/H2's shape (`Mohammed. Rahman` → title 'Mohammed.'): 10 of the 22,986 ORCID names opening with one of the five long spellings write it so, and no other local corpus does (2026-11-14: in orcid-researchers' `corpus.jsonl`, `grep -ciE '^"(muhammad|mohammad|mohammed|mohamed|mohamad)\. '` gives 10 and the same pattern with a space for the stop, `'^"(…) '`, 22,986; the second review's own count, by another recipe, gave 23,028). - Left to their own issues: #1394 (a stop gluing `MD.` to the next word ends a Malay name in a suffix, `SITI AMINAH MD.NOOR` → suffix 'MD. NOOR') and #1178 (`Ab` and `Md.` at the head of a name, the wider question this entry answers for `Md.` alone; `Ab` answered 2026-11-21, decisions/vocabulary-collisions' #1178 entry, the Bengali `মোঃ` unchanged). -- 2026-11-19 #1469 — QARI, MOULANA, ALHAJ AND ALHAJJ ARE TITLES; HAFIZ, HAFEZ, HAJI AND MAULANA ARE LEFT OUT, WANTING A CHOICE; SYED, MIAN, CHAUDHRY AND MAKHDOOM STAY NAME WORDS. Decided on 2026-11-19, each word by its counts, as rules/H9's batches are: the religious honorifics written before a name in Pakistan and Bangladesh, which 1.4.0 through 3.1.0 read as the given name (`mufti` and `hajji` were titles already, in ar.toml). It takes up the 2026-09-06 bundle's hafiz and syed forms, "skipped pending a corpus check"; `shahid` is not counted here. +- 2026-11-19 #1469 (its left-out question, "Open, above", declined by the 2026-11-21 #1469 entry) — QARI, MOULANA, ALHAJ AND ALHAJJ ARE TITLES; HAFIZ, HAFEZ, HAJI AND MAULANA ARE LEFT OUT, WANTING A CHOICE; SYED, MIAN, CHAUDHRY AND MAKHDOOM STAY NAME WORDS. Decided on 2026-11-19, each word by its counts, as rules/H9's batches are: the religious honorifics written before a name in Pakistan and Bangladesh, which 1.4.0 through 3.1.0 read as the given name (`mufti` and `hajji` were titles already, in ar.toml). It takes up the 2026-09-06 bundle's hafiz and syed forms, "skipped pending a corpus check"; `shahid` is not counted here. - THE COUNTS, as borne names. ORCID's 2025 extract (24,990,909 people; `tools/name_usage.py --boxes --country PK --country BD --country IN --country MY --country ID`), given box / family box: `hafiz` 2,300 / 371 (given: Pakistan 600, Malaysia 192, Indonesia 71, Bangladesh 29); `hafez` 245 / 564 (given: Iran 30, Egypt 28; family: Egypt 169); `haji` 232 / 1,178 (given: Iraq 20, Pakistan 15, Tanzania 13, Malaysia 10; family: Iran 156, Iraq 72, Brunei 50); `maulana` 971 / 1,231 (Indonesia 531 / 504, an Indonesian given name and surname); `qari` 9 / 43 (given: Pakistan 4); `moulana` 6 / 16; `alhaj` 17 / 269 (given: Sudan 5; the family box a surname written last); `alhajj` 5 / 47; `syed` 9,229 / 2,725 (given: Pakistan 1,810, India 907); `mian` 753 / 319 (given: China 130, Pakistan 103); `chaudhry` 81 / 814; `makhdoom` 16 / 57. US SSA given-name births: `syed` 6,043, `hafiz` 136, `mian` 110, `haji` 105, `hafez` 11, `qari` 10, the rest under 5 a year. - THE NAMES OPENING WITH THE WORD, read by hand in the local corpora: `maulana`'s 18 in orcid-researchers are all given names (16 Indonesian), and JRC-Names' 69 the Pakistani cleric's title; `haji`'s 29 in orcid-researchers are mostly given names (Tanzania 12, Ethiopia 3, Azerbaijan 2), psc-individuals' 34 mostly the title, and my-candidates' 26 and opensanctions-parliaments' 7 (`pk_na_members` 3, `in_sansad` 4) the title; `qari` (orcid-researchers 1, psc-individuals 5, JRC-Names 53), `moulana` (`pk_na_members` 2, psc-individuals 3, JRC-Names 1) and `alhaj` (psc-individuals 2, JRC-Names 1, orcid-researchers 1 of 2) are the title in every one but one: an orcid-researchers byline writing its family name `Alhaj` first and its given name as initials, which master read given 'Alhaj' and this change title 'Alhaj', both missing the filer's boxes; no name opens with `alhajj`. Read as a title by default, `hafiz` would move 630 names in the local corpora, 266 in orcid-researchers and 237 in psc-individuals, nearly all filed in the forename box. - BOX AGREEMENT DOES NOT DECIDE A TITLE: filers type the honorific in the forename box, so a title reading scores as a miss (`tools/differential/config_diff.py score default 'expr:Parser(lexicon=Lexicon.default().add("qari", kind="religious"))' --group PK --group BD --group MY --group ID --group TZ --group EG --group Pakistani --group Bangladeshi --group Malaysian --group Indonesian --cap 20000`, one spec per word). Each word read as a default title kept or lowered every group: `qari`, `moulana` and `alhaj` by at most 0.01 points; `maulana` ORCID ID 89.36 → 89.29; `haji` ORCID TZ 94.13 → 94.02; `hafiz` ORCID PK 93.59 → 92.94 and PSC Pakistani 94.27 → 93.35. So the four titles are decided on the lists that write a name as its bearer is addressed, and the four left out on the names their bearers file. @@ -76,3 +77,4 @@ Open: #514 (whether the Tibetan prefix titles Tulku, Khenpo, Geshe, Kyabje and J - MEASURED (`tools/differential/measure.py --base `, master `34771e2d`): the committed snapshot, CLDR and GND agreement and every local corpus but four read as master did. JRC-Names moved 55 names (`qari` 53, `alhaj` 1, `moulana` 1), opensanctions-parliaments 2 (`moulana`, both `pk_na_members`), orcid-researchers 7 and psc-individuals 10 (`qari` 5, `moulana` 3, `alhaj` 2): in every one the word left the given name for the title, the words after it reading as a name without it (where one name word was left, in 14 names, 12 of two words and 2 written behind `Mr`, it is the family, rules/H1: `Qari Khan` → title 'Qari', family 'Khan'), save the byline above and two of orcid-researchers' that open with `Lama`, an Arabic given name that is also a listed title (rules/H1's renunciate class): one written `Lama Alhaj` and a surname, which master read title 'Lama', given 'Alhaj', now reads title 'Lama Alhaj' and the surname as the family, and one holding `Lama` and `Alhajj` and nothing else keeps title 'Lama', given 'Alhajj' and now reports `title-or-name`, its one name word being title vocabulary. Neither reading is the filer's; the cost is `lama`'s, which master paid already. Scored against the filers' boxes, psc-individuals loses 10 records, each a forename box holding the honorific (behind `Mr` in the title box in nine), and orcid-researchers moves 3; JRC-Names reads 8 persons' spellings apart that master read alike, the spellings with the title against those without it. my-candidates, FEC and ClinicalTrials.gov move nothing. - 2026-11-21 #1180 — `haji` IS A TITLE UNDER `locales.MS`. ms.toml writes it a `religious` reading `default = false`, which the Malay pack turns on, plain or strict (`parser_for(locales.MS, strict=True).parse("Haji Abdul Hadi Awang")` gives title 'Haji'), where the #1469 entry left it out of every choice; that entry's strict-choice bullet, about qari, moulana, alhaj and alhajj, still holds under MS (`Qari Ahmed Khan` given 'Qari'), and the default is unchanged (decisions/salutation-titles, the 2026-11-21 #1180 entry). +- 2026-11-21 #1469 — NEITHER A BENGALI NOR AN URDU CHOICE READS `hafiz`, `hafez`, `haji` OR `maulana` AS A TITLE. Decided 2026-11-21: no `locales.BN` change and no Urdu pack is built for them. Measured the same day on master 81a24221, each name counted where the word opens it after any listed title (`Mr`, `Dr`): under `locales.BN` with the four added as titles, ORCID's Bangladesh draw (20,000 records) holds 3 names opening with one, 0 fixed and 2 broken, PSC's Bangladeshi filers (3,374) 3, 0 fixed and 3 broken, PatentsView's Bangladesh inventors (191) none; under the default with the four added, `hafiz` opens 161 names and `haji` 4 of ORCID's Pakistan draw (20,000 records), 174 and 4 of PSC's Pakistani filers (16,532) and 3 and 0 of PatentsView's Pakistan inventors (676), the agreement with the filed boxes, all four words added, falling 93.60% → 92.94%, 94.24% → 93.29% and 99.11% → 98.67%, and only the National Assembly and Senate lists (425 members) gain, 4 names. The figures are #1469's closing comment's, which names no command; a reopening re-measures them against the boxes the 2026-11-19 entry scores. People who file their own name treat the word as part of it: of PSC's 178 filers opening with one (174 `hafiz`, 4 `haji`) none typed it in the title box, and in 17 records the forename box holds it alone, so a title reading leaves no given name. `hafez` and `maulana` open no Pakistani name in the four sources. Whether `Hafiz` is a title depends on who wrote the list, an official roll writing it as an honorific and the bearer as a name: a convention of the data, which a caller declares (`Lexicon.default().add("hafiz", kind="religious")`). `locales.MS` reads `haji` as a title already (#1180, above), and the default titles of the 2026-11-19 #1469 entry stand. diff --git a/docs/design/decisions/script-properties.md b/docs/design/decisions/script-properties.md index db8cf03f7..513e7dba8 100644 --- a/docs/design/decisions/script-properties.md +++ b/docs/design/decisions/script-properties.md @@ -16,7 +16,7 @@ - The Lao script (U+0E80–0EFF) writes no initials, decided by the CLDR count (`lo` 0 of 37 locale-authored patterns produce one, its block its own), and writes period abbreviations, so a Lao title written short (`ດຣ.`) reads as before — 2026-11-20 #1380. -Open: Persian and Urdu. The Arabic row covers them because a row is per script, on thin evidence for both: the Wikidata native corpus holds 30 Persian and 32 Urdu names, none with an initial, CLDR's `fa` block is mostly `en`'s (6 of its 7 patterns with an initial equal) and `ur`'s half its own (4 of 8), and no measured list of either language's names written by their bearers has been read — #1149. +Open: Persian and Urdu. The Arabic row covers them because a row is per script, on thin evidence for both: the Wikidata native corpus holds 30 Persian and 32 Urdu names, none with an initial, CLDR's `fa` block is mostly `en`'s (6 of its 7 patterns with an initial equal) and `ur`'s half its own (4 of 8), and no measured list of either language's names written by their bearers has been read — raised by #1149 (closed 2026-11-20); no issue filed. Open: [#1273](https://github.com/derek73/python-nameparser/issues/1273) — what an initial looks like in the Brahmic scripts, the brahmic row's own question (`initials()` gives a vowel sign's base, not the syllable written). [#1274](https://github.com/derek73/python-nameparser/issues/1274) — the Uzbek apostrophe in case repair, a language question beside #1214. [#1242](https://github.com/derek73/python-nameparser/issues/1242) — the Dutch `IJ`, a language question, out of the table by the decision. diff --git a/docs/design/mechanisms.md b/docs/design/mechanisms.md index df25d09b4..4bc7bcaf9 100644 --- a/docs/design/mechanisms.md +++ b/docs/design/mechanisms.md @@ -348,9 +348,9 @@ rules/O8's letters are the same shape at the family's other edge: the family wri **Problem shape.** Language-specific behavior needs a home that cannot drift from the core. -**Contract statement.** A locale pack is pure data — a choice of languages, a Lexicon fragment of ADDITIONS (one pack's of removals, `locales.VI`'s, below) and a Policy patch — applied by parser_for, a shipped pack's patch compiled from its language file's `[rules]` table where one is written, each key the `Policy` field of its name: the packs' languages union with the base's recorded choice into one choice, recorded on the `Lexicon`, which selects among the base's shipped readings by the file each sits in, the fragments join in pack order and the caller's lexicon after them, its own readings applying after the choice, and the patches fold in order (set-valued fields union, `script_orders` merges by script, scalars override); packs contain no code paths of their own. A vocabulary pack's deviations are derived from the reading index, the words whose compiled readings its choice changes; a policy or segmentation pack declares its own in its docstring and `DEVIATES`. +**Contract statement.** A locale pack is pure data — a choice of languages, a Lexicon fragment of ADDITIONS (two packs' of removals, `locales.VI`'s and `locales.CS`'s, below) and a Policy patch — applied by parser_for, a shipped pack's patch compiled from its language file's `[rules]` table where one is written, each key the `Policy` field of its name: the packs' languages union with the base's recorded choice into one choice, recorded on the `Lexicon`, which selects among the base's shipped readings by the file each sits in, the fragments join in pack order and the caller's lexicon after them, its own readings applying after the choice, and the patches fold in order (set-valued fields union, `script_orders` merges by script, scalars override); packs contain no code paths of their own. A vocabulary pack's deviations are derived from the reading index, the words whose compiled readings its choice changes; a policy or segmentation pack declares its own in its docstring and `DEVIATES`. -**How it works.** What is policy for every language (an order constant) is policy, not pack data; packs are lowercase modules exposing uppercase constants; a pack error is wrapped with the pack's code (rule D2). A choice changes the base's readings only by selection, never by a list of removals (a pack's fragment may remove, as a caller's lexicon may, and one shipped pack's does: `locales.VI` takes out the particle, connective and credential readings of the Vietnamese syllables its order would otherwise chain or cut off, `Van` in `Nguyen Van Anh`, a settling no reading in its file can do, decisions 6 and 15 of decisions/vocabulary-model, bent there on 2026-11-05 #1108; `locales.MY`'s fragment did the same for Burmese syllables until a strict choice of `my` replaced it, which settles those clashes by reading no other language's file, decisions/vocabulary-collisions, 2026-11-19 #1231 and #1483): a chosen language's `default = false` readings join; on a word a chosen language holds a vocabulary reading of, other languages' vocabulary readings leave, save `mul.toml`'s; and a chosen language's conjunction loses `may_be_initial`, its clash with the initial being a shape reading a preference outranks, which is how a `pt` choice drops `e` from `conjunctions_ambiguous` (decisions/vocabulary-model, 2026-10-27 #753, items 1, 2 and 7; built 2026-10-29, phase 3b). A strict choice, `parser_for(..., strict=True)`, selects by file alone: only the chosen files, `mul.toml` and native-script words' readings as a plain choice of the same languages keeps them (name readings included) compile, `und.toml`'s readings leaving with every other file's (decisions/vocabulary-model, 2026-10-30 #753, file-strict; built 2026-10-31, phase 3j; `mul.toml` kept since 2026-11-02 #1005). So a bad default is routed around only by choosing the language whose reading is right, which is why #342-class fixes still change shipped vocabulary. The choice filters the base's shipped readings and the caller's own `add` and `remove` calls apply after it, so a choice never drops a caller's word, and one that clashes with a reading the choice turns on is refused at `parser_for`, naming the edit; a lexicon built from `Lexicon.empty()` holds no shipped reading, so a choice turns none on in it; a pack choosing no language leaves the base's exactly as it was. The choice is recorded on the `Lexicon`, so `parser_for(EN, base=parser_for(PT))` chooses both, as `parser_for(PT, EN)` does (decisions/vocabulary-model, 2026-11-02 #754, the `Lexicon` surface, items 3 and 4; built 2026-11-02, sub-phase 4i-c). Pure data means a pack can be audited: a vocabulary pack's whole content is its tag, but what it changes reaches other files too, prefer dropping their readings of its words (a `de` choice drops `ca.toml`'s conjunction `i`), so the audit is the derived surface, `changed_words`, not the pack's file alone. A country pack is the same data with a region tag: `locales.ES_AR` chooses `es-AR`, which selects `es.toml` by ancestry until a reading is Argentina's own, names its language's `[rules]` (`rules_patch("es")`) rather than inheriting them, and carries its own lexicon fragment, so stacked on its language's pack it reads as itself where its fragment holds the language pack's (decisions/O6, 2026-11-04). A country that turns on a rule its language leaves off writes the table in a file of its own, which may hold nothing else: `locales.PT_BR` reads `pt-BR.toml`'s and `locales.PT_PT` `pt-PT.toml`'s, while `locales.PT` reads none, and the two country packs share one lexicon fragment (decisions/O6, 2026-11-19). +**How it works.** What is policy for every language (an order constant) is policy, not pack data; packs are lowercase modules exposing uppercase constants; a pack error is wrapped with the pack's code (rule D2). A choice changes the base's readings only by selection, never by a list of removals (a pack's fragment may remove, as a caller's lexicon may, and two shipped packs' do: `locales.CS` takes out `ing`'s given reading, so `Ing` is a title wherever one is read before the name (decisions/H9, 2026-11-21 #970), and `locales.VI` takes out the particle, connective and credential readings of the Vietnamese syllables its order would otherwise chain or cut off, `Van` in `Nguyen Van Anh`, a settling no reading in its file can do, decisions 6 and 15 of decisions/vocabulary-model, bent there on 2026-11-05 #1108; `locales.MY`'s fragment did the same for Burmese syllables until a strict choice of `my` replaced it, which settles those clashes by reading no other language's file, decisions/vocabulary-collisions, 2026-11-19 #1231 and #1483): a chosen language's `default = false` readings join; on a word a chosen language holds a vocabulary reading of, other languages' vocabulary readings leave, save `mul.toml`'s; and a chosen language's conjunction loses `may_be_initial`, its clash with the initial being a shape reading a preference outranks, which is how a `pt` choice drops `e` from `conjunctions_ambiguous` (decisions/vocabulary-model, 2026-10-27 #753, items 1, 2 and 7; built 2026-10-29, phase 3b). A strict choice, `parser_for(..., strict=True)`, selects by file alone: only the chosen files, `mul.toml` and native-script words' readings as a plain choice of the same languages keeps them (name readings included) compile, `und.toml`'s readings leaving with every other file's (decisions/vocabulary-model, 2026-10-30 #753, file-strict; built 2026-10-31, phase 3j; `mul.toml` kept since 2026-11-02 #1005). So a bad default is routed around only by choosing the language whose reading is right, which is why #342-class fixes still change shipped vocabulary. The choice filters the base's shipped readings and the caller's own `add` and `remove` calls apply after it, so a choice never drops a caller's word, and one that clashes with a reading the choice turns on is refused at `parser_for`, naming the edit; a lexicon built from `Lexicon.empty()` holds no shipped reading, so a choice turns none on in it; a pack choosing no language leaves the base's exactly as it was. The choice is recorded on the `Lexicon`, so `parser_for(EN, base=parser_for(PT))` chooses both, as `parser_for(PT, EN)` does (decisions/vocabulary-model, 2026-11-02 #754, the `Lexicon` surface, items 3 and 4; built 2026-11-02, sub-phase 4i-c). Pure data means a pack can be audited: a vocabulary pack's whole content is its tag, but what it changes reaches other files too, prefer dropping their readings of its words (a `de` choice drops `ca.toml`'s conjunction `i`), so the audit is the derived surface, `changed_words`, not the pack's file alone. A country pack is the same data with a region tag: `locales.ES_AR` chooses `es-AR`, which selects `es.toml` by ancestry until a reading is Argentina's own, names its language's `[rules]` (`rules_patch("es")`) rather than inheriting them, and carries its own lexicon fragment, so stacked on its language's pack it reads as itself where its fragment holds the language pack's (decisions/O6, 2026-11-04). A country that turns on a rule its language leaves off writes the table in a file of its own, which may hold nothing else: `locales.PT_BR` reads `pt-BR.toml`'s and `locales.PT_PT` `pt-PT.toml`'s, while `locales.PT` reads none, and the two country packs share one lexicon fragment (decisions/O6, 2026-11-19). **Lives in.** nameparser/locales/ (packs), nameparser/_parser.py (parser_for, the one applier), nameparser/_lexicon.py (the compile under a recorded choice, `_chosen_pool` and `_built`), nameparser/_reading_index.py (the selection, `choose`, and the derived surface, `changed_words`), nameparser/_locale.py (`rules_patch`, a file's compiled `[rules]` as a patch) and tools/vocab/build.py (`RULE_KEYS`, the rules a file may turn on, and `PACK_RULES`, the files the shipped packs read; decisions/vocabulary-model, 2026-10-29 4f). A rule a file turns on is a `Policy` field; a new rule kind is a core change, never code in a pack: a new `Policy` field (with `ADDED_IN`), a row in build.py's `RULE_KEYS` and in `_locale._RULE_VALUES`, and a mechanisms.md entry of its own for the rule kind. diff --git a/docs/design/rules/C12-suffix-word-ending-the-name-before-the-comma.md b/docs/design/rules/C12-suffix-word-ending-the-name-before-the-comma.md index 68b2a7e53..fc602a2c2 100644 --- a/docs/design/rules/C12-suffix-word-ending-the-name-before-the-comma.md +++ b/docs/design/rules/C12-suffix-word-ending-the-name-before-the-comma.md @@ -64,7 +64,7 @@ ``` "Lloret Palol II, JA" → suffix="II, JA" ``` -- A name written in one case, or in a script without case, has no contrast to read and keeps the listing form, as C6's unlisted all-caps word does. +- A name written in one case, or in a script without case, has no contrast to read and keeps the listing form, as C6's unlisted word in the caps shape does. ``` "JOHN SMITH JR, AD" → given="AD" · boundary ``` diff --git a/docs/design/rules/C16-initials-spelling-a-credential-after-one-word-and-a-comma.md b/docs/design/rules/C16-initials-spelling-a-credential-after-one-word-and-a-comma.md index 0179a7f17..3f28ec631 100644 --- a/docs/design/rules/C16-initials-spelling-a-credential-after-one-word-and-a-comma.md +++ b/docs/design/rules/C16-initials-spelling-a-credential-after-one-word-and-a-comma.md @@ -33,7 +33,7 @@ **Except:** -- **A suffix word in front of the run, or credentials as the only other words of the part, make it the credential run**: a credential, a word of the ambiguous class, a title/suffix dual written in capitals (in a name written in one case, in either) or an unlisted capitals word C6 admits, the name carrying C6's contrast, behind the run speaks for it, a spaced delimiter counting as none, unlike a run spelling nothing, which C5's speaker reads only in front of it. The letters spell a listed credential, so a credential beside them is company; a generation is not, being a name's, nor a dual written as the title it also is. +- **A suffix word in front of the run, or credentials as the only other words of the part, make it the credential run**: a credential, a word of the ambiguous class, a title/suffix dual written in capitals (in a name written in one case, in either) or an unlisted word in a shape C6 admits, the name carrying C6's contrast, behind the run speaks for it, a spaced delimiter counting as none, unlike a run spelling nothing, which C5's speaker reads only in front of it. The letters spell a listed credential, so a credential beside them is company; a generation is not, being a name's, nor a dual written as the title it also is. ``` "Smith, M.D. Ph.D." → suffix="M.D. Ph.D." "Smith, M.D. MS" → suffix="M.D. MS" diff --git a/docs/design/rules/README.md b/docs/design/rules/README.md index 946849afc..000ff36a0 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. 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; its two-word guard for a pair read from its second word counts none, asking the parse instead whether the pair holds every name word it read. +- **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 for `abdul` counts the words the parse read as given, middle and family names, each holding a letter, the two parts of a family comma together; its two-word guard for a pair read from its second word counts none, asking the parse instead whether the pair holds every name word it read. - **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/nameparser/AGENTS.md b/nameparser/AGENTS.md index 94293d166..0046d2efd 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. 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. And a new way of joining two words into one unit must be taught to every reader of units, not only to the join: #1072's pair joined from its second word was cut by P1's family-first fold and by O6's take and division until `_vocab.unit_ends` and `_divide_family` read its tag, as they read `vocab:bound-given` (mechanisms.md#UNIT-PARTITION lists the readers); its first build also counted a title or a suffix as a name word for its two-word guard. Put the pair under `two_family_names` and a family-first order, behind a particle, and beside a title and a suffix, in the grid of any new join. Its fix then narrowed in turn, found by the review of the fix commit: counting only plain words after the pair dropped a bare trailing title the parse reads as the family (`عز الدين الحاج`), and the pair was still cut before a family comma, where group joins nothing and had stripped the tag the unit readers counted it by. Compare a name's comma writing with its comma-free twin (`حداد عز الدين، سامر` against `سامر حداد عز الدين`) in the grid of any view a join feeds. And a third review found the guard's word count, made in classify, narrowing once more, since classify cannot know what the trailing run will take: a guard on how many name words a name holds belongs where the parse has read them (post_rules here), not in a stage that guesses the later stages' reading. #1531 moved `abdul`'s four-word count there and met the trap from the other side: the parse places a lone mark (`Tariq - Abdul Aziz`) as a middle name, so a count read off roles must still ask for a letter, and the split must lay the mark out as the piece it is (`Dr - Abdul Aziz`), a mark being a name piece to the layout and no name word to the count; put a mark in front of the counted words, and behind a title, in the grid of any count read off roles. And a split made after group must cut `state.pieces` too: rules/O9's layout reads pieces, and its first build left the pair one piece there, so `TARIQ Abdul Aziz` under `capitals_as_family` read given 'Abdul Aziz' where the unjoined parse reads given 'Abdul', middle 'Aziz' (found by review); put every policy switch whose rule reads pieces in the grid of a late split. +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 then read every kind of non-name word the parse knew, and ran where the stage had 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. And a new way of joining two words into one unit must be taught to every reader of units, not only to the join: #1072's pair joined from its second word was cut by P1's family-first fold and by O6's take and division until `_vocab.unit_ends` and `_divide_family` read its tag, as they read `vocab:bound-given` (mechanisms.md#UNIT-PARTITION lists the readers); its first build also counted a title or a suffix as a name word for its two-word guard. Put the pair under `two_family_names` and a family-first order, behind a particle, and beside a title and a suffix, in the grid of any new join. Its fix then narrowed in turn, found by the review of the fix commit: counting only plain words after the pair dropped a bare trailing title the parse reads as the family (`عز الدين الحاج`), and the pair was still cut before a family comma, where group joins nothing and had stripped the tag the unit readers counted it by. Compare a name's comma writing with its comma-free twin (`حداد عز الدين، سامر` against `سامر حداد عز الدين`) in the grid of any view a join feeds. And a third review found the guard's word count, made in classify, narrowing once more, since classify cannot know what the trailing run will take: a guard on how many name words a name holds belongs where the parse has read them (post_rules here), not in a stage that guesses the later stages' reading. #1531 moved `abdul`'s four-word count there and met the trap from the other side: the parse places a lone mark (`Tariq - Abdul Aziz`) as a middle name, so a count read off roles must still ask for a letter, and the split must lay the mark out as the piece it is (`Dr - Abdul Aziz`), a mark being a name piece to the layout and no name word to the count; put a mark in front of the counted words, and behind a title, in the grid of any count read off roles. Read off roles, the count reads what the parse gave each word, not the tags an earlier stage left: a tag says what a word MAY be, and the classify-side count had read a contested title the parse reads as the family (`Tariq Abdul Aziz King`, `vocab:title-ambiguous`) as no word for carrying a tag, a numeral behind an initial (`J. VI`) likewise, and a word after a suffix the trailing run takes (`Ali Abdul Rahim VI Hassan`) as one. And a split made after group must cut `state.pieces` too: rules/O9's layout reads pieces, and its first build left the pair one piece there, so `TARIQ Abdul Aziz` under `capitals_as_family` read given 'Abdul Aziz' where the unjoined parse reads given 'Abdul', middle 'Aziz' (found by review); put every policy switch whose rule reads pieces in the grid of a late split. ### Orders @@ -24,7 +24,7 @@ Read a generated grid's moves by SHAPE, not by corpus membership: #614's first d ### Heads and title runs -#614's second review found two gaps. The first was a shape: no grid put TWO words that are both a title and a particle at the head (`Freiherr St van Berg MA`, where an index into the pieces was applied to a merged view of them -- `TITLES ∩ particles_ambiguous` is `{freiherr, st}` with the ranks `graf`, `gräfin`, `fürst` and `prinz` since #709 and the Armenian `տեր` since #1320 (2026-11-16, `sorted(L.titles & L.particles_ambiguous)` with `L = Parser().lexicon._sets`), so put `Freiherr` and `St` (and one rank) in every head list, each in its bare and its period-marked spelling -- #637's grid had `St` and `Freiherr` alone and missed that `St.` and `Freiherr.` are declined by the bound join and then attached by P6). #701's review added one: put a title/suffix dual (`Ms`, `Sr.`, `Cpl`) SECOND in a title run, behind an ordinary title. A stop that asks only "is this word suffix vocabulary" passes every row that opens with the dual and fails `Rev. Sr. Smith, Mary`; it was found by comparing `T Smith, John` against `T John Smith` over every title word, and a comma-versus-comma-less comparison is the cheap check for any rule that moves a word between the two slots. +#614's second review found two gaps. The first was a shape: no grid put TWO words that are both a title and a particle at the head (`Freiherr St van Berg MA`, where an index into the pieces was applied to a merged view of them -- `TITLES ∩ particles_ambiguous` is `{freiherr, st}` with the ranks `graf`, `gräfin`, `fürst` and `prinz` since #709 and the Armenian `տեր` since #1320 (2026-11-16, `sorted(L.titles & L.particles_ambiguous)` with `L = Parser().lexicon._sets`), so put `Freiherr` and `St` (and one rank) in every head list, each in its bare and its period-marked spelling -- #637's grid had `St` and `Freiherr` alone and missed that `St.` and `Freiherr.` are declined by the bound join and then attached by P6). #701's review added one: put a title/suffix dual (`Ms`, `Sr.`, `Cpl`) SECOND in a title run, behind an ordinary title. A stop that asks only "is this word suffix vocabulary" passes every row that opens with the dual and fails `Rev. Sr. Smith, Mary`; it was found by comparing `T Smith, John` against `T John Smith` over every title word, and a comma-versus-comma-less comparison is the cheap check for any rule that moves a word between the two slots. And put a marker written with a full stop (`Urf.`, `Née.`) inside a title run: H2's shape takes it as a title where `is_title_piece` does not, so a bound asking one disagrees with a run asking the other, and #1529's first commit, bounding an alias take by `is_title_piece`, read `Dr. Urf. Sr. Jr. @ Bob Smith` as given `@` where master read nickname `Bob Smith` (found by its code review). ### A report's field diff --git a/nameparser/locales/AGENTS.md b/nameparser/locales/AGENTS.md index fb48c3349..d9abf97a3 100644 --- a/nameparser/locales/AGENTS.md +++ b/nameparser/locales/AGENTS.md @@ -69,7 +69,7 @@ The shipped packs are the rows of `_REGISTRY` in `nameparser/locales/__init__.py | Carries a vocabulary list, declared by codepoint range | `nameparser/locales/zh.py` | | Its main contribution is turning a stage on (segmentation, through an optional dependency) | `nameparser/locales/ja.py` | | Nothing but a choice of languages | `nameparser/locales/hi.py` (`nameparser/locales/my.py`, its language's file copying the English ranks a strict choice keeps) | -| A choice of languages beside a `[rules]` table | `nameparser/locales/cs.py` | +| A choice of languages beside a `[rules]` table | `nameparser/locales/hr.py` (`nameparser/locales/cs.py` carries a fragment beside the two, #1518) | | A choice that changes no word, beside a patch | `nameparser/locales/mn.py` | | A fragment that takes readings out | `nameparser/locales/vi.py` | | A country pack reading its language's `[rules]` table | `nameparser/locales/es_ar.py` | diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index 085e716fa..87f4b2788 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -321,4 +321,4 @@ Phase 2 gave `default` and `attaches` their meaning (2026-10-25, see [Properties Two property values are refused for the same reason, with a message saying a later phase: `addresses = "full"` and `"any"`. `attached` takes the one `side` its category reads, `"after"` on a suffix and `"before"` on a title (#317 gave it the second), and the build refuses the other. -A locale pack's words are written in this folder and reached through its choice of languages (`Locale.languages`, phase 3). Not here are the lists outside the per-word model, whole lists a stage reads rather than readings of a word: the Korean surname list, a segmentation list, in `nameparser/config/_ko_surnames.py` because the default lexicon reads it (`Lexicon.default().surnames`), and the lists a pack carries beside its module in `nameparser/locales/` (ZH's surnames in `zh.py`, ES's and ES_AR's given names in `_es_given_names.py` and `_es_ar_given_names.py`). +A locale pack's words are written in this folder and reached through its choice of languages (`Locale.languages`, phase 3). Not here are the lists outside the per-word model, whole lists a stage reads rather than readings of a word: the Korean surname list, a segmentation list, in `nameparser/config/_ko_surnames.py` because the default lexicon reads it (`Lexicon.default().surnames`), and the lists a pack carries beside its module in `nameparser/locales/` (ZH's surnames in `zh.py`, ES's and ES_AR's given names in `_es_given_names.py` and `_es_ar_given_names.py`, PT_BR's and PT_PT's in `_pt_given_names.py`).