From e4f043c5e7b802fef1e805241be848c99a68dd75 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 15:30:35 -0800 Subject: [PATCH 1/3] Read a wholly Burmese list with a strict choice of my; drop locales.MY's fragment (#1483) A strict choice of `my` reads Burmese syllables (San, Van, PE, EI) as name words by reading no other language's file, so the pack's removal list goes: locales.MY is the choice of `my` alone. my.toml copies en.toml's readings of the English ranks and Sir that Burmese lists write, default = false, so the strict choice keeps them while the default and the plain pack read as before. The docs give the strict choice for a wholly Burmese list, with its measured cost to other names, and nameparser/locales/AGENTS.md asks for a strict choice to be measured before a pack removes another language's readings. Co-Authored-By: Claude Opus 5.5 --- .../design/decisions/vocabulary-collisions.md | 10 +- docs/design/decisions/vocabulary-model.md | 6 +- docs/design/mechanisms.md | 4 +- docs/languages.rst | 138 +++++++++---- docs/locales.rst | 26 +-- docs/release_log.rst | 2 +- nameparser/config/_index.py | 42 ++-- nameparser/locales/AGENTS.md | 5 +- nameparser/locales/my.py | 106 +++------- nameparser/vocab/AGENTS.md | 2 +- nameparser/vocab/my.toml | 85 ++++++++ tests/v2/cases.py | 28 +-- tests/v2/test_locales.py | 191 +++++++++--------- tests/v2/test_reading_index.py | 4 +- 14 files changed, 372 insertions(+), 277 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 11e33255a..3900378e6 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -30,7 +30,7 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - `el` (ar.toml) is an article that may be given, as `al` is, on by default: a decided exception to the Latin-spelling half of the rule above, which it fails, on its fixed/broken table, Algeria's compound given names the accepted cost — 2026-11-12 #1257. - `oude` (nl.toml) is a particle on by default, of the generic kind `particle`, no kind naming an adjective, that may be given (nam_dict's rare Dutch given name), with its case mask `Oude`: it passes rule 2 of the 2026-11-12 #1257 entry — 2026-11-18 #1455. - `ten` (nl.toml) is a preposition written `default = false`, which `locales.NL`, a pack choosing `nl` alone, turns on; it fails rule 2's mid-name test (`Kheng Ten Choo`), and zh.toml declares the Chinese given-name syllable it opens, so a plain Dutch choice keeps a leading `Ten` the given name, reported, and a strict one reads it as the family name — 2026-11-18 #1455. -- `u` and `daw` (my.toml) are Burmese salutations written `default = false`, which `locales.MY`, a pack choosing `my` with a lexicon fragment, turns on; the fragment takes out the particle readings of `san`, `la`, `le`, `do`, `da`, `du`, `te`, `di` and `van`, Burmese name syllables, and `do`'s credential reading, as `locales.VI`'s takes out Vietnamese ones; `ko`, `ma`, `maung` and the ethnic prefixes stay name words, and the military and religious styles stay out; `U.` written with its full stop is read as the title vocabulary reads `U` under the pack, so an initial can be the title (`U. S. Grant` → title 'U.', `Smith, U.` → title 'U.', no given name), which no rule vetoes — 2026-11-19 #1231. +- `u` and `daw` (my.toml) are Burmese salutations written `default = false`, which `locales.MY`, a pack choosing `my` and nothing else, turns on; a list of nothing but Burmese names is read with the strict choice, `parser_for(locales.MY, strict=True)`, which reads Burmese name syllables (`san`, `van`, `pe`, `ei`) as name words by reading no other language's file, and my.toml copies `en.toml`'s readings of the English ranks and `sir` such lists write, `default = false`, so the strict choice keeps them — 2026-11-19 #1483; `ko`, `ma`, `maung` and the ethnic prefixes stay name words, and the military and religious styles stay out; `U.` written with its full stop is read as the title vocabulary reads `U` under the pack, so an initial can be the title (`U. S. Grant` → title 'U.', `Smith, U.` → title 'U.', no given name), which no rule vetoes — 2026-11-19 #1231. ## Log @@ -108,3 +108,11 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - **The cost to names that are not Burmese**, measured on this branch (2026-11-19), the local and scored figures the same at the pack's final state as while the drafted rule stood. The committed corpora at the pack's final state (the branch's tree on master `6560abde` once the drafted rule's examples left the rules corpus), `config_diff.py diff default plain:MY --committed`: 279 of 7,644 names move, 4 of them opening with `U`, `U.` or `Daw` (`Daw Thida`, `U Kyaw Win`, rules/H1's `U Thant` and the Western initial `U. S. Grant`), 3 holding a period-joined `U` chunk (`John Smith J.u.n.i.o.r.`, `John Smith U.S. Dean.`, `U.S. and U.K. Ambassador Jane Doe`) and the rest the syllables, `van` 130, `da` 20, `do` 19 (the credential among them), `la` 11, `di` 6, `du` 5; the first count, before `do`'s credential left, was 253 of 7,643. `config_diff.py diff default plain:MY --local tse-donors --local psc-individuals --local ukec-individuals`: TSE's Brazilian donors 116,114 of 848,351 (`da` 100,949, `do` 12,588), PSC's filers 3,859 of 1,034,888, UK donors 22 of 15,214. `config_diff.py score default plain:MY --group MM --group NL --group BE --group ES --group IT --group PT --group BR --group FR --group PH --group MX --group VN --group KR --group US --group GB`, every box agreeing, capped at 20,000 records a group, ORCID then PatentsView: the Netherlands 94.05% to 83.34% and 96.74% to 79.47%, Belgium 95.29% to 89.03% and 97.34% to 89.94%, Italy 97.05% to 95.13% and 98.38% to 96.99%, Brazil 49.61% to 48.11% and 75.74% to 73.72%, Portugal 71.79% to 71.24% and 57.55% to 54.89%, France 94.52% to 93.35% and 98.00% to 96.63%, the United States, Britain, Spain, the Philippines and Mexico each 0.4 of a point or less (Britain's ORCID 96.45% to 96.08%, the Philippines' 97.71% to 97.62% on master `6560abde`, 97.67% to 97.58% on `9afb2209`); Vietnam 68.50% to 67.23% in ORCID and 90.26% to 94.05% in PatentsView, South Korea alike within a fifth of a point; Myanmar's ORCID holders 85.05% to 85.39% (8 fixed, 3 broken: filers who wrote two words in the family box or `Daw` in the given box), ORCID being blind to the honorifics: its 1,737 Myanmar holders open no box with `U` and two with `Daw` (the issue's 2026-11-19 comment). The CLDR locale view's `my` file, in Burmese script, reads 19/24 with and without the pack. - **Accepted:** under the pack a Dutch, Romance, Filipino or Māori particle among the nine is a name word (`Jan van Dijk` → middle 'van', family 'Dijk'; `Kiri Te Kanawa` → middle 'Te'), and the credential DO a name word (`Jane Doe, DO` → given 'DO'), which the pack's docstring and docs/languages.rst say, with the figures above; a `U` can be the title, bare or written with its full stop (the `U.` bullet above), a Korean surname `U` (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19) and a Western initial (`U. S. Grant` → title 'U.') included, and a period-joined word holding a `U` chunk reads as a title (`John Smith J.u.n.i.o.r.` → title 'J.u.n.i.o.r.', where the default reads the suffix); a removed particle in the family before a comma no longer keeps the given part after it from reading as a credential, so the given name is lost (`Van Buren, Ed` → given 'Van', family 'Buren', suffix 'Ed'; `De La Cruz, Ed` → suffix 'Ed', no given name; `De La Cruz, M.J. K.L.` → suffix 'M.J. K.L.', where the default reads given 'M.'), the shape nameparser/vocab/AGENTS.md's "A reading taken out" names, found by the PR's last review, 4 names of the committed corpora; a title and one name word gives the family a word a Burmese name does not hold as a family name (rules/H1). - **Left out:** `Mg` (#1232); the Burmese-script honorifics and the Burmese comma `၊` (#1233, #1202); the Burmese honorifics ending the given part after a family comma (`after_given`); the other credential syllables above. + +- 2026-11-19 #1483 — A WHOLLY BURMESE LIST IS READ WITH A STRICT CHOICE OF `my`; `LOCALES.MY`'S FRAGMENT IS DROPPED; MY.TOML COPIES THE ENGLISH RANKS; PROPOSAL A IS DROPPED. Decided on the issue (its two 2026-11-19 comments), after it found five Burmese syllables the #1231 fragment had not listed reading as credentials ending a name written in capitals (`THEIN AUNG PE` → suffix 'PE'; `pe`, `lat`, `ei`, `si`, `pa`, and `ra`, ungated). A removal list names other languages' words, so it fails silently twice: removing a reading no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name (checked on master `d12af9d6`). A strict choice names no other language's word, so neither can happen to it; nameparser/locales/AGENTS.md now asks for it to be measured before a pack removes readings. + - **The strict choice against the pack**, on the 2,990 names of the #1231 entry's population, read by the same scratch probe (an opening `U` or `Daw` the title, the last word the family; `Mg` counted neither way), measured on master `4b0b9441` before this change: `Parser()` 2,834 as written (94.8%) and 2,825 with every name upper-cased (94.5%); the pack with its fragment 2,987 (99.9%) and 2,977 (99.6%); `parser_for(locales.MY, strict=True)` 2,980 (99.7%) in both writings; a strict choice of `my` with an empty fragment the same names as the strict pack in both writings, and on 361,391 names of the committed corpus and ClinicalTrials.gov's officials, the fragment being inert under strict, which never loads the files whose readings it removed. Upper-cased, strict read 13 names the pack missed (`PE` 4, `LAT` 3, `EI` 2, `RA` 2, `SI` 1, a doubled `PA`), and as written the 2 ending in `Ra`; it read the 10 `Mg` names as #1232 asks (`Mg Htoo Aung` → given 'Mg'), where the default and the pack read en.toml's military `MG`. It lost 9 names' bare English ranks and one `Sir` (`General` 7, `Lieutenant` 3, `Senior` 2, `Admiral` 1, `Vice` 1 as title words), ranks written with their full stops being kept by H2's shape. + - **The ranks.** my.toml now holds the English ranks and `sir`, each a copy of en.toml's reading with its properties (`same_as`, `attaches`, `abbreviation`, `addresses`), written `default = false` so the default never reads them: `senior`, `vice`, `rear` (modifiers), `general`, `gen`, `lieutenant`, `lt`, `major`, `maj`, `brigadier`, `brig`, `colonel`, `col`, `captain`, `capt`, `admiral`, `adm`, `commodore`, `commander`, `cdr`, and `sir`; the population writes the first five that are words of their own and `Sir`, the rest are the Tatmadaw's ranks as staff lists write them. ORCID's Myanmar given and family boxes hold none of the 21 (1,755 holders, `tools/name_usage.py --country MM`, 2026-11-19). A choice holding a vocabulary reading of a word drops every other file's (`choose`'s prefer step), so `lt`'s credential is copied with its rank: without it the plain pack read `John Smith, LT` title 'LT', found by the builder before commit. The plain pack reads every rank as the default does (`_compiled.py` and `changed_words` unchanged), and the strict choice reads `gen`, `maj`, `brig` and `major` without en.toml's given readings, so a bare one opening a name is the rank there (`Gen Goto` → title 'Gen'), the four words joining tests/v2/test_reading_index.py's `STRICT_UNGATED` for `my`. With them, on this branch: the strict choice 2,989 of 2,990 in both writings (100.0%), the one left a string holding two names, which every configuration misreads. + - **The fragment, dropped.** Measured first on this branch, as the decision required: the pack without its fragment reads 2,932 names right as written (98.1%), 55 fewer than with it (the estimate was about 55), and 2,923 upper-cased (97.8%), 54 fewer; every name the two read differently is one the fragment read right (`san` 39, `la` 7, `van`, `te`, `da` 2 each, `do`, `le`, `du` 1 each, as written). So `locales.MY` is the choice of `my` alone, declaring no `DEVIATES`, and the #1231 entry's accepted costs of the fragment (`Jan van Dijk`, `Van Buren, Ed`, the credential DO) no longer apply to the plain pack; a caller reading a mixed list plainly reads those syllables as the default does, and one reading a wholly Burmese list chooses strictly. The fragment was unreleased. + - **What the strict choice costs other names**, on this branch, `config_diff.py diff plain:MY strict:MY --committed --local ctgov-officials --local ctgov-contacts`: 88,009 of 720,837 names move (committed 1,884 of 7,662, ctgov-contacts 42,863 of 359,428, ctgov-officials 49,151 of 353,747), 29,233 of them in their ambiguity reports alone and 58,776 in their fields; the words moved most are `de` 4,676 (family to middle), `master` 3,628 (title to given), `van` 3,364, `pr` 2,432, `rn` 2,404 (suffix to given), `mbchb` 1,738, `of` 1,720, `pd` 1,688, `do` 1,590. Against the pack with its fragment, on master `4b0b9441`, 45,867 of 720,819 had moved in their fields. docs/languages.rst states the cost and keeps the strict choice to a wholly Burmese list. + - **`locales.VI` measured under strict, not changed** (its list shipped in 3.1; whether strict replaces it is a later question): `uit-vinames`, scored as `local_agreement.py` scores it, every box agreeing for 21,085 of 21,090 under `parser_for(locales.VI)` (99.98%) and 21,089 under `parser_for(locales.VI, strict=True)` (100.00%), 4 fixed and none broken; `vn-assembly` 499 of 499 under both, no name read differently. On names that are not Vietnamese, `config_diff.py diff plain:VI strict:VI --committed --local ctgov-officials --local ctgov-contacts`: 80,628 of 720,837 names move, 52,108 in their fields. + - **Proposal A** (the pack removing the five credential readings) is dropped: the strict choice reads them. **Proposal B** (`ra` a name by default) is a question about Korean names as much as Burmese ones and stays open on #1483. #1232's `Mg` is read as that issue asks under the strict choice; the default and the plain pack still read the military `MG`. diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index ac0e46103..a55b27ea1 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -7,7 +7,7 @@ The vocabulary was a set of base sets plus marker subsets (`particles` and `part - The vocabulary redesign comes before adding many packs: it is designed for 3.0, and what is safe is pulled forward in four phases, (1) the data format and a compiler, snapshot-neutral, (2) derived ambiguity with the gate on every reading kind, (3) pack semantics, (4) the rules menu, order and shapes, and the output model — 2026-10-15/16. - Each word is described by its readings (word → reading → properties), each kind belonging to one category that decides the compiled field it feeds; detailed kinds are recorded even where the kinds of a category behave alike, generation and credential being separate kinds of the suffix category (its kinds are the entries `CATEGORY` in `nameparser/_reading_index.py` maps to `suffix`) — 2026-10-15/16; 2026-10-18 #737. - A language file holds the words the parser might meet in names written in that language, immigrant particles included, not the words of its etymology, and a word sits in the file of every language whose names it occurs in, a Latin transliteration in its source language's file; `mul.toml` holds the words shared on purpose instead (the generations `i` to `v`, `2` and `jr` with `junior` and `jnr`, `&`, the European titles below, and the degrees and salutations every country's data writes alike), a word joining it where it harms no language and would otherwise be duplicated into every language's file — 2026-10-15/16; 2026-10-18 #737; 2026-10-19 #749; 2026-10-19 #750, title kinds; 2026-11-02 #1005 (Derek); 2026-11-03 #1005, the strict-gap batches (Derek). -- The default loads every language and keeps working for names of any language. Choosing a language narrows it since 3.0's phase 3 (#753): a pack settles only the clashes where its language has a vocabulary reading (`locales.VI` and `locales.MY` excepted: each fragment removes readings of syllables no reading in its file can settle, Vietnamese 2026-11-05 #1108, Burmese decisions/vocabulary-collisions' 2026-11-19 #1231 entry), a strict choice reads only the chosen languages' files, `mul.toml` and native-script words' readings as a plain choice of the same languages keeps them (name readings included), and a pack's preferred reading can outrank one a shape rule derives — 2026-10-15/16; 2026-10-30 #753, file-strict; 2026-11-02 #1005 (Derek); 2026-11-07 #1148. +- The default loads every language and keeps working for names of any language. Choosing a language narrows it since 3.0's phase 3 (#753): a pack settles only the clashes where its language has a vocabulary reading (`locales.VI` excepted: its fragment removes readings of Vietnamese syllables no reading in its file can settle, 2026-11-05 #1108; `locales.MY`'s fragment, 2026-11-19 #1231, was dropped the same day for a strict choice, decisions/vocabulary-collisions' #1483 entry), a strict choice reads only the chosen languages' files, `mul.toml` and native-script words' readings as a plain choice of the same languages keeps them (name readings included), and a pack's preferred reading can outrank one a shape rule derives — 2026-10-15/16; 2026-10-30 #753, file-strict; 2026-11-02 #1005 (Derek); 2026-11-07 #1148. - `e`, `y` and `i` stay in the default; choosing a language settles their one-case fork for that language's own reading, `may_be_initial` not holding on a chosen file's conjunction, as `locales.PT`, `locales.PT_BR` and `locales.PT_PT` do for `e` — 2026-10-15/16; 2026-10-29 #753, phase 3b; 2026-10-30 #753, phase 3g. - A patronymic field came in 3.0, as a view that names its words without emptying `family`, and the particle kinds already draw the `clan`/`patronymic` line for it: a patronymic is followed by a parent's name, a clan prefix by a family name the lineage shares — 2026-10-15/16; 2026-10-19 #749; 2026-10-28 #754 (Derek); landed as rules/R9, 2026-10-29 #754, sub-phase 4c. - A shipped pack that is only a choice of languages declares no `DEVIATES`, its surface the words its choice changes; `ga` turns on `nic`, `mhic`, `mic` and `uí` as clan particles, `gd` `nic`, and `pt-BR` `sb` as Sobrinho's spelling, while the single letters `f` and `n` are excluded, the pack included, the letter abbreviating a surname more often than the agnomen in the filings that write it — 2026-10-30 #753, phase 3h. @@ -97,7 +97,7 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis 3. Detailed kinds are recorded during the migration even where every kind of a category behaves alike at first; generation and credential are separate kinds (#326). 4. A language file means "the words the parser might encounter in names in that language" — what occurs in names and records written in it, including particles common there through immigration — not words of that language's etymology. 5. The default loads every language and keeps working for names of any language, as today; choosing a language narrows it. - 6. Packs prefer and strict packs restrict: a pack settles only the clashes where its language has a VOCABULARY reading, and a strict variant also drops other languages' name-level readings. (Excepted for two packs, 2026-11-05 #1108, below: `locales.VI`'s fragment removes readings of Vietnamese syllables where vi.toml holds none; and `locales.MY`'s of Burmese syllables, decisions/vocabulary-collisions' 2026-11-19 #1231 entry.) + 6. Packs prefer and strict packs restrict: a pack settles only the clashes where its language has a VOCABULARY reading, and a strict variant also drops other languages' name-level readings. (Excepted for one pack, 2026-11-05 #1108, below: `locales.VI`'s fragment removes readings of Vietnamese syllables where vi.toml holds none. `locales.MY`'s removed Burmese syllables' readings from 2026-11-19 #1231 until #1483 the same day, which read a wholly Burmese list strictly instead, decisions/vocabulary-collisions.) 7. `e`/`y`/`i` stay in the default, at least to start; choosing a language settles the one-case fork. 8. A patronymic field belongs in 3.0. 9. Gender is recorded only where a word gives a definitive clue. @@ -106,7 +106,7 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis 12. Bearer counts are structured provenance (source + count), never used to compute a reading: two data sets deciding one reading would make the decision unclear. A new census flags changed names for review. 13. `Dean Smith` reads given `Dean`, as today. 14. Order and shape are separate: a language supplies only a default order; the shapes (where titles, suffixes, particles and commas sit) belong to each order and live in the core. - 15. Vocabulary readings settle a clash; name readings only keep the gate on. (Bent for two packs, 2026-11-05 #1108, below: `locales.VI`'s fragment removes the particle, connective and credential readings of Vietnamese syllables, the settling no reading in vi.toml can do; and `locales.MY`'s the particle readings of Burmese syllables and `do`'s credential, decisions/vocabulary-collisions' 2026-11-19 #1231 entry.) + 15. Vocabulary readings settle a clash; name readings only keep the gate on. (Bent for one pack, 2026-11-05 #1108, below: `locales.VI`'s fragment removes the particle, connective and credential readings of Vietnamese syllables, the settling no reading in vi.toml can do. `locales.MY`'s removed the particle readings of Burmese syllables and `do`'s credential from 2026-11-19 #1231 until #1483 the same day, decisions/vocabulary-collisions.) 16. The contested-head rule covers only words outside `titles` today (`dean`, `justice`, `major`); a title that is also a given name today is decided one word at a time, like the graf class (decisions/salutation-titles). 17. `cased` and `same_as` replace a "canonical" spelling, and `cased` replaces `capitalization_exceptions`; both default to the word, and a reading's `native` spelling is for surfacing. 18. `acronym` is a reading property, replacing the `suffix_acronyms`/`suffix_words` split; `expands` records the meaning an entry was added for, not every meaning. diff --git a/docs/design/mechanisms.md b/docs/design/mechanisms.md index c4e0b21ef..2c1b27d34 100644 --- a/docs/design/mechanisms.md +++ b/docs/design/mechanisms.md @@ -346,9 +346,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 (two packs' of removals, `locales.VI`'s and `locales.MY`'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 (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`. -**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.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` the particle readings of the Burmese syllables, `San` in `Aung San Win`, and `do`'s credential reading, which the particle chain had kept from ending `AUNG SAN DO`, decisions/vocabulary-collisions, 2026-11-19 #1231): 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 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). **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/languages.rst b/docs/languages.rst index 7720cb641..1097e2ec8 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1276,8 +1276,9 @@ Burmese names ------------- Turn on ``locales.MY`` when your data is Burmese names written in Latin -letters. ``my`` is the language tag of Burmese; Malaysia, whose region -code is also MY, writes Malay, ``ms``, which this pack is not for. +letters, and choose it strictly when your list holds nothing else (below). +``my`` is the language tag of Burmese; Malaysia, whose region code is +also MY, writes Malay, ``ms``, which this pack is not for. A Burmese name has no family name: every word is a personal name, and an honorific goes in front, ``U`` for a man and ``Daw`` for a woman. @@ -1293,28 +1294,98 @@ family name, as in any name, and the honorific is the title: >>> thein_sein.title, thein_sein.given, thein_sein.family ('U', 'Thein', 'Sein') -Burmese syllables such as ``San``, ``La`` and the Chin ``Van`` are -particles in Spanish, Italian, Portuguese, French or Dutch, and the -default takes them, and every word after them, into the family name. -The pack keeps them name words: +A list of nothing but Burmese names +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Choose the pack strictly, ``parser_for(locales.MY, strict=True)`` +(:ref:`strict-choice`). Many Burmese syllables are spelled like +another language's word: ``San``, ``La`` and the Chin ``Van`` like +Spanish, Italian or Dutch particles, which take every word after them +into the family name, and ``Pe``, ``Lat``, ``Ei``, ``Si``, ``Pa`` and +``Ra`` like English credentials, which end a name written in capitals. +A strict choice reads no other language's words, so each is a name +word: .. doctest:: - >>> parse("Daw Aung San Suu Kyi").family + >>> strict_burmese = parser_for(locales.MY, strict=True) + >>> burmese.parse("Daw Aung San Suu Kyi").family 'San Suu Kyi' - >>> suu_kyi = burmese.parse("Daw Aung San Suu Kyi") + >>> suu_kyi = strict_burmese.parse("Daw Aung San Suu Kyi") >>> suu_kyi.title, suu_kyi.middle, suu_kyi.family ('Daw', 'San Suu', 'Kyi') + >>> burmese.parse("THEIN AUNG PE").suffix + 'PE' + >>> strict_burmese.parse("THEIN AUNG PE").family + 'PE' + +The English military ranks such lists write, and ``Sir``, are the +Burmese vocabulary's own, so a strict choice keeps them, written whole +or short (``Senior General``, ``Lt Gen``, ``Maj Gen``, ``Brig Gen``, +``Col``, ``Capt``, ``Rear Admiral``, ``Cdr``). ``Mg``, Maung written +short, is the given name, where by default and under the plain pack +it is read as the military abbreviation: + +.. doctest:: -The nine are ``San``, ``La``, ``Le``, ``Do``, ``Da``, ``Du``, ``Te``, -``Di`` and ``Van``, and ``Do`` is no credential either, so a name -written in capitals keeps a final ``DO``. + >>> strict_burmese.parse("Lt Gen Kyaw Win").title + 'Lt Gen' + >>> burmese.parse("Mg Htoo Aung").title + 'Mg' + >>> strict_burmese.parse("Mg Htoo Aung").given + 'Mg' On 2,990 names of people from Myanmar, from sanctions and politically -exposed persons lists and from Wikidata, the honorific read as the -title and the last word as the family hold for 94.8% by default and -99.9% under the pack (``docs/design/decisions/vocabulary-collisions.md``, -:issue:`1231`). +exposed persons lists and from Wikidata, read right is the honorific +as the title and the last word as the family +(``docs/design/decisions/vocabulary-collisions.md``, :issue:`1231`, +:issue:`1483`): + +.. list-table:: + :header-rows: 1 + + * - Parser + - As written + - In capitals + * - ``Parser()`` + - 94.8% + - 94.5% + * - ``parser_for(locales.MY)`` + - 98.1% + - 97.8% + * - ``parser_for(locales.MY, strict=True)`` + - 100.0% (2,989) + - 100.0% (2,989) + +What a strict choice costs other names +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A strict choice drops every word only another language reads, from +every name, so keep it to a list that is wholly Burmese: + +- **Particles, credentials and titles of other languages** are name + words. ``Jan van Dijk`` gives middle ``van``, and a credential after + a comma can become the given name (``Jane Doe, PA`` gives given + ``PA``, family ``Jane Doe``). The shared credentials, ``Dr``, + ``PhD`` and ``MBBS`` among them, are kept. +- **A rank that is also a given name** is the rank: ``Gen``, ``Maj``, + ``Brig`` and ``Major`` opening a name are titles (``Gen Goto`` gives + title ``Gen``), where by default they are the given name unless a + title phrase follows. + +.. doctest:: + + >>> strict_burmese.parse("Jan van Dijk").family + 'Dijk' + >>> strict_burmese.parse("Jane Doe, PA").given + 'PA' + >>> burmese.parse("Jane Doe, PA").suffix + 'PA' + +On the committed test corpora and ClinicalTrials.gov's officials and +site contacts, 720,837 names that are mostly not Burmese, the strict +choice reads 58,776 differently from the plain pack in their fields, +8.2% of them. What the pack leaves as it is ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1334,38 +1405,19 @@ What the pack leaves as it is When not to use it ~~~~~~~~~~~~~~~~~~ -The pack is for lists of Burmese names. On other names it costs: - -- **Nine particles.** Their particle readings, which Dutch, Portuguese, - Italian, French, Spanish, Filipino and Māori family names hold - (``de`` and ``del`` keep theirs, so ``Juan de la Cruz`` reads as by - default, but a ``de la`` in other shapes, after a comma, beside another - particle or under a family-first order, can read otherwise). Where one - stands in the family name before a comma, the given part after it - can read as a credential, the given name lost (``Van Buren, Ed`` - gives suffix ``Ed``). -- **The credential DO**, read as a name word. -- **An initial U.** ``U`` is the honorific however it is written, so - an initial ``U.`` can be read as the title: ``Smith, U.`` and ``Dr. - U. Smith`` give no given name, though ``John U. Smith`` and ``Smith, - John U.`` keep it an initial. - -Keep it to a parser of its own for the Burmese names in your data: +The plain pack reads names that are not Burmese as the default does, +save one word: ``U`` is the honorific however it is written, so an +initial ``U.`` can be read as the title. ``Smith, U.`` and ``Dr. U. +Smith`` give no given name, though ``John U. Smith`` and ``Smith, John +U.`` keep it an initial: .. doctest:: - >>> burmese.parse("Jan van Dijk").family - 'Dijk' - >>> burmese.parse("Maria da Silva").family - 'Silva' >>> grant = burmese.parse("U. S. Grant") >>> grant.title, grant.given ('U.', 'S.') -Measured on names that are not Burmese, the pack changes the reading of -14% of the names of Brazilian election donors, and among researchers -who filed their own given and family names in ORCID it lowers the -share read right in both boxes from 94% to 83% in the Netherlands and -from 95% to 89% in Belgium. A Korean name written with no comma and opening with the -surname ``U`` reads ``U`` as the title under the pack (``U Minjun``), -where ``U, Minjun`` keeps it as the family name. +A Korean name written with no comma and opening with the surname ``U`` +reads ``U`` as the title under the pack (``U Minjun``), where ``U, +Minjun`` keeps it as the family name. Keep the pack to a parser of its +own for the Burmese names in your data. diff --git a/docs/locales.rst b/docs/locales.rst index 901af09dd..b1adf0130 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -144,12 +144,10 @@ shape covers much: the order moves every name a family comma does not fix, and its titles and removed readings reach the comma names too. - ``mn`` may read any name written wholly in Cyrillic differently. -- ``my`` may read any name holding ``San``, ``La``, ``Le``, ``Do``, - ``Da``, ``Du``, ``Te``, ``Di`` or ``Van`` as a word differently, - Spanish, Portuguese, Italian, French, Filipino and Dutch family names - among them, a name holding the credential ``DO``, and any holding - ``U`` or ``Daw`` as a word, with or without its full stop, or ``U`` - as a letter of a word joined by full stops. +- ``my`` may read any name holding ``U`` or ``Daw`` as a word + differently, with or without its full stop, or ``U`` as a letter of + a word joined by full stops. Chosen strictly, it may read any name + differently that holds another language's word (:ref:`strict-choice`). .. warning:: @@ -301,10 +299,11 @@ says which parts each pack is made of. * - ``my`` - Burmese - Chooses ``my``, which reads the honorifics ``U`` and ``Daw`` - as titles (``U Thein Sein``), and keeps the syllables ``San``, - ``La``, ``Van`` and six more as name words where other - languages read particles. See :ref:`burmese-names`. - - ``Daw Aung San Suu Kyi`` → title ``Daw``, family ``Kyi`` + as titles (``U Thein Sein``). Choose it strictly for a list of + nothing but Burmese names, which keeps ``San``, ``Van`` and the + other syllables name words where other languages read particles + or credentials. See :ref:`burmese-names`. + - ``U Thein Sein`` → title ``U``, given ``Thein``, family ``Sein`` * - ``ne`` - Nepali - Chooses ``ne``, which reads ``श्री``, ``गुरु`` and ``Guru`` as @@ -1148,6 +1147,7 @@ right, validated on its own, and it may hold any of these: where another pack would choose because a choice prefers its language's reading of a word only where that reading is a title, a particle or another vocabulary kind, never a name, so no reading - ``vi.toml`` could write would keep ``Van`` a name word. ``my``'s - fragment takes out the particle readings of the Burmese syllables, - and ``do``'s credential reading, the same way. + ``vi.toml`` could write would keep ``Van`` a name word. A strict + choice settles the same clashes without a list, by reading no other + language's words, which is how a wholly Burmese list is read + (:ref:`burmese-names`). diff --git a/docs/release_log.rst b/docs/release_log.rst index 56bee9be4..eb116cf64 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -10,7 +10,7 @@ Release Log - **Fix Malaysian a/l, a/p and anak, which read as middle names and cut the father's name.** ``parse("KUMAR A/L RAJAN NAIDU")`` gives family ``A/L RAJAN NAIDU`` and the same ``patronymic``, as ``bin`` reads, where 1.4.0 through 3.1.0 gave middle ``A/L RAJAN``, family ``NAIDU``; ``anak`` opening a name written without a comma (Balinese ``Anak Agung``) is left to position, the given name by default, and reported. :issue:`1468` - **Fix Dutch Oude, which read as a middle name.** ``parse("Piet Oude Luttikhuis")`` gives family ``Oude Luttikhuis``, where 1.4.0 through 3.1.0 gave middle ``Oude``, family ``Luttikhuis``; ``Oude`` opening a name stays the given name, reported, being a rare Dutch given name too. :issue:`1455` - **Add locales.NL, which reads ten as a family-name particle.** ``parser_for(locales.NL).parse("Jan ten Brink")`` gives family ``ten Brink``, where the default, as 1.4.0 through 3.1.0, gives middle ``ten``; a ``Ten`` opening a name stays the given name, reported, save under ``strict=True``. It also takes a Chinese given-name syllable inside a name into the family (``Kheng Ten Choo`` gives family ``Ten Choo``), and choosing Dutch reads ``VD`` as ``van der`` rather than the credential (``John Smith, VD`` gives family ``John Smith VD``). See :ref:`dutch-particles`. :issue:`1455` - - **Add locales.MY, a Burmese pack, which reads U and Daw as titles.** ``parser_for(locales.MY).parse("Daw Aung San Suu Kyi")`` gives title ``Daw``, given ``Aung``, middle ``San Suu``, family ``Kyi``, where the default, as 1.4.0 through 3.1.0, gives given ``Daw``, family ``San Suu Kyi``. It reads ``San``, ``La``, ``Van`` and six more as name words, so names holding ``van``, ``da``, ``la`` and the rest lose them as particles (``Jan van Dijk`` gives family ``Dijk``), and an initial ``U.`` can become the title (``Smith, U.`` gives no given name): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` + - **Add locales.MY, a Burmese pack, which reads U and Daw as titles, and reads a wholly Burmese list strictly.** ``parser_for(locales.MY).parse("U Thein Sein")`` gives title ``U``, given ``Thein``, family ``Sein``, where the default, as 1.4.0 through 3.1.0, gives given ``U``, middle ``Thein``; ``parser_for(locales.MY, strict=True)`` also keeps syllables such as ``San`` and ``PE`` name words and the English ranks Burmese lists write titles, and costs a list of other names their particles and credentials. An initial ``U.`` can become the title under the pack (``Smith, U.`` gives no given name): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231`, :issue:`1483` - **Fix MD inside a name written in capitals, which read as the degree and took the name behind it.** ``parse("SITI NORA MD YUSRI")`` gives middle ``NORA MD``, family ``YUSRI``, as 1.4.0 through 2.3.0 did, where 2.4.0 through 3.1.0 gave family ``NORA``, suffix ``MD YUSRI``; a name in lower case reads the same way, and both report ``suffix-or-name``, the degree being the other reading. The degree written before a family name in capitals reads so too (``JOHN SMITH MD JONES`` gives family ``JONES``, reported), where ``John Smith MD Jones`` and ``JOHN SMITH M.D. JONES`` keep it. :issue:`1394` - **Fix Emeritus, which read as a given name.** ``parse("Professor Emeritus John Smith")`` gives title ``Professor Emeritus``, given ``John``, where 1.4.0 through 3.1.0 gave title ``Professor``, given ``Emeritus``, middle ``John``; ``Emeritus Professor`` and ``Professor Emerita`` read the same way. ``Emerita`` alone stays the given name, reported, being a given name too. A title other than ``Professor`` or ``Prof`` before it still leaves it a name word (``Bishop Emeritus John Smith`` gives given ``Emeritus``). :issue:`1471` - **Change locales.PT_BR to read two family names, and add locales.PT_PT, which reads names from Portugal the same way.** ``parser_for(locales.PT_BR).parse("Ana Souza Lima")`` gives family ``Souza Lima``, where 3.0.0 through 3.1.0 gave middle ``Souza``, family ``Lima``; a second given name on the packs' Portuguese given-name list stays where it stands (``Ana Beatriz Costa`` keeps family ``Costa``), and ``locales.PT``, chosen for Portuguese names from any country, is unchanged. :issue:`1453` diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 40bfe0e52..d4d7468c0 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -84,9 +84,9 @@ ('adi', (('en', 'familiar', (('short_for', ('aditya', 'adrian')),)),)), ('adjunct', (('en', 'modifier', ()),)), ('adjutant', (('en', 'military', (('attaches', ('gen',)),)),)), - ('adm', (('en', 'military', (('same_as', 'admiral'),)),)), + ('adm', (('en', 'military', (('same_as', 'admiral'),)), ('my', 'military', (('default', False), ('same_as', 'admiral'))))), ('administrator', (('en', 'office', ()),)), - ('admiral', (('en', 'military', ()),)), + ('admiral', (('en', 'military', ()), ('my', 'military', (('default', False),)))), ('adv', (('en', 'academic', (('same_as', 'advocate'),)),)), ('advertising', (('en', 'modifier', ()),)), ('adviser', (('en', 'occupation', ()),)), @@ -370,8 +370,8 @@ ('bram', (('nl', 'familiar', (('short_for', ('abraham',)),)),)), ('bri', (('en', 'familiar', (('short_for', ('brianna',)),)),)), ('brie', (('en', 'familiar', (('short_for', ('brianne',)),)),)), - ('brig', (('en', 'military', (('abbreviation', True), ('attaches', ('gen', 'general', 'sir')), ('same_as', 'brigadier'))), ('en', 'given', ()))), - ('brigadier', (('en', 'military', (('attaches', ('gen',)),)),)), + ('brig', (('en', 'military', (('abbreviation', True), ('attaches', ('gen', 'general', 'sir')), ('same_as', 'brigadier'))), ('en', 'given', ()), ('my', 'military', (('abbreviation', True), ('attaches', ('gen', 'general', 'sir')), ('default', False), ('same_as', 'brigadier'))))), + ('brigadier', (('en', 'military', (('attaches', ('gen',)),)), ('my', 'military', (('attaches', ('gen',)), ('default', False))))), ('briggen', (('en', 'military', (('same_as', 'bg'),)),)), ('brit', (('en', 'familiar', (('short_for', ('brittany',)),)),)), ('british', (('en', 'modifier', ()),)), @@ -412,8 +412,8 @@ ('capm', (('en', 'credential', ()),)), ('capp', (('en', 'credential', ()), ('en', 'given', ()), ('en', 'family', ()))), ('caps', (('en', 'credential', ()),)), - ('capt', (('en', 'military', (('same_as', 'captain'),)),)), - ('captain', (('en', 'military', ()),)), + ('capt', (('en', 'military', (('same_as', 'captain'),)), ('my', 'military', (('default', False), ('same_as', 'captain'))))), + ('captain', (('en', 'military', ()), ('my', 'military', (('default', False),)))), ('cardinal', (('en', 'religious', ()),)), ('cardiologist', (('en', 'occupation', ()),)), ('caridad', (('es', 'given', (('after_particle', True),)),)), @@ -483,7 +483,7 @@ ('cdfm', (('en', 'credential', ()),)), ('cdmp', (('en', 'credential', ()),)), ('cdn', (('en', 'credential', ()),)), - ('cdr', (('en', 'military', (('same_as', 'commander'),)),)), + ('cdr', (('en', 'military', (('same_as', 'commander'),)), ('my', 'military', (('default', False), ('same_as', 'commander'))))), ('cds', (('en', 'credential', ()),)), ('cdt', (('en', 'credential', ()),)), ('cea', (('en', 'credential', ()), ('en', 'family', ()))), @@ -623,16 +623,16 @@ ('co-chairs', (('en', 'office', (('same_as', 'co-chair'),)),)), ('co-founder', (('en', 'occupation', ()),)), ('coach', (('en', 'occupation', ()),)), - ('col', (('en', 'military', (('attaches', ('gen',)), ('same_as', 'colonel'))),)), + ('col', (('en', 'military', (('attaches', ('gen',)), ('same_as', 'colonel'))), ('my', 'military', (('attaches', ('gen',)), ('default', False), ('same_as', 'colonel'))))), ('collector', (('en', 'occupation', ()),)), - ('colonel', (('en', 'military', (('attaches', ('gen',)),)),)), + ('colonel', (('en', 'military', (('attaches', ('gen',)),)), ('my', 'military', (('attaches', ('gen',)), ('default', False))))), ('comedian', (('en', 'occupation', ()),)), ('comedienne', (('en', 'occupation', ()),)), ('comic', (('en', 'occupation', ()),)), - ('commander', (('en', 'military', ()),)), + ('commander', (('en', 'military', ()), ('my', 'military', (('default', False),)))), ('commander-in-chief', (('en', 'military', ()),)), ('commissioner', (('en', 'office', ()),)), - ('commodore', (('en', 'military', ()),)), + ('commodore', (('en', 'military', ()), ('my', 'military', (('default', False),)))), ('composer', (('en', 'occupation', ()),)), ('compositeur', (('fr', 'occupation', ()),)), ('comptroller', (('en', 'office', (('attaches', ('gen',)),)),)), @@ -1173,9 +1173,9 @@ ('geboren', (('nl', 'birth_marker', ()),)), ('geborene', (('de', 'birth_marker', ()),)), ('ged', (('en', 'familiar', (('short_for', ('gerard',)),)),)), - ('gen', (('en', 'military', (('abbreviation', True), ('attaches', ('sir',)), ('same_as', 'general'))), ('en', 'given', ()), ('en', 'family', ()))), + ('gen', (('en', 'military', (('abbreviation', True), ('attaches', ('sir',)), ('same_as', 'general'))), ('en', 'given', ()), ('en', 'family', ()), ('my', 'military', (('abbreviation', True), ('attaches', ('sir',)), ('default', False), ('same_as', 'general'))))), ('gene', (('en', 'familiar', (('short_for', ('eugene',)),)),)), - ('general', (('en', 'military', ()),)), + ('general', (('en', 'military', ()), ('my', 'military', (('default', False),)))), ('generalissimo', (('en', 'military', ()),)), ('gent.le', (('it', 'style', (('cased', 'Gent.le'),)),)), ('gent.ma', (('it', 'style', (('cased', 'Gent.ma'),)),)), @@ -1584,7 +1584,7 @@ ('licenciado', (('es', 'academic', ()),)), ('licsw', (('en', 'credential', ()),)), ('lidiya', (('ru', 'spelling', (('spelling_of', ('lidia', 'lidiia')),)),)), - ('lieutenant', (('en', 'military', (('attaches', ('gen',)),)),)), + ('lieutenant', (('en', 'military', (('attaches', ('gen',)),)), ('my', 'military', (('attaches', ('gen',)), ('default', False))))), ('liliia', (('ru', 'spelling', (('spelling_of', ('lilia',)),)), ('uk', 'spelling', (('spelling_of', ('lilia',)),)))), ('liliya', (('ru', 'spelling', (('spelling_of', ('lilia', 'liliia')),)), ('uk', 'spelling', (('spelling_of', ('liliia',)),)))), ('lilly', (('en', 'familiar', (('short_for', ('lillian',)),)),)), @@ -1634,7 +1634,7 @@ ('lsi', (('en', 'credential', ()),)), ('lsit', (('en', 'credential', ()),)), ('lsw', (('en', 'credential', ()),)), - ('lt', (('en', 'military', (('attaches', ('gen',)), ('same_as', 'lieutenant'))), ('en', 'credential', ()))), + ('lt', (('en', 'military', (('attaches', ('gen',)), ('same_as', 'lieutenant'))), ('en', 'credential', ()), ('my', 'military', (('attaches', ('gen',)), ('default', False), ('same_as', 'lieutenant'))), ('my', 'credential', (('default', False),)))), ('ltc', (('en', 'military', ()),)), ('ltcol', (('en', 'military', (('same_as', 'ltc'),)),)), ('ltg', (('en', 'military', ()),)), @@ -1727,10 +1727,10 @@ ('mahdiyeh', (('fa', 'spelling', (('spelling_of', ('mahdieh',)),)),)), ('mahmoud', (('en', 'spelling', (('spelling_of', ('mahmood',)),)), ('fa', 'spelling', (('spelling_of', ('mahmood',)),)))), ('maid', (('en', 'occupation', (('addresses', 'given'),)),)), - ('maj', (('en', 'military', (('abbreviation', True), ('attaches', ('gen', 'general', 'sir')))), ('en', 'given', ()), ('en', 'family', ()))), + ('maj', (('en', 'military', (('abbreviation', True), ('attaches', ('gen', 'general', 'sir')))), ('en', 'given', ()), ('en', 'family', ()), ('my', 'military', (('abbreviation', True), ('attaches', ('gen', 'general', 'sir')), ('default', False))))), ('majesty', (('en', 'style', ()), ('en', 'given', ()))), ('majgen', (('en', 'military', (('same_as', 'mg'),)),)), - ('major', (('en', 'military', (('attaches', ('gen', 'general')),)), ('en', 'given', ()), ('en', 'family', ()))), + ('major', (('en', 'military', (('attaches', ('gen', 'general')),)), ('en', 'given', ()), ('en', 'family', ()), ('my', 'military', (('attaches', ('gen', 'general')), ('default', False))))), ('mal', (('en', 'familiar', (('short_for', ('malcolm',)),)),)), ('malam', (('ha', 'given', ()), ('ha', 'family', ()))), ('manaes', (('en', 'credential', (('cased', 'MAnaes'),)),)), @@ -2341,7 +2341,7 @@ ('rdml', (('en', 'military', (('same_as', 'radm'),)),)), ('rdms', (('en', 'credential', ()),)), ('rdn', (('en', 'credential', ()),)), - ('rear', (('en', 'modifier', ()),)), + ('rear', (('en', 'modifier', ()), ('my', 'modifier', (('default', False),)))), ('rebbe', (('yi', 'religious', ()),)), ('reggie', (('en', 'familiar', (('short_for', ('reginald',)),)),)), ('registered', (('en', 'modifier', ()),)), @@ -2483,7 +2483,7 @@ ('senhor', (('pt', 'salutation', (('after_given', True),)),)), ('senhora', (('pt', 'salutation', (('after_given', True),)),)), ('senhorita', (('pt', 'salutation', (('after_given', True),)),)), - ('senior', (('en', 'modifier', ()),)), + ('senior', (('en', 'modifier', ()), ('my', 'modifier', (('default', False),)))), ('senior-judge', (('en', 'office', ()),)), ('sepideh', (('fa', 'spelling', (('spelling_of', ('sepide',)),)),)), ('sergeant', (('en', 'military', (('attaches', ('maj', 'major')),)),)), @@ -2536,7 +2536,7 @@ ('singer', (('en', 'occupation', ()),)), ('singer-songwriter', (('en', 'occupation', ()),)), ('singh', (('mul', 'family', (('shared', True),)),)), - ('sir', (('en', 'nobility', (('addresses', 'given'),)),)), + ('sir', (('en', 'nobility', (('addresses', 'given'),)), ('my', 'nobility', (('addresses', 'given'), ('default', False))))), ('sister', (('en', 'religious', (('addresses', 'given'),)),)), ('sk', (('bn', 'given', (('same_as', 'sheikh'),)),)), ('skom', (('id', 'credential', (('cased', 'SKom'),)),)), @@ -2808,7 +2808,7 @@ ('vet', (('en', 'status', ()),)), ('vic', (('en', 'familiar', (('short_for', ('victor', 'victoria')),)),)), ('vicar', (('en', 'religious', (('attaches', ('gen',)),)),)), - ('vice', (('en', 'modifier', ()),)), + ('vice', (('en', 'modifier', ()), ('my', 'modifier', (('default', False),)))), ('vicki', (('en', 'familiar', (('short_for', ('victoria',)),)),)), ('vickie', (('mul', 'familiar', (('short_for', ('victoria',)),)),)), ('vicky', (('el', 'familiar', (('short_for', ('vasiliki',)),)), ('en', 'familiar', (('short_for', ('vasiliki', 'victoria')),)))), diff --git a/nameparser/locales/AGENTS.md b/nameparser/locales/AGENTS.md index 2a0d79a28..8839f1a65 100644 --- a/nameparser/locales/AGENTS.md +++ b/nameparser/locales/AGENTS.md @@ -11,6 +11,7 @@ Decide which layer the vocabulary belongs in, if the pack carries any. - **Self-selecting vocabulary is default-safe, and belongs in the default lexicon.** Self-selecting means able to match only text of the tradition it came from, the way a hangul surname can only ever match hangul. It goes in `nameparser/vocab/*.toml` (a segmentation surname list such as the Korean one, in `nameparser/config/_ko_surnames.py`, is read as `Lexicon.default().surnames`) rather than in a pack: a pack nobody knows to ask for is vocabulary nobody gets. - **Vocabulary that declares a language its script does not belongs in the pack**, where asking for it is the declaration. A Chinese surname list silently mangles the Japanese names written in the same characters. - **A word reading that is right in its language and wrong as a default** is written in that language's vocabulary file with `default = false` (`nameparser/vocab/README.md`, Properties), and the pack's `languages` turns it on; the pack module lists nothing (`nameparser/locales/hi.py`). +- **Before a pack removes another language's readings, measure a strict choice of its language.** A removal list names other languages' words, so it fails silently in two ways, checked on master `d12af9d6`: removing a reading that is no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name. A strict choice (`parser_for(PACK, strict=True)`) reads no other language's file, so neither can happen to it. Prefer it, with what the language's lists write that strict drops added to the language's own vocabulary file, `default = false` (copies of another file's reading must copy every vocabulary reading of the word, since a choice that holds one drops the other files', as `my.toml`'s `lt` copies `en.toml`'s credential with its rank). A pack that removes readings records in its docstring why strict would not do; `locales.VI`'s list predates this rule, and strict `vi` was measured beside it in #1483 and left for a later decision (decisions/vocabulary-collisions, the 2026-11-19 #1483 entry). #1231 shipped `locales.MY` with nine particles and a credential removed; #1483 found five syllables the list missed (`PE`, `LAT`, `EI`, `SI`, `PA`), all read right by strict `my`, and the fragment was dropped for strict plus my.toml's English ranks. - **A pack with no list of its own ships an empty `Lexicon`** (`Lexicon.empty()`, as `nameparser/locales/ru.py` does); `nameparser/locales/zh.py` is the template for one that carries a list. Curate vocabulary conservatively, the same rule as the user guide's "Words that are also ordinary names" (docs/customize.rst, label `ambiguous-words`): when you're unsure whether a word or a marker belongs, leave it out. @@ -66,9 +67,9 @@ The shipped packs are the rows of `_REGISTRY` in `nameparser/locales/__init__.py | Policy only, rules from a `[rules]` table, declared by marker regex | `nameparser/locales/ru.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` | +| 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 that changes no word, beside a patch | `nameparser/locales/mn.py` | -| A fragment that takes readings out | `nameparser/locales/vi.py` (`nameparser/locales/my.py` beside a choice alone) | +| A fragment that takes readings out | `nameparser/locales/vi.py` | | A country pack reading its language's `[rules]` table | `nameparser/locales/es_ar.py` | | A country pack writing a `[rules]` table its language's file does not, sharing its list with another country's pack | `nameparser/locales/pt_pt.py` | diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index 6d6cf95bc..49022985f 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -1,28 +1,33 @@ -"""The Burmese locale pack (#1231): it chooses the language ``my``, the +"""The Burmese locale pack (#1231): a choice of the language ``my``, the BCP 47 tag of Burmese (not the country code of Malaysia, whose language -is Malay, ``ms``), which turns on the readings nameparser/vocab/my.toml -writes ``default = false``: the honorifics ``U`` (Mr.) and ``Daw`` -(Mrs.) written before a name, read as titles, so ``U Thein Sein`` gives -title ``U``, given ``Thein``, family ``Sein`` where the default gives -given ``U``, middle ``Thein``. And its lexicon fragment takes out the -particle readings other languages give the syllables Burmese names are -written with, so ``Daw Aung San Suu Kyi`` gives middle ``San Suu``, -family ``Kyi`` where the Spanish ``san`` would take ``San Suu Kyi`` into -the family name. It also takes out ``do``'s credential reading, so a -name written in capitals keeps a final ``DO`` (``AUNG SAN DO`` gives -family ``DO``, where with ``san`` no particle the credential would end -the name). +is Malay, ``ms``), and nothing else. The choice turns on the readings +nameparser/vocab/my.toml writes ``default = false``: the honorifics +``U`` (Mr.) and ``Daw`` (Mrs.) written before a name, read as titles, +so ``U Thein Sein`` gives title ``U``, given ``Thein``, family ``Sein`` +where the default gives given ``U``, middle ``Thein``. Burmese names have no family name: every word is a personal name, and the last one lands in ``family`` by position as it does in any name read positionally. The title vocabulary reads ``U.`` with its full stop as it reads ``U``, so a Western initial can be the title under -the pack too (``U. S. -Grant`` gives title ``U.``, given ``S.``; ``Smith, U.`` and ``Dr. U. -Smith`` give no given name), the accepted cost and the reason to keep -the pack to Burmese names; a bare ``U.`` between two name words stays -an initial (``John U. Smith``). A title and one name word reads the word as the family -name, as everywhere (rules/H1), so ``U Thant`` gives family ``Thant``. +the pack too (``U. S. Grant`` gives title ``U.``, given ``S.``; +``Smith, U.`` and ``Dr. U. Smith`` give no given name), the accepted +cost and the reason to keep the pack to Burmese names; a bare ``U.`` +between two name words stays an initial (``John U. Smith``). A title +and one name word reads the word as the family name, as everywhere +(rules/H1), so ``U Thant`` gives family ``Thant``. + +**A list of nothing but Burmese names is read with the strict +choice**, ``parser_for(locales.MY, strict=True)`` (#1483): it reads no +other language's file, so the syllables Burmese names are written with +lose the particle and credential readings Spanish, Italian, Dutch or +English give them (``Aung San Win`` gives middle ``San``, family +``Win``; ``THEIN AUNG PE`` keeps family ``PE``), and the English ranks +and ``Sir`` such lists write are my.toml's own readings +(``Lt Gen``, ``Senior General``). The plain choice reads those +syllables as other languages do (``Aung San Win`` gives family ``San +Win``, as by default): it suits a list mixing Burmese names with +others, whose particles and credentials a strict choice would cost. Left as name words: the honorifics ``Ko``, ``Ma`` and ``Maung``, which are also name syllables (``Maung Maung Kyaw``), and the ethnic prefixes @@ -30,67 +35,20 @@ military and religious styles (``Bogyoke``, ``Sayadaw``), each rare (decisions/vocabulary-collisions, the 2026-11-19 #1231 entry). -The fragment removes readings, as ``locales.VI``'s does, the one kind -of pack content that may: a choice prefers only by a vocabulary reading, and a -name reading never settles a clash (decision 15 of -decisions/vocabulary-model), so no reading my.toml could write makes -``san`` a name word under a plain choice. The removals cost a caller who -applies the pack to names that are not Burmese those nine words' -particle readings in Spanish, Italian, Portuguese, French, Filipino, -Dutch and Māori surnames (``Juan de la Cruz`` keeps ``de la Cruz``, -``de`` not being among them, but ``Maria la Torre``, ``Jan van Dijk`` -and ``Kiri Te Kanawa`` lose theirs, and ``Van Buren, Ed`` reads ``Ed`` -as a credential, its given name lost, as a given part of initials can -be after one) and the credential DO -(``Jane Doe, DO`` gives given ``DO``), the measured cost in the -decisions entry. - Data sources: the honorifics' vetting is on the words in my.toml -(tools/name_usage.py); the syllables were measured on OpenSanctions' +(tools/name_usage.py); the strict choice was measured on OpenSanctions' sanctions and PEP records of Myanmar and Wikidata's labels of people -with Myanmar citizenship, in the decisions entry. +with Myanmar citizenship, in decisions/vocabulary-collisions (the +2026-11-19 #1483 entry). -Declared deviations (mechanisms.md#LOCALE-PACKS-PURE-DATA): the -choice's own words, ``u`` and ``daw``, are derived -(``_reading_index.changed_words``), which the non-interference gate in -tests/v2/test_locales.py ors in; DEVIATES below declares what the -fragment changes, every name holding one of its syllables as a word -(``do`` among them). +Declared deviations (mechanisms.md#LOCALE-PACKS-PURE-DATA): none. The +pack is nothing but a choice, whose words (``u`` and ``daw``) are +derived (``_reading_index.changed_words``), so it declares no +DEVIATES. """ from __future__ import annotations from nameparser._lexicon import Lexicon from nameparser._locale import Locale -#: Syllables of Burmese names that another language's file reads as a -#: particle: San (Aung San), La, Le, Do, Da, Du, Te, Di, and Van, a -#: syllable of Chin names (#1231) -_PARTICLES = ("da", "di", "do", "du", "la", "le", "san", "te", "van") - -#: and as a credential, which the particle chain had kept from ending a -#: name written in capitals (``AUNG SAN DO``): Do -_CREDENTIALS = ("do",) - -_SYLLABLES = frozenset(_PARTICLES + _CREDENTIALS) - -MY = Locale( - code="my", - lexicon=(Lexicon.empty() - .remove(*_PARTICLES, kind="particle") - .remove(*_CREDENTIALS, kind="credential")), - languages=frozenset({"my"}), -) - - -def DEVIATES(name: str) -> bool: - """True when this pack's fragment may parse `name` differently from - the default parser (the declared-deviation predicate the - non-interference gate consumes): a name holding one of the - syllables whose particle reading the fragment takes out as a word - of its own, cut at every character that is no letter or digit, so - the halves of a hyphenated or apostrophized word and a word written - with its full stop count too (over-declaring, the safe direction). - Cut without a pattern: the pack contract reads a module that - imports ``re`` as one declaring by marker regex.""" - words = "".join(c if c.isalnum() else " " for c in name.lower()).split() - return not _SYLLABLES.isdisjoint(words) +MY = Locale(code="my", lexicon=Lexicon.empty(), languages=frozenset({"my"})) diff --git a/nameparser/vocab/AGENTS.md b/nameparser/vocab/AGENTS.md index 065da4126..740e20ca5 100644 --- a/nameparser/vocab/AGENTS.md +++ b/nameparser/vocab/AGENTS.md @@ -58,4 +58,4 @@ Every strict choice reads `mul.toml` (#1005), so a word there is read in names o ## A reading taken out: what it used to override -Taking a reading out of a word, by a `remove` in a pack's fragment or by moving it between files, leaves the readings it used to override to act, the word's own others and its neighbours', and a grid in mixed case does not show it. #1108's fragment took `van`'s particle reading out under `locales.VI`, and `NGUYEN VAN DO` then read suffix 'DO': the `van` chain had kept `DO`'s credential reading from ending the name, and only the code review's one-case row found it, every grid row being mixed case or a syllable no file holds. List every reading the word and the words it chained keep (`uv run python tools/vocab/query.py --word `), and parse each removed word with the word it used to absorb ending the name, in one case, beside a mixed-case control; then parse it after a family comma, where an order a pack sets reads nothing differently and the removal still acts (`Beethoven, Ludwig van` under `locales.VI`, found by #1108's second design-docs review). Put a removed particle in the family before a comma in the grid too, with a short given name and with initials after the comma: it had kept the given part from reading as a credential, and #1231's `locales.MY` read `Van Buren, Ed` given 'Van', suffix 'Ed' and `De La Cruz, M.J. K.L.` suffix 'M.J. K.L.', found only by its last reviews. And before proposing a name reading to settle a clash under a language choice, check that the reading is a vocabulary one: `choose` prefers only by those, and a `given` or `family` reading never settles (decision 15 of decisions/vocabulary-model), the premise #1108 was filed on. +Taking a reading out of a word, by a `remove` in a pack's fragment or by moving it between files, leaves the readings it used to override to act, the word's own others and its neighbours', and a grid in mixed case does not show it. #1108's fragment took `van`'s particle reading out under `locales.VI`, and `NGUYEN VAN DO` then read suffix 'DO': the `van` chain had kept `DO`'s credential reading from ending the name, and only the code review's one-case row found it, every grid row being mixed case or a syllable no file holds. List every reading the word and the words it chained keep (`uv run python tools/vocab/query.py --word `), and parse each removed word with the word it used to absorb ending the name, in one case, beside a mixed-case control; then parse it after a family comma, where an order a pack sets reads nothing differently and the removal still acts (`Beethoven, Ludwig van` under `locales.VI`, found by #1108's second design-docs review). Put a removed particle in the family before a comma in the grid too, with a short given name and with initials after the comma: it had kept the given part from reading as a credential, and #1231's `locales.MY`, under the fragment #1483 later dropped for a strict choice, read `Van Buren, Ed` given 'Van', suffix 'Ed' and `De La Cruz, M.J. K.L.` suffix 'M.J. K.L.', found only by its last reviews. And before proposing a name reading to settle a clash under a language choice, check that the reading is a vocabulary one: `choose` prefers only by those, and a `given` or `family` reading never settles (decision 15 of decisions/vocabulary-model), the premise #1108 was filed on. diff --git a/nameparser/vocab/my.toml b/nameparser/vocab/my.toml index 946929bef..bf98c704a 100644 --- a/nameparser/vocab/my.toml +++ b/nameparser/vocab/my.toml @@ -8,6 +8,91 @@ salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1 text = "u" salutation = { default = false, gender = "m", native = "ဦး", issue = 1231, expands = "U, the honorific written before a man's name (Mr.)", note = "a Korean surname (Wikidata 154 family, South Korea 122; 12 given, 2026-11-19) and, written with its full stop, an initial, which the reading can take as the title under the pack (U. S. Grant, Smith, U.), the accepted cost (decisions/vocabulary-collisions, the 2026-11-19 #1231 entry). Written bare by Burmese names as a rule (U Thein Sein; 1 of the 71 names opening with the honorific in the #1231 population writes U.); FEC writes U 187 times and U. 163, 320 of the 351 after a comma; ctgov-officials U 260, U. 61 (tools/name_usage.py, 2026-11-19)" } +[[word]] +text = "sir" +nobility = { default = false, addresses = "given", gender = "m", expands = "a knight or baronet, 'Sir John'", issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. the colonial knighthoods (Sir U ..., a title run with the honorific): once in the #1231 population; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "admiral" +military = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Admiral, the Navy's rank: once in the #1231 population (Vice Senior General's navy kin, Admiral, Vice Admiral, Rear Admiral); ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "adm" +military = { default = false, same_as = "admiral", issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Adm, as staff lists write it; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "brigadier" +military = { default = false, attaches = ["gen"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Brigadier General; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "brig" +military = { default = false, same_as = "brigadier", abbreviation = true, attaches = ["gen", "general", "sir"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Brig Gen, as staff lists write it; en.toml's given reading stays out of a strict choice; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "captain" +military = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Captain; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "capt" +military = { default = false, same_as = "captain", issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Capt, as staff lists write it; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "colonel" +military = { default = false, attaches = ["gen"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Colonel and Lieutenant Colonel; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "col" +military = { default = false, same_as = "colonel", attaches = ["gen"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Col and Lt Col, as staff lists write them; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "commander" +military = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Commander, a rank and a regional command's head; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "cdr" +military = { default = false, same_as = "commander", issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Cdr, as staff lists write it; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "commodore" +military = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Commodore, the Navy's rank; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "general" +military = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. the #1231 population writes General 7 times (Senior General, Lieutenant General); ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "gen" +military = { default = false, same_as = "general", abbreviation = true, attaches = ["sir"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Gen, as staff lists write it (Lt Gen, Maj Gen, Brig Gen); en.toml's given reading, a Japanese and Chinese name, stays out of a strict choice, so a bare Gen opening a name is the rank there; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "lieutenant" +military = { default = false, attaches = ["gen"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Lieutenant General: 3 times in the #1231 population; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "lt" +military = { default = false, same_as = "lieutenant", attaches = ["gen"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Lt Gen and Lt Col, as staff lists write them; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } +credential = { default = false, issue = 1483, note = "en.toml's credential, copied with the rank: a choice that holds a vocabulary reading of a word drops every other file's, so without it a plain choice of Burmese would read John Smith, LT as the title" } + +[[word]] +text = "maj" +military = { default = false, expands = "Major", abbreviation = true, attaches = ["gen", "general", "sir"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Maj Gen, as staff lists write it; en.toml's given reading stays out of a strict choice; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "major" +military = { default = false, attaches = ["gen", "general"], issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Major General and Major; en.toml's given reading stays out of a strict choice, so a bare Major opening a name is the rank there; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "rear" +modifier = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Rear Admiral; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "senior" +modifier = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Senior General, the Tatmadaw's highest rank: the #1231 population writes it twice; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + +[[word]] +text = "vice" +modifier = { default = false, issue = 1483, note = "en.toml's reading, here so a strict choice of Burmese keeps it (#1483), which reads no en.toml; the vetting is on the en.toml entry. Vice Senior General: once in the #1231 population; ORCID's Myanmar given and family boxes hold it 0 times of 1,755 holders (tools/name_usage.py --country MM, 2026-11-19)" } + [[word]] text = "ဂျူနီယာ" generation = { issue = 679 } diff --git a/tests/v2/cases.py b/tests/v2/cases.py index e994ec758..89c122d27 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1116,11 +1116,14 @@ def _check_cjk_shape_purity(self) -> None: {"title": "U", "given": "Thein", "family": "Sein"}, locale="my", classification="feat(#1231)", notes="1.4.0 through 3.1.0 read given 'U', middle 'Thein'"), - Case("the_burmese_pack_reads_daw_as_the_title_and_san_as_a_name_word", + Case("the_burmese_pack_reads_daw_as_the_title", "Daw Aung San Suu Kyi", - {"title": "Daw", "given": "Aung", "middle": "San Suu", "family": "Kyi"}, + {"title": "Daw", "given": "Aung", "family": "San Suu Kyi"}, locale="my", classification="feat(#1231)", - notes="1.4.0 through 3.1.0 read given 'Daw', family 'San Suu Kyi'"), + notes="san keeps its particle reading under the plain choice, as " + "by default; the strict choice reads it as a name word, " + "family 'Kyi' (#1483); 1.4.0 through 3.1.0 read given " + "'Daw', family 'San Suu Kyi'"), Case("the_burmese_pack_reads_the_honorific_after_a_family_comma", "Sein, U Thein", {"title": "U", "given": "Thein", "family": "Sein"}, @@ -1132,19 +1135,6 @@ def _check_cjk_shape_purity(self) -> None: locale="my", classification="feat(#1231)", notes="a title and one name word, the word the family (rules/H1); " "1.4.0 through 3.1.0 read given 'U', family 'Thant'"), - Case("the_burmese_pack_keeps_a_chin_van_a_name_word", - "Henry Van Thio", - {"given": "Henry", "middle": "Van", "family": "Thio"}, - locale="my", classification="feat(#1231)", - notes="the fragment takes out van's particle reading; 1.4.0 through " - "3.1.0 read family 'Van Thio'"), - Case("the_burmese_pack_keeps_san_a_name_word_after_a_family_comma", - "AUNG, Saw San", - {"given": "Saw", "middle": "San", "family": "AUNG"}, - locale="my", classification="parity", - notes="rules/P6's trailing attachment has no particle to attach; " - "1.4.0 and 2.0.0 read the same fields, 2.4.0 through 3.1.0 " - "family 'San AUNG'"), Case("the_burmese_pack_reads_u_with_its_full_stop_as_the_title", "U. Thein Sein", {"title": "U.", "given": "Thein", "family": "Sein"}, @@ -1160,12 +1150,6 @@ def _check_cjk_shape_purity(self) -> None: "(decisions/vocabulary-collisions, the #1231 entry): the " "reason not to apply the pack to a mixed list; 1.4.0 through " "3.1.0 read given 'U.', middle 'S.'"), - Case("the_burmese_pack_costs_a_dutch_particle", - "Jan van Dijk", - {"given": "Jan", "middle": "van", "family": "Dijk"}, - locale="my", classification="feat(#1231)", - notes="the cost of applying the pack to names that are not Burmese " - "(docs/languages.rst); the default reads family 'van Dijk'"), # #1257: the Maghrebi and Hebrew particles, each row checked against # the 1.4.0 wheel and master 161ebd28 on 2026-11-12 Case("an_amazigh_ait_starts_the_family_name", diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 716038747..84446e43b 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -690,97 +690,112 @@ def test_vi_differs_from_the_default_where_the_default_reads_given_first() -> No def test_my_pack_contents() -> None: - # a choice of my, which turns on the honorifics, and a fragment that - # only removes particle readings (decisions/vocabulary-collisions, - # the 2026-11-19 #1231 entry); no policy patch + # a choice of my and nothing else: no fragment and no policy patch, + # the fragment of #1231 dropped for the strict choice (#1483; + # decisions/vocabulary-collisions, the 2026-11-19 #1483 entry) import pickle - assert locales.MY.languages == {"my"} - assert locales.MY.policy == PolicyPatch() + assert locales.MY == Locale(code="my", lexicon=Lexicon.empty(), + languages=frozenset({"my"})) + assert not hasattr(_my, "DEVIATES") assert _ri.changed_words(_ri.selected(locales.MY.languages)) == {"u", "daw"} sets = _require_packed("my").lexicon._sets - assert not set(_my._PARTICLES) & sets.particles - assert not set(_my._CREDENTIALS) & sets.suffix_acronyms - # the particles and credentials it leaves - assert {"de", "von", "del", "bin", "mac"} <= sets.particles - assert {"md", "ma", "ba", "phd"} <= sets.suffix_acronyms assert {"u", "daw"} <= sets.titles assert not {"u", "daw"} & Lexicon.default()._sets.titles assert pickle.loads(pickle.dumps(locales.MY)) == locales.MY parser = pickle.loads(pickle.dumps(parser_for(locales.MY))) assert parser.parse("U Thein Sein").title == "U" - assert _my.DEVIATES("Aung San Win") and _my.DEVIATES("SAN-MARTIN") - assert not _my.DEVIATES("Sandra Lee") and not _my.DEVIATES("Thein Sein") - - -#: Each reading the MY fragment removes, with a name its removal alone -#: moves: the syllable between two name words, which its particle -#: reading would chain into the family name, and DO ending a name -#: written in capitals, which its credential reading would take as the -#: suffix once SAN no longer chains it (nameparser/vocab/AGENTS.md, "A -#: reading taken out") -_MY_REMOVALS = [ - ("san", "particle", "Aung San Win"), ("la", "particle", "Akyaung La Aung"), - ("le", "particle", "Saw Eh Le Htoo"), ("do", "particle", "Htan Do Kyint"), - ("da", "particle", "Thi Da Oo"), ("du", "particle", "Swam Du Naw Aung"), - ("te", "particle", "Kyauk Te Chan"), ("di", "particle", "Aung Di Win"), - ("van", "particle", "Henry Van Thio"), - ("do", "credential", "AUNG SAN DO"), -] - - -def test_each_my_removal_moves_its_own_row() -> None: - # the negative control for the fragment, as VI's: with one removal - # put back, the row that witnesses it reads otherwise - lists = {"particle": _my._PARTICLES, "credential": _my._CREDENTIALS} - assert sorted((w, k) for w, k, _ in _MY_REMOVALS) == sorted( - (w, k) for k, words in lists.items() for w in words) - my = _require_packed("my") - def put_back(removal: tuple[str, str] | None) -> Parser: - lexicon = Lexicon.empty() - for k, words in lists.items(): - if kept := [w for w in words if (w, k) != removal]: - lexicon = lexicon.remove(*kept, kind=k) - return parser_for(dataclasses.replace(locales.MY, lexicon=lexicon)) - rebuilt = put_back(None) - for word, kind, text in _MY_REMOVALS: - assert rebuilt.parse(text).as_dict() == my.parse(text).as_dict(), text - assert put_back((word, kind)).parse(text).as_dict() != my.parse( - text).as_dict(), (word, kind, text) - assert len(my.parse(text).family.split()) == 1, text +@pytest.mark.parametrize("text, given, middle, family, suffix", [ + # #1483: a strict choice reads no other language's file, so a + # Burmese syllable another language reads as a particle or a + # credential is a name word, between two name words, after a comma + # and ending a name written in capitals; the plain pack reads each + # as the default does + ("Aung San Win", "Aung", "San", "Win", ""), + ("Henry Van Thio", "Henry", "Van", "Thio", ""), + ("KYAW, AUNG DO", "AUNG", "DO", "KYAW", ""), + ("THEIN AUNG PE", "THEIN", "AUNG", "PE", ""), + ("THEIN AUNG LAT", "THEIN", "AUNG", "LAT", ""), + ("Thein Aung Ra", "Thein", "Aung", "Ra", ""), + # #1232: Mg, a title by default, is the given name + ("Mg Htoo Aung", "Mg", "Htoo", "Aung", ""), +]) +def test_my_strict_reads_the_syllables_as_name_words( + text: str, given: str, middle: str, family: str, suffix: str) -> None: + name = parser_for(locales.MY, strict=True).parse(text) + assert (name.given, name.middle, name.family, name.suffix) == ( + given, middle, family, suffix) + assert _require_packed("my").parse(text).as_dict() == _default_parse(text) + assert name.as_dict() != _default_parse(text) + + +@pytest.mark.parametrize("text, title", [ + # #1483: the English ranks and Sir Burmese lists write are my.toml's + # own readings, so a strict choice keeps them, bare and written short, + # at the head and after a family comma, as the default and the plain + # pack read them + ("Senior General Kyaw Win", "Senior General"), + ("Vice Senior General Kyaw Win", "Vice Senior General"), + ("Lieutenant General Kyaw Win", "Lieutenant General"), + ("Lt Gen Kyaw Win", "Lt Gen"), + ("Maj Gen Kyaw Win", "Maj Gen"), + ("Brig Gen Kyaw Win", "Brig Gen"), + ("Major General Kyaw Win", "Major General"), + ("Lt Col Kyaw Win", "Lt Col"), + ("Col Kyaw Win", "Col"), + ("Capt Kyaw Win", "Capt"), + ("Rear Admiral Kyaw Win", "Rear Admiral"), + ("Adm Kyaw Win", "Adm"), + ("Commodore Kyaw Win", "Commodore"), + ("Cdr Kyaw Win", "Cdr"), + ("Win, Lt Gen Kyaw", "Lt Gen"), + ("Kyaw Win, Maj Gen", "Maj Gen"), + ("Sir U Kyaw Win", "Sir U"), +]) +def test_my_strict_keeps_the_ranks(text: str, title: str) -> None: + strict = parser_for(locales.MY, strict=True).parse(text) + plain = _require_packed("my").parse(text) + assert strict.title == plain.title == title + assert strict.as_dict() == plain.as_dict() @pytest.mark.parametrize("text, given, family, suffix", [ - # the accepted cost of a removed particle in the family before a - # comma: it no longer keeps the given part after the comma from - # reading as a credential (decisions/vocabulary-collisions, the - # 2026-11-19 #1231 entry) - ("Van Buren, Ed", "Van", "Buren", "Ed"), - ("De La Cruz, Ed", "", "De La Cruz", "Ed"), - ("De La Cruz, M.J. K.L.", "", "De La Cruz", "M.J. K.L."), + # the rank readings are written default = false, so the default + # never reads them, and copies of en.toml's, so the plain pack, which + # prefers them, reads as the default does: a rank en.toml gates by a + # given name stays a given name, and lt's credential, copied with + # its rank, stays the suffix + ("Gen Goto", "Gen", "Goto", ""), + ("Major Smith", "Major", "Smith", ""), + ("Maj Sjöwall", "Maj", "Sjöwall", ""), + ("John Smith, LT", "John", "Smith", "LT"), ]) -def test_my_costs_a_given_name_after_a_particle_and_a_comma( +def test_my_rank_readings_move_no_plain_parse( text: str, given: str, family: str, suffix: str) -> None: name = _require_packed("my").parse(text) - assert (name.given, name.family, name.suffix) == (given, family, suffix) - assert _default_parse(text)["given"] - - -@pytest.mark.parametrize("text, middle, family", [ - # the credential DO, which SAN's particle chain kept from ending a - # name written in capitals, in each comma shape, beside the mixed-case - # control (nameparser/vocab/AGENTS.md, "A reading taken out") - ("AUNG SAN DO", "SAN", "DO"), - ("Aung San Do", "San", "Do"), - ("KYAW, AUNG DO", "DO", "KYAW"), - ("Kyaw, Aung Do", "Do", "Kyaw"), - ("DAW KHIN MYA DO", "MYA", "DO"), + assert (name.title, name.given, name.family, name.suffix) == ( + "", given, family, suffix) + assert name.as_dict() == _default_parse(text) + + +@pytest.mark.parametrize("text, title, given, family, suffix", [ + # what a strict choice costs a name that is not Burmese, the reason + # the plain pack stays for a mixed list (decisions/vocabulary- + # collisions, the 2026-11-19 #1483 entry): the given names en.toml + # gates the ranks by are not read, nor the credentials Burmese lists + # do not write, so a credential after a comma reads as a given name + ("Gen Goto", "Gen", "", "Goto", ""), + ("Major Smith", "Major", "", "Smith", ""), + ("Jane Doe, PA", "", "PA", "Jane Doe", ""), + ("Juan de la Cruz", "", "Juan", "Cruz", ""), ]) -def test_my_keeps_a_final_do_a_name_word( - text: str, middle: str, family: str) -> None: - name = _require_packed("my").parse(text) - assert (name.middle, name.family, name.suffix) == (middle, family, "") +def test_my_strict_costs_a_name_that_is_not_burmese( + text: str, title: str, given: str, family: str, suffix: str) -> None: + name = parser_for(locales.MY, strict=True).parse(text) + assert (name.title, name.given, name.family, name.suffix) == ( + title, given, family, suffix) + assert _require_packed("my").parse(text).as_dict() == _default_parse(text) @pytest.mark.parametrize("order", [GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) @@ -849,13 +864,15 @@ def test_my_reads_u_written_with_its_full_stop_as_the_title_vocabulary_does( def test_my_differs_from_the_default_only_through_its_words() -> None: - # the honorifics and syllables move a name; a Burmese name holding - # none of them reads as the default reads it, its last word the family + # the honorifics move a name; a Burmese name holding neither reads + # as the default reads it, its last word the family, its syllables + # and ranks included (a strict choice reads those, #1483) my = _require_packed("my") for text in ("Thein Sein", "Min Aung Hlaing", "Maung Maung Kyaw", - "Ko Ko Lwin", "Saw Ba Hline", "Sai Lone Hsai"): + "Ko Ko Lwin", "Saw Ba Hline", "Sai Lone Hsai", + "Aung San Win", "THEIN AUNG PE", "Lt Gen Kyaw Win"): assert my.parse(text).as_dict() == _default_parse(text), text - for text in ("U Thein Sein", "Daw Aung San Suu Kyi", "Aung San Win"): + for text in ("U Thein Sein", "Daw Aung San Suu Kyi", "Sir U Kyaw Win"): assert my.parse(text).as_dict() != _default_parse(text), text @@ -2184,27 +2201,15 @@ def _default_corpus() -> list[str]: "John Smith, VD", # vd after a comma ] # my (#1231): each honorific at the head, in each case and after a -# family comma; each syllable the fragment takes out, between two name -# words, as a word of its own after a comma and in one case +# family comma, and behind a title (the ranks my.toml copies from +# en.toml move no plain parse, so no rotator holds them: #1483's tests) _ROTATORS["my"] = [ "U Thein Sein", # u "Daw Khin Mya", # daw "DAW KHIN MYA", # daw, in one case "Sein, U Thein", # u after a family comma - "Aung San Win", # san - "Akyaung La Aung", # la - "Saw Eh Le Htoo", # le - "Htan Do Kyint", # do - "Thi Da Oo", # da - "Swam Du Naw Aung", # du - "Kyauk Te Chan", # te - "Aung Di Win", # di - "Henry Van Thio", # van - "AUNG, Saw San", # san ending the given part - "AUNG SAN WIN", # san, in one case - "AUNG SAN DO", # do's credential, in one case - "KYAW, AUNG DO", # do's credential after a comma "Thein Sein Daw.", # daw, dotted, ending the name (rules/H5) + "Sir U Kyaw Win", # u behind a title ] # hi and bn: each romanized title at the head, in each case, behind a # listed title, after a family comma and before one (rules/H6); a dotted diff --git a/tests/v2/test_reading_index.py b/tests/v2/test_reading_index.py index 082f55f6c..8a78c0653 100644 --- a/tests/v2/test_reading_index.py +++ b/tests/v2/test_reading_index.py @@ -385,7 +385,8 @@ def test_a_file_holding_only_familiar_readings_is_chosen_only_strictly( #: choice of the same tag (decisions/vocabulary-model's 2026-10-30 #753, #: file-strict entry measured 16 words, 27 word-and-tag pairs over 13 #: tags on 2026-10-31; the strict-gap batches of 2026-11-03 moved it, and -#: #345 added hi's sushri, its Odia given name in or.toml). A +#: #345 added hi's sushri, its Odia given name in or.toml; #1483 my's +#: ranks, whose given names only en.toml writes). A #: word leaves this table when a name reading is written in the chosen #: file whose names carry it, and joins it when a chosen file's #: vocabulary reading loses its gate: review each move. @@ -401,6 +402,7 @@ def test_a_file_holding_only_familiar_readings_is_chosen_only_strictly( "hr": {"st"}, "it": {"del", "la", "san", "santa"}, "ms": {"bin", "sultan"}, + "my": {"brig", "gen", "maj", "major"}, "nl": {"den", "ten", "tho"}, "pt": {"da", "do", "santa"}, "pt-BR": {"da", "do", "santa"}, From ed871d5b28013cb5ed248aad89f60584c7bc01e3 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 15:42:35 -0800 Subject: [PATCH 2/3] Address review of the #1483 change: stale fragment docs, supersession marker, counts, test gaps Co-Authored-By: Claude Opus 5.5 --- .../design/decisions/vocabulary-collisions.md | 16 ++-- docs/languages.rst | 25 ++--- docs/locales.rst | 6 +- docs/release_log.rst | 2 +- nameparser/locales/AGENTS.md | 2 +- nameparser/locales/my.py | 2 +- tests/v2/test_locales.py | 91 +++++++++++++++++-- 7 files changed, 113 insertions(+), 31 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 3900378e6..36d03c98b 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -100,7 +100,7 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - **Accepted:** under the pack, a Chinese given name holding `Ten` between two words gives it and the rest to the family (rules/P2's Accepted); a surname-only `Oude Luttikhuis` reads given 'Oude', reported; under a strict Dutch choice a leading `Ten` is the family (`Ten Kao Liu` → family 'Ten Kao Liu'), and so is one opening the given part after a family comma (`Brink, Ten Jan` → family 'Brink Ten Jan', `, Ten Brink` → family 'Ten Brink'), the given name lost; a family name of two Dutch names whose second opens with `ten` keeps only the second under the pack (`Jutte van der Werff ten Bosch` → middle 'van der Werff'), as a second name opening with `ter` does by default; the pack drops the credential VD (`John Smith VD` → family 'VD', and after a comma the whole name, `John Smith, VD` → family 'John Smith VD'). - **Left out:** a kind for Dutch and Low German farm-name qualifiers, and the other qualifiers themselves; `Ten` as a Korean (Koryo-saram), Chinese and Turkish family name written alone, which no reading moves; Dutch `in` (`in 't Veld`), which docs/customize.rst now uses as its example of an unlisted particle; a possibly-given particle opening a name before a suffix comma folds into the family unreported (`Ten Smith, Jr.` under the pack, `Van Smith, Jr.` by default), a shape not settled here. -- 2026-11-19 #1231 — `LOCALES.MY` SHIPS: A BURMESE CHOICE READS `U` AND `DAW` AS TITLES AND TAKES OUT NINE PARTICLE READINGS BURMESE NAMES WRITE AS SYLLABLES. Built on the working answers the 3.2 coordinator gave the issue's five questions, each open to review on the PR under "Decisions to confirm": (1) a pack, as `locales.VI` (#1108), since a vocabulary file cannot remove a reading another file gives (decision 15 of decisions/vocabulary-model); (2) `Ko`, `Ma`, `Maung` and the ethnic prefixes (`Saw`, `Sai`, `Nang`, `Naw`, `Khun`, `Mahn`) stay name words, being name syllables too (`Maung Maung Kyaw`, `Ko Ko Lwin`); (3) `U.` with its full stop stays an initial under the pack, reversed the same day (below); (4) no new machinery for a title and one name word, which reads the word as the family as rules/H1 reads it everywhere (`U Thant` → family 'Thant'); (5) the military and religious styles (`Bogyoke`, `Thura`, `Thakin`, `Sayadaw`, `Ashin`) stay out, `Thakin` opening 7 names in the population below, `Thura` and `Ashin` 4 each, `Bogyoke` none and `Sayadaw` none, the 9 names holding `Sayadaw` writing it after the name. +- 2026-11-19 #1231 (its fragment, the syllables bullet, `DEVIATES` and the fragment's accepted costs, superseded by 2026-11-19 #1483, below) — `LOCALES.MY` SHIPS: A BURMESE CHOICE READS `U` AND `DAW` AS TITLES AND TAKES OUT NINE PARTICLE READINGS BURMESE NAMES WRITE AS SYLLABLES. Built on the working answers the 3.2 coordinator gave the issue's five questions, each open to review on the PR under "Decisions to confirm": (1) a pack, as `locales.VI` (#1108), since a vocabulary file cannot remove a reading another file gives (decision 15 of decisions/vocabulary-model); (2) `Ko`, `Ma`, `Maung` and the ethnic prefixes (`Saw`, `Sai`, `Nang`, `Naw`, `Khun`, `Mahn`) stay name words, being name syllables too (`Maung Maung Kyaw`, `Ko Ko Lwin`); (3) `U.` with its full stop stays an initial under the pack, reversed the same day (below); (4) no new machinery for a title and one name word, which reads the word as the family as rules/H1 reads it everywhere (`U Thant` → family 'Thant'); (5) the military and religious styles (`Bogyoke`, `Thura`, `Thakin`, `Sayadaw`, `Ashin`) stay out, `Thakin` opening 7 names in the population below, `Thura` and `Ashin` 4 each, `Bogyoke` none and `Sayadaw` none, the 9 names holding `Sayadaw` writing it after the name. - **The honorifics.** `u` and `daw` had no reading in any file. Each is a `salutation` in my.toml written `default = false`, its vetting on the word (tools/name_usage.py, 2026-11-19): `U` a Korean surname (Wikidata 154 family, South Korea 122) and an initial, `Daw` a surname (US Census 2010, 2,670) and borne in ORCID's family box 118 times. Neither carries a name reading, which would make it a title only inside a title phrase (rules/H9): the counts are in each reading's `note`. Neither is `after_given`: a Burmese honorific opens the name. The native spellings `ဦး` and `ဒေါ်` are recorded as `native` and given no reading, Burmese-script names being #1233's. The pack's name is its language's tag, `my`, as every language pack's is (country packs carry a region, `es_ar`, `pt_br`); `MY` is also Malaysia's region code, and the local corpus `my-candidates` holds Malaysian names, whose language is Malay, `ms`. - **`U.` with its full stop: read as the title vocabulary reads it, decided 2026-11-19, reversing working answer (3).** The title match folds edge stops away, so the `u` reading claims `U.` too: `U. Thein Sein` → title 'U.', and an initial with it in many places, these among them: opening a Western name (`U. S. Grant` → title 'U.', given 'S.'), after a family comma or behind another title, where the given name can be lost (`Smith, U.` and `Kim, U` → title, no given name; `Dr. U. Smith` → title 'Dr. U.'; among FEC's names, 16 of the 351 holding `U` or `U.` as a word move under the pack and 3 of those lose their given name, `config_diff.py diff default plain:MY --local fec-individuals --match '(?:^|[\s,(])[Uu]\.?(?=[\s,)]|$)'` with each moved name's given field compared, 2026-11-19; the list is of examples, the vocabulary reading a title in more places than it names), in brackets (`John (U.) Smith` → title 'U.'), joined to another initial after a comma (`Grant, U.S.` → title 'U.S.', where `U.S. Grant` keeps its initials, rules/H10 giving the run back), and glued to a title at its stop (`Dr.U. Smith` → title 'Dr.U.'); ending the name it stays a name word (`John Smith U.` → family 'U.'), where `Daw.` reads as the title (`John Smith Daw.`, rules/H5). The PR first built working answer (3) as a rule of its own, drafted as H11 and never shipped, which required a one-letter word written with its period, in a script with capitals, to be the initial it spells and never a title, at every reader of the title vocabulary: two review rounds found it needed asking at more than a dozen readers (classify's tags, the period-joined derivation, the comma count, the title phrase, T8's glued-stop tests, the Thai glued-title walk, C2's third part, a title run's addressing, the group suggester) before `U. Smith, Ed` and `Vice U. Smith` stopped reading `U.` as a title. It was dropped: a caller who chose the pack is reading Burmese names, no Burmese list measured writes `U.` as an initial (the population below writes it once, as the honorific), and a veto at every reader of the title set was new machinery on the shared parse path for a reading only this pack's vocabulary reaches. The cost is the reason docs/languages.rst gives not to apply the pack to a mixed list. #1205 asks the same of Indonesian `H.` (Haji). - **The syllables.** The fragment removes `kind="particle"` from the nine words the issue measured pulling the rest of a name into the family (`Daw Aung San Suu Kyi` → family 'San Suu Kyi'), and `kind="credential"` from `do`, a builder's choice: with `san` no particle, `AUNG SAN DO` read suffix 'DO' where the default reads family 'SAN DO', the one-case shape the 2026-11-05 #1108 entry of decisions/vocabulary-model found a removal unmasking (nameparser/vocab/AGENTS.md, "A reading taken out"), found here by the PR's test review; `locales.VI` removes `do`'s credential for the same reason. Other credential syllables a Burmese name written in capitals ends in read the suffix by default and under the pack alike (`PE`, `LAT`, `RA`, `EI`, `SI`: 12 of the population's names once every name is upper-cased, the regnal numerals aside, none of the 57 it writes in capitals, 2026-11-19) and are left to an issue of their own. `DEVIATES` declares every name holding one of the nine as a word of its own, cut at every character that is no letter or digit. @@ -109,10 +109,10 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - **Accepted:** under the pack a Dutch, Romance, Filipino or Māori particle among the nine is a name word (`Jan van Dijk` → middle 'van', family 'Dijk'; `Kiri Te Kanawa` → middle 'Te'), and the credential DO a name word (`Jane Doe, DO` → given 'DO'), which the pack's docstring and docs/languages.rst say, with the figures above; a `U` can be the title, bare or written with its full stop (the `U.` bullet above), a Korean surname `U` (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19) and a Western initial (`U. S. Grant` → title 'U.') included, and a period-joined word holding a `U` chunk reads as a title (`John Smith J.u.n.i.o.r.` → title 'J.u.n.i.o.r.', where the default reads the suffix); a removed particle in the family before a comma no longer keeps the given part after it from reading as a credential, so the given name is lost (`Van Buren, Ed` → given 'Van', family 'Buren', suffix 'Ed'; `De La Cruz, Ed` → suffix 'Ed', no given name; `De La Cruz, M.J. K.L.` → suffix 'M.J. K.L.', where the default reads given 'M.'), the shape nameparser/vocab/AGENTS.md's "A reading taken out" names, found by the PR's last review, 4 names of the committed corpora; a title and one name word gives the family a word a Burmese name does not hold as a family name (rules/H1). - **Left out:** `Mg` (#1232); the Burmese-script honorifics and the Burmese comma `၊` (#1233, #1202); the Burmese honorifics ending the given part after a family comma (`after_given`); the other credential syllables above. -- 2026-11-19 #1483 — A WHOLLY BURMESE LIST IS READ WITH A STRICT CHOICE OF `my`; `LOCALES.MY`'S FRAGMENT IS DROPPED; MY.TOML COPIES THE ENGLISH RANKS; PROPOSAL A IS DROPPED. Decided on the issue (its two 2026-11-19 comments), after it found five Burmese syllables the #1231 fragment had not listed reading as credentials ending a name written in capitals (`THEIN AUNG PE` → suffix 'PE'; `pe`, `lat`, `ei`, `si`, `pa`, and `ra`, ungated). A removal list names other languages' words, so it fails silently twice: removing a reading no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name (checked on master `d12af9d6`). A strict choice names no other language's word, so neither can happen to it; nameparser/locales/AGENTS.md now asks for it to be measured before a pack removes readings. - - **The strict choice against the pack**, on the 2,990 names of the #1231 entry's population, read by the same scratch probe (an opening `U` or `Daw` the title, the last word the family; `Mg` counted neither way), measured on master `4b0b9441` before this change: `Parser()` 2,834 as written (94.8%) and 2,825 with every name upper-cased (94.5%); the pack with its fragment 2,987 (99.9%) and 2,977 (99.6%); `parser_for(locales.MY, strict=True)` 2,980 (99.7%) in both writings; a strict choice of `my` with an empty fragment the same names as the strict pack in both writings, and on 361,391 names of the committed corpus and ClinicalTrials.gov's officials, the fragment being inert under strict, which never loads the files whose readings it removed. Upper-cased, strict read 13 names the pack missed (`PE` 4, `LAT` 3, `EI` 2, `RA` 2, `SI` 1, a doubled `PA`), and as written the 2 ending in `Ra`; it read the 10 `Mg` names as #1232 asks (`Mg Htoo Aung` → given 'Mg'), where the default and the pack read en.toml's military `MG`. It lost 9 names' bare English ranks and one `Sir` (`General` 7, `Lieutenant` 3, `Senior` 2, `Admiral` 1, `Vice` 1 as title words), ranks written with their full stops being kept by H2's shape. - - **The ranks.** my.toml now holds the English ranks and `sir`, each a copy of en.toml's reading with its properties (`same_as`, `attaches`, `abbreviation`, `addresses`), written `default = false` so the default never reads them: `senior`, `vice`, `rear` (modifiers), `general`, `gen`, `lieutenant`, `lt`, `major`, `maj`, `brigadier`, `brig`, `colonel`, `col`, `captain`, `capt`, `admiral`, `adm`, `commodore`, `commander`, `cdr`, and `sir`; the population writes the first five that are words of their own and `Sir`, the rest are the Tatmadaw's ranks as staff lists write them. ORCID's Myanmar given and family boxes hold none of the 21 (1,755 holders, `tools/name_usage.py --country MM`, 2026-11-19). A choice holding a vocabulary reading of a word drops every other file's (`choose`'s prefer step), so `lt`'s credential is copied with its rank: without it the plain pack read `John Smith, LT` title 'LT', found by the builder before commit. The plain pack reads every rank as the default does (`_compiled.py` and `changed_words` unchanged), and the strict choice reads `gen`, `maj`, `brig` and `major` without en.toml's given readings, so a bare one opening a name is the rank there (`Gen Goto` → title 'Gen'), the four words joining tests/v2/test_reading_index.py's `STRICT_UNGATED` for `my`. With them, on this branch: the strict choice 2,989 of 2,990 in both writings (100.0%), the one left a string holding two names, which every configuration misreads. - - **The fragment, dropped.** Measured first on this branch, as the decision required: the pack without its fragment reads 2,932 names right as written (98.1%), 55 fewer than with it (the estimate was about 55), and 2,923 upper-cased (97.8%), 54 fewer; every name the two read differently is one the fragment read right (`san` 39, `la` 7, `van`, `te`, `da` 2 each, `do`, `le`, `du` 1 each, as written). So `locales.MY` is the choice of `my` alone, declaring no `DEVIATES`, and the #1231 entry's accepted costs of the fragment (`Jan van Dijk`, `Van Buren, Ed`, the credential DO) no longer apply to the plain pack; a caller reading a mixed list plainly reads those syllables as the default does, and one reading a wholly Burmese list chooses strictly. The fragment was unreleased. - - **What the strict choice costs other names**, on this branch, `config_diff.py diff plain:MY strict:MY --committed --local ctgov-officials --local ctgov-contacts`: 88,009 of 720,837 names move (committed 1,884 of 7,662, ctgov-contacts 42,863 of 359,428, ctgov-officials 49,151 of 353,747), 29,233 of them in their ambiguity reports alone and 58,776 in their fields; the words moved most are `de` 4,676 (family to middle), `master` 3,628 (title to given), `van` 3,364, `pr` 2,432, `rn` 2,404 (suffix to given), `mbchb` 1,738, `of` 1,720, `pd` 1,688, `do` 1,590. Against the pack with its fragment, on master `4b0b9441`, 45,867 of 720,819 had moved in their fields. docs/languages.rst states the cost and keeps the strict choice to a wholly Burmese list. - - **`locales.VI` measured under strict, not changed** (its list shipped in 3.1; whether strict replaces it is a later question): `uit-vinames`, scored as `local_agreement.py` scores it, every box agreeing for 21,085 of 21,090 under `parser_for(locales.VI)` (99.98%) and 21,089 under `parser_for(locales.VI, strict=True)` (100.00%), 4 fixed and none broken; `vn-assembly` 499 of 499 under both, no name read differently. On names that are not Vietnamese, `config_diff.py diff plain:VI strict:VI --committed --local ctgov-officials --local ctgov-contacts`: 80,628 of 720,837 names move, 52,108 in their fields. - - **Proposal A** (the pack removing the five credential readings) is dropped: the strict choice reads them. **Proposal B** (`ra` a name by default) is a question about Korean names as much as Burmese ones and stays open on #1483. #1232's `Mg` is read as that issue asks under the strict choice; the default and the plain pack still read the military `MG`. +- 2026-11-19 #1483 — A WHOLLY BURMESE LIST IS READ WITH A STRICT CHOICE OF `my`; `LOCALES.MY`'S FRAGMENT IS DROPPED; MY.TOML COPIES THE ENGLISH RANKS; PROPOSAL A IS DROPPED. SUPERSEDES: the 2026-11-19 #1231 entry's fragment (its syllables bullet, its `DEVIATES` and the fragment's costs in its Accepted bullet); its honorifics, its `U.` reading and their costs stand. Decided on the issue (its two 2026-11-19 comments), after it found five Burmese syllables the #1231 fragment had not listed reading as credentials ending a name written in capitals (`THEIN AUNG PE` → suffix 'PE'; `pe`, `lat`, `ei`, `si`, `pa`, and `ra`, ungated). A removal list names other languages' words, so it fails silently twice: removing a reading no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name (checked on master `d12af9d6`). A strict choice names no other language's word, so neither can happen to it; nameparser/locales/AGENTS.md now asks for it to be measured before a pack removes readings. + - **The strict choice against the pack**, on the 2,990 names of the #1231 entry's population, read by the same scratch probe (an opening `U` or `Daw` the title, the last word the family; `Mg` counted neither way), measured on master `4b0b9441` before this change and again on this branch (on master `12b568f8`) with the fragment rebuilt in a scratch lexicon and the rank readings left out of the strict choice, the same counts on both: `Parser()` 2,834 as written (94.8%) and 2,825 with every name upper-cased (94.5%); the pack with its fragment 2,987 (99.9%) and 2,977 (99.6%); `parser_for(locales.MY, strict=True)` 2,980 (99.7%) in both writings; a strict choice of `my` with an empty fragment the same names as the strict pack in both writings, and on 361,391 names of the committed corpus and ClinicalTrials.gov's officials, the fragment being inert under strict, which never loads the files whose readings it removed. Upper-cased, strict read 12 names the pack missed, holding `PE` 4 times, `LAT` 3, `EI` 2, `RA` 2, `SI` 1 and a doubled `PA` (13 words), and as written the 2 ending in `Ra`; this entry's probe counts the default 2,834 where the #1231 entry's counted 2,835, a one-name difference between the two probe versions that was not traced, the pack's 2,987 agreeing; it read the 10 `Mg` names as #1232 asks (`Mg Htoo Aung` → given 'Mg'), where the default and the pack read en.toml's military `MG`. It lost 9 names in both writings, to their bare English ranks and, in one of them, `Sir` (`General` 7, `Lieutenant` 3, `Senior` 2, `Admiral` 1, `Vice` 1 as title words), ranks written with their full stops being kept by H2's shape. + - **The ranks.** my.toml now holds the English ranks and `sir`, each a copy of en.toml's reading with its properties (`same_as`, `attaches`, `abbreviation`, `addresses`), written `default = false` so the default never reads them: `senior`, `vice`, `rear` (modifiers), `general`, `gen`, `lieutenant`, `lt`, `major`, `maj`, `brigadier`, `brig`, `colonel`, `col`, `captain`, `capt`, `admiral`, `adm`, `commodore`, `commander`, `cdr`, and `sir`; the population writes the first five that are words of their own and `Sir`, the rest are the Tatmadaw's ranks as staff lists write them. ORCID's Myanmar given and family boxes hold none of the 21 (1,755 holders in `tools/name_usage.py --country MM`'s index, which counts every record whose country is Myanmar; the #1231 entry's 1,737 is the issue comment's count, 2026-11-19). A choice holding a vocabulary reading of a word drops every other file's (`choose`'s prefer step), so `lt`'s credential is copied with its rank: without it the plain pack read `John Smith, LT` title 'LT', found by the builder before commit. The plain pack reads every rank in its fields as the default does (`_compiled.py` and `changed_words` unchanged; `Reading.languages` names `my` for the 21 words there, the file the choice reads), and the strict choice reads `gen`, `maj`, `brig` and `major` without en.toml's given readings, so a bare one opening a name is the rank there (`Gen Goto` → title 'Gen'), the four words joining tests/v2/test_reading_index.py's `STRICT_UNGATED` for `my`. With them, on this branch: the strict choice 2,989 of 2,990 in both writings (100.0%), the one left a string holding two names, which every configuration misreads. + - **The fragment, dropped.** Measured first on this branch, as the decision required, both sides on it: the pack without its fragment reads 2,932 names right as written (98.1%), 55 fewer than with it (2,987) (the estimate was about 55), and 2,923 upper-cased (97.8%), 54 fewer than its 2,977; every name the two read differently is one the fragment read right (`san` 39, `la` 7, `van`, `te`, `da` 2 each, `do`, `le`, `du` 1 each, as written). So `locales.MY` is the choice of `my` alone, declaring no `DEVIATES`, and the #1231 entry's accepted costs of the fragment (`Jan van Dijk`, `Van Buren, Ed`, the credential DO) no longer apply to the plain pack; a caller reading a mixed list plainly reads those syllables as the default does, and one reading a wholly Burmese list chooses strictly. The fragment was unreleased. + - **What the strict choice costs other names**, on this branch, `config_diff.py diff plain:MY strict:MY --committed --local ctgov-officials --local ctgov-contacts`: 88,009 of the 660,410 distinct names move (a name read once however many inputs hold it; per input, committed 1,884 of 7,662, ctgov-contacts 42,863 of 359,428, ctgov-officials 49,151 of 353,747), 29,233 of them in their ambiguity reports alone and 58,776 in their fields (8.9%); the words moved most are `de` 4,676 (family to middle), `master` 3,628 (title to given), `van` 3,364, `pr` 2,432, `rn` 2,404 (suffix to given), `mbchb` 1,738, `of` 1,720, `pd` 1,688, `do` 1,590. Against the pack with its fragment, on master `4b0b9441`, 45,867 of 660,392 distinct names had moved in their fields. docs/languages.rst states the cost and keeps the strict choice to a wholly Burmese list. + - **`locales.VI` measured under strict, not changed** (its list shipped in 3.0.0, #1112; whether strict replaces it is a later question): `uit-vinames`, scored as `local_agreement.py` scores it, every box agreeing for 21,085 of 21,090 under `parser_for(locales.VI)` (99.98%) and 21,089 under `parser_for(locales.VI, strict=True)` (100.00%), 4 fixed and none broken; `vn-assembly` 499 of 499 under both, no name read differently. On names that are not Vietnamese, `config_diff.py diff plain:VI strict:VI --committed --local ctgov-officials --local ctgov-contacts`: 80,628 of the 660,410 distinct names move, 52,108 in their fields. + - **Proposal A** (the pack removing the five credential readings) is dropped: the strict choice reads them. **Proposal B** (`ra` a name by default) is a question about Korean names as much as Burmese ones and stays open on #1483, which this change leaves open. #1232's `Mg` is read as that issue asks under the strict choice; the default and the plain pack still read the military `MG`. diff --git a/docs/languages.rst b/docs/languages.rst index 1097e2ec8..82d0a2152 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1301,8 +1301,9 @@ Choose the pack strictly, ``parser_for(locales.MY, strict=True)`` (:ref:`strict-choice`). Many Burmese syllables are spelled like another language's word: ``San``, ``La`` and the Chin ``Van`` like Spanish, Italian or Dutch particles, which take every word after them -into the family name, and ``Pe``, ``Lat``, ``Ei``, ``Si``, ``Pa`` and -``Ra`` like English credentials, which end a name written in capitals. +into the family name, and ``Pe``, ``Lat``, ``Ei``, ``Si`` and ``Pa`` +like English credentials, which end a name written in capitals, and +``Ra`` like one that ends a name in any case. A strict choice reads no other language's words, so each is a name word: @@ -1354,8 +1355,8 @@ as the title and the last word as the family - 98.1% - 97.8% * - ``parser_for(locales.MY, strict=True)`` - - 100.0% (2,989) - - 100.0% (2,989) + - 2,989 of 2,990 + - 2,989 of 2,990 What a strict choice costs other names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1366,8 +1367,8 @@ every name, so keep it to a list that is wholly Burmese: - **Particles, credentials and titles of other languages** are name words. ``Jan van Dijk`` gives middle ``van``, and a credential after a comma can become the given name (``Jane Doe, PA`` gives given - ``PA``, family ``Jane Doe``). The shared credentials, ``Dr``, - ``PhD`` and ``MBBS`` among them, are kept. + ``PA``, family ``Jane Doe``). The words every language + shares are kept, ``Dr``, ``PhD``, ``MD`` and ``MSc`` among them. - **A rank that is also a given name** is the rank: ``Gen``, ``Maj``, ``Brig`` and ``Major`` opening a name are titles (``Gen Goto`` gives title ``Gen``), where by default they are the given name unless a @@ -1383,9 +1384,9 @@ every name, so keep it to a list that is wholly Burmese: 'PA' On the committed test corpora and ClinicalTrials.gov's officials and -site contacts, 720,837 names that are mostly not Burmese, the strict -choice reads 58,776 differently from the plain pack in their fields, -8.2% of them. +site contacts, 660,410 distinct names that are mostly not Burmese, the +strict choice reads 58,776 differently from the plain pack in their +fields, 8.9% of them (measured 2026-11-19, :issue:`1483`). What the pack leaves as it is ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1406,8 +1407,10 @@ When not to use it ~~~~~~~~~~~~~~~~~~ The plain pack reads names that are not Burmese as the default does, -save one word: ``U`` is the honorific however it is written, so an -initial ``U.`` can be read as the title. ``Smith, U.`` and ``Dr. U. +save two words, ``U`` and ``Daw``, read as titles wherever a title is +read (``Daw Smith`` gives title ``Daw``), and ``U`` as a letter of a +word joined by full stops. ``U`` is the honorific however it is +written, so an initial ``U.`` can be read as the title. ``Smith, U.`` and ``Dr. U. Smith`` give no given name, though ``John U. Smith`` and ``Smith, John U.`` keep it an initial: diff --git a/docs/locales.rst b/docs/locales.rst index b1adf0130..2001ae4f1 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -414,7 +414,7 @@ says what it can change: * - ``my`` - yes - none - - none; it takes readings out instead + - none * - ``ne`` - yes - ``initials_as_family`` @@ -432,8 +432,8 @@ says what it can change: - ``segment_scripts``, for the script its list covers - a surname list -``vi`` and ``my`` are the packs whose own fragments take readings out -rather than adding them (`What a pack's lexicon may hold`_). +``vi`` is the pack whose own fragment takes readings out rather than +adding them (`What a pack's lexicon may hold`_). See :ref:`config-containers` for how that split (language vocabulary vs. behavior) is drawn. Which half a new naming rule belongs in is diff --git a/docs/release_log.rst b/docs/release_log.rst index eb116cf64..ce7205e0e 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -10,7 +10,7 @@ Release Log - **Fix Malaysian a/l, a/p and anak, which read as middle names and cut the father's name.** ``parse("KUMAR A/L RAJAN NAIDU")`` gives family ``A/L RAJAN NAIDU`` and the same ``patronymic``, as ``bin`` reads, where 1.4.0 through 3.1.0 gave middle ``A/L RAJAN``, family ``NAIDU``; ``anak`` opening a name written without a comma (Balinese ``Anak Agung``) is left to position, the given name by default, and reported. :issue:`1468` - **Fix Dutch Oude, which read as a middle name.** ``parse("Piet Oude Luttikhuis")`` gives family ``Oude Luttikhuis``, where 1.4.0 through 3.1.0 gave middle ``Oude``, family ``Luttikhuis``; ``Oude`` opening a name stays the given name, reported, being a rare Dutch given name too. :issue:`1455` - **Add locales.NL, which reads ten as a family-name particle.** ``parser_for(locales.NL).parse("Jan ten Brink")`` gives family ``ten Brink``, where the default, as 1.4.0 through 3.1.0, gives middle ``ten``; a ``Ten`` opening a name stays the given name, reported, save under ``strict=True``. It also takes a Chinese given-name syllable inside a name into the family (``Kheng Ten Choo`` gives family ``Ten Choo``), and choosing Dutch reads ``VD`` as ``van der`` rather than the credential (``John Smith, VD`` gives family ``John Smith VD``). See :ref:`dutch-particles`. :issue:`1455` - - **Add locales.MY, a Burmese pack, which reads U and Daw as titles, and reads a wholly Burmese list strictly.** ``parser_for(locales.MY).parse("U Thein Sein")`` gives title ``U``, given ``Thein``, family ``Sein``, where the default, as 1.4.0 through 3.1.0, gives given ``U``, middle ``Thein``; ``parser_for(locales.MY, strict=True)`` also keeps syllables such as ``San`` and ``PE`` name words and the English ranks Burmese lists write titles, and costs a list of other names their particles and credentials. An initial ``U.`` can become the title under the pack (``Smith, U.`` gives no given name): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231`, :issue:`1483` + - **Add locales.MY, a Burmese pack, which reads U and Daw as titles; chosen strictly, it reads a wholly Burmese list.** ``parser_for(locales.MY).parse("U Thein Sein")`` gives title ``U``, given ``Thein``, family ``Sein``, where the default, as 1.4.0 through 3.1.0, gives given ``U``, middle ``Thein``; ``parser_for(locales.MY, strict=True)`` also keeps syllables such as ``San`` and ``PE`` name words and the English ranks Burmese lists write titles, and costs a list of other names their particles and credentials and reads a rank that is also a given name as the rank (``Gen Goto`` gives title ``Gen``). An initial ``U.`` can become the title under the pack (``Smith, U.`` gives no given name): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231`, :issue:`1483` - **Fix MD inside a name written in capitals, which read as the degree and took the name behind it.** ``parse("SITI NORA MD YUSRI")`` gives middle ``NORA MD``, family ``YUSRI``, as 1.4.0 through 2.3.0 did, where 2.4.0 through 3.1.0 gave family ``NORA``, suffix ``MD YUSRI``; a name in lower case reads the same way, and both report ``suffix-or-name``, the degree being the other reading. The degree written before a family name in capitals reads so too (``JOHN SMITH MD JONES`` gives family ``JONES``, reported), where ``John Smith MD Jones`` and ``JOHN SMITH M.D. JONES`` keep it. :issue:`1394` - **Fix Emeritus, which read as a given name.** ``parse("Professor Emeritus John Smith")`` gives title ``Professor Emeritus``, given ``John``, where 1.4.0 through 3.1.0 gave title ``Professor``, given ``Emeritus``, middle ``John``; ``Emeritus Professor`` and ``Professor Emerita`` read the same way. ``Emerita`` alone stays the given name, reported, being a given name too. A title other than ``Professor`` or ``Prof`` before it still leaves it a name word (``Bishop Emeritus John Smith`` gives given ``Emeritus``). :issue:`1471` - **Change locales.PT_BR to read two family names, and add locales.PT_PT, which reads names from Portugal the same way.** ``parser_for(locales.PT_BR).parse("Ana Souza Lima")`` gives family ``Souza Lima``, where 3.0.0 through 3.1.0 gave middle ``Souza``, family ``Lima``; a second given name on the packs' Portuguese given-name list stays where it stands (``Ana Beatriz Costa`` keeps family ``Costa``), and ``locales.PT``, chosen for Portuguese names from any country, is unchanged. :issue:`1453` diff --git a/nameparser/locales/AGENTS.md b/nameparser/locales/AGENTS.md index 8839f1a65..9ded69a38 100644 --- a/nameparser/locales/AGENTS.md +++ b/nameparser/locales/AGENTS.md @@ -11,7 +11,7 @@ Decide which layer the vocabulary belongs in, if the pack carries any. - **Self-selecting vocabulary is default-safe, and belongs in the default lexicon.** Self-selecting means able to match only text of the tradition it came from, the way a hangul surname can only ever match hangul. It goes in `nameparser/vocab/*.toml` (a segmentation surname list such as the Korean one, in `nameparser/config/_ko_surnames.py`, is read as `Lexicon.default().surnames`) rather than in a pack: a pack nobody knows to ask for is vocabulary nobody gets. - **Vocabulary that declares a language its script does not belongs in the pack**, where asking for it is the declaration. A Chinese surname list silently mangles the Japanese names written in the same characters. - **A word reading that is right in its language and wrong as a default** is written in that language's vocabulary file with `default = false` (`nameparser/vocab/README.md`, Properties), and the pack's `languages` turns it on; the pack module lists nothing (`nameparser/locales/hi.py`). -- **Before a pack removes another language's readings, measure a strict choice of its language.** A removal list names other languages' words, so it fails silently in two ways, checked on master `d12af9d6`: removing a reading that is no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name. A strict choice (`parser_for(PACK, strict=True)`) reads no other language's file, so neither can happen to it. Prefer it, with what the language's lists write that strict drops added to the language's own vocabulary file, `default = false` (copies of another file's reading must copy every vocabulary reading of the word, since a choice that holds one drops the other files', as `my.toml`'s `lt` copies `en.toml`'s credential with its rank). A pack that removes readings records in its docstring why strict would not do; `locales.VI`'s list predates this rule, and strict `vi` was measured beside it in #1483 and left for a later decision (decisions/vocabulary-collisions, the 2026-11-19 #1483 entry). #1231 shipped `locales.MY` with nine particles and a credential removed; #1483 found five syllables the list missed (`PE`, `LAT`, `EI`, `SI`, `PA`), all read right by strict `my`, and the fragment was dropped for strict plus my.toml's English ranks. +- **Before a pack removes another language's readings, measure a strict choice of its language.** A removal list names other languages' words, so it fails silently in two ways, checked on master `d12af9d6`: removing a reading that is no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name. A strict choice (`parser_for(PACK, strict=True)`) reads no other language's file, so neither can happen to it. Prefer it, with what the language's lists write that strict drops added to the language's own vocabulary file, `default = false` (copies of another file's reading must copy every vocabulary reading of the word, since a choice that holds one drops the other files', as `my.toml`'s `lt` copies `en.toml`'s credential with its rank). A pack that removes readings records in its docstring why strict would not do; `locales.VI`'s list predates this rule, and strict `vi` was measured beside it in #1483 and left for a later decision (decisions/vocabulary-collisions, the 2026-11-19 #1483 entry). #1231 shipped `locales.MY` with nine particles and a credential removed; #1483 found five syllables the list missed (`PE`, `LAT`, `EI`, `SI`, `PA`, and `RA`, ungated), all read right by strict `my`, and the fragment was dropped for strict plus my.toml's English ranks. - **A pack with no list of its own ships an empty `Lexicon`** (`Lexicon.empty()`, as `nameparser/locales/ru.py` does); `nameparser/locales/zh.py` is the template for one that carries a list. Curate vocabulary conservatively, the same rule as the user guide's "Words that are also ordinary names" (docs/customize.rst, label `ambiguous-words`): when you're unsure whether a word or a marker belongs, leave it out. diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index 49022985f..2101a385e 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -22,7 +22,7 @@ other language's file, so the syllables Burmese names are written with lose the particle and credential readings Spanish, Italian, Dutch or English give them (``Aung San Win`` gives middle ``San``, family -``Win``; ``THEIN AUNG PE`` keeps family ``PE``), and the English ranks +``Win``; ``THEIN AUNG PE`` gives family ``PE``), and the English ranks and ``Sir`` such lists write are my.toml's own readings (``Lt Gen``, ``Senior General``). The plain choice reads those syllables as other languages do (``Aung San Win`` gives family ``San diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 84446e43b..36bd69b76 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -717,7 +717,13 @@ def test_my_pack_contents() -> None: ("KYAW, AUNG DO", "AUNG", "DO", "KYAW", ""), ("THEIN AUNG PE", "THEIN", "AUNG", "PE", ""), ("THEIN AUNG LAT", "THEIN", "AUNG", "LAT", ""), + ("THEIN AUNG EI", "THEIN", "AUNG", "EI", ""), + ("THEIN AUNG SI", "THEIN", "AUNG", "SI", ""), + ("THEIN AUNG PA", "THEIN", "AUNG", "PA", ""), ("Thein Aung Ra", "Thein", "Aung", "Ra", ""), + ("AUNG SAN WIN", "AUNG", "SAN", "WIN", ""), + ("Win, Aung San", "Aung", "San", "Win", ""), + (", AUNG PE", "AUNG", "PE", "", ""), # #1232: Mg, a title by default, is the given name ("Mg Htoo Aung", "Mg", "Htoo", "Aung", ""), ]) @@ -726,15 +732,66 @@ def test_my_strict_reads_the_syllables_as_name_words( name = parser_for(locales.MY, strict=True).parse(text) assert (name.given, name.middle, name.family, name.suffix) == ( given, middle, family, suffix) + assert not name.ambiguities assert _require_packed("my").parse(text).as_dict() == _default_parse(text) assert name.as_dict() != _default_parse(text) +@pytest.mark.parametrize("order", [GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +@pytest.mark.parametrize("text, title, words", [ + # the strict choice under each order: the syllables stay name words + # and the ranks titles, the order laying the name words out + ("Daw Aung San Suu Kyi", "Daw", ("Aung", "San", "Suu", "Kyi")), + ("AUNG SAN WIN", "", ("AUNG", "SAN", "WIN")), + ("THEIN AUNG PE", "", ("THEIN", "AUNG", "PE")), + ("Lt Gen Kyaw Win", "Lt Gen", ("Kyaw", "Win")), + ("Gen Kyaw Win", "Gen", ("Kyaw", "Win")), +]) +def test_my_strict_reads_alike_under_every_order( + text: str, title: str, words: tuple[str, ...], + order: tuple[Role, Role, Role]) -> None: + strict = parser_for(locales.MY, strict=True, + base=Parser(policy=Policy(name_order=order))) + name = strict.parse(text) + assert name.title == title and not name.suffix + assert sorted(" ".join(w for w in (name.given, name.middle, name.family) + if w).split()) == sorted(words) + assert not name.ambiguities + + +#: The words my.toml copies from en.toml's ranks (#1483) +_MY_RANK_COPIES = ( + "admiral", "adm", "brigadier", "brig", "captain", "capt", "cdr", + "col", "colonel", "commander", "commodore", "gen", "general", + "lieutenant", "lt", "maj", "major", "rear", "senior", "sir", "vice") + + +@pytest.mark.parametrize("word", _MY_RANK_COPIES) +def test_my_rank_copies_are_off_by_default_and_en_toml_readings( + word: str) -> None: + # written default = false, so the default never reads them, which + # no parse's fields would show (en.toml reads them alike): the + # Reading.languages view would (`General` naming my); and each a + # kind en.toml gives the word, with its properties + mine = [r for r in _ri.readings_of(word) if r.tag == "my"] + theirs = {r.kind: {k: v for k, v in r.props.items() + if k not in ("note", "issue", "decided")} + for r in _ri.readings_of(word) if r.tag == "en"} + assert mine and all(r.props.get("default") is False for r in mine) + for r in mine: + props = {k: v for k, v in r.props.items() + if k not in ("note", "issue", "decided", "default")} + assert theirs[r.kind] == props, (word, r.kind) + assert {r.kind for r in mine} == { + r.kind for r in _ri.readings_of(word) if r.tag == "en" + and _ri.CATEGORY[r.kind] not in _ri.UNPREFERRED} + + @pytest.mark.parametrize("text, title", [ # #1483: the English ranks and Sir Burmese lists write are my.toml's # own readings, so a strict choice keeps them, bare and written short, - # at the head and after a family comma, as the default and the plain - # pack read them + # at the head, after a family comma and in a part after a full name, + # as the default and the plain pack read them ("Senior General Kyaw Win", "Senior General"), ("Vice Senior General Kyaw Win", "Vice Senior General"), ("Lieutenant General Kyaw Win", "Lieutenant General"), @@ -743,6 +800,12 @@ def test_my_strict_reads_the_syllables_as_name_words( ("Brig Gen Kyaw Win", "Brig Gen"), ("Major General Kyaw Win", "Major General"), ("Lt Col Kyaw Win", "Lt Col"), + ("Captain Kyaw Win", "Captain"), + ("Colonel Kyaw Win", "Colonel"), + ("Commander Kyaw Win", "Commander"), + ("Brigadier General Kyaw Win", "Brigadier General"), + ("LT GEN KYAW WIN", "LT GEN"), + (", Lt Gen Kyaw Win", "Lt Gen"), ("Col Kyaw Win", "Col"), ("Capt Kyaw Win", "Capt"), ("Rear Admiral Kyaw Win", "Rear Admiral"), @@ -758,6 +821,8 @@ def test_my_strict_keeps_the_ranks(text: str, title: str) -> None: plain = _require_packed("my").parse(text) assert strict.title == plain.title == title assert strict.as_dict() == plain.as_dict() + if "U" not in text.split(): # the honorific is the pack's own word + assert plain.as_dict() == _default_parse(text) @pytest.mark.parametrize("text, given, family, suffix", [ @@ -765,7 +830,9 @@ def test_my_strict_keeps_the_ranks(text: str, title: str) -> None: # never reads them, and copies of en.toml's, so the plain pack, which # prefers them, reads as the default does: a rank en.toml gates by a # given name stays a given name, and lt's credential, copied with - # its rank, stays the suffix + # its rank, stays the suffix. The fields only: Reading.languages + # names my under the pack, the file the choice reads (decisions/ + # vocabulary-collisions, the 2026-11-19 #1483 entry) ("Gen Goto", "Gen", "Goto", ""), ("Major Smith", "Major", "Smith", ""), ("Maj Sjöwall", "Maj", "Sjöwall", ""), @@ -779,18 +846,30 @@ def test_my_rank_readings_move_no_plain_parse( assert name.as_dict() == _default_parse(text) +@pytest.mark.parametrize("text", [ + # the words every language shares (mul.toml) are kept by a strict + # choice, as docs/languages.rst says + "Dr. Kyaw Win, PhD", "Kyaw Win MD", "Kyaw Win, MSc"]) +def test_my_strict_keeps_the_shared_words(text: str) -> None: + assert parser_for(locales.MY, strict=True).parse(text).as_dict() == \ + _require_packed("my").parse(text).as_dict() + + @pytest.mark.parametrize("text, title, given, family, suffix", [ # what a strict choice costs a name that is not Burmese, the reason # the plain pack stays for a mixed list (decisions/vocabulary- # collisions, the 2026-11-19 #1483 entry): the given names en.toml - # gates the ranks by are not read, nor the credentials Burmese lists - # do not write, so a credential after a comma reads as a given name + # gates the ranks by are not read, nor other languages' particles and + # credentials, so a credential after a comma reads as a given name ("Gen Goto", "Gen", "", "Goto", ""), ("Major Smith", "Major", "", "Smith", ""), ("Jane Doe, PA", "", "PA", "Jane Doe", ""), + # and a Burmese name with a credential syllable after a comma, the + # credential gone: read as the given name, as any word there + ("THEIN AUNG, PE", "", "PE", "THEIN AUNG", ""), ("Juan de la Cruz", "", "Juan", "Cruz", ""), ]) -def test_my_strict_costs_a_name_that_is_not_burmese( +def test_my_strict_costs_a_name_that_is_not_burmese_or_a_comma_credential( text: str, title: str, given: str, family: str, suffix: str) -> None: name = parser_for(locales.MY, strict=True).parse(text) assert (name.title, name.given, name.family, name.suffix) == ( From 3d91ce0bcf799b7a3ca1b6bc0ae3175e5902652d Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 15:46:56 -0800 Subject: [PATCH 3/3] Address the fix-commit review: a count, a vacuous row, strict's U.S. cost Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/vocabulary-collisions.md | 2 +- docs/languages.rst | 6 ++++-- nameparser/locales/AGENTS.md | 2 +- tests/v2/test_locales.py | 5 ++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 36d03c98b..023013d81 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -110,7 +110,7 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - **Left out:** `Mg` (#1232); the Burmese-script honorifics and the Burmese comma `၊` (#1233, #1202); the Burmese honorifics ending the given part after a family comma (`after_given`); the other credential syllables above. - 2026-11-19 #1483 — A WHOLLY BURMESE LIST IS READ WITH A STRICT CHOICE OF `my`; `LOCALES.MY`'S FRAGMENT IS DROPPED; MY.TOML COPIES THE ENGLISH RANKS; PROPOSAL A IS DROPPED. SUPERSEDES: the 2026-11-19 #1231 entry's fragment (its syllables bullet, its `DEVIATES` and the fragment's costs in its Accepted bullet); its honorifics, its `U.` reading and their costs stand. Decided on the issue (its two 2026-11-19 comments), after it found five Burmese syllables the #1231 fragment had not listed reading as credentials ending a name written in capitals (`THEIN AUNG PE` → suffix 'PE'; `pe`, `lat`, `ei`, `si`, `pa`, and `ra`, ungated). A removal list names other languages' words, so it fails silently twice: removing a reading no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name (checked on master `d12af9d6`). A strict choice names no other language's word, so neither can happen to it; nameparser/locales/AGENTS.md now asks for it to be measured before a pack removes readings. - - **The strict choice against the pack**, on the 2,990 names of the #1231 entry's population, read by the same scratch probe (an opening `U` or `Daw` the title, the last word the family; `Mg` counted neither way), measured on master `4b0b9441` before this change and again on this branch (on master `12b568f8`) with the fragment rebuilt in a scratch lexicon and the rank readings left out of the strict choice, the same counts on both: `Parser()` 2,834 as written (94.8%) and 2,825 with every name upper-cased (94.5%); the pack with its fragment 2,987 (99.9%) and 2,977 (99.6%); `parser_for(locales.MY, strict=True)` 2,980 (99.7%) in both writings; a strict choice of `my` with an empty fragment the same names as the strict pack in both writings, and on 361,391 names of the committed corpus and ClinicalTrials.gov's officials, the fragment being inert under strict, which never loads the files whose readings it removed. Upper-cased, strict read 12 names the pack missed, holding `PE` 4 times, `LAT` 3, `EI` 2, `RA` 2, `SI` 1 and a doubled `PA` (13 words), and as written the 2 ending in `Ra`; this entry's probe counts the default 2,834 where the #1231 entry's counted 2,835, a one-name difference between the two probe versions that was not traced, the pack's 2,987 agreeing; it read the 10 `Mg` names as #1232 asks (`Mg Htoo Aung` → given 'Mg'), where the default and the pack read en.toml's military `MG`. It lost 9 names in both writings, to their bare English ranks and, in one of them, `Sir` (`General` 7, `Lieutenant` 3, `Senior` 2, `Admiral` 1, `Vice` 1 as title words), ranks written with their full stops being kept by H2's shape. + - **The strict choice against the pack**, on the 2,990 names of the #1231 entry's population, read by the same scratch probe (an opening `U` or `Daw` the title, the last word the family; `Mg` counted neither way), measured on master `4b0b9441` before this change and again on this branch (on master `12b568f8`) with the fragment rebuilt in a scratch lexicon and the rank readings left out of the strict choice, the same counts on both: `Parser()` 2,834 as written (94.8%) and 2,825 with every name upper-cased (94.5%); the pack with its fragment 2,987 (99.9%) and 2,977 (99.6%); `parser_for(locales.MY, strict=True)` 2,980 (99.7%) in both writings; a strict choice of `my` with an empty fragment the same names as the strict pack in both writings, and on 361,391 names of the committed corpus and ClinicalTrials.gov's officials, the fragment being inert under strict, which never loads the files whose readings it removed. Upper-cased, strict read 12 names the pack missed, holding `PE` (4 names), `LAT` (3), `EI` (2), `RA` (2), `SI` (1) and a doubled `PA` (1), one name holding two of them, and as written the 2 ending in `Ra`; this entry's probe counts the default 2,834 where the #1231 entry's counted 2,835, a one-name difference between the two probe versions that was not traced, the pack's 2,987 agreeing; it read the 10 `Mg` names as #1232 asks (`Mg Htoo Aung` → given 'Mg'), where the default and the pack read en.toml's military `MG`. It lost 9 names in both writings, to their bare English ranks and, in one of them, `Sir` (`General` 7, `Lieutenant` 3, `Senior` 2, `Admiral` 1, `Vice` 1 as title words), ranks written with their full stops being kept by H2's shape. - **The ranks.** my.toml now holds the English ranks and `sir`, each a copy of en.toml's reading with its properties (`same_as`, `attaches`, `abbreviation`, `addresses`), written `default = false` so the default never reads them: `senior`, `vice`, `rear` (modifiers), `general`, `gen`, `lieutenant`, `lt`, `major`, `maj`, `brigadier`, `brig`, `colonel`, `col`, `captain`, `capt`, `admiral`, `adm`, `commodore`, `commander`, `cdr`, and `sir`; the population writes the first five that are words of their own and `Sir`, the rest are the Tatmadaw's ranks as staff lists write them. ORCID's Myanmar given and family boxes hold none of the 21 (1,755 holders in `tools/name_usage.py --country MM`'s index, which counts every record whose country is Myanmar; the #1231 entry's 1,737 is the issue comment's count, 2026-11-19). A choice holding a vocabulary reading of a word drops every other file's (`choose`'s prefer step), so `lt`'s credential is copied with its rank: without it the plain pack read `John Smith, LT` title 'LT', found by the builder before commit. The plain pack reads every rank in its fields as the default does (`_compiled.py` and `changed_words` unchanged; `Reading.languages` names `my` for the 21 words there, the file the choice reads), and the strict choice reads `gen`, `maj`, `brig` and `major` without en.toml's given readings, so a bare one opening a name is the rank there (`Gen Goto` → title 'Gen'), the four words joining tests/v2/test_reading_index.py's `STRICT_UNGATED` for `my`. With them, on this branch: the strict choice 2,989 of 2,990 in both writings (100.0%), the one left a string holding two names, which every configuration misreads. - **The fragment, dropped.** Measured first on this branch, as the decision required, both sides on it: the pack without its fragment reads 2,932 names right as written (98.1%), 55 fewer than with it (2,987) (the estimate was about 55), and 2,923 upper-cased (97.8%), 54 fewer than its 2,977; every name the two read differently is one the fragment read right (`san` 39, `la` 7, `van`, `te`, `da` 2 each, `do`, `le`, `du` 1 each, as written). So `locales.MY` is the choice of `my` alone, declaring no `DEVIATES`, and the #1231 entry's accepted costs of the fragment (`Jan van Dijk`, `Van Buren, Ed`, the credential DO) no longer apply to the plain pack; a caller reading a mixed list plainly reads those syllables as the default does, and one reading a wholly Burmese list chooses strictly. The fragment was unreleased. - **What the strict choice costs other names**, on this branch, `config_diff.py diff plain:MY strict:MY --committed --local ctgov-officials --local ctgov-contacts`: 88,009 of the 660,410 distinct names move (a name read once however many inputs hold it; per input, committed 1,884 of 7,662, ctgov-contacts 42,863 of 359,428, ctgov-officials 49,151 of 353,747), 29,233 of them in their ambiguity reports alone and 58,776 in their fields (8.9%); the words moved most are `de` 4,676 (family to middle), `master` 3,628 (title to given), `van` 3,364, `pr` 2,432, `rn` 2,404 (suffix to given), `mbchb` 1,738, `of` 1,720, `pd` 1,688, `do` 1,590. Against the pack with its fragment, on master `4b0b9441`, 45,867 of 660,392 distinct names had moved in their fields. docs/languages.rst states the cost and keeps the strict choice to a wholly Burmese list. diff --git a/docs/languages.rst b/docs/languages.rst index 82d0a2152..617c9346f 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1422,5 +1422,7 @@ U.`` keep it an initial: A Korean name written with no comma and opening with the surname ``U`` reads ``U`` as the title under the pack (``U Minjun``), where ``U, -Minjun`` keeps it as the family name. Keep the pack to a parser of its -own for the Burmese names in your data. +Minjun`` keeps it as the family name. Chosen strictly, the pack also +reads a run of initials holding ``U`` as the title (``U.S. Grant`` +gives title ``U.S.``, family ``Grant``). Keep the pack to a parser of +its own for the Burmese names in your data. diff --git a/nameparser/locales/AGENTS.md b/nameparser/locales/AGENTS.md index 9ded69a38..b5c024af4 100644 --- a/nameparser/locales/AGENTS.md +++ b/nameparser/locales/AGENTS.md @@ -11,7 +11,7 @@ Decide which layer the vocabulary belongs in, if the pack carries any. - **Self-selecting vocabulary is default-safe, and belongs in the default lexicon.** Self-selecting means able to match only text of the tradition it came from, the way a hangul surname can only ever match hangul. It goes in `nameparser/vocab/*.toml` (a segmentation surname list such as the Korean one, in `nameparser/config/_ko_surnames.py`, is read as `Lexicon.default().surnames`) rather than in a pack: a pack nobody knows to ask for is vocabulary nobody gets. - **Vocabulary that declares a language its script does not belongs in the pack**, where asking for it is the declaration. A Chinese surname list silently mangles the Japanese names written in the same characters. - **A word reading that is right in its language and wrong as a default** is written in that language's vocabulary file with `default = false` (`nameparser/vocab/README.md`, Properties), and the pack's `languages` turns it on; the pack module lists nothing (`nameparser/locales/hi.py`). -- **Before a pack removes another language's readings, measure a strict choice of its language.** A removal list names other languages' words, so it fails silently in two ways, checked on master `d12af9d6`: removing a reading that is no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name. A strict choice (`parser_for(PACK, strict=True)`) reads no other language's file, so neither can happen to it. Prefer it, with what the language's lists write that strict drops added to the language's own vocabulary file, `default = false` (copies of another file's reading must copy every vocabulary reading of the word, since a choice that holds one drops the other files', as `my.toml`'s `lt` copies `en.toml`'s credential with its rank). A pack that removes readings records in its docstring why strict would not do; `locales.VI`'s list predates this rule, and strict `vi` was measured beside it in #1483 and left for a later decision (decisions/vocabulary-collisions, the 2026-11-19 #1483 entry). #1231 shipped `locales.MY` with nine particles and a credential removed; #1483 found five syllables the list missed (`PE`, `LAT`, `EI`, `SI`, `PA`, and `RA`, ungated), all read right by strict `my`, and the fragment was dropped for strict plus my.toml's English ranks. +- **Before a pack removes another language's readings, measure a strict choice of its language.** A removal list names other languages' words, so it fails silently in two ways, checked on master `d12af9d6`: removing a reading that is no longer there raises nothing, in a lexicon or a pack, and a reading another language gains later is not on the list, which misreads names and which no test can name. A strict choice (`parser_for(PACK, strict=True)`) reads no other language's file, so neither can happen to it. Prefer it, with what the language's lists write that strict drops added to the language's own vocabulary file, `default = false` (copies of another file's reading must copy every vocabulary reading of the word, since a choice that holds one drops the other files', as `my.toml`'s `lt` copies `en.toml`'s credential with its rank). A pack that removes readings records in its docstring why strict would not do; `locales.VI`'s list predates this rule, and strict `vi` was measured beside it in #1483 and left for a later decision (decisions/vocabulary-collisions, the 2026-11-19 #1483 entry). #1231 shipped `locales.MY` with nine particles and a credential removed; #1483 found five credential syllables the list missed (`PE`, `LAT`, `EI`, `SI`, `PA`), and `RA`, ungated,, all read right by strict `my`, and the fragment was dropped for strict plus my.toml's English ranks. - **A pack with no list of its own ships an empty `Lexicon`** (`Lexicon.empty()`, as `nameparser/locales/ru.py` does); `nameparser/locales/zh.py` is the template for one that carries a list. Curate vocabulary conservatively, the same rule as the user guide's "Words that are also ordinary names" (docs/customize.rst, label `ambiguous-words`): when you're unsure whether a word or a marker belongs, leave it out. diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 36bd69b76..9c61c6ab8 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -849,7 +849,7 @@ def test_my_rank_readings_move_no_plain_parse( @pytest.mark.parametrize("text", [ # the words every language shares (mul.toml) are kept by a strict # choice, as docs/languages.rst says - "Dr. Kyaw Win, PhD", "Kyaw Win MD", "Kyaw Win, MSc"]) + "Dr Kyaw Win, PhD", "Kyaw Win MD", "Kyaw Win, MSc"]) def test_my_strict_keeps_the_shared_words(text: str) -> None: assert parser_for(locales.MY, strict=True).parse(text).as_dict() == \ _require_packed("my").parse(text).as_dict() @@ -867,6 +867,9 @@ def test_my_strict_keeps_the_shared_words(text: str) -> None: # and a Burmese name with a credential syllable after a comma, the # credential gone: read as the given name, as any word there ("THEIN AUNG, PE", "", "PE", "THEIN AUNG", ""), + # and a run of initials holding U, which the honorific claims once + # en.toml's dotted title us no longer reads it (rules/H10) + ("U.S. Grant", "U.S.", "", "Grant", ""), ("Juan de la Cruz", "", "Juan", "Cruz", ""), ]) def test_my_strict_costs_a_name_that_is_not_burmese_or_a_comma_credential(