From 5fe588eb5943e0450ec1101a8606fbc93609deb7 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:07:01 -0800 Subject: [PATCH 01/13] Add locales.MY, a Burmese pack: U and Daw as titles, nine syllables kept name words (#1231) my.toml gains the salutations u and daw written default = false, and locales.MY chooses my with a lexicon fragment taking out the particle readings of san, la, le, do, da, du, te, di and van, Burmese name syllables, as locales.VI's takes out Vietnamese ones. DEVIATES declares every name holding one of the nine as a word. rules/H11: a one-letter title written with its period is the initial it spells where the letter has a capital, at classify's title tag and the period-joined derivation's chunk test, so U. S. Grant, U.S. Grant and Grant, U.S. read as the default reads them under the pack. The default holds no such title, so no default parse moves; the committed snapshot gains the rule examples only. Registered, with contents, removal, comma-shape, order and U. tests, rotators, case rows, H11 tests with negative controls, and the CLDR locale view's my file (19/24 with and without the pack). Co-Authored-By: Claude Opus 5.5 --- nameparser/_lexicon.py | 13 ++ nameparser/_pipeline/_classify.py | 9 +- nameparser/_pipeline/_vocab.py | 15 +- nameparser/config/_index.py | 2 + nameparser/locales/AGENTS.md | 2 +- nameparser/locales/__init__.py | 1 + nameparser/locales/my.py | 78 ++++++++++ nameparser/vocab/my.toml | 8 + tests/v2/cases.py | 51 ++++++ tests/v2/pipeline/test_classify.py | 49 ++++++ tests/v2/test_layering.py | 6 +- tests/v2/test_locales.py | 147 +++++++++++++++++- tools/differential/cldr_agreement.py | 5 +- .../differential/cldr_agreement_locales.json | 115 ++++++++++++++ tools/differential/corpus_rules.jsonl | 9 ++ tools/differential/snapshot.jsonl | 8 + 16 files changed, 508 insertions(+), 10 deletions(-) create mode 100644 nameparser/locales/my.py diff --git a/nameparser/_lexicon.py b/nameparser/_lexicon.py index ceddd17a5..0ccb71668 100644 --- a/nameparser/_lexicon.py +++ b/nameparser/_lexicon.py @@ -156,6 +156,19 @@ def _spells_an_initial(n: str, text: str) -> bool: return len(n) == 1 and text[-1] == "." +# rules/H11: "a one-letter word written with its period is an initial +# and not a title, where the letter has a capital" +def _spells_a_cased_initial(n: str, text: str) -> bool: + """`_spells_an_initial`, narrowed to a letter that has a capital + ('U.', 'h.'): such a word is an initial whatever title the letter + also spells (#1231). A letter of a script without case ('ড.', the + Bengali doctor) keeps its title reading, the full stop being how + that title is written. `n` is `_normalize(text)`, folded once by + the caller, and lower case, so a letter with a capital is one that + upper-cases to something else.""" + return _spells_an_initial(n, text) and n.upper() != n + + def _fold_words(words: Iterable[str]) -> list[str]: """The words of a title run, folded for storage and lookup. diff --git a/nameparser/_pipeline/_classify.py b/nameparser/_pipeline/_classify.py index 25e17f1f2..acbd452a4 100644 --- a/nameparser/_pipeline/_classify.py +++ b/nameparser/_pipeline/_classify.py @@ -97,7 +97,7 @@ class (rules/S12). import unicodedata -from nameparser._lexicon import _normalize, _spells_an_initial +from nameparser._lexicon import _normalize, _spells_a_cased_initial, _spells_an_initial from nameparser._policy import CapsSuffixes from nameparser._pipeline._state import ( AGNOMEN_TAG, AMBIGUOUS_ACRONYM_TAG, AMBIGUOUS_WORD_TAG, COMMA_STRIP, CREDENTIAL_WORD_TAG, @@ -173,7 +173,12 @@ def _tags_for(token: WorkToken, n: str, state: ParseState, tags = set(token.tags) if marker_tag is not None: tags.add(marker_tag) - if n in lex._sets.titles: + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" -- the + # set and length tests first, at C level, so only a one-letter + # title pays the frame + if n in lex._sets.titles and not ( + len(n) == 1 and _spells_a_cased_initial(n, token.text)): tags.add("vocab:title") # rules/H5: "a title the vocabulary lists whole with a period # inside it chains without a final one" -- marked here, where diff --git a/nameparser/_pipeline/_vocab.py b/nameparser/_pipeline/_vocab.py index 425a21bbd..c396c8565 100644 --- a/nameparser/_pipeline/_vocab.py +++ b/nameparser/_pipeline/_vocab.py @@ -1684,6 +1684,17 @@ def period_member(word: str, lexicon: Lexicon) -> bool: and _holds_a_member(bare, lexicon)) +# rules/H11: "single letter with a capital between full stops inside a +# word is an initial too" -- 'U.S.' and 'U.Thein' are cut at their full +# stops, and a one-letter chunk is an initial there, never the title the +# letter spells (#1231) +def _title_chunk(chunk: str, lexicon: Lexicon) -> bool: + """Whether CHUNK, one folded piece of a word cut at its periods, is + title vocabulary, a single letter with a capital excepted.""" + return chunk in lexicon._sets.titles and not ( + len(chunk) == 1 and chunk.upper() != chunk) + + # rules/H5: "a word with interior periods every one of whose chunks is # a title chains without a final period" -- 'Lt.Gov', where the # periods join nothing but titles (decisions/H5, #1131) @@ -1693,7 +1704,7 @@ def period_joined_title(text: str, lexicon: Lexicon) -> bool: 'Dr.PhD' or 'St.John').""" chunks = [_normalize(c) for c in text.split(".") if c] return len(chunks) >= 2 and all( - c in lexicon._sets.titles for c in chunks) + _title_chunk(c, lexicon) for c in chunks) def _is_suffix_strict_n(n: str, text: str, lexicon: Lexicon, @@ -1903,7 +1914,7 @@ class by shape for the first time (measured regression, #516 if glued_saint_cut(text, lexicon) is not None: return None chunks = [_normalize(c) for c in text.split(".") if c] - if any(c in lexicon._sets.titles for c in chunks): + if any(_title_chunk(c, lexicon) for c in chunks): return "title" if period_joined_credential(text, lexicon): return "suffix" diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 92deae59c..7a0cad8df 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -771,6 +771,7 @@ ('darya', (('ru', 'spelling', (('spelling_of', ('daria',)),)),)), ('das', (('pt', 'preposition', ()),)), ('dave', (('en', 'familiar', (('short_for', ('david',)),)),)), + ('daw', (('my', 'salutation', (('default', False),)),)), ('dbe', (('en', 'credential', ()),)), ('dbqh', (('vi', 'office', (('same_as', 'đbqh'),)),)), ('dc', (('en', 'credential', ()),)), @@ -2683,6 +2684,7 @@ ('tte', (('es', 'military', ()),)), ('tunde', (('mul', 'familiar', (('short_for', ('babatunde',)),)),)), ('ty', (('en', 'familiar', (('short_for', ('tyler',)),)),)), + ('u', (('my', 'salutation', (('default', False),)),)), ('ua', (('ga', 'clan', (('cased', 'Ua'), ('same_as', 'ó'))), ('ga', 'given', ()))), ('ud', (('en', 'credential', ()),)), ('uk', (('en', 'modifier', (('dotted', True),)),)), diff --git a/nameparser/locales/AGENTS.md b/nameparser/locales/AGENTS.md index 6cf77c044..eca04153d 100644 --- a/nameparser/locales/AGENTS.md +++ b/nameparser/locales/AGENTS.md @@ -69,5 +69,5 @@ The shipped packs are the rows of `_REGISTRY` in `nameparser/locales/__init__.py | Nothing but a choice of languages | `nameparser/locales/hi.py` | | 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` | +| A fragment that takes readings out | `nameparser/locales/vi.py` (`nameparser/locales/my.py` beside a choice alone) | | A country pack reading its language's `[rules]` table | `nameparser/locales/es_ar.py` | diff --git a/nameparser/locales/__init__.py b/nameparser/locales/__init__.py index 83d1012ac..7f4a87a70 100644 --- a/nameparser/locales/__init__.py +++ b/nameparser/locales/__init__.py @@ -35,6 +35,7 @@ "HR": ("nameparser.locales.hr", "HR"), "JA": ("nameparser.locales.ja", "JA"), "MN": ("nameparser.locales.mn", "MN"), + "MY": ("nameparser.locales.my", "MY"), "NE": ("nameparser.locales.ne", "NE"), "NL": ("nameparser.locales.nl", "NL"), "PT": ("nameparser.locales.pt", "PT"), diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py new file mode 100644 index 000000000..50625ca9d --- /dev/null +++ b/nameparser/locales/my.py @@ -0,0 +1,78 @@ +"""The Burmese locale pack (#1231): it chooses 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. + +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. ``U.`` with its full stop stays an initial +(``U. S. Grant``), a one-letter cased word written with its period +being no title in any lexicon (rules/H11). A title and one name word +reads the word as the family name, as everywhere (rules/H1), so ``U +Thant`` gives family ``Thant``. + +Left as name words: the honorifics ``Ko``, ``Ma`` and ``Maung``, which +are also name syllables (``Maung Maung Kyaw``), and the ethnic prefixes +``Saw``, ``Sai``, ``Nang``, ``Naw``, ``Khun`` and ``Mahn``; and the +military and religious styles (``Bogyoke``, ``Sayadaw``), each rare +(decisions/vocabulary-collisions, the 2026-11-19 #1231 entry). + +The fragment is the one pack content that removes, as in +``locales.VI``: 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 the particles of +Spanish, Italian, Portuguese, French, Filipino and Dutch surnames +(``Juan de la Cruz`` keeps ``de``, but ``Maria la Torre`` and ``Jan van +Dijk`` lose theirs), 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' +sanctions and PEP records of Myanmar and Wikidata's labels of people +with Myanmar citizenship, in the decisions 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. +""" +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") + +_SYLLABLES = frozenset(_PARTICLES) + +MY = Locale( + code="my", + lexicon=Lexicon.empty().remove(*_PARTICLES, kind="particle"), + 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) diff --git a/nameparser/vocab/my.toml b/nameparser/vocab/my.toml index 766e1f1bc..d85643262 100644 --- a/nameparser/vocab/my.toml +++ b/nameparser/vocab/my.toml @@ -1,5 +1,13 @@ schema = 1 +[[word]] +text = "daw" +salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1231, expands = "Daw, the honorific written before a woman's name (Mrs.)", note = "Burmese names have no family name and an honorific opens them, so the default reads Daw as the given name; on by default it would take the given name of the people who bear it: US Census 2010 2,670 as a surname, Wikidata 3 given (Sudan 1) and 20 family; ORCID's given box 29, MM 2, family box 118; PatentsView 9 given, 54 family (tools/name_usage.py, 2026-11-19). Written bare as a word of its own, never with a full stop" } + +[[word]] +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: the full stop keeps U. an initial under the pack too, a one-letter cased word written with its period being no title (rules/H11). Written bare by Burmese names (U Thein Sein); FEC writes U 187 times and U. 163, mostly a middle initial after a comma; ctgov-officials U 260, U. 61 (tools/name_usage.py, 2026-11-19)" } + [[word]] text = "ဂျူနီယာ" generation = { issue = 679 } diff --git a/tests/v2/cases.py b/tests/v2/cases.py index e710e6d6a..59cc1fdbc 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1039,6 +1039,57 @@ def _check_cjk_shape_purity(self) -> None: notes="the mid-name cost that keeps ten off by default " "(rules/P2's Accepted); 1.4.0 through 3.1.0 read middle " "'Ten'"), + # #1231: the Burmese pack. Burmese names have no family name, so the + # last word lands in family by position. Each row's notes checked + # against the 1.4.0, 2.0.0, 2.4.0, 2.8.2 and 3.1.0 wheels on + # 2026-11-19; on master, where no `my` pack exists, every row fails + Case("the_burmese_pack_reads_u_as_the_title", + "U Thein Sein", + {"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", + "Daw Aung San Suu Kyi", + {"title": "Daw", "given": "Aung", "middle": "San Suu", "family": "Kyi"}, + locale="my", classification="feat(#1231)", + notes="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"}, + locale="my", classification="feat(#1231)", + notes="1.4.0 through 3.1.0 read given 'U', middle 'Thein'"), + Case("the_burmese_pack_reads_a_title_and_one_name_word_as_h1_does", + "U Thant", + {"title": "U", "family": "Thant"}, + 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_keeps_u_with_its_full_stop_an_initial", + "U. S. Grant", + {"given": "U.", "middle": "S.", "family": "Grant"}, + locale="my", classification="parity", + notes="a one-letter cased word written with its period (rules/H11) " + "is an initial, never a title; the issue's simulated lexicon " + "read title 'U.' on master; 1.4.0 reads the same fields"), + 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/pipeline/test_classify.py b/tests/v2/pipeline/test_classify.py index e1106b0c3..f44e6febd 100644 --- a/tests/v2/pipeline/test_classify.py +++ b/tests/v2/pipeline/test_classify.py @@ -865,3 +865,52 @@ def test_the_surname_unit_agreement_test_sees_the_initial_veto( monkeypatch.setattr(_vocab, "_spells_an_initial", lambda n, text: False) assert _surname_unit_disagreements() == ["Ó.", "ó.", "ณ."] + + +#: A caller's one-letter title in a cased script (rules/H11), each name +#: with the reading the title gives written bare, the initial written +#: with its period, and the letter cut from a word at its full stops +_ONE_LETTER_TITLE = Parser(lexicon=Lexicon.default().add("q", kind="salutation") + .add("ü", kind="salutation")) + + +@pytest.mark.parametrize("text, title, given", [ + ("Q Smith", "Q", ""), + ("Ü Smith", "Ü", ""), + ("Q. Smith", "", "Q."), + ("q. smith", "", "q."), + ("Ü. Smith", "", "Ü."), + ("Q. R. Smith", "", "Q."), + ("Q.R. Smith", "", "Q."), + ("Smith, Q.R.", "", "Q."), + ("Q.John Smith", "", "Q."), + ("Smith, Q.", "", "Q."), + ("Smith, Q", "Q", ""), +]) +def test_a_one_letter_title_written_with_its_period_is_an_initial( + text: str, title: str, given: str) -> None: + # #1231: the period, not the letter, decides, for any lexicon + name = _ONE_LETTER_TITLE.parse(text) + assert (name.title, name.given) == (title, given) + + +def test_the_one_letter_title_veto_needs_a_letter_with_a_capital() -> None: + # the Bengali doctor is written with its full stop: no capital, no veto + assert Parser().parse("ড. রহিম উদ্দিন").title == "ড." + from nameparser._pipeline import _classify + assert _classify._spells_a_cased_initial("q", "Q.") + assert not _classify._spells_a_cased_initial("ড", "ড.") + + +def test_the_one_letter_title_veto_is_what_keeps_the_initial( + monkeypatch: pytest.MonkeyPatch) -> None: + # negative controls for both sites, classify's tag and the period- + # joined derivation's chunk test: with either veto off, the dotted + # letter is the title, so the rows above read the veto + from nameparser._pipeline import _classify + monkeypatch.setattr(_classify, "_spells_a_cased_initial", lambda n, text: False) + assert _ONE_LETTER_TITLE.parse("Q. Smith").title == "Q." + monkeypatch.undo() + monkeypatch.setattr(_vocab, "_title_chunk", + lambda c, lexicon: c in lexicon._sets.titles) + assert _ONE_LETTER_TITLE.parse("Smith, Q.R.").title == "Q.R." diff --git a/tests/v2/test_layering.py b/tests/v2/test_layering.py index b802ec081..303648b67 100644 --- a/tests/v2/test_layering.py +++ b/tests/v2/test_layering.py @@ -887,7 +887,9 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: a listed title, its `sets =` binding and the two title sets it #: reads, 200 -> 203; the 3.1 simplify pass folding T8's two copies #: of the unambiguous title-or-suffix test after a glued stop into -#: `_vocab._claimed_after_the_stop`, 203 -> 198); +#: `_vocab._claimed_after_the_stop`, 203 -> 198; #1231's +#: `_vocab._title_chunk`, rules/H11's chunk test, folding the two +#: period-joined title reads into one, 198 -> 197); #: the tools' first 20 are 18 #: attribute loads, every tool scanned, and config_diff.py's #: `sets =` binding and the roster `getattr` through it (its @@ -909,7 +911,7 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: `_lexicon._fields_of` from 4i-b until 4i-c retired it. #: A reader added through `_sets` moves these, and they are re-taken #: then: they count what the check would refuse with the move undone. -_UNGUARDED_READS = {"library": 198, "tools": 28} +_UNGUARDED_READS = {"library": 197, "tools": 28} def test_the_check_refuses_every_read_4i_a_moved() -> None: diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 736509996..980f8c995 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -118,10 +118,10 @@ def test_locales_get_and_available() -> None: assert locales.get("ru") is locales.RU assert set(locales.available()) == { "ar", "bn", "cs", "es", "es_ar", "ga", "gd", "he", "hi", "hr", "ja", "mn", - "ne", "nl", "pt", "pt_br", "ru", "sk", "sl", "tr_az", "vi", "zh"} + "my", "ne", "nl", "pt", "pt_br", "ru", "sk", "sl", "tr_az", "vi", "zh"} with pytest.raises( KeyError, - match="ar, bn, cs, es, es_ar, ga, gd, he, hi, hr, ja, mn, ne, nl, pt, pt_br, ru, sk, sl, tr_az, vi, zh"): + match="ar, bn, cs, es, es_ar, ga, gd, he, hi, hr, ja, mn, my, ne, nl, pt, pt_br, ru, sk, sl, tr_az, vi, zh"): locales.get("xx") # the segmenter FACTORY is not a locale: it is an ordinary function # on the package, so it must not appear among the codes @@ -688,6 +688,129 @@ def test_vi_differs_from_the_default_where_the_default_reads_given_first() -> No assert vi.parse(text).as_dict() == _default_parse(text) +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 + import pickle + from nameparser.locales import my as _my + assert locales.MY.languages == {"my"} + assert locales.MY.policy == PolicyPatch() + assert _ri.changed_words(_ri.selected(locales.MY.languages)) == {"u", "daw"} + sets = _require_packed("my").lexicon._sets + assert not set(_my._PARTICLES) & sets.particles + # the particles it leaves, and every other kind of the words it names + assert {"de", "von", "del", "bin", "mac"} <= sets.particles + assert "do" in 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 particle the MY fragment removes, with a name its removal alone +#: moves: the syllable between two name words, which its reading would +#: chain into the family name +_MY_REMOVALS = [ + ("san", "Aung San Win"), ("la", "Akyaung La Aung"), + ("le", "Saw Eh Le Htoo"), ("do", "Htan Do Kyint"), + ("da", "Thi Da Oo"), ("du", "Swam Du Naw Aung"), + ("te", "Kyauk Te Chan"), ("di", "Aung Di Win"), + ("van", "Henry Van Thio"), +] + + +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 + from nameparser.locales import my as _my + assert sorted(w for w, _ in _MY_REMOVALS) == sorted(_my._PARTICLES) + my = _require_packed("my") + + def put_back(word: str | None) -> Parser: + lexicon = Lexicon.empty().remove( + *[w for w in _my._PARTICLES if w != word], kind="particle") + return parser_for(dataclasses.replace(locales.MY, lexicon=lexicon)) + + rebuilt = put_back(None) + for word, text in _MY_REMOVALS: + assert rebuilt.parse(text).as_dict() == my.parse(text).as_dict(), text + assert put_back(word).parse(text).as_dict() != my.parse(text).as_dict(), ( + word, text) + assert len(my.parse(text).family.split()) == 1, text + + +@pytest.mark.parametrize("order", [GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +@pytest.mark.parametrize("text, title, rest", [ + # #1231: the honorific opening the name, in each comma shape and case, + # behind a listed title and before one; `rest` is the name's other + # words, which the order lays out + ("U Thein Sein", "U", ("Thein", "Sein")), + ("Daw Khin Mya", "Daw", ("Khin", "Mya")), + ("DAW KHIN MYA", "DAW", ("KHIN", "MYA")), + ("u thein sein", "u", ("thein", "sein")), + ("Dr. U Thein Sein", "Dr. U", ("Thein", "Sein")), + ("U Dr. Thein Sein", "U Dr.", ("Thein", "Sein")), + ("U Thein Sein, Jr.", "U", ("Thein", "Sein")), +]) +def test_my_reads_the_honorific_opening_a_name_as_the_title( + text: str, title: str, rest: tuple[str, ...], + order: tuple[Role, Role, Role]) -> None: + my = parser_for(locales.MY, base=Parser(policy=Policy(name_order=order))) + name = my.parse(text) + assert name.title == title + assert sorted(w for w in (name.given, name.middle, name.family) if w) == sorted(rest) + assert not name.ambiguities + + +@pytest.mark.parametrize("text, title, given, family", [ + # after a family comma, with nothing before the comma, and past the + # second comma (rules/C2); a title and one name word (rules/H1) + ("Sein, U Thein", "U", "Thein", "Sein"), + ("Sein, Daw Thein", "Daw", "Thein", "Sein"), + (", U Thein", "U", "", "Thein"), + ("Sein, Thein, U", "U", "Thein", "Sein"), + ("U Thant", "U", "", "Thant"), + ("Thant, U", "U", "", "Thant"), +]) +def test_my_reads_the_honorific_in_every_comma_shape( + text: str, title: str, given: str, family: str) -> None: + name = _require_packed("my").parse(text) + assert (name.title, name.given, name.family) == (title, given, family) + + +@pytest.mark.parametrize("order", [GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +@pytest.mark.parametrize("text", [ + # U written with its full stop is an initial under the pack (rules/H11), + # in every comma shape, joined to the next initial or the + # next name at its full stop, and in a name of one case + "U. S. Grant", "U.S. Grant", "Grant, U. S.", "Grant, U.S.", "U. Grant", + "John U. Smith", "Smith, John U.", "Smith, U.", ", U. Smith", + "U.Thein Sein", "U. Thein Sein", "U. S. GRANT", "u. s. grant", + "U.S. District Judge Jane Roe", "Dr. U. Smith", +]) +def test_my_keeps_u_written_with_its_full_stop_an_initial( + text: str, order: tuple[Role, Role, Role]) -> None: + base = Parser(policy=Policy(name_order=order)) + packed = parser_for(locales.MY, base=base).parse(text) + assert packed.as_dict() == base.parse(text).as_dict() + assert "U." not in packed.title.upper().split() + + +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 + my = _require_packed("my") + for text in ("Thein Sein", "Min Aung Hlaing", "Maung Maung Kyaw", + "Ko Ko Lwin", "Saw Ba Hline", "Sai Lone Hsai"): + assert my.parse(text).as_dict() == _default_parse(text), text + for text in ("U Thein Sein", "Daw Aung San Suu Kyi", "Aung San Win"): + assert my.parse(text).as_dict() != _default_parse(text), text + + def test_mn_pack_contents() -> None: # a choice of mn and a Cyrillic script order, nothing else: the # order is keyed to the script, so a romanized name keeps the @@ -2012,6 +2135,26 @@ def _default_corpus() -> list[str]: "John Smith VD", # vd, the credential leaving "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 +_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 +] # 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 # one where it ends the given part after a family comma (rules/H8) or diff --git a/tools/differential/cldr_agreement.py b/tools/differential/cldr_agreement.py index fdfa8464e..1acd8f252 100644 --- a/tools/differential/cldr_agreement.py +++ b/tools/differential/cldr_agreement.py @@ -164,7 +164,10 @@ "ga": "GA", "gd": "GD", "pt": "PT_BR", "es": "ES", # hi_Latn is the romanized Hindi the pack's Latin readings are for "hi": "HI", "hi_Latn": "HI", "bn": "BN", "vi": "VI", - "mn": "MN", "ar": "AR", "he": "HE", "nl": "NL"} + "mn": "MN", "ar": "AR", "he": "HE", "nl": "NL", + # CLDR's my file is in Burmese script, which the pack's + # Latin readings do not reach + "my": "MY"} #: Packs with no CLDR file to measure them on. CLDR's pt is Brazilian, #: read with PT_BR, which chooses PT's language and more; CLDR 48 has no #: pt_PT names file, and no es_AR one (its es is read with ES). diff --git a/tools/differential/cldr_agreement_locales.json b/tools/differential/cldr_agreement_locales.json index 37fa04f06..7aa057b00 100644 --- a/tools/differential/cldr_agreement_locales.json +++ b/tools/differential/cldr_agreement_locales.json @@ -1327,6 +1327,121 @@ }, "text": "Цэцэг Дорж" }, + "my/foreignFull/givenFirst": { + "family": { + "expected": "ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ", + "got": "ပရော်ဖက်ဆာ ဒေါက်တာ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင် ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ" + }, + "family_base": { + "expected": "ဝူစ်တာ ဘရူ", + "got": "ပရော်ဖက်ဆာ ဒေါက်တာ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင် ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ" + }, + "family_particles": { + "expected": "ဝူစ်တာ ဗွန်", + "got": "" + }, + "given_names": { + "expected": "အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင်", + "got": "ဒေါက်တာ" + }, + "suffix": { + "expected": "ဒေါက်တာ ဂျူနီယာ", + "got": "ဂျူနီယာ" + }, + "text": "ပရော်ဖက်ဆာ ဒေါက်တာ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင် ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ ဂျူနီယာ၊ ဒေါက်တာ", + "title": { + "expected": "ပရော်ဖက်ဆာ ဒေါက်တာ", + "got": "" + } + }, + "my/foreignFull/sorting": { + "family": { + "expected": "ဝူစ်တာ ဘရူ ဝူစ်တာ ဗွန်", + "got": "ဝူစ်တာ ဘရူ" + }, + "family_particles": { + "expected": "ဝူစ်တာ ဗွန်", + "got": "" + }, + "given_names": { + "expected": "အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင်", + "got": "အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင် ဝူစ်တာ ဗွန်" + }, + "text": "ဝူစ်တာ ဘရူ၊ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင် ဝူစ်တာ ဗွန်" + }, + "my/foreignFull/surnameFirst": { + "family": { + "expected": "ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ", + "got": "ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ ပရော်ဖက်ဆာ ဒေါက်တာ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင်" + }, + "family_base": { + "expected": "ဝူစ်တာ ဘရူ", + "got": "ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ ပရော်ဖက်ဆာ ဒေါက်တာ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင်" + }, + "family_particles": { + "expected": "ဝူစ်တာ ဗွန်", + "got": "" + }, + "given_names": { + "expected": "အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင်", + "got": "ဒေါက်တာ" + }, + "suffix": { + "expected": "ဒေါက်တာ ဂျူနီယာ", + "got": "ဂျူနီယာ" + }, + "text": "ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ ပရော်ဖက်ဆာ ဒေါက်တာ အာဒါ ကွန်နီလီယာ ဆီဇာ မာတင် ဂျူနီယာ၊ ဒေါက်တာ", + "title": { + "expected": "ပရော်ဖက်ဆာ ဒေါက်တာ", + "got": "" + } + }, + "my/nativeFull/givenFirst": { + "family": { + "expected": "ဝူစ်တာ", + "got": "မစ္စတာ ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ် ဝူစ်တာ" + }, + "family_base": { + "expected": "ဝူစ်တာ", + "got": "မစ္စတာ ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ် ဝူစ်တာ" + }, + "given_names": { + "expected": "ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ်", + "got": "ဒေါက်တာ" + }, + "suffix": { + "expected": "ဂျူနီယာ ဒေါက်တာ", + "got": "ဂျူနီယာ" + }, + "text": "မစ္စတာ ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ် ဝူစ်တာ ဂျူနီယာ၊ ဒေါက်တာ", + "title": { + "expected": "မစ္စတာ", + "got": "" + } + }, + "my/nativeFull/surnameFirst": { + "family": { + "expected": "ဝူစ်တာ", + "got": "ဝူစ်တာ မစ္စတာ ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ်" + }, + "family_base": { + "expected": "ဝူစ်တာ", + "got": "ဝူစ်တာ မစ္စတာ ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ်" + }, + "given_names": { + "expected": "ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ်", + "got": "ဒေါက်တာ" + }, + "suffix": { + "expected": "ဂျူနီယာ ဒေါက်တာ", + "got": "ဂျူနီယာ" + }, + "text": "ဝူစ်တာ မစ္စတာ ဘာထရမ် ဝဲလ်ဘာဖို့စ် ဟင်နရီ ရောဘတ် ဂျူနီယာ၊ ဒေါက်တာ", + "title": { + "expected": "မစ္စတာ", + "got": "" + } + }, "ne/foreignFull/givenFirst": { "family": { "expected": "भोन ब्रुहल", diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index bb5cd2400..750f8f924 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -454,6 +454,7 @@ "Grace Smith" "Graf Lambsdorff, Otto" "Grand Duke of Tuscany" +"Grant, U.S." "Greve Anna" "Greve Smith, Anna" "Greve, Anna" @@ -1062,6 +1063,7 @@ "John Smith-Jones" "John Smith-Jones, MD-PhD" "John Smith, Jr." +"John U. Smith" "John V" "John V, Dr." "John W Ingram V" @@ -1702,6 +1704,7 @@ "Smith, Sgt Major" "Smith, Sir" "Smith, Sr." +"Smith, U." "Smith, U.S. Senator John" "Smith, V; MD" "Smith, Van V" @@ -1740,6 +1743,10 @@ "Torres Sánchez-Cid Andrés" "Treadwell, U.S. District Judge Marc" "Ts. Dr. Norziha Che Him" +"U Min Ho" +"U Thant" +"U Thein Sein" +"U. S. Grant" "U.S. District Judge Marc Thomas Treadwell" "U.S. Grant" "U.S. Grant Smith, John" @@ -1749,6 +1756,7 @@ "U.S. Senator Smith, Ed" "U.S. Senator Smith, John" "U.S. and U.K. Ambassador Jane Doe" +"U.Thein Sein" "URSULA VON DER LEYEN" "US Senator John Smith" "Uddin, Mr Md" @@ -2010,6 +2018,7 @@ "शर्मा, राम बाबू" "श्री कृष्ण श्रेष्ठ" "এম. আবদুল লতিফ" +"ড. রহিম উদ্দিন" "প্রকৌশলী. Sen" "ਐਮ. ਸਿੰਘ" "ஔவையார் கண்ணன்" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 2b4e55aba..9f44e3794 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -1387,6 +1387,7 @@ {"name": "Grandmaison, Louis de", "given": "Louis", "family": "de Grandmaison", "initials": "L. G."} {"name": "Granger Hermione", "order": "FAMILY_FIRST", "given": "Hermione", "family": "Granger", "initials": "H. G."} {"name": "Granger, Hermione", "given": "Hermione", "family": "Granger", "initials": "H. G."} +{"name": "Grant, U.S.", "given": "U.", "middle": "S.", "family": "Grant", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (shape)"], "initials": "U. S. G."} {"name": "Gregorio Chillón de la Fuente", "given": "Gregorio", "middle": "Chillón", "family": "de la Fuente", "initials": "G. C. F."} {"name": "Gregorio Modrego Casaus", "given": "Gregorio", "middle": "Modrego", "family": "Casaus", "initials": "G. M. C."} {"name": "Grettir Björnsson", "given": "Grettir", "family": "Björnsson", "initials": "G. B."} @@ -2411,6 +2412,7 @@ {"name": "John Smith-Jones", "given": "John", "family": "Smith-Jones", "initials": "J. S."} {"name": "John Smith-Jones, MD-PhD", "given": "John", "family": "Smith-Jones", "suffix": "MD-PhD", "initials": "J. S."} {"name": "John Smith, Jr.", "given": "John", "family": "Smith", "suffix": "Jr.", "initials": "J. S.", "generation": "Jr."} +{"name": "John U. Smith", "given": "John", "middle": "U.", "family": "Smith", "initials": "J. U. S."} {"name": "John V", "given": "John", "family": "V", "ambiguities": ["ORDER", "SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: generation as suffix (vocabulary)"], "initials": "J. V."} {"name": "John V, Dr.", "title": "Dr.", "given": "John", "family": "V", "ambiguities": ["ORDER", "SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: generation as suffix (vocabulary)"], "initials": "J. V."} {"name": "John V. Smith", "given": "John", "middle": "V.", "family": "Smith", "initials": "J. V. S."} @@ -4182,6 +4184,7 @@ {"name": "Smith, Sgt Major", "title": "Sgt Major", "family": "Smith", "initials": "S."} {"name": "Smith, Sir", "title": "Sir", "given": "Smith", "initials": "S."} {"name": "Smith, Sr.", "family": "Smith", "suffix": "Sr.", "initials": "S.", "generation": "Sr."} +{"name": "Smith, U.", "given": "U.", "family": "Smith", "initials": "U. S."} {"name": "Smith, U.S. Senator John", "title": "U.S. Senator", "given": "John", "family": "Smith", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (shape)"], "initials": "J. S."} {"name": "Smith, V; MD", "given": "V;", "family": "Smith", "suffix": "MD", "initials": "V. S."} {"name": "Smith, Van V", "given": "Van", "family": "Smith", "suffix": "V", "initials": "V. S.", "generation": "V"} @@ -4368,6 +4371,9 @@ {"name": "Tschurtschenthaler, Anton von", "given": "Anton", "family": "von Tschurtschenthaler", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: name as middle (declared)"], "initials": "A. T."} {"name": "Tunde Seun Okeke", "given": "Tunde", "middle": "Seun", "family": "Okeke", "initials": "T. S. O."} {"name": "U Kyaw Win", "given": "U", "middle": "Kyaw", "family": "Win", "initials": "U. K. W."} +{"name": "U Min Ho", "given": "U", "middle": "Min", "family": "Ho", "initials": "U. M. H."} +{"name": "U Thant", "given": "U", "family": "Thant", "initials": "U. T."} +{"name": "U Thein Sein", "given": "U", "middle": "Thein", "family": "Sein", "initials": "U. T. S."} {"name": "U. S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} {"name": "U.S. District Judge Marc Thomas Treadwell", "title": "U.S. District Judge", "given": "Marc", "middle": "Thomas", "family": "Treadwell", "initials": "M. T. T."} {"name": "U.S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} @@ -4378,6 +4384,7 @@ {"name": "U.S. Senator Smith, Ed", "title": "U.S. Senator", "given": "Ed", "family": "Smith", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (vocabulary)"], "initials": "E. S."} {"name": "U.S. Senator Smith, John", "title": "U.S. Senator", "given": "John", "family": "Smith", "initials": "J. S."} {"name": "U.S. and U.K. Ambassador Jane Doe", "given": "U.S. and U.K.", "middle": "Ambassador Jane", "family": "Doe", "initials": "U. S. U. K. A. J. D."} +{"name": "U.Thein Sein", "given": "U.", "middle": "Thein", "family": "Sein", "initials": "U. T. S."} {"name": "UNILEVER LTD", "given": "UNILEVER", "family": "LTD", "initials": "U. L.", "capitalized": "Unilever Ltd"} {"name": "URSULA VON DER LEYEN", "given": "URSULA", "family": "VON DER LEYEN", "initials": "U. L.", "capitalized": "Ursula von der Leyen"} {"name": "US Magistrate Judge T Michael Putnam", "title": "US Magistrate Judge", "given": "T", "middle": "Michael", "family": "Putnam", "initials": "T. M. P.", "capitalized_force": "Us Magistrate Judge T Michael Putnam"} @@ -6522,6 +6529,7 @@ {"name": "জুহি চাওলা", "given": "জুহি", "family": "চাওলা", "initials": "জ. চ."} {"name": "জেনদায়া", "given": "জেনদায়া", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "জ."} {"name": "জেনদায়া", "order": "FAMILY_FIRST", "given": "জেনদায়া", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "জ."} +{"name": "ড. রহিম উদ্দিন", "title": "ড.", "given": "রহিম", "family": "উদ্দিন", "initials": "র. উ."} {"name": "দেবী শর্মা", "given": "দেবী", "family": "শর্মা", "initials": "দ. শ."} {"name": "নগেন বৰা", "given": "নগেন", "family": "বৰা", "initials": "ন. ব."} {"name": "নমিতা বৰুৱা", "given": "নমিতা", "family": "বৰুৱা", "initials": "ন. ব."} From af68dc6982f113296ab8315e0a147e4753833199 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:07:01 -0800 Subject: [PATCH 02/13] Record locales.MY and rules/H11 in the rules, decisions and docs (#1231) rules/H11 and decisions/H11 state the one-letter title veto; rules/H1 gains the Burmese title-and-one-word cost; decisions/vocabulary- collisions gains a Standing line and a dated entry with the population, its recipe and the pack's cost on other names; mechanisms.md and the locales AGENTS.md name the second removing pack. docs/languages.rst gains a Burmese section with when not to use the pack, docs/locales.rst and README.rst the pack's rows, the release log a bullet. Co-Authored-By: Claude Opus 5.5 --- README.rst | 2 +- ...ter-title-against-the-initial-it-spells.md | 20 ++++ docs/design/decisions/README.md | 1 + .../design/decisions/vocabulary-collisions.md | 9 ++ docs/design/mechanisms.md | 4 +- .../rules/H1-title-and-one-name-word.md | 4 + ...ter-title-against-the-initial-it-spells.md | 38 ++++++++ docs/design/rules/README.md | 1 + docs/languages.rst | 91 ++++++++++++++++++- docs/locales.rst | 25 ++++- docs/release_log.rst | 1 + 11 files changed, 187 insertions(+), 9 deletions(-) create mode 100644 docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md create mode 100644 docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md diff --git a/README.rst b/README.rst index 72ff022de..4561143ff 100644 --- a/README.rst +++ b/README.rst @@ -184,7 +184,7 @@ the patronymic in Russian. See `Locale packs >>> ivan.given, ivan.patronymic, ivan.family ('Иван', 'Петрович', 'Сидоров') >>> locales.available() # every pack that ships - ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'ne', 'nl', 'pt', 'pt_br', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') + ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'my', 'ne', 'nl', 'pt', 'pt_br', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') When a reading is wrong for your data ------------------------------------- diff --git a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md new file mode 100644 index 000000000..3e312f925 --- /dev/null +++ b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md @@ -0,0 +1,20 @@ +# H11 — a one-letter title against the initial it spells + +## Standing + +- A one-letter word written with its period is an initial and not a title where its letter has a capital, whatever title the letter spells, and so is such a letter cut from a word at its full stops (`U. S. Grant`, `Grant, U.S.` and `U.Thein Sein` under `locales.MY` read as the default reads them); written bare it is the title (`U Thein Sein` → title 'U' under the pack); a letter of a script without capitals keeps its title written with its period (`ড. রহিম উদ্দিন` → title 'ড.') — 2026-11-19 #1231. +- The veto is a shape, stated once for every one-letter title a lexicon holds, a caller's included, as rules/P7 states it for the particles; no per-word property (the reserved `bare_only`) is built for it — 2026-11-19 #1231. + +Open: none in this file. + +## Log + +- 2026-11-19 #1231 — A ONE-LETTER TITLE WRITTEN WITH ITS PERIOD IS THE INITIAL IT SPELLS, WHERE THE LETTER HAS A CAPITAL. `locales.MY` turns on `u`, the Burmese honorific (my.toml, `default = false`), the first one-letter title in a cased script any lexicon the project ships has held: the default's are the Bengali `ড` and the Thai `ศ` (`sorted(w for w in L.titles | L.titles_ambiguous if len(w) == 1)` with `L = Parser().lexicon._sets`, 2026-11-19). The title match folds edge periods away, so the reading alone also claimed `U.`: the issue's simulated lexicon read `U. S. Grant` title 'U.', given 'S.', and `Grant, U.S.` title 'U.S.' through the period-joined derivation, which reads a word whose chunk is a title as a title. The issue asked whether `U` should need the absence of a period, and the working answer (decision 3 of the 2026-11-19 #1231 entry in decisions/vocabulary-collisions) was yes; the period is a fact about initials, the same line rules/P7 draws for a one-letter particle (`Juan Ó. Pérez`), so it is stated as a shape, not as a property of `u`, and reaches a caller's one-letter title too. + - **Where it reads.** Two sites, the two that turn the vocabulary into a reading of a word written with periods: classify's title tag, asking `_lexicon._spells_a_cased_initial` after its membership hit (`_spells_an_initial`, P7's helper, narrowed to a letter that upper-cases to something else), and the period-joined derivation's chunk test, `_vocab._title_chunk`, which both `period_joined_vocab` and `period_joined_title` ask. The other readers of the title set (the comma's unit count, the glued-stop test, the title phrase's head run, the suggester) were not changed. Measured: over 23 shapes holding a one-letter word (every comma shape, behind and before a title, in one case, with `Jr.` and `PhD` after it) × 6 spellings (`U.`, `u.`, `U.S.`, `U.S`, `Ü.`, `U.Thein`) × the three orders, `parser_for(locales.MY)` read every name as the default does except where the fragment's `la` moved one (`Vega, U. de la`), 2026-11-19 on this branch (a scratch probe comparing `as_dict()` and the ambiguity kinds). + - **The capital.** The Bengali `ড` is written `ড.` as the doctor (bn.toml's note), the full stop being the title's writing, so a letter of a script without case keeps its title reading. The default moves nothing: it holds no one-letter title in a cased script, and the committed snapshot is byte-identical across the change. + - **Accepted:** under the pack a name opening with a bare `U` reads it as the title, a Korean surname `U` written bare included (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19), and so does a bare `U` written as an initial without its period, which FEC writes 187 times beside 163 `U.`, mostly a middle initial after a comma, where no title reads. + - **Left out:** #1205's `H.` (Haji) under an Indonesian choice asks the opposite, the dotted letter as the title; this entry makes that a title only where a reading or a rule says so for that letter, which #1205's decision would add. + +Declined: + +- A per-reading property read only bare (`bare_only`, reserved, unbuilt, for 3.x in tools/vocab/build.py) — the period convention is a fact about initials, not about `u`, as decisions/P7 declined a flag for `ó`; a property would be one more axis for every guard roster to sweep, for a question no entry answers differently today. #1205 may be the first entry that does. diff --git a/docs/design/decisions/README.md b/docs/design/decisions/README.md index 7dc9878ae..7afecda98 100644 --- a/docs/design/decisions/README.md +++ b/docs/design/decisions/README.md @@ -33,6 +33,7 @@ Entry conventions: - [H8 — a salutation ending the given part](H8-salutation-ending-the-given-part.md) - [H9 — the title phrase](H9-title-phrase.md) - [H10 — a title written as a run of letters](H10-title-written-as-a-run-of-letters.md) +- [H11 — a one-letter title against the initial it spells](H11-one-letter-title-against-the-initial-it-spells.md) ## Particles & surname prefixes (P) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 0a6f9a38b..0f9ad0979 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -30,6 +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, 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 — 2026-11-19 #1231. ## Log @@ -98,3 +99,11 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - **Scored** against the filed boxes, `uv run python tools/differential/config_diff.py score "expr:Parser(lexicon=Lexicon.default().remove('oude'))" default plain:NL strict:NL --cap 20000`, ORCID and PatentsView by country and PSC by nationality, the 434 groups of 100 records or more, each capped at 20,000 (2026-11-18): the default fixes 16 to 1 broken (ORCID Netherlands 10, PatentsView Netherlands 5 and Germany 1; the break a PatentsView filer who typed `Oude` at the end of the given box), the vetting's figure. `plain:NL` fixes 102 to 10, so `ten` under the pack 86 to 9: the Netherlands and its filers 66 to 4 (ORCID 31 to 0, PatentsView 28 to 4, PSC's Dutch 7 to 0), Belgium 2 to 0, elsewhere 18 to 5. Read one by one with `local_agreement.read` (a scratch probe, the same day), two of the nine breaks are the mid-name syllable (PatentsView Malaysia `Kheng Ten Choo` and Singapore `Terence Ten Teck Hong`), the other seven filers who typed `ten` at the end of the given box (`Nils Ten` / `Hoeve`). The 20 fixes outside the Netherlands are the Dutch-surnamed people the decision gives up for the default caller. `uv run python tools/differential/config_diff.py gaps nl` (the same day) reads the strict choice against the plain one over the Dutch-language groups: 456 broken to 54 fixed, other languages' Latin particles dropped (`el`, `di`, `al`, `le`, `da`), `ten` not among its twenty words. - **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, which rules/H11 states as a shape (decisions/H11); (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, each opening 4 names or fewer in the population below. + - **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`. + - **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 nothing else: `do`'s credential reading stays, so a name written wholly in capitals ending in `DO` reads the suffix as by default (`DAW KHIN MYA DO` → suffix 'DO'), the one-case shape the 2026-11-05 #1108 entry of decisions/vocabulary-model found unmasked by a removal, here masked neither way. `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. + - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. 153 names move, 151 from a misreading to the intended reading (`u` 71, `san` 39, `daw` 27, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (`Daw Nu Mya Zan, Daw Nu Mara Zan`, two names in one string). The intended reading holds for 2,836 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. + - **The cost to names that are not Burmese**, measured on this branch (2026-11-19). `config_diff.py diff default plain:MY --committed`: 253 of 7,643 names move, 2 of them Burmese (`Daw Thida`, `U Kyaw Win`) and 251 others, `van` 129, `da` 20, `do` 14, `la` 11, `di` 6, `du` 5. `config_diff.py diff default plain:MY --local tse-donors --local psc-individuals --local ukec-individuals`: TSE's Brazilian donors 116,044 of 848,351 (`da` 100,949, `do` 12,550), PSC's filers 3,823 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 a third of a point or less; Vietnam 68.50% to 67.20% 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 or Filipino particle among the nine is a name word (`Jan van Dijk` → middle 'van', family 'Dijk'), which the pack's docstring and docs/languages.rst say, with the figures above; a bare `U` opening a name is the title, a Korean surname `U` included (rules/H11's Accepted); 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`); `do`'s credential reading under the pack. diff --git a/docs/design/mechanisms.md b/docs/design/mechanisms.md index c2d4262b5..a98a72e21 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 (one pack's of removals, `locales.VI`'s, below) and a Policy patch — applied by parser_for, a shipped pack's patch compiled from its language file's `[rules]` table where one is written, each key the `Policy` field of its name: the packs' languages union with the base's recorded choice into one choice, recorded on the `Lexicon`, which selects among the base's shipped readings by the file each sits in, the fragments join in pack order and the caller's lexicon after them, its own readings applying after the choice, and the patches fold in order (set-valued fields union, `script_orders` merges by script, scalars override); packs contain no code paths of their own. A vocabulary pack's deviations are derived from the reading index, the words whose compiled readings its choice changes; a policy or segmentation pack declares its own in its docstring and `DEVIATES`. +**Contract statement.** A locale pack is pure data — a choice of languages, a Lexicon fragment of ADDITIONS (two packs' of removals, `locales.VI`'s and `locales.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`. -**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): 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). +**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`, 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). **Lives in.** nameparser/locales/ (packs), nameparser/_parser.py (parser_for, the one applier), nameparser/_lexicon.py (the compile under a recorded choice, `_chosen_pool` and `_built`), nameparser/_reading_index.py (the selection, `choose`, and the derived surface, `changed_words`), nameparser/_locale.py (`rules_patch`, a file's compiled `[rules]` as a patch) and tools/vocab/build.py (`RULE_KEYS`, the rules a file may turn on, and `PACK_RULES`, the files the shipped packs read; decisions/vocabulary-model, 2026-10-29 4f). A rule a file turns on is a `Policy` field; a new rule kind is a core change, never code in a pack: a new `Policy` field (with `ADDED_IN`), a row in build.py's `RULE_KEYS` and in `_locale._RULE_VALUES`, and a mechanisms.md entry of its own for the rule kind. diff --git a/docs/design/rules/H1-title-and-one-name-word.md b/docs/design/rules/H1-title-and-one-name-word.md index 783e4af98..9f2899d06 100644 --- a/docs/design/rules/H1-title-and-one-name-word.md +++ b/docs/design/rules/H1-title-and-one-name-word.md @@ -78,6 +78,10 @@ "Anna Greve" → family="Greve" "Greve, Anna" → family="Greve" ``` +- A Burmese name of an honorific and one name word gives the word to the family under a Burmese choice, though a Burmese name holds no family name: the position reads it as any other name's last word (#1231). + ``` + "U Thant" [my] → family="Thant" + ``` --- **Signal:** count: exactly one name word beside a title run, read by the run's addressing title diff --git a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md new file mode 100644 index 000000000..452ceb45d --- /dev/null +++ b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md @@ -0,0 +1,38 @@ +# H11 — a one-letter title against the initial it spells + +**When:** a one-letter word the title vocabulary holds stands in a name, as the Burmese honorific U does under a Burmese choice in "U Thein Sein". + +**Then:** a one-letter word written with its period is an initial and not a title, where the letter has a capital, whatever title the same letter spells; written bare, it is the title. + +- **A single letter with a capital between full stops inside a word is an initial too**, so a word cut at its full stops into initials is no title for holding the letter. + ``` + "Grant, U.S." [my] → given="U." + "U.Thein Sein" [my] → given="U." + ``` + +**Because:** a one-letter title is spelled with the same letter as an initial, and the full stop is what tells them apart. An initial is an abbreviation and is written with one; an honorific written as one letter is a whole word and is not. The Burmese U is never written with a full stop, while U. is the initial of Ulysses or Ursula. + +``` +"U. S. Grant" [my] → given="U." +"John U. Smith" [my] → middle="U." +"Smith, U." [my] → given="U." +"U Thein Sein" [my] → title="U" · boundary +``` + +**Except:** + +- **A letter of a script without capitals keeps its title reading written with its period**, the full stop being how that title is written, as the Bengali ড. (doctor) is. + ``` + "ড. রহিম উদ্দিন" → title="ড." + ``` + +**Accepted:** + +- A Korean name opening with the surname U, written bare, reads the surname as the title under a Burmese choice, as any name opening with the bare letter does there. + ``` + "U Min Ho" [my] → title="U" + ``` + +--- +**Signal:** shape: a one-letter word's full stop, and whether its letter has a capital +**history:** decisions/H11 · **implemented:** nameparser/_lexicon.py, nameparser/_pipeline/_classify.py, nameparser/_pipeline/_vocab.py diff --git a/docs/design/rules/README.md b/docs/design/rules/README.md index 55d887a8f..403358047 100644 --- a/docs/design/rules/README.md +++ b/docs/design/rules/README.md @@ -125,6 +125,7 @@ Terms the rules use without defining them each time, each with the rule that def - [H8 — a salutation ending the given part](H8-salutation-ending-the-given-part.md) - [H9 — the title phrase](H9-title-phrase.md) - [H10 — a title written as a run of letters](H10-title-written-as-a-run-of-letters.md) +- [H11 — a one-letter title against the initial it spells](H11-one-letter-title-against-the-initial-it-spells.md) ## [Particles & surname prefixes (P)](P-particles-and-surname-prefixes.md) diff --git a/docs/languages.rst b/docs/languages.rst index 4debde7b8..71eaa4e15 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -18,8 +18,8 @@ subset with its own parser, or pass several packs to ``parser_for``: The sections below cover Czech, Slovak, Slovenian and Croatian names, Spanish and Portuguese titles and family names, romanized Indic titles, -Vietnamese, Mongolian and Thai names, and Maghrebi, Amazigh, Hebrew and -Dutch particles. Other languages are described where their mechanism is: +Vietnamese, Mongolian and Thai names, Maghrebi, Amazigh, Hebrew and +Dutch particles, and Burmese names. Other languages are described where their mechanism is: - **East Slavic patronymics** (``ru``): :ref:`east-slavic-patronymics`. - **Turkic patronymic markers** (``tr_az``): @@ -1177,3 +1177,90 @@ What the pack costs ... languages=frozenset({"en"})) >>> parser_for(locales.NL, english).parse("John Smith VD").suffix 'VD' + +.. _burmese-names: + +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. + +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. +The parser reads by position, so under the pack the last word is the +family name, as in any name, and the honorific is the title: + +.. doctest:: + + >>> parse("U Thein Sein").given + 'U' + >>> burmese = parser_for(locales.MY) + >>> thein_sein = burmese.parse("U Thein Sein") + >>> 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: + +.. doctest:: + + >>> parse("Daw Aung San Suu Kyi").family + 'San Suu Kyi' + >>> suu_kyi = burmese.parse("Daw Aung San Suu Kyi") + >>> suu_kyi.title, suu_kyi.middle, suu_kyi.family + ('Daw', 'San Suu', 'Kyi') + +The nine are ``San``, ``La``, ``Le``, ``Do``, ``Da``, ``Du``, ``Te``, +``Di`` and ``Van``. ``U`` written with its full stop stays an initial, +as it is in ``U. S. Grant``: + +.. doctest:: + + >>> burmese.parse("U. S. Grant").given + 'U.' + +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`). + +What the pack leaves as it is +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- **Other honorifics and prefixes.** ``Ko``, ``Ma`` and ``Maung`` are + honorifics too but also name syllables (``Maung Maung Kyaw``), and the + ethnic prefixes ``Saw``, ``Sai``, ``Nang``, ``Naw``, ``Khun`` and + ``Mahn`` are part of the name, so each stays a name word. +- **An honorific and one word.** ``U Thant`` gives title ``U``, family + ``Thant``, as a title and one name word reads in any name. +- **Military and religious styles** (``Bogyoke``, ``Sayadaw``) are read + as given names, as by default. +- **Burmese script.** The pack reads Latin letters only; ``ဦး`` and + ``ဒေါ်`` have no reading yet. + +When not to use it +~~~~~~~~~~~~~~~~~~ + +The pack is for lists of Burmese names. On other names it costs the +particles of Spanish, Portuguese, Italian, French and Dutch family +names, so keep it to a parser of its own for the Burmese names in your +data: + +.. doctest:: + + >>> burmese.parse("Jan van Dijk").family + 'Dijk' + >>> burmese.parse("Maria da Silva").family + 'Silva' + +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 it lowers the share read +right in both from 94% to 83% in the Netherlands and from 95% to 89% in +Belgium. A Korean name opening with the surname ``U`` written bare +reads ``U`` as the title under the pack. diff --git a/docs/locales.rst b/docs/locales.rst index 2e22cf3ce..854c045a2 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -144,6 +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 and Dutch family names among + them, and any opening with ``U`` or ``Daw``. .. warning:: @@ -182,7 +186,7 @@ look one up dynamically by its lowercase code with .. doctest:: >>> locales.available() - ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'ne', 'nl', 'pt', 'pt_br', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') + ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'my', 'ne', 'nl', 'pt', 'pt_br', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') >>> locales.get("ru") is locales.RU True @@ -292,6 +296,13 @@ says which parts each pack is made of. name last, so the father's name, written first, is the family. See :ref:`Mongolian names `. - ``Батын Сүхээ`` → family ``Батын``, given ``Сүхээ`` + * - ``my`` + - Burmese + - Chooses ``my``, which reads the honorifics ``U`` and ``Daw`` + opening a name as titles, 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`` * - ``ne`` - Nepali - Chooses ``ne``, which reads ``श्री``, ``गुरु`` and ``Guru`` as @@ -395,6 +406,10 @@ says what it can change: - yes - ``initials_as_family`` - none + * - ``my`` + - yes + - none + - none; it takes readings out instead * - ``vi`` - yes - ``name_order`` @@ -408,8 +423,8 @@ says what it can change: - ``segment_scripts``, for the script its list covers - a surname list -``vi`` is the one pack whose own fragment takes readings out rather -than adding them (`What a pack's lexicon may hold`_). +``vi`` and ``my`` are the packs whose own fragments take 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 @@ -1121,4 +1136,6 @@ 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. + ``vi.toml`` could write would keep ``Van`` a name word. ``my``'s + fragment takes out the particle readings of the Burmese syllables + the same way. diff --git a/docs/release_log.rst b/docs/release_log.rst index 855c9284f..513f3b870 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -7,6 +7,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``; ``U.`` with its full stop stays an initial. It reads ``San``, ``La``, ``Van`` and six more as name words, so it costs Spanish, Portuguese, Italian, French and Dutch particles (``Jan van Dijk`` gives family ``Dijk``): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` - **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.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` From d5c7e4de4d5f2190264bdb31f77aca74b164ed34 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:24:59 -0800 Subject: [PATCH 03/13] Ask rules/H11 at every reader of the titles, and take out do's credential under MY (#1231) The review found U. still read as a title through the comma count (U. Smith, Ed reversed), the title phrase (Vice U. Smith), the glued-stop cut (Dr.U. Smith), the set-apart clause ((U.) Smith), C2's third part (its report lost) and the group suggester. _lexicon._spells_a_cased_initial is now the one predicate, asked after each reader's membership hit and a C-level length test, so only a one-letter title pays a frame; _vocab._title_chunk is folded back into its two callers. The H8, given-title and trailing-title tags take the veto too, and the title phrase reads a vetoed word as no title and no phrase member. Tests: a 288-row two-input invariant (a caller's q title against the default, every comma shape, order and reader) with its recorded control (228 rows move with the veto off); every kind of title reading a caller can write; a Greek capital; the reviewers' U. shapes under MY, with ambiguities compared; the suggester. locales.MY also takes out do's credential reading: with san no particle, AUNG SAN DO read suffix 'DO' (nameparser/vocab/AGENTS.md, "A reading taken out"). rules/H11 is rewritten: the Bengali case a boundary, the chunk bullet reworded, the Because's universal dropped, and a Burmese U written with its stop recorded as accepted. Co-Authored-By: Claude Opus 5.5 --- ...ter-title-against-the-initial-it-spells.md | 26 ++-- nameparser/_lexicon.py | 25 ++-- nameparser/_pipeline/_classify.py | 20 ++-- nameparser/_pipeline/_segment.py | 8 +- nameparser/_pipeline/_vocab.py | 64 ++++++---- nameparser/_suggest.py | 10 +- nameparser/locales/my.py | 38 ++++-- tests/v2/pipeline/test_classify.py | 111 ++++++++++++++++-- tests/v2/test_layering.py | 8 +- tests/v2/test_locales.py | 86 ++++++++++---- tools/differential/corpus_rules.jsonl | 5 + tools/differential/snapshot.jsonl | 5 + 12 files changed, 306 insertions(+), 100 deletions(-) diff --git a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md index 452ceb45d..0444924fa 100644 --- a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md +++ b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md @@ -2,37 +2,39 @@ **When:** a one-letter word the title vocabulary holds stands in a name, as the Burmese honorific U does under a Burmese choice in "U Thein Sein". -**Then:** a one-letter word written with its period is an initial and not a title, where the letter has a capital, whatever title the same letter spells; written bare, it is the title. +**Then:** a one-letter word written with its period is an initial and not a title, where the letter has a capital, whatever title the same letter spells and wherever the word stands; written bare, it is the title. -- **A single letter with a capital between full stops inside a word is an initial too**, so a word cut at its full stops into initials is no title for holding the letter. +- **A single letter with a capital cut from a word at its full stops is an initial too**, so a word of initials, or a name glued to an initial at its full stop, is no title for holding the letter. ``` "Grant, U.S." [my] → given="U." "U.Thein Sein" [my] → given="U." + "Dr.U. Smith" [my] → given="U." ``` -**Because:** a one-letter title is spelled with the same letter as an initial, and the full stop is what tells them apart. An initial is an abbreviation and is written with one; an honorific written as one letter is a whole word and is not. The Burmese U is never written with a full stop, while U. is the initial of Ulysses or Ursula. +**Because:** a one-letter title is spelled with the same letter as an initial, and the full stop is what tells them apart. An initial is an abbreviation and is written with one; an honorific written as one letter is a whole word and is written bare as a rule, as the Burmese U is in the names #1231 measured, while U. is the initial of Ulysses or Ursula. A letter of a script without capitals is outside the rule: the full stop is how such a title is written, as the Bengali ড. (doctor) is. ``` "U. S. Grant" [my] → given="U." "John U. Smith" [my] → middle="U." "Smith, U." [my] → given="U." +"U. Smith, Ed" [my] → suffix="Ed" +"Vice U. Smith" [my] → given="Vice" +"John (U.) Smith" [my] → middle="U." "U Thein Sein" [my] → title="U" · boundary +"ড. রহিম উদ্দিন" → title="ড." · boundary ``` -**Except:** - -- **A letter of a script without capitals keeps its title reading written with its period**, the full stop being how that title is written, as the Bengali ড. (doctor) is. - ``` - "ড. রহিম উদ্দিন" → title="ড." - ``` - **Accepted:** - A Korean name opening with the surname U, written bare, reads the surname as the title under a Burmese choice, as any name opening with the bare letter does there. ``` "U Min Ho" [my] → title="U" ``` +- A Burmese U written with a full stop reads as the given name under a Burmese choice, the writing being an initial's. + ``` + "U. Thein Aung" [my] → given="U." + ``` --- -**Signal:** shape: a one-letter word's full stop, and whether its letter has a capital -**history:** decisions/H11 · **implemented:** nameparser/_lexicon.py, nameparser/_pipeline/_classify.py, nameparser/_pipeline/_vocab.py +**Signal:** shape: a one-letter word written with its full stop, in a script with capitals +**history:** decisions/H11 · **implemented:** nameparser/_lexicon.py, nameparser/_pipeline/_classify.py, nameparser/_pipeline/_vocab.py, nameparser/_pipeline/_segment.py diff --git a/nameparser/_lexicon.py b/nameparser/_lexicon.py index 0ccb71668..96d8501ea 100644 --- a/nameparser/_lexicon.py +++ b/nameparser/_lexicon.py @@ -159,14 +159,23 @@ def _spells_an_initial(n: str, text: str) -> bool: # rules/H11: "a one-letter word written with its period is an initial # and not a title, where the letter has a capital" def _spells_a_cased_initial(n: str, text: str) -> bool: - """`_spells_an_initial`, narrowed to a letter that has a capital - ('U.', 'h.'): such a word is an initial whatever title the letter - also spells (#1231). A letter of a script without case ('ড.', the - Bengali doctor) keeps its title reading, the full stop being how - that title is written. `n` is `_normalize(text)`, folded once by - the caller, and lower case, so a letter with a capital is one that - upper-cases to something else.""" - return _spells_an_initial(n, text) and n.upper() != n + """Whether `text`, folded to `n`, is one letter with a capital + written with a full stop ('U.', 'h.', the 'U.' of 'U.S.' cut at its + stops): an initial whatever title the letter also spells (#1231). + A letter of a script without case ('ড.', the Bengali doctor) keeps + its title reading, the full stop being how that title is written. + `n` is `_normalize(text)`, so its edge stops are gone and a full + stop left in `text` beside a one-letter `n` is one of them; and it + is lower case, so a letter with a capital is one that upper-cases + to something else. + + Every reader of the title vocabulary asks it, after its membership + hit and its own `len(n) != 1` test at C level, so only a one-letter + title pays the frame: classify's tags, the period-joined + derivation's chunks, the set-apart clause's kind, the glued-stop + cut, the comma count, the title phrase, C2's third part and the + group suggester.""" + return len(n) == 1 and "." in text and n.upper() != n def _fold_words(words: Iterable[str]) -> list[str]: diff --git a/nameparser/_pipeline/_classify.py b/nameparser/_pipeline/_classify.py index acbd452a4..5241bc9b0 100644 --- a/nameparser/_pipeline/_classify.py +++ b/nameparser/_pipeline/_classify.py @@ -174,11 +174,14 @@ def _tags_for(token: WorkToken, n: str, state: ParseState, if marker_tag is not None: tags.add(marker_tag) # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" -- the - # set and length tests first, at C level, so only a one-letter - # title pays the frame - if n in lex._sets.titles and not ( - len(n) == 1 and _spells_a_cased_initial(n, token.text)): + # initial and not a title, where the letter has a capital" -- for + # every title tag below; the length and set tests first, at C level, + # so only a one-letter title pays the frame, not every initial (the + # tags below read sets inside these two) + initial = (len(n) == 1 + and (n in lex._sets.titles or n in lex._sets.titles_ambiguous) + and _spells_a_cased_initial(n, token.text)) + if n in lex._sets.titles and not initial: tags.add("vocab:title") # rules/H5: "a title the vocabulary lists whole with a period # inside it chains without a final one" -- marked here, where @@ -197,17 +200,18 @@ def _tags_for(token: WorkToken, n: str, state: ParseState, elif ("." in n and n.replace(".", "") in lex._sets.dotted_titles and is_dotted_title(token.text, n, lex)): tags.add(DOTTED_TITLE_TAG) - if n in lex._sets.given_name_titles: + if n in lex._sets.given_name_titles and not initial: tags.add("vocab:given-title") # rules/H5: "a title that may be a given name is title vocabulary # there where its title reading is written short" -- marked here, # where the sets are at hand, so the chain reads a tag if (n in lex._sets.title_abbreviations - and n in lex._sets.titles_ambiguous): + and n in lex._sets.titles_ambiguous and not initial): tags.add(TRAILING_TITLE_TAG) # rules/H8: "the word joins the title field" -- tagged only where the # word is a title too, so an entry outside `titles` is inert - if n in lex._sets.after_given_titles and n in lex._sets.titles: + if (n in lex._sets.after_given_titles and n in lex._sets.titles + and not initial): tags.add("vocab:after-given-title") if suffix_as_written(n, token.text, lex): tags.add("vocab:suffix") diff --git a/nameparser/_pipeline/_segment.py b/nameparser/_pipeline/_segment.py index c76fc21e1..139e07dae 100644 --- a/nameparser/_pipeline/_segment.py +++ b/nameparser/_pipeline/_segment.py @@ -34,7 +34,7 @@ """ from __future__ import annotations -from nameparser._lexicon import _normalize +from nameparser._lexicon import _normalize, _spells_a_cased_initial from nameparser._pipeline._pieces import own_words from nameparser._pipeline._state import ( ParseState, PendingAmbiguity, Structure, comma_bucket, copy_with, @@ -162,8 +162,12 @@ def titles_and_suffixes(seg: tuple[int, ...]) -> bool: # reads as the title, as classify tags it (decisions/C10) titles = state.lexicon._sets.titles cores = glued_cores(state.policy.extra_suffix_delimiters) + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" rest = tuple([i for i in seg - if _normalize(t := state.tokens[i].text) not in titles + if ((n := _normalize(t := state.tokens[i].text)) + not in titles + or len(n) == 1 and _spells_a_cased_initial(n, t)) and ("." not in t or period_joined_vocab(t, state.lexicon) != "title") diff --git a/nameparser/_pipeline/_vocab.py b/nameparser/_pipeline/_vocab.py index c396c8565..091cf5ced 100644 --- a/nameparser/_pipeline/_vocab.py +++ b/nameparser/_pipeline/_vocab.py @@ -56,7 +56,7 @@ from nameparser._lexicon import ( FULL_STOPS, Lexicon, _HYPHEN_CHARS, _VOCAB_FIELDS, _normalize, - _spells_an_initial, + _spells_a_cased_initial, _spells_an_initial, ) from nameparser._policy import ( CapsSuffixes, Policy, Script, _CASELESS_LETTERS, _EAST_ASIAN_SCRIPTS, @@ -575,8 +575,11 @@ def set_apart_kind(word: str, lexicon: Lexicon, # the period test asked at C level first (decisions/S3, #1131) joined = ("." in folded and folded not in sets.titles and acronym not in sets.suffix_acronyms) - title = folded in sets.titles or joined and period_joined_title( - bare, lexicon) + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" -- '(U.)' + title = folded in sets.titles and ( + len(folded) != 1 or not _spells_a_cased_initial(folded, bare) + ) or joined and period_joined_title(bare, lexicon) if joined and not title and period_joined_credential(bare, lexicon): # rules/S3: "a joined word holding a member is a member itself" # -- 'Msc.Ed' as 'MA/PhD', settled by S13's position (#1138) @@ -1006,7 +1009,11 @@ def _claimed_after_the_stop(w: str, lexicon: Lexicon) -> bool: unambiguous title or suffix word, and so no name (rules/T8): the one test `glued_cuts` and `glued_saint_cut` ask of it.""" sets = lexicon._sets - return w in sets.titles or ( + # rules/H11: "single letter with a capital cut from a word at its + # full stops is an initial too" -- the word after a glued stop is cut + # at it ('Dr.U.') + return w in sets.titles and ( + len(w) != 1 or not _spells_a_cased_initial(w, ".")) or ( w in sets.suffix_acronyms and w not in sets.suffix_acronyms_ambiguous) or ( (w in sets.suffix_words or w in sets.credential_words) @@ -1223,9 +1230,12 @@ def is_title_chunk(chunk: str, lexicon: Lexicon) -> bool: word, `glued_saint_cut`).""" sets = lexicon._sets n = _normalize(chunk) + # rules/H11: "single letter with a capital cut from a word at its + # full stops is an initial too" -- a chunk read before its full stop return n not in sets.saint_particles and ( n in sets.titles or n in sets.titles_ambiguous - or n in sets.title_modifiers or n in sets.title_styles) + or n in sets.title_modifiers or n in sets.title_styles) and ( + len(n) != 1 or not _spells_a_cased_initial(n, ".")) def is_dotted_title(text: str, n: str, lexicon: Lexicon) -> bool: @@ -1684,17 +1694,6 @@ def period_member(word: str, lexicon: Lexicon) -> bool: and _holds_a_member(bare, lexicon)) -# rules/H11: "single letter with a capital between full stops inside a -# word is an initial too" -- 'U.S.' and 'U.Thein' are cut at their full -# stops, and a one-letter chunk is an initial there, never the title the -# letter spells (#1231) -def _title_chunk(chunk: str, lexicon: Lexicon) -> bool: - """Whether CHUNK, one folded piece of a word cut at its periods, is - title vocabulary, a single letter with a capital excepted.""" - return chunk in lexicon._sets.titles and not ( - len(chunk) == 1 and chunk.upper() != chunk) - - # rules/H5: "a word with interior periods every one of whose chunks is # a title chains without a final period" -- 'Lt.Gov', where the # periods join nothing but titles (decisions/H5, #1131) @@ -1703,8 +1702,13 @@ def period_joined_title(text: str, lexicon: Lexicon) -> bool: one of which is title vocabulary ('Lt.Gov', 'Lt.Col'; not 'Dr.PhD' or 'St.John').""" chunks = [_normalize(c) for c in text.split(".") if c] + titles = lexicon._sets.titles + # rules/H11: "single letter with a capital cut from a word at its + # full stops is an initial too" -- a chunk is cut at a full stop, so it + # is written with one; the length test first, at C level return len(chunks) >= 2 and all( - _title_chunk(c, lexicon) for c in chunks) + c in titles and (len(c) != 1 or not _spells_a_cased_initial(c, ".")) + for c in chunks) def _is_suffix_strict_n(n: str, text: str, lexicon: Lexicon, @@ -1914,7 +1918,11 @@ class by shape for the first time (measured regression, #516 if glued_saint_cut(text, lexicon) is not None: return None chunks = [_normalize(c) for c in text.split(".") if c] - if any(_title_chunk(c, lexicon) for c in chunks): + titles = lexicon._sets.titles + # rules/H11: "single letter with a capital cut from a word at its + # full stops is an initial too" -- as in `period_joined_title` + if any(c in titles and (len(c) != 1 or not _spells_a_cased_initial(c, ".")) + for c in chunks): return "title" if period_joined_credential(text, lexicon): return "suffix" @@ -2556,14 +2564,21 @@ def title_readings(texts: Sequence[str], folded: Sequence[str], # a word in titles is a title wherever it stands, whatever else it # is listed as; one of titles_ambiguous alone is listed as a title # to its neighbours and read by its phrase - reading = [n in titles or n in contested for n in folded] + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" -- read + # as no title here, nor by its phrase below + initial = [len(n) == 1 and (n in titles or n in contested) + and _spells_a_cased_initial(n, text) + for n, text in zip(folded, texts)] + reading = [(n in titles or n in contested) and not vetoed + for n, vetoed in zip(folded, initial)] if titled is not None: reading = [r or t for r, t in zip(reading, titled)] listed = list(reading) phrases = lexicon._sets.title_phrases last = len(folded) - 1 for i, n in enumerate(folded): - if n in titles or n not in contested or n in modifiers: + if n in titles or n not in contested or n in modifiers or initial[i]: continue prev = folded[i - 1] if i else None nxt = folded[i + 1] if i < last else None @@ -2690,7 +2705,11 @@ def name_word_count(texts: Sequence[str], lexicon: Lexicon, else title_readings(texts, folded, lexicon, head=True)) for i, n in enumerate(folded): text = texts[i] - title = n in lexicon._sets.titles if titled is None else titled[i] + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" + title = (n in lexicon._sets.titles + and (len(n) != 1 or not _spells_a_cased_initial(n, text)) + if titled is None else titled[i]) if title and i in dotted: # a title only opening the part (behind any titles), and only # with a title, listed or by H2's shape, behind it and a word @@ -2701,6 +2720,9 @@ def name_word_count(texts: Sequence[str], lexicon: Lexicon, nxt = i + 1 title = (lead is None and nxt < len(folded) and ((folded[nxt] in lexicon._sets.titles + and (len(folded[nxt]) != 1 + or not _spells_a_cased_initial( + folded[nxt], texts[nxt])) if titled is None else titled[nxt]) or is_title_shaped(texts[nxt], lexicon)) and nxt + 1 < len(folded)) diff --git a/nameparser/_suggest.py b/nameparser/_suggest.py index 89fc0ea1e..a1438f1c8 100644 --- a/nameparser/_suggest.py +++ b/nameparser/_suggest.py @@ -68,7 +68,7 @@ from types import MappingProxyType from typing import TYPE_CHECKING, cast -from ._lexicon import Lexicon, _normalize +from ._lexicon import Lexicon, _normalize, _spells_a_cased_initial from ._pipeline._state import COMMA_CHARS from ._pipeline._post_rules import _listed_suffix from ._pipeline._vocab import ( @@ -249,9 +249,13 @@ def _a_listed_name(word: str) -> bool: def _is_leading_title(word: str, lexicon: Lexicon) -> bool: """A word the lexicon lists as a title, or one rules/H2's shape - reads as a title at the head of a name (`Prof.`, `Insp.`).""" + reads as a title at the head of a name (`Prof.`, `Insp.`), save a + one-letter one written with its period, which the parse reads as an + initial (rules/H11).""" + n = _normalize(word) return not _a_listed_name(word) and ( - _normalize(word) in lexicon._sets.titles + n in lexicon._sets.titles + and (len(n) != 1 or not _spells_a_cased_initial(n, word)) or is_title_shaped(word, lexicon)) diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index 50625ca9d..03c905aac 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -8,13 +8,17 @@ 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. +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). 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. ``U.`` with its full stop stays an initial -(``U. S. Grant``), a one-letter cased word written with its period -being no title in any lexicon (rules/H11). A title and one name word +(``U. S. Grant``), a one-letter word with a capital written with its +period being no title in any lexicon (rules/H11); a Burmese ``U.`` +written so (``U. Thein Aung``) reads as the given name. A title and one name word reads the word as the family name, as everywhere (rules/H1), so ``U Thant`` gives family ``Thant``. @@ -24,15 +28,18 @@ military and religious styles (``Bogyoke``, ``Sayadaw``), each rare (decisions/vocabulary-collisions, the 2026-11-19 #1231 entry). -The fragment is the one pack content that removes, as in -``locales.VI``: a choice prefers only by a vocabulary reading, and a +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 the particles of -Spanish, Italian, Portuguese, French, Filipino and Dutch surnames -(``Juan de la Cruz`` keeps ``de``, but ``Maria la Torre`` and ``Jan van -Dijk`` lose theirs), the measured cost in the decisions entry. +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 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' @@ -43,7 +50,8 @@ 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. +fragment changes, every name holding one of its syllables as a word +(``do`` among them). """ from __future__ import annotations @@ -55,11 +63,17 @@ #: syllable of Chin names (#1231) _PARTICLES = ("da", "di", "do", "du", "la", "le", "san", "te", "van") -_SYLLABLES = frozenset(_PARTICLES) +#: 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"), + lexicon=(Lexicon.empty() + .remove(*_PARTICLES, kind="particle") + .remove(*_CREDENTIALS, kind="credential")), languages=frozenset({"my"}), ) diff --git a/tests/v2/pipeline/test_classify.py b/tests/v2/pipeline/test_classify.py index f44e6febd..65d109c13 100644 --- a/tests/v2/pipeline/test_classify.py +++ b/tests/v2/pipeline/test_classify.py @@ -897,20 +897,111 @@ def test_a_one_letter_title_written_with_its_period_is_an_initial( def test_the_one_letter_title_veto_needs_a_letter_with_a_capital() -> None: # the Bengali doctor is written with its full stop: no capital, no veto assert Parser().parse("ড. রহিম উদ্দিন").title == "ড." - from nameparser._pipeline import _classify - assert _classify._spells_a_cased_initial("q", "Q.") - assert not _classify._spells_a_cased_initial("ড", "ড.") + assert _classify_module._spells_a_cased_initial("q", "Q.") + assert _classify_module._spells_a_cased_initial("κ", "Κ.") + assert not _classify_module._spells_a_cased_initial("ড", "ড.") + assert not _classify_module._spells_a_cased_initial("q", "Q") + + +@pytest.mark.parametrize("kind, props", [ + # every title reading a caller can write on the letter + ("salutation", {}), + ("salutation", {"after_given": True}), + ("nobility", {"addresses": "given"}), + ("style", {}), + ("military", {"abbreviation": True}), +]) +@pytest.mark.parametrize("text", [ + "Q. Smith", "Smith, John Q.", "Q. of Smith", "Vice Q. Smith", + "Q. Smith, Ed", +]) +def test_the_veto_reaches_every_kind_of_title_reading( + kind: str, props: dict[str, object], text: str) -> None: + parser = Parser(lexicon=Lexicon.default().add("q", kind=kind, **props)) + name = parser.parse(text) + assert not name.title + assert name.as_dict() == Parser().parse(text).as_dict() + + +def test_the_veto_reaches_a_title_that_may_be_a_given_name() -> None: + # a title reading beside a given one compiles into the ambiguous + # titles, read by the title phrase (rules/H9) + parser = Parser(lexicon=Lexicon.default().add("q", kind="office") + .add("q", kind="given")) + for text in ("Q. of Smith", "Vice Q. Smith", "Q. Smith"): + assert parser.parse(text).as_dict() == Parser().parse(text).as_dict(), text + + +def test_the_veto_reaches_a_greek_capital() -> None: + parser = Parser(lexicon=Lexicon.default().add("κ", kind="salutation")) + assert parser.parse("Κ. Παπαδόπουλος").given == "Κ." + assert parser.parse("Κ Παπαδόπουλος").title == "Κ" def test_the_one_letter_title_veto_is_what_keeps_the_initial( monkeypatch: pytest.MonkeyPatch) -> None: - # negative controls for both sites, classify's tag and the period- - # joined derivation's chunk test: with either veto off, the dotted - # letter is the title, so the rows above read the veto - from nameparser._pipeline import _classify - monkeypatch.setattr(_classify, "_spells_a_cased_initial", lambda n, text: False) + # negative controls for the tag and the chunk: with the veto off in + # classify, the dotted letter is the title; with it off in _vocab, + # a word of initials holding it is a period-joined title + monkeypatch.setattr(_classify_module, "_spells_a_cased_initial", + lambda n, text: False) assert _ONE_LETTER_TITLE.parse("Q. Smith").title == "Q." monkeypatch.undo() - monkeypatch.setattr(_vocab, "_title_chunk", - lambda c, lexicon: c in lexicon._sets.titles) + monkeypatch.setattr(_vocab, "_spells_a_cased_initial", lambda n, text: False) assert _ONE_LETTER_TITLE.parse("Smith, Q.R.").title == "Q.R." + + +#: rules/H11's two-input invariant: under a lexicon holding the one-letter +#: title `q`, a name holding Q written with its full stop reads exactly as +#: under the default, which holds no such title, in every comma shape, +#: every order and every reader of the title vocabulary (the comma count, +#: the title phrase, the glued stop, the set-apart clause, C2's third +#: part), the shapes #1231's review found reading it as a title +_H11_SHAPES = [ + "{q} S. Grant", "John {q} Smith", "Smith, John {q}", "Smith, {q}", + "{q} Smith", ", {q} Smith", "{q} Smith, Ed", "{q} Smith, Ma", + "Smith {q}, Ed", "Vice {q} Smith", "Vice {q} Smith, Ed", + "Associate {q} Smith", "Smith, John, {q}", "John Smith, Jr., {q}", + "Dr. {q} Smith", "Dr.{q} Smith", "John Smith Dr.{q}", "John ({q}) Smith", + "({q}) Smith", "John Smith ({q})", 'John "{q}" Smith', "{q} van Berg, Ed", + "JOHN {q} SMITH", "{q} Smith, Jr.", +] +_H11_SPELLINGS = ["Q.", "q.", "Q.R.", "Q.John"] +_H11_ROWS = [(shape.format(q=q), order) + for shape in _H11_SHAPES for q in _H11_SPELLINGS + for order in ("given", "family", "family-given-last")] +#: The recorded negative control: rows of the grid that read otherwise +#: with the veto answering no at every reader, measured 2026-11-19 +#: (re-take it when the grid moves) +_H11_UNGUARDED_EFFECT = 228 + + +def _h11_differences() -> int: + from nameparser._policy import ( + FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST, GIVEN_FIRST) + orders = {"given": GIVEN_FIRST, "family": FAMILY_FIRST, + "family-given-last": FAMILY_FIRST_GIVEN_LAST} + moved = 0 + for text, order in _H11_ROWS: + policy = Policy(name_order=orders[order]) + with_q = Parser(policy=policy, lexicon=Lexicon.default().add( + "q", kind="salutation")).parse(text) + without = Parser(policy=policy).parse(text) + moved += (with_q.as_dict() != without.as_dict() + or [a.kind for a in with_q.ambiguities] + != [a.kind for a in without.ambiguities]) + return moved + + +def test_a_one_letter_title_with_its_period_reads_as_no_title_at_all() -> None: + assert len(_H11_ROWS) == 288 + assert _h11_differences() == 0 + + +def test_the_h11_invariant_fails_with_the_veto_off( + monkeypatch: pytest.MonkeyPatch) -> None: + from nameparser._pipeline import _segment + for module in (_classify_module, _vocab, _segment): + monkeypatch.setattr(module, "_spells_a_cased_initial", + lambda n, text: False) + assert _h11_differences() == _H11_UNGUARDED_EFFECT diff --git a/tests/v2/test_layering.py b/tests/v2/test_layering.py index 303648b67..1cdfc00ea 100644 --- a/tests/v2/test_layering.py +++ b/tests/v2/test_layering.py @@ -887,9 +887,9 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: a listed title, its `sets =` binding and the two title sets it #: reads, 200 -> 203; the 3.1 simplify pass folding T8's two copies #: of the unambiguous title-or-suffix test after a glued stop into -#: `_vocab._claimed_after_the_stop`, 203 -> 198; #1231's -#: `_vocab._title_chunk`, rules/H11's chunk test, folding the two -#: period-joined title reads into one, 198 -> 197); +#: `_vocab._claimed_after_the_stop`, 203 -> 198; #1231's rules/H11 +#: veto in classify, asking the two title sets before its frame, +#: 198 -> 200); #: the tools' first 20 are 18 #: attribute loads, every tool scanned, and config_diff.py's #: `sets =` binding and the roster `getattr` through it (its @@ -911,7 +911,7 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: `_lexicon._fields_of` from 4i-b until 4i-c retired it. #: A reader added through `_sets` moves these, and they are re-taken #: then: they count what the check would refuse with the move undone. -_UNGUARDED_READS = {"library": 197, "tools": 28} +_UNGUARDED_READS = {"library": 200, "tools": 28} def test_the_check_refuses_every_read_4i_a_moved() -> None: diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 980f8c995..0272e5847 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -26,6 +26,7 @@ ) from nameparser._types import AmbiguityKind, Role from nameparser.locales import ja as _ja +from nameparser.locales import my as _my from nameparser.locales import ru as _ru from nameparser.locales import tr_az as _tr_az from nameparser.locales import zh as _zh @@ -693,15 +694,15 @@ def test_my_pack_contents() -> None: # only removes particle readings (decisions/vocabulary-collisions, # the 2026-11-19 #1231 entry); no policy patch import pickle - from nameparser.locales import my as _my assert locales.MY.languages == {"my"} assert locales.MY.policy == PolicyPatch() assert _ri.changed_words(_ri.selected(locales.MY.languages)) == {"u", "daw"} sets = _require_packed("my").lexicon._sets assert not set(_my._PARTICLES) & sets.particles - # the particles it leaves, and every other kind of the words it names + assert not set(_my._CREDENTIALS) & sets.suffix_acronyms + # the particles and credentials it leaves assert {"de", "von", "del", "bin", "mac"} <= sets.particles - assert "do" in sets.suffix_acronyms + 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 @@ -711,38 +712,61 @@ def test_my_pack_contents() -> None: assert not _my.DEVIATES("Sandra Lee") and not _my.DEVIATES("Thein Sein") -#: Each particle the MY fragment removes, with a name its removal alone -#: moves: the syllable between two name words, which its reading would -#: chain into the family name +#: 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", "Aung San Win"), ("la", "Akyaung La Aung"), - ("le", "Saw Eh Le Htoo"), ("do", "Htan Do Kyint"), - ("da", "Thi Da Oo"), ("du", "Swam Du Naw Aung"), - ("te", "Kyauk Te Chan"), ("di", "Aung Di Win"), - ("van", "Henry Van Thio"), + ("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 - from nameparser.locales import my as _my - assert sorted(w for w, _ in _MY_REMOVALS) == sorted(_my._PARTICLES) + 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(word: str | None) -> Parser: - lexicon = Lexicon.empty().remove( - *[w for w in _my._PARTICLES if w != word], kind="particle") + 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, text in _MY_REMOVALS: + for word, kind, text in _MY_REMOVALS: assert rebuilt.parse(text).as_dict() == my.parse(text).as_dict(), text - assert put_back(word).parse(text).as_dict() != my.parse(text).as_dict(), ( - word, 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, 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"), +]) +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, "") + + @pytest.mark.parametrize("order", [GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) @pytest.mark.parametrize("text, title, rest", [ # #1231: the honorific opening the name, in each comma shape and case, @@ -791,15 +815,35 @@ def test_my_reads_the_honorific_in_every_comma_shape( "John U. Smith", "Smith, John U.", "Smith, U.", ", U. Smith", "U.Thein Sein", "U. Thein Sein", "U. S. GRANT", "u. s. grant", "U.S. District Judge Jane Roe", "Dr. U. Smith", + # #1231's review: the comma count, the title phrase, the glued stop, + # the set-apart clause and C2's third part + "U. Smith, Ed", "U. Smith, Ma", "Smith U., Ed", "Vice U. Smith", + "Vice U.Thein Smith, Ed", "Smith, John, U.", "John Smith, Jr., U.", + "Dr.U. Smith", "John Smith Dr.U.", "John (U.) Smith", "(U.) Smith", + 'John "U." Smith', ]) def test_my_keeps_u_written_with_its_full_stop_an_initial( text: str, order: tuple[Role, Role, Role]) -> None: base = Parser(policy=Policy(name_order=order)) packed = parser_for(locales.MY, base=base).parse(text) - assert packed.as_dict() == base.parse(text).as_dict() + default = base.parse(text) + assert packed.as_dict() == default.as_dict() + assert [a.kind for a in packed.ambiguities] == [ + a.kind for a in default.ambiguities] assert "U." not in packed.title.upper().split() +def test_my_suggests_as_the_default_over_names_opening_with_u_dotted() -> None: + # the group suggester reads past a leading title as the parse does, + # so `U.` is a given name to it under the pack too (rules/H11) + names = ["U. Wang Xiaoming", "U. Zhang Wei", "U. Li Na", "U. Liu Yang", + "U. Chen Jie", "U. Wang Fang"] + # the evidence, below the first line, which names the base parser + packed, default = (str(p.suggest(names)).split("\n", 1)[1] + for p in (_require_packed("my"), Parser())) + assert packed == default + + 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 @@ -2154,6 +2198,8 @@ def _default_corpus() -> list[str]: "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 ] # 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/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index 750f8f924..d90f85599 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -375,6 +375,7 @@ "Dr.MD Smith" "Dr.McDonald Jones" "Dr.Smith" +"Dr.U. Smith" "Dr.med. Lukas Mayer" "Duke of Edinburgh" "Dumas VI MD, Ed" @@ -754,6 +755,7 @@ "John (NP-C) Smith" "John (Sr) Smith" "John (Sr.) Smith" +"John (U.) Smith" "John . Smith" "John A B Smith" "John Dean Smith" @@ -1747,6 +1749,8 @@ "U Thant" "U Thein Sein" "U. S. Grant" +"U. Smith, Ed" +"U. Thein Aung" "U.S. District Judge Marc Thomas Treadwell" "U.S. Grant" "U.S. Grant Smith, John" @@ -1777,6 +1781,7 @@ "Van der Walt" "Van née Jones" "Vega, Juan de la" +"Vice U. Smith" "Vice Yu. Petrov" "Vincent van Gogh van Beethoven" "W. Russell (Jr.) Withers" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 9f44e3794..1126dd740 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -1049,6 +1049,7 @@ {"name": "Dr.MD Smith", "title": "Dr.MD", "family": "Smith", "initials": "S.", "capitalized_force": "Dr.Md Smith"} {"name": "Dr.McDonald Jones", "title": "Dr.", "given": "McDonald", "family": "Jones", "initials": "M. J."} {"name": "Dr.Smith", "title": "Dr.", "family": "Smith", "initials": "S."} +{"name": "Dr.U. Smith", "title": "Dr.", "given": "U.", "family": "Smith", "initials": "U. S."} {"name": "Dr.med. Lukas Mayer", "title": "Dr.med.", "given": "Lukas", "family": "Mayer", "initials": "L. M.", "capitalized_force": "Dr.Med. Lukas Mayer"} {"name": "Dr.philol. Laima Kristīne Eva Sofija van den Volfa Bērziņa-Kalniņa", "title": "Dr.philol.", "given": "Laima", "middle": "Kristīne Eva Sofija", "family": "van den Volfa Bērziņa-Kalniņa", "initials": "L. K. E. S. V. B.", "capitalized_force": "Dr.Philol. Laima Kristīne Eva Sofija van den Volfa Bērziņa-Kalniņa"} {"name": "Dra. Andréia da Silva", "title": "Dra.", "given": "Andréia", "family": "da Silva", "initials": "A. S."} @@ -2026,6 +2027,7 @@ {"name": "John (NP-C) Smith", "given": "John", "family": "Smith", "suffix": "NP-C", "initials": "J. S."} {"name": "John (Sr) Smith", "given": "John", "family": "Smith", "suffix": "Sr", "initials": "J. S.", "generation": "Sr"} {"name": "John (Sr.) Smith", "given": "John", "family": "Smith", "suffix": "Sr.", "initials": "J. S.", "generation": "Sr."} +{"name": "John (U.) Smith", "given": "John", "middle": "U.", "family": "Smith", "initials": "J. U. S."} {"name": "John . Smith", "given": "John", "middle": ".", "family": "Smith", "initials": "J. .. S."} {"name": "John A B Smith", "given": "John", "middle": "A B", "family": "Smith", "initials": "J. A. B. S."} {"name": "John A. Doe", "given": "John", "middle": "A.", "family": "Doe", "initials": "J. A. D."} @@ -4375,6 +4377,8 @@ {"name": "U Thant", "given": "U", "family": "Thant", "initials": "U. T."} {"name": "U Thein Sein", "given": "U", "middle": "Thein", "family": "Sein", "initials": "U. T. S."} {"name": "U. S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} +{"name": "U. Smith, Ed", "given": "U.", "family": "Smith", "suffix": "Ed", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as given (declared)"], "initials": "U. S.", "capitalized_force": "U. Smith, ED"} +{"name": "U. Thein Aung", "given": "U.", "middle": "Thein", "family": "Aung", "initials": "U. T. A."} {"name": "U.S. District Judge Marc Thomas Treadwell", "title": "U.S. District Judge", "given": "Marc", "middle": "Thomas", "family": "Treadwell", "initials": "M. T. T."} {"name": "U.S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} {"name": "U.S. Grant Smith, John", "given": "John", "family": "U.S. Grant Smith", "initials": "J. U. S. G. S."} @@ -4472,6 +4476,7 @@ {"name": "Velasquez y Garcia, Juan Q., Jr.", "given": "Juan", "middle": "Q.", "family": "Velasquez y Garcia", "suffix": "Jr.", "initials": "J. Q. V. G.", "generation": "Jr."} {"name": "Velasquez y Garcia, Juan, Jr.", "given": "Juan", "family": "Velasquez y Garcia", "suffix": "Jr.", "initials": "J. V. G.", "generation": "Jr."} {"name": "Venerable Ananda", "title": "Venerable", "family": "Ananda", "initials": "A."} +{"name": "Vice U. Smith", "given": "Vice", "middle": "U.", "family": "Smith", "initials": "V. U. S."} {"name": "Vice Yu. Petrov", "given": "Vice", "middle": "Yu.", "family": "Petrov", "initials": "V. Y. P."} {"name": "Vicente Becerra Vaca", "given": "Vicente", "middle": "Becerra", "family": "Vaca", "initials": "V. B. V."} {"name": "Vicente Gómez Mier", "given": "Vicente", "middle": "Gómez", "family": "Mier", "initials": "V. G. M."} From 10edc1d6a12d47159b72b6b66e9292a4b2c017dd Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:28:51 -0800 Subject: [PATCH 04/13] Correct #1231's records and docs on review (#1231) decisions/H11 names every reader the veto is asked at, the invariant and its control, and the Burmese U written with a stop as accepted. decisions/vocabulary-collisions re-takes its figures at the fix commit (committed 273 of 7,656, TSE 116,114, PSC 3,859), counts the fixes by word over the 151 fixes, scores a leading U. by the parse, records do's credential, the Maori Te and the other credential syllables, and corrects Britain's figure. vocabulary-model's Standing line names MY beside VI. docs/locales.rst's scope list reaches a comma part and Filipino names, its table is in order; docs/languages.rst names the nine words' cost exactly, do's credential and U written with a stop; the release log's limit sentence names the words; my.toml's notes no longer claim a universal. Co-Authored-By: Claude Opus 5.5 --- ...e-letter-title-against-the-initial-it-spells.md | 14 +++++++------- docs/design/decisions/vocabulary-collisions.md | 12 ++++++------ docs/design/decisions/vocabulary-model.md | 2 +- docs/languages.rst | 14 +++++++++----- docs/locales.rst | 13 +++++++------ docs/release_log.rst | 2 +- nameparser/vocab/my.toml | 4 ++-- 7 files changed, 33 insertions(+), 28 deletions(-) diff --git a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md index 3e312f925..1383e92c2 100644 --- a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md +++ b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md @@ -2,18 +2,18 @@ ## Standing -- A one-letter word written with its period is an initial and not a title where its letter has a capital, whatever title the letter spells, and so is such a letter cut from a word at its full stops (`U. S. Grant`, `Grant, U.S.` and `U.Thein Sein` under `locales.MY` read as the default reads them); written bare it is the title (`U Thein Sein` → title 'U' under the pack); a letter of a script without capitals keeps its title written with its period (`ড. রহিম উদ্দিন` → title 'ড.') — 2026-11-19 #1231. -- The veto is a shape, stated once for every one-letter title a lexicon holds, a caller's included, as rules/P7 states it for the particles; no per-word property (the reserved `bare_only`) is built for it — 2026-11-19 #1231. +- A one-letter word written with its period is an initial and not a title where its letter has a capital, whatever title the letter spells, at every reader of the title vocabulary, and so is such a letter cut from a word at its full stops (`U. S. Grant`, `Grant, U.S.`, `U. Smith, Ed`, `Vice U. Smith`, `Dr.U. Smith` and `John (U.) Smith` under `locales.MY` read as the default reads them); written bare it is the title (`U Thein Sein` → title 'U' under the pack); a letter of a script without capitals keeps its title written with its period (`ড. রহিম উদ্দিন` → title 'ড.') — 2026-11-19 #1231. +- The veto is a shape, stated once for every one-letter title a lexicon holds, a caller's included, as rules/P7 states it for the particles, and asked through one predicate, `_lexicon._spells_a_cased_initial`; no per-word property (the reserved `bare_only`) is built for it — 2026-11-19 #1231. Open: none in this file. ## Log -- 2026-11-19 #1231 — A ONE-LETTER TITLE WRITTEN WITH ITS PERIOD IS THE INITIAL IT SPELLS, WHERE THE LETTER HAS A CAPITAL. `locales.MY` turns on `u`, the Burmese honorific (my.toml, `default = false`), the first one-letter title in a cased script any lexicon the project ships has held: the default's are the Bengali `ড` and the Thai `ศ` (`sorted(w for w in L.titles | L.titles_ambiguous if len(w) == 1)` with `L = Parser().lexicon._sets`, 2026-11-19). The title match folds edge periods away, so the reading alone also claimed `U.`: the issue's simulated lexicon read `U. S. Grant` title 'U.', given 'S.', and `Grant, U.S.` title 'U.S.' through the period-joined derivation, which reads a word whose chunk is a title as a title. The issue asked whether `U` should need the absence of a period, and the working answer (decision 3 of the 2026-11-19 #1231 entry in decisions/vocabulary-collisions) was yes; the period is a fact about initials, the same line rules/P7 draws for a one-letter particle (`Juan Ó. Pérez`), so it is stated as a shape, not as a property of `u`, and reaches a caller's one-letter title too. - - **Where it reads.** Two sites, the two that turn the vocabulary into a reading of a word written with periods: classify's title tag, asking `_lexicon._spells_a_cased_initial` after its membership hit (`_spells_an_initial`, P7's helper, narrowed to a letter that upper-cases to something else), and the period-joined derivation's chunk test, `_vocab._title_chunk`, which both `period_joined_vocab` and `period_joined_title` ask. The other readers of the title set (the comma's unit count, the glued-stop test, the title phrase's head run, the suggester) were not changed. Measured: over 23 shapes holding a one-letter word (every comma shape, behind and before a title, in one case, with `Jr.` and `PhD` after it) × 6 spellings (`U.`, `u.`, `U.S.`, `U.S`, `Ü.`, `U.Thein`) × the three orders, `parser_for(locales.MY)` read every name as the default does except where the fragment's `la` moved one (`Vega, U. de la`), 2026-11-19 on this branch (a scratch probe comparing `as_dict()` and the ambiguity kinds). - - **The capital.** The Bengali `ড` is written `ড.` as the doctor (bn.toml's note), the full stop being the title's writing, so a letter of a script without case keeps its title reading. The default moves nothing: it holds no one-letter title in a cased script, and the committed snapshot is byte-identical across the change. - - **Accepted:** under the pack a name opening with a bare `U` reads it as the title, a Korean surname `U` written bare included (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19), and so does a bare `U` written as an initial without its period, which FEC writes 187 times beside 163 `U.`, mostly a middle initial after a comma, where no title reads. - - **Left out:** #1205's `H.` (Haji) under an Indonesian choice asks the opposite, the dotted letter as the title; this entry makes that a title only where a reading or a rule says so for that letter, which #1205's decision would add. +- 2026-11-19 #1231 — A ONE-LETTER TITLE WRITTEN WITH ITS PERIOD IS THE INITIAL IT SPELLS, WHERE THE LETTER HAS A CAPITAL. `locales.MY` turns on `u`, the Burmese honorific (my.toml, `default = false`), the first one-letter title in a cased script any lexicon the project ships has held: the default's are the Bengali `ড` and the Thai `ศ` (`sorted(w for w in L.titles | L.titles_ambiguous if len(w) == 1)` with `L = Parser().lexicon._sets`, 2026-11-19), and no other shipped pack adds one. The title match folds edge periods away, so the reading alone also claimed `U.`: the issue's simulated lexicon read `U. S. Grant` title 'U.', given 'S.', and `Grant, U.S.` title 'U.S.' through the period-joined derivation, which reads a word whose chunk is a title as a title. The issue asked whether `U` should need the absence of a period, and the working answer (decision 3 of the 2026-11-19 #1231 entry in decisions/vocabulary-collisions) was yes; the period is a fact about initials, the same line rules/P7 draws for a one-letter particle (`Juan Ó. Pérez`), so it is stated as a shape, not as a property of `u`, and reaches a caller's one-letter title too. + - **Where it reads: every reader of the title vocabulary.** The first build asked the veto at classify's title tag and the period-joined derivation's chunk test only, and its sweep held no comma shape with a word after the comma that the comma count weighs; the PR's review found `U.` still read as a title by six other readers under the pack: the comma count (`U. Smith, Ed` reversed to given 'Ed', family 'U. Smith', the shape AGENTS.md's Gotchas name for any change to the title shape), the title phrase (`Vice U. Smith` → title 'Vice'), the glued-stop cut (`Dr.U. Smith` → title 'Dr.U.'), the set-apart clause (`John (U.) Smith` → title 'U.'), C2's third part (`Smith, John, U.` losing its comma-structure report) and the group suggester (six names opening with `U.` suggested `FAMILY_FIRST`). So `_lexicon._spells_a_cased_initial` is the one predicate, asked after each reader's membership hit and a C-level length test, so only a one-letter title pays a frame (`tools/perf/call_count.py` reads 197.72 on the branch and on master): classify's title, given-name-title, trailing-title and after-given-title tags, the period-joined title and its chunks, the set-apart kind, the glued-stop test and the title chunk before a stop, the comma count, the title phrase (a vetoed word is neither a title nor a phrase member there), C2's titles-and-suffixes part and the suggester's leading title. tests/v2/pipeline/test_classify.py holds the invariant over two inputs (docs/design/AGENTS.md's axis 11): under a lexicon adding the title `q`, 24 shapes (every comma shape, behind a modifier and a title, glued at a stop, in brackets and quotes, past the second comma, in one case) × 4 spellings (`Q.`, `q.`, `Q.R.`, `Q.John`) × the three orders, 288 rows, read exactly as under the default, ambiguities included; with the veto answering no at every reader 228 of them move, the recorded control (2026-11-19). + - **The capital.** The Bengali `ড` is written `ড.` as the doctor (bn.toml's note), the full stop being the title's writing, so a letter of a script without case keeps its title reading. The default moves nothing, holding no one-letter title in a cased script: the committed snapshot gains only the new rule examples, and no reading it held moves. + - **Accepted:** under the pack a name opening with a bare `U` reads it as the title, a Korean surname `U` written bare included (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19), and so does a bare `U` written as an initial without its period; and a Burmese `U` written with a full stop reads as the given name (1 of the 71 names opening with the honorific in the population of the vocabulary-collisions entry, 2026-11-19), the writing being an initial's. + - **Left out:** #1205's `H.` (Haji) under an Indonesian choice asks the opposite, the dotted letter as the title; this entry makes that a title only where a reading or a rule says so for that letter, which #1205's decision would add. A word holding the letter beside a title chunk is a title for the title (`U.Daw Smith` → title 'U.Daw' under the pack), and the fullwidth `U.` is no initial, as `J.` is not (rules/T5). Declined: diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 0f9ad0979..1fef7c167 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, 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 — 2026-11-19 #1231. +- `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 — 2026-11-19 #1231. ## Log @@ -102,8 +102,8 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - 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, which rules/H11 states as a shape (decisions/H11); (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, each opening 4 names or fewer in the population below. - **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`. - - **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 nothing else: `do`'s credential reading stays, so a name written wholly in capitals ending in `DO` reads the suffix as by default (`DAW KHIN MYA DO` → suffix 'DO'), the one-case shape the 2026-11-05 #1108 entry of decisions/vocabulary-model found unmasked by a removal, here masked neither way. `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. - - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. 153 names move, 151 from a misreading to the intended reading (`u` 71, `san` 39, `daw` 27, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (`Daw Nu Mya Zan, Daw Nu Mara Zan`, two names in one string). The intended reading holds for 2,836 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - - **The cost to names that are not Burmese**, measured on this branch (2026-11-19). `config_diff.py diff default plain:MY --committed`: 253 of 7,643 names move, 2 of them Burmese (`Daw Thida`, `U Kyaw Win`) and 251 others, `van` 129, `da` 20, `do` 14, `la` 11, `di` 6, `du` 5. `config_diff.py diff default plain:MY --local tse-donors --local psc-individuals --local ukec-individuals`: TSE's Brazilian donors 116,044 of 848,351 (`da` 100,949, `do` 12,550), PSC's filers 3,823 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 a third of a point or less; Vietnam 68.50% to 67.20% 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 or Filipino particle among the nine is a name word (`Jan van Dijk` → middle 'van', family 'Dijk'), which the pack's docstring and docs/languages.rst say, with the figures above; a bare `U` opening a name is the title, a Korean surname `U` included (rules/H11's Accepted); 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`); `do`'s credential reading under the pack. + - **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 written in capitals, the regnal numerals aside, 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. + - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. 153 names move, 151 from a misreading to the intended reading (holding `u` 70, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,986 under the pack (99.9%); the four it misses are that string, two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default, and one name opening with `U.`, which rules/H11 reads as an initial (decisions/H11's Accepted). The first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. + - **The cost to names that are not Burmese**, measured on this branch (2026-11-19). at the fix commit `31738f17`, `config_diff.py diff default plain:MY --committed`: 273 of 7,656 names move, 5 of them opening with `U` or `Daw` (`Daw Thida`, `U Kyaw Win`, and three rule examples this change adds, the Korean `U Min Ho` among them) and 268 others, `van` 130, `da` 20, `do` 19 (the credential among them), `la` 11, `di` 6, `du` 5; the first count, before `do`'s credential left and the rule examples were added, 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%); 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 bare `U` opening a name is the title, a Korean surname `U` included (rules/H11's Accepted); 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. diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 6f1b47c82..802ed4e3b 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` excepted: its fragment removes readings of Vietnamese syllables no vi.toml reading can settle, 2026-11-05 #1108), 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` 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. - `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` and `locales.PT_BR` 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. diff --git a/docs/languages.rst b/docs/languages.rst index 71eaa4e15..63fd4dc66 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1215,8 +1215,9 @@ The pack keeps them name words: ('Daw', 'San Suu', 'Kyi') The nine are ``San``, ``La``, ``Le``, ``Do``, ``Da``, ``Du``, ``Te``, -``Di`` and ``Van``. ``U`` written with its full stop stays an initial, -as it is in ``U. S. Grant``: +``Di`` and ``Van``, and ``Do`` is no credential either, so a name +written in capitals keeps a final ``DO``. ``U`` written with its full +stop stays an initial, as it is in ``U. S. Grant``: .. doctest:: @@ -1240,6 +1241,8 @@ What the pack leaves as it is ``Thant``, as a title and one name word reads in any name. - **Military and religious styles** (``Bogyoke``, ``Sayadaw``) are read as given names, as by default. +- **U with a full stop.** ``U.`` is read as an initial, so a Burmese + name written ``U. Thein Aung`` gives given ``U.``. - **Burmese script.** The pack reads Latin letters only; ``ဦး`` and ``ဒေါ်`` have no reading yet. @@ -1247,9 +1250,10 @@ When not to use it ~~~~~~~~~~~~~~~~~~ The pack is for lists of Burmese names. On other names it costs the -particles of Spanish, Portuguese, Italian, French and Dutch family -names, so keep it to a parser of its own for the Burmese names in your -data: +nine words' particle readings, which Dutch, Portuguese, Italian, +French, Spanish, Filipino and Māori family names hold (``de`` and +``del`` are kept), and the credential DO, so keep it to a parser of its +own for the Burmese names in your data: .. doctest:: diff --git a/docs/locales.rst b/docs/locales.rst index 854c045a2..634a223b9 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -146,8 +146,9 @@ shape covers much: - ``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 and Dutch family names among - them, and any opening with ``U`` or ``Daw``. + Spanish, Portuguese, Italian, French, Filipino and Dutch family names + among them, and any where ``U`` or ``Daw`` opens the name or the part + after a comma. .. warning:: @@ -402,14 +403,14 @@ says what it can change: - yes (turns on nothing) - a ``script_orders`` entry for Cyrillic - none - * - ``ne`` - - yes - - ``initials_as_family`` - - none * - ``my`` - yes - none - none; it takes readings out instead + * - ``ne`` + - yes + - ``initials_as_family`` + - none * - ``vi`` - yes - ``name_order`` diff --git a/docs/release_log.rst b/docs/release_log.rst index 513f3b870..9c999e52e 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -7,7 +7,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``; ``U.`` with its full stop stays an initial. It reads ``San``, ``La``, ``Van`` and six more as name words, so it costs Spanish, Portuguese, Italian, French and Dutch particles (``Jan van Dijk`` gives family ``Dijk``): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` + - **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``): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` - **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.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` diff --git a/nameparser/vocab/my.toml b/nameparser/vocab/my.toml index d85643262..7f1abb286 100644 --- a/nameparser/vocab/my.toml +++ b/nameparser/vocab/my.toml @@ -2,11 +2,11 @@ schema = 1 [[word]] text = "daw" -salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1231, expands = "Daw, the honorific written before a woman's name (Mrs.)", note = "Burmese names have no family name and an honorific opens them, so the default reads Daw as the given name; on by default it would take the given name of the people who bear it: US Census 2010 2,670 as a surname, Wikidata 3 given (Sudan 1) and 20 family; ORCID's given box 29, MM 2, family box 118; PatentsView 9 given, 54 family (tools/name_usage.py, 2026-11-19). Written bare as a word of its own, never with a full stop" } +salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1231, expands = "Daw, the honorific written before a woman's name (Mrs.)", note = "Burmese names have no family name and an honorific opens them, so the default reads Daw as the given name; on by default it would take the given name of the people who bear it: US Census 2010 2,670 as a surname, Wikidata 3 given (Sudan 1) and 20 family; ORCID's given box 29, MM 2, family box 118; PatentsView 9 given, 54 family (tools/name_usage.py, 2026-11-19). Written bare as a word of its own; written Daw. it is a title by its shape by default already (rules/H2)" } [[word]] 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: the full stop keeps U. an initial under the pack too, a one-letter cased word written with its period being no title (rules/H11). Written bare by Burmese names (U Thein Sein); FEC writes U 187 times and U. 163, mostly a middle initial after a comma; ctgov-officials U 260, U. 61 (tools/name_usage.py, 2026-11-19)" } +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: the full stop keeps U. an initial under the pack too, a one-letter word with a capital written with its period being no title (rules/H11). 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., which the pack reads as the given name); 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 = "ဂျူနီယာ" From eb87f472a19b9b60b0e19cce8b010af0d713d6bf Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:42:06 -0800 Subject: [PATCH 05/13] Ask rules/H11 at the readers the fix commit's review found; record the lesson (#1231) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fix commit's code and design-docs reviews found four more readers still claiming U. under the pack or a caller's one-letter title: T8's two tests of the word before a glued one (Juan dela U. Sta.Maria read family 'dela U. Sta.Maria'; U. J.Smith lost its report), the Thai glued-title walk (U. นายสมชาย), classify's title-phrase fork (a false title-or-name report) and a title run's addressing by its last word (Mr. and Q. Smith). Each now asks the predicate; the invariant grid gains their shapes (360 rows, control 279, each module's veto seen), the phrase test compares ambiguities, and a run test pins the addressing. rules/H11 gains Accepted rows for U.Daw and the fullwidth stop; decisions/H11 names the reads left out and why. docs/locales.rst and mechanisms.md name do's credential among the fragment's removals, the scope list reaches a U after a title, the capitals figure states its recipe, and nameparser/AGENTS.md records the class: a veto on a vocabulary set reaches every reader of the set. Co-Authored-By: Claude Opus 5.5 --- ...ter-title-against-the-initial-it-spells.md | 6 ++-- .../design/decisions/vocabulary-collisions.md | 2 +- docs/design/mechanisms.md | 2 +- ...ter-title-against-the-initial-it-spells.md | 10 +++++- docs/locales.rst | 9 ++--- nameparser/AGENTS.md | 4 +++ nameparser/_lexicon.py | 26 ++++++++++---- nameparser/_pipeline/_classify.py | 5 +++ nameparser/_pipeline/_script_segment.py | 24 +++++++++---- tests/v2/pipeline/test_classify.py | 36 +++++++++++++++---- tools/differential/corpus_rules.jsonl | 2 ++ tools/differential/snapshot.jsonl | 2 ++ 12 files changed, 98 insertions(+), 30 deletions(-) diff --git a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md index 1383e92c2..330dadc75 100644 --- a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md +++ b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md @@ -2,7 +2,7 @@ ## Standing -- A one-letter word written with its period is an initial and not a title where its letter has a capital, whatever title the letter spells, at every reader of the title vocabulary, and so is such a letter cut from a word at its full stops (`U. S. Grant`, `Grant, U.S.`, `U. Smith, Ed`, `Vice U. Smith`, `Dr.U. Smith` and `John (U.) Smith` under `locales.MY` read as the default reads them); written bare it is the title (`U Thein Sein` → title 'U' under the pack); a letter of a script without capitals keeps its title written with its period (`ড. রহিম উদ্দিন` → title 'ড.') — 2026-11-19 #1231. +- A one-letter word written with its period is an initial and not a title where its letter has a capital, whatever title the letter spells, at every reader of the title vocabulary whose answer such a word can move, and so is such a letter cut from a word at its full stops (`U. S. Grant`, `Grant, U.S.`, `U. Smith, Ed`, `Vice U. Smith`, `Dr.U. Smith` and `John (U.) Smith` under `locales.MY` read as the default reads them); written bare it is the title (`U Thein Sein` → title 'U' under the pack); a letter of a script without capitals keeps its title written with its period (`ড. রহিম উদ্দিন` → title 'ড.') — 2026-11-19 #1231. - The veto is a shape, stated once for every one-letter title a lexicon holds, a caller's included, as rules/P7 states it for the particles, and asked through one predicate, `_lexicon._spells_a_cased_initial`; no per-word property (the reserved `bare_only`) is built for it — 2026-11-19 #1231. Open: none in this file. @@ -10,10 +10,10 @@ Open: none in this file. ## Log - 2026-11-19 #1231 — A ONE-LETTER TITLE WRITTEN WITH ITS PERIOD IS THE INITIAL IT SPELLS, WHERE THE LETTER HAS A CAPITAL. `locales.MY` turns on `u`, the Burmese honorific (my.toml, `default = false`), the first one-letter title in a cased script any lexicon the project ships has held: the default's are the Bengali `ড` and the Thai `ศ` (`sorted(w for w in L.titles | L.titles_ambiguous if len(w) == 1)` with `L = Parser().lexicon._sets`, 2026-11-19), and no other shipped pack adds one. The title match folds edge periods away, so the reading alone also claimed `U.`: the issue's simulated lexicon read `U. S. Grant` title 'U.', given 'S.', and `Grant, U.S.` title 'U.S.' through the period-joined derivation, which reads a word whose chunk is a title as a title. The issue asked whether `U` should need the absence of a period, and the working answer (decision 3 of the 2026-11-19 #1231 entry in decisions/vocabulary-collisions) was yes; the period is a fact about initials, the same line rules/P7 draws for a one-letter particle (`Juan Ó. Pérez`), so it is stated as a shape, not as a property of `u`, and reaches a caller's one-letter title too. - - **Where it reads: every reader of the title vocabulary.** The first build asked the veto at classify's title tag and the period-joined derivation's chunk test only, and its sweep held no comma shape with a word after the comma that the comma count weighs; the PR's review found `U.` still read as a title by six other readers under the pack: the comma count (`U. Smith, Ed` reversed to given 'Ed', family 'U. Smith', the shape AGENTS.md's Gotchas name for any change to the title shape), the title phrase (`Vice U. Smith` → title 'Vice'), the glued-stop cut (`Dr.U. Smith` → title 'Dr.U.'), the set-apart clause (`John (U.) Smith` → title 'U.'), C2's third part (`Smith, John, U.` losing its comma-structure report) and the group suggester (six names opening with `U.` suggested `FAMILY_FIRST`). So `_lexicon._spells_a_cased_initial` is the one predicate, asked after each reader's membership hit and a C-level length test, so only a one-letter title pays a frame (`tools/perf/call_count.py` reads 197.72 on the branch and on master): classify's title, given-name-title, trailing-title and after-given-title tags, the period-joined title and its chunks, the set-apart kind, the glued-stop test and the title chunk before a stop, the comma count, the title phrase (a vetoed word is neither a title nor a phrase member there), C2's titles-and-suffixes part and the suggester's leading title. tests/v2/pipeline/test_classify.py holds the invariant over two inputs (docs/design/AGENTS.md's axis 11): under a lexicon adding the title `q`, 24 shapes (every comma shape, behind a modifier and a title, glued at a stop, in brackets and quotes, past the second comma, in one case) × 4 spellings (`Q.`, `q.`, `Q.R.`, `Q.John`) × the three orders, 288 rows, read exactly as under the default, ambiguities included; with the veto answering no at every reader 228 of them move, the recorded control (2026-11-19). + - **Where it reads: every reader of the title vocabulary whose answer such a word can move.** The first build asked the veto at classify's title tag and the period-joined derivation's chunk test only, and its sweep held no comma shape with a word after the comma that the comma count weighs; the PR's review found `U.` still read as a title by six other readers under the pack: the comma count (`U. Smith, Ed` reversed to given 'Ed', family 'U. Smith', the shape AGENTS.md's Gotchas name for any change to the title shape), the title phrase (`Vice U. Smith` → title 'Vice'), the glued-stop cut (`Dr.U. Smith` → title 'Dr.U.'), the set-apart clause (`John (U.) Smith` → title 'U.'), C2's third part (`Smith, John, U.` losing its comma-structure report) and the group suggester (six names opening with `U.` suggested `FAMILY_FIRST`). So `_lexicon._spells_a_cased_initial` is the one predicate, asked after each reader's membership hit and a C-level length test, so only a one-letter title pays a frame (`tools/perf/call_count.py` reads 197.72 on the branch and on master): classify's title, given-name-title, trailing-title and after-given-title tags and its title-phrase fork, the period-joined title and its chunks, the set-apart kind, the glued-stop test and the title chunk before a stop, the comma count, the title phrase (a vetoed word is neither a title nor a phrase member there), C2's titles-and-suffixes part, the suggester's leading title, and, found by the fix commit's review, T8's two tests of the word before a glued one (`Juan dela U. Sta.Maria`, `U. J.Smith` losing its report), the glued-title walk past titles written apart (`U. นายสมชาย`) and the given-name addressing of a title run by its last word (`Mr. and Q. Smith` under a caller's given-addressing `q`). Three reads are left as they were, none movable by such a word: T8's whole-word test in `glued_cuts`, which a run of letters leaves before it asks; the suffix test that excludes a title (`_settles`), which a vetoed initial, no suffix, never reaches; and the surname-unit count's mirror of classify, which agrees by test. tests/v2/pipeline/test_classify.py holds the invariant over two inputs (docs/design/AGENTS.md's axis 11): under a lexicon adding the title `q`, 30 shapes (every comma shape, behind a modifier and a title, glued at a stop, in brackets and quotes, past the second comma, in one case, beside a glued word T8 divides and before a glued Thai title) × 4 spellings (`Q.`, `q.`, `Q.R.`, `Q.John`) × the three orders, 360 rows, read exactly as under the default, ambiguities included; with the veto answering no at every reader 279 of them move, the recorded control (2026-11-19), and with it off in one module at a time each module moves some. - **The capital.** The Bengali `ড` is written `ড.` as the doctor (bn.toml's note), the full stop being the title's writing, so a letter of a script without case keeps its title reading. The default moves nothing, holding no one-letter title in a cased script: the committed snapshot gains only the new rule examples, and no reading it held moves. - **Accepted:** under the pack a name opening with a bare `U` reads it as the title, a Korean surname `U` written bare included (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19), and so does a bare `U` written as an initial without its period; and a Burmese `U` written with a full stop reads as the given name (1 of the 71 names opening with the honorific in the population of the vocabulary-collisions entry, 2026-11-19), the writing being an initial's. - - **Left out:** #1205's `H.` (Haji) under an Indonesian choice asks the opposite, the dotted letter as the title; this entry makes that a title only where a reading or a rule says so for that letter, which #1205's decision would add. A word holding the letter beside a title chunk is a title for the title (`U.Daw Smith` → title 'U.Daw' under the pack), and the fullwidth `U.` is no initial, as `J.` is not (rules/T5). + - **Left out:** #1205's `H.` (Haji) under an Indonesian choice asks the opposite, the dotted letter as the title; this entry makes that a title only where a reading or a rule says so for that letter, which #1205's decision would add. A word holding the letter beside a title chunk is a title for the title (`U.Daw Smith` → title 'U.Daw' under the pack), and the fullwidth `U.` is no initial, as `J.` is not (rules/T5), each an Accepted bullet of rules/H11. Declined: diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 1fef7c167..25be5551a 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -102,7 +102,7 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - 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, which rules/H11 states as a shape (decisions/H11); (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, each opening 4 names or fewer in the population below. - **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`. - - **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 written in capitals, the regnal numerals aside, 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. + - **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. - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. 153 names move, 151 from a misreading to the intended reading (holding `u` 70, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,986 under the pack (99.9%); the four it misses are that string, two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default, and one name opening with `U.`, which rules/H11 reads as an initial (decisions/H11's Accepted). The first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - **The cost to names that are not Burmese**, measured on this branch (2026-11-19). at the fix commit `31738f17`, `config_diff.py diff default plain:MY --committed`: 273 of 7,656 names move, 5 of them opening with `U` or `Daw` (`Daw Thida`, `U Kyaw Win`, and three rule examples this change adds, the Korean `U Min Ho` among them) and 268 others, `van` 130, `da` 20, `do` 19 (the credential among them), `la` 11, `di` 6, `du` 5; the first count, before `do`'s credential left and the rule examples were added, 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%); 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 bare `U` opening a name is the title, a Korean surname `U` included (rules/H11's Accepted); a title and one name word gives the family a word a Burmese name does not hold as a family name (rules/H1). diff --git a/docs/design/mechanisms.md b/docs/design/mechanisms.md index a98a72e21..9d1c11553 100644 --- a/docs/design/mechanisms.md +++ b/docs/design/mechanisms.md @@ -348,7 +348,7 @@ rules/O8's letters are the same shape at the family's other edge: the family wri **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`. -**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`, 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). +**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). **Lives in.** nameparser/locales/ (packs), nameparser/_parser.py (parser_for, the one applier), nameparser/_lexicon.py (the compile under a recorded choice, `_chosen_pool` and `_built`), nameparser/_reading_index.py (the selection, `choose`, and the derived surface, `changed_words`), nameparser/_locale.py (`rules_patch`, a file's compiled `[rules]` as a patch) and tools/vocab/build.py (`RULE_KEYS`, the rules a file may turn on, and `PACK_RULES`, the files the shipped packs read; decisions/vocabulary-model, 2026-10-29 4f). A rule a file turns on is a `Policy` field; a new rule kind is a core change, never code in a pack: a new `Policy` field (with `ADDED_IN`), a row in build.py's `RULE_KEYS` and in `_locale._RULE_VALUES`, and a mechanisms.md entry of its own for the rule kind. diff --git a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md index 0444924fa..c66337fff 100644 --- a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md +++ b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md @@ -34,7 +34,15 @@ ``` "U. Thein Aung" [my] → given="U." ``` +- A word holding the letter beside a title cut from it at its full stop is a title for the title it holds, not for the letter. + ``` + "U.Daw Smith" [my] → title="U.Daw" + ``` +- A letter written with a fullwidth full stop is no initial (T5), so it keeps its title reading. + ``` + "U. Smith" [my] → title="U." + ``` --- **Signal:** shape: a one-letter word written with its full stop, in a script with capitals -**history:** decisions/H11 · **implemented:** nameparser/_lexicon.py, nameparser/_pipeline/_classify.py, nameparser/_pipeline/_vocab.py, nameparser/_pipeline/_segment.py +**history:** decisions/H11 · **implemented:** nameparser/_lexicon.py, nameparser/_pipeline/_classify.py, nameparser/_pipeline/_vocab.py, nameparser/_pipeline/_segment.py, nameparser/_pipeline/_script_segment.py diff --git a/docs/locales.rst b/docs/locales.rst index 634a223b9..4672bba02 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -147,8 +147,9 @@ shape covers much: - ``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, and any where ``U`` or ``Daw`` opens the name or the part - after a comma. + among them, a name holding the credential ``DO``, and any where ``U`` + or ``Daw`` opens the name, follows a title opening it, or opens the + part after a comma. .. warning:: @@ -1138,5 +1139,5 @@ right, validated on its own, and it may hold any of these: 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 - the same way. + fragment takes out the particle readings of the Burmese syllables, + and ``do``'s credential reading, the same way. diff --git a/nameparser/AGENTS.md b/nameparser/AGENTS.md index daa38f078..1b74c7b28 100644 --- a/nameparser/AGENTS.md +++ b/nameparser/AGENTS.md @@ -36,6 +36,10 @@ The second was in what the grids compared: they compared ambiguity KINDS, so a r A test that uses only the listed spelling of a word class walks only the vocabulary path, and the shape path is a separate branch that can be missing while every test passes. When a change touches a word class, test one spelling from each path. Each subsection below is a class where a path was missed, with the PR that found it; add a new class here when a review finds one (root AGENTS.md's Workflow section says how). +### A veto on a vocabulary set reaches every reader of the set + +A rule that narrows what a vocabulary set claims (P7's one-letter particle, H11's one-letter title) narrows it only where a reader asks it, and a set has many readers that test membership on their own: #1231's H11 was first asked at classify's tag and the period-joined chunks, and two review rounds found eleven more readers of the title sets still claiming `U.` under `locales.MY` (the comma count, the title phrase, T8's glued-stop tests, the set-apart clause, C2's third part, the Thai glued-title walk, a title run's addressing, the group suggester), each with its own input (`U. Smith, Ed` reversed). Before calling a veto done, grep every read of the set (`git grep -nE '_sets\.(titles|titles_ambiguous|...)' nameparser/` and the `titles = ...` bindings), ask the veto at each one whose answer the vetoed word can move or say why not, and hold it with an invariant over two inputs (a lexicon holding the word against one that does not) whose grid holds a shape for each reader, with a recorded control: tests/v2/pipeline/test_classify.py's `_H11_ROWS` is the worked one. + ### Roman numerals Roman numerals are the sharpest case: `ii`, `iii` and `iv` are suffix vocabulary; `i` and `v` are vocabulary too but initial-shaped, so `is_suffix_piece` vetoes them and only the numeral fork reads them; and `vi` through `x` are in no list at all, read by the fork's shape test alone (checked 2026-10-04 against `Lexicon.default()`) -- which stops at `x`: `_vocab._ROMAN` matches I to X, so `John Smith XI` reads `XI` as a name word (re-checked 2026-10-07, #614's /simplify, which found a docstring claiming "any length"). diff --git a/nameparser/_lexicon.py b/nameparser/_lexicon.py index 96d8501ea..8bc968dc7 100644 --- a/nameparser/_lexicon.py +++ b/nameparser/_lexicon.py @@ -169,12 +169,14 @@ def _spells_a_cased_initial(n: str, text: str) -> bool: is lower case, so a letter with a capital is one that upper-cases to something else. - Every reader of the title vocabulary asks it, after its membership - hit and its own `len(n) != 1` test at C level, so only a one-letter - title pays the frame: classify's tags, the period-joined - derivation's chunks, the set-apart clause's kind, the glued-stop - cut, the comma count, the title phrase, C2's third part and the - group suggester.""" + Every reader of the title vocabulary whose answer such a word can + move asks it, after its membership hit and its own `len(n) != 1` + test at C level, so only a one-letter title pays the frame: + classify's tags, the period-joined derivation's chunks, the + set-apart clause's kind, the glued-stop cut and T8's tests of the + word before a glued one, the glued-title walk, the comma count, the + title phrase, C2's third part, a title run's addressing and the + group suggester (decisions/H11 names the reads left out).""" return len(n) == 1 and "." in text and n.upper() != n @@ -264,12 +266,22 @@ def _run_addresses_by_given(words: Iterable[str], The vocabulary is passed in rather than read off a default: a caller's own Lexicon is the one that has to be consulted, and this module is where Lexicon is defined.""" + words = list(words) folded = _fold_words(words) if not folded: # every word folded away, so there is no key and no last word: # the joined spelling built "" here, which matched nothing return False - return " ".join(folded) in vocabulary or folded[-1] in vocabulary + last = folded[-1] + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" -- the + # last word a connective chained into the run ('Mr. and Q. Smith') + # addresses nothing; the length test first, so a run of longer + # words pays no frame + if len(last) == 1 and _spells_a_cased_initial( + last, next(w for w in reversed(words) if _normalize(w) == last)): + return " ".join(folded) in vocabulary + return " ".join(folded) in vocabulary or last in vocabulary def _reject_buffer(value: object, label: str, plural: str) -> None: diff --git a/nameparser/_pipeline/_classify.py b/nameparser/_pipeline/_classify.py index 5241bc9b0..539aaba5b 100644 --- a/nameparser/_pipeline/_classify.py +++ b/nameparser/_pipeline/_classify.py @@ -604,6 +604,11 @@ def classify(state: ParseState) -> ParseState: n = folded[i] if n not in lex._sets.titles_ambiguous and n not in lex._sets.title_modifiers: continue + # rules/H11: "a one-letter word written with its period is + # an initial and not a title, where the letter has a + # capital" -- so no fork between title and name either + if len(n) == 1 and _spells_a_cased_initial(n, written[i].text): + continue if n in lex._sets.titles_ambiguous and n not in lex._sets.titles: tags = tags | {TITLE_AMBIGUOUS_TAG} if title: diff --git a/nameparser/_pipeline/_script_segment.py b/nameparser/_pipeline/_script_segment.py index 1d3590ddc..a610d0137 100644 --- a/nameparser/_pipeline/_script_segment.py +++ b/nameparser/_pipeline/_script_segment.py @@ -90,7 +90,7 @@ import unicodedata from collections.abc import Callable, Sequence -from nameparser._lexicon import FULL_STOPS, _normalize +from nameparser._lexicon import FULL_STOPS, _normalize, _spells_a_cased_initial import nameparser._pipeline._comma as _comma from nameparser._pipeline._classify import classify from nameparser._pipeline._state import ( @@ -556,10 +556,15 @@ def _all_titles(text: str, titles: frozenset[str]) -> bool: written apart, which the site walk passes over; a word holding a name ('ดร.สมชาย') is a site, never passed over.""" n = _normalize(text) + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" -- and + # so is such a letter between the stops; the length test first if n in titles: - return True + return len(n) != 1 or not _spells_a_cased_initial(n, text) chunks = [c for c in n.split(".") if c] - return bool(chunks) and all(c in titles for c in chunks) + return bool(chunks) and all( + c in titles and (len(c) != 1 or not _spells_a_cased_initial(c, ".")) + for c in chunks) # rules/W6: "a title the vocabulary marks to peel, glued to the start of @@ -998,8 +1003,12 @@ def _a_name_before(texts: Sequence[str], state: ParseState) -> bool: if _normalize(before) in sets.conjunctions: return False last = _normalize(texts[-1]) - if (last in sets.titles or last in sets.titles_ambiguous - or last in sets.title_modifiers or last in sets.title_styles): + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" + if ((last in sets.titles or last in sets.titles_ambiguous + or last in sets.title_modifiers or last in sets.title_styles) + and (len(last) != 1 + or not _spells_a_cased_initial(last, texts[-1]))): return False return (period_joined_vocab(texts[-1], state.lexicon) != "title" or bool(glued_cuts(texts[-1], state.lexicon))) @@ -1024,7 +1033,10 @@ def _a_word_to_spare(texts: Sequence[str], state: ParseState) -> bool: St.Clair', 'Dr. A.Smith').""" sets = state.lexicon._sets lexicon = state.lexicon - return any(_normalize(before) not in sets.titles + # rules/H11: "a one-letter word written with its period is an + # initial and not a title, where the letter has a capital" + return any(((n := _normalize(before)) not in sets.titles + or len(n) == 1 and _spells_a_cased_initial(n, before)) and (period_joined_vocab(before, lexicon) != "title" or glued_cuts(before, lexicon)) for before in texts) diff --git a/tests/v2/pipeline/test_classify.py b/tests/v2/pipeline/test_classify.py index 65d109c13..b85dee47b 100644 --- a/tests/v2/pipeline/test_classify.py +++ b/tests/v2/pipeline/test_classify.py @@ -925,11 +925,27 @@ def test_the_veto_reaches_every_kind_of_title_reading( def test_the_veto_reaches_a_title_that_may_be_a_given_name() -> None: # a title reading beside a given one compiles into the ambiguous - # titles, read by the title phrase (rules/H9) + # titles, read by the title phrase (rules/H9), which reports no fork + # for the initial; the control lexicon holds the given name alone parser = Parser(lexicon=Lexicon.default().add("q", kind="office") .add("q", kind="given")) - for text in ("Q. of Smith", "Vice Q. Smith", "Q. Smith"): - assert parser.parse(text).as_dict() == Parser().parse(text).as_dict(), text + control = Parser(lexicon=Lexicon.default().add("q", kind="given")) + for text in ("Q. of Smith", "Vice Q. Smith", "Q. Smith", "Dr. Q. Smith", + "Q.John Smith", "(Q.) Smith"): + got, want = parser.parse(text), control.parse(text) + assert got.as_dict() == want.as_dict(), text + assert [a.kind for a in got.ambiguities] == [ + a.kind for a in want.ambiguities], text + + +def test_a_run_ending_in_an_initial_addresses_no_given_name() -> None: + # the last word of a title run a connective chained an initial into + # addresses nothing (rules/H1's run, read by its last word) + parser = Parser(lexicon=Lexicon.default().add( + "q", kind="nobility", addresses="given")) + assert parser.parse("Mr. and Q. Smith").as_dict() == Parser().parse( + "Mr. and Q. Smith").as_dict() + assert parser.parse("Mr. and Q Smith").given == "Smith" def test_the_veto_reaches_a_greek_capital() -> None: @@ -965,6 +981,10 @@ def test_the_one_letter_title_veto_is_what_keeps_the_initial( "Dr. {q} Smith", "Dr.{q} Smith", "John Smith Dr.{q}", "John ({q}) Smith", "({q}) Smith", "John Smith ({q})", 'John "{q}" Smith', "{q} van Berg, Ed", "JOHN {q} SMITH", "{q} Smith, Jr.", + # the fix commit's review: the glued words T8 divides, read by its + # own title tests, and the Thai glued-title walk past a title + "Juan dela {q} Sta.Maria", "{q} J.Smith", "Mr. {q} A.Smith", + "{q} A.Brown, PhD", "{q} นายสมชาย", "Mr. and {q} Smith", ] _H11_SPELLINGS = ["Q.", "q.", "Q.R.", "Q.John"] _H11_ROWS = [(shape.format(q=q), order) @@ -973,7 +993,7 @@ def test_the_one_letter_title_veto_is_what_keeps_the_initial( #: The recorded negative control: rows of the grid that read otherwise #: with the veto answering no at every reader, measured 2026-11-19 #: (re-take it when the grid moves) -_H11_UNGUARDED_EFFECT = 228 +_H11_UNGUARDED_EFFECT = 279 def _h11_differences() -> int: @@ -994,14 +1014,16 @@ def _h11_differences() -> int: def test_a_one_letter_title_with_its_period_reads_as_no_title_at_all() -> None: - assert len(_H11_ROWS) == 288 + assert len(_H11_ROWS) == 360 assert _h11_differences() == 0 def test_the_h11_invariant_fails_with_the_veto_off( monkeypatch: pytest.MonkeyPatch) -> None: - from nameparser._pipeline import _segment - for module in (_classify_module, _vocab, _segment): + from nameparser import _lexicon + from nameparser._pipeline import _script_segment, _segment + for module in (_lexicon, _classify_module, _vocab, _segment, + _script_segment): monkeypatch.setattr(module, "_spells_a_cased_initial", lambda n, text: False) assert _h11_differences() == _H11_UNGUARDED_EFFECT diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index d90f85599..757d7e5a9 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -1751,6 +1751,7 @@ "U. S. Grant" "U. Smith, Ed" "U. Thein Aung" +"U.Daw Smith" "U.S. District Judge Marc Thomas Treadwell" "U.S. Grant" "U.S. Grant Smith, John" @@ -1765,6 +1766,7 @@ "US Senator John Smith" "Uddin, Mr Md" "Uddin, Mr Md Karim" +"U. Smith" "VAN DER BERG, JAN" "VAN DER WALT" "VAN GOGH VINCENT" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 1126dd740..7c25a2c39 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -4379,6 +4379,7 @@ {"name": "U. S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} {"name": "U. Smith, Ed", "given": "U.", "family": "Smith", "suffix": "Ed", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as given (declared)"], "initials": "U. S.", "capitalized_force": "U. Smith, ED"} {"name": "U. Thein Aung", "given": "U.", "middle": "Thein", "family": "Aung", "initials": "U. T. A."} +{"name": "U.Daw Smith", "given": "U.", "middle": "Daw", "family": "Smith", "initials": "U. D. S."} {"name": "U.S. District Judge Marc Thomas Treadwell", "title": "U.S. District Judge", "given": "Marc", "middle": "Thomas", "family": "Treadwell", "initials": "M. T. T."} {"name": "U.S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} {"name": "U.S. Grant Smith, John", "given": "John", "family": "U.S. Grant Smith", "initials": "J. U. S. G. S."} @@ -4419,6 +4420,7 @@ {"name": "Ursula von der Leyen geb. Albrecht", "given": "Ursula", "family": "von der Leyen", "maiden": "Albrecht", "initials": "U. L."} {"name": "Uxía", "given": "Uxía", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "U."} {"name": "Uxía", "order": "FAMILY_FIRST", "given": "Uxía", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "U."} +{"name": "U. Smith", "given": "U.", "family": "Smith", "initials": "U. S."} {"name": "VAN DER BERG, JAN", "given": "JAN", "family": "VAN DER BERG", "initials": "J. B.", "capitalized": "Jan van der Berg"} {"name": "VAN DER WALT", "given": "VAN", "family": "DER WALT", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: particle as family (vocabulary)"], "initials": "V. W.", "capitalized": "Van der Walt"} {"name": "VAN GOGH VINCENT", "given": "VAN", "middle": "GOGH", "family": "VINCENT", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: particle as family (vocabulary)"], "initials": "V. G. V.", "capitalized": "Van Gogh Vincent"} From f29a4da69dcb7925b55e34417687f19411ae0ce4 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:46:39 -0800 Subject: [PATCH 06/13] Drop rules/H11: U. reads as the title vocabulary reads it under MY (#1231) Decided 2026-11-19, reversing the working answer that U. with a full stop stays an initial under the pack: a caller who chose the pack is reading Burmese names, no Burmese list measured writes U. as an initial, and vetoing a one-letter dotted title at every reader of the title vocabulary was new machinery on the shared parse path. The pipeline, _lexicon, _suggest and their tests return to master's; rules/H11 and decisions/H11 are removed with their index lines and the nameparser/AGENTS.md paragraph they earned. Under the pack U. Thein Sein and U. S. Grant now read title 'U.', pinned as the accepted reading in tests/v2/test_locales.py and the case rows; my.py, my.toml and docs/languages.rst say so as a reason not to apply the pack to a mixed list, the release log too. Co-Authored-By: Claude Opus 5.5 --- ...ter-title-against-the-initial-it-spells.md | 20 --- docs/design/decisions/README.md | 1 - ...ter-title-against-the-initial-it-spells.md | 48 ------ docs/design/rules/README.md | 1 - docs/languages.rst | 17 +- docs/release_log.rst | 2 +- nameparser/AGENTS.md | 4 - nameparser/_lexicon.py | 36 +--- nameparser/_pipeline/_classify.py | 24 +-- nameparser/_pipeline/_script_segment.py | 24 +-- nameparser/_pipeline/_segment.py | 8 +- nameparser/_pipeline/_vocab.py | 53 ++---- nameparser/_suggest.py | 10 +- nameparser/locales/my.py | 13 +- nameparser/vocab/my.toml | 2 +- tests/v2/cases.py | 20 ++- tests/v2/pipeline/test_classify.py | 162 ------------------ tests/v2/test_layering.py | 6 +- tests/v2/test_locales.py | 55 +++--- 19 files changed, 79 insertions(+), 427 deletions(-) delete mode 100644 docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md delete mode 100644 docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md diff --git a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md deleted file mode 100644 index 330dadc75..000000000 --- a/docs/design/decisions/H11-one-letter-title-against-the-initial-it-spells.md +++ /dev/null @@ -1,20 +0,0 @@ -# H11 — a one-letter title against the initial it spells - -## Standing - -- A one-letter word written with its period is an initial and not a title where its letter has a capital, whatever title the letter spells, at every reader of the title vocabulary whose answer such a word can move, and so is such a letter cut from a word at its full stops (`U. S. Grant`, `Grant, U.S.`, `U. Smith, Ed`, `Vice U. Smith`, `Dr.U. Smith` and `John (U.) Smith` under `locales.MY` read as the default reads them); written bare it is the title (`U Thein Sein` → title 'U' under the pack); a letter of a script without capitals keeps its title written with its period (`ড. রহিম উদ্দিন` → title 'ড.') — 2026-11-19 #1231. -- The veto is a shape, stated once for every one-letter title a lexicon holds, a caller's included, as rules/P7 states it for the particles, and asked through one predicate, `_lexicon._spells_a_cased_initial`; no per-word property (the reserved `bare_only`) is built for it — 2026-11-19 #1231. - -Open: none in this file. - -## Log - -- 2026-11-19 #1231 — A ONE-LETTER TITLE WRITTEN WITH ITS PERIOD IS THE INITIAL IT SPELLS, WHERE THE LETTER HAS A CAPITAL. `locales.MY` turns on `u`, the Burmese honorific (my.toml, `default = false`), the first one-letter title in a cased script any lexicon the project ships has held: the default's are the Bengali `ড` and the Thai `ศ` (`sorted(w for w in L.titles | L.titles_ambiguous if len(w) == 1)` with `L = Parser().lexicon._sets`, 2026-11-19), and no other shipped pack adds one. The title match folds edge periods away, so the reading alone also claimed `U.`: the issue's simulated lexicon read `U. S. Grant` title 'U.', given 'S.', and `Grant, U.S.` title 'U.S.' through the period-joined derivation, which reads a word whose chunk is a title as a title. The issue asked whether `U` should need the absence of a period, and the working answer (decision 3 of the 2026-11-19 #1231 entry in decisions/vocabulary-collisions) was yes; the period is a fact about initials, the same line rules/P7 draws for a one-letter particle (`Juan Ó. Pérez`), so it is stated as a shape, not as a property of `u`, and reaches a caller's one-letter title too. - - **Where it reads: every reader of the title vocabulary whose answer such a word can move.** The first build asked the veto at classify's title tag and the period-joined derivation's chunk test only, and its sweep held no comma shape with a word after the comma that the comma count weighs; the PR's review found `U.` still read as a title by six other readers under the pack: the comma count (`U. Smith, Ed` reversed to given 'Ed', family 'U. Smith', the shape AGENTS.md's Gotchas name for any change to the title shape), the title phrase (`Vice U. Smith` → title 'Vice'), the glued-stop cut (`Dr.U. Smith` → title 'Dr.U.'), the set-apart clause (`John (U.) Smith` → title 'U.'), C2's third part (`Smith, John, U.` losing its comma-structure report) and the group suggester (six names opening with `U.` suggested `FAMILY_FIRST`). So `_lexicon._spells_a_cased_initial` is the one predicate, asked after each reader's membership hit and a C-level length test, so only a one-letter title pays a frame (`tools/perf/call_count.py` reads 197.72 on the branch and on master): classify's title, given-name-title, trailing-title and after-given-title tags and its title-phrase fork, the period-joined title and its chunks, the set-apart kind, the glued-stop test and the title chunk before a stop, the comma count, the title phrase (a vetoed word is neither a title nor a phrase member there), C2's titles-and-suffixes part, the suggester's leading title, and, found by the fix commit's review, T8's two tests of the word before a glued one (`Juan dela U. Sta.Maria`, `U. J.Smith` losing its report), the glued-title walk past titles written apart (`U. นายสมชาย`) and the given-name addressing of a title run by its last word (`Mr. and Q. Smith` under a caller's given-addressing `q`). Three reads are left as they were, none movable by such a word: T8's whole-word test in `glued_cuts`, which a run of letters leaves before it asks; the suffix test that excludes a title (`_settles`), which a vetoed initial, no suffix, never reaches; and the surname-unit count's mirror of classify, which agrees by test. tests/v2/pipeline/test_classify.py holds the invariant over two inputs (docs/design/AGENTS.md's axis 11): under a lexicon adding the title `q`, 30 shapes (every comma shape, behind a modifier and a title, glued at a stop, in brackets and quotes, past the second comma, in one case, beside a glued word T8 divides and before a glued Thai title) × 4 spellings (`Q.`, `q.`, `Q.R.`, `Q.John`) × the three orders, 360 rows, read exactly as under the default, ambiguities included; with the veto answering no at every reader 279 of them move, the recorded control (2026-11-19), and with it off in one module at a time each module moves some. - - **The capital.** The Bengali `ড` is written `ড.` as the doctor (bn.toml's note), the full stop being the title's writing, so a letter of a script without case keeps its title reading. The default moves nothing, holding no one-letter title in a cased script: the committed snapshot gains only the new rule examples, and no reading it held moves. - - **Accepted:** under the pack a name opening with a bare `U` reads it as the title, a Korean surname `U` written bare included (`U Min Ho` → title 'U'; Wikidata holds 122 South Koreans with the family name U, tools/name_usage.py, 2026-11-19), and so does a bare `U` written as an initial without its period; and a Burmese `U` written with a full stop reads as the given name (1 of the 71 names opening with the honorific in the population of the vocabulary-collisions entry, 2026-11-19), the writing being an initial's. - - **Left out:** #1205's `H.` (Haji) under an Indonesian choice asks the opposite, the dotted letter as the title; this entry makes that a title only where a reading or a rule says so for that letter, which #1205's decision would add. A word holding the letter beside a title chunk is a title for the title (`U.Daw Smith` → title 'U.Daw' under the pack), and the fullwidth `U.` is no initial, as `J.` is not (rules/T5), each an Accepted bullet of rules/H11. - -Declined: - -- A per-reading property read only bare (`bare_only`, reserved, unbuilt, for 3.x in tools/vocab/build.py) — the period convention is a fact about initials, not about `u`, as decisions/P7 declined a flag for `ó`; a property would be one more axis for every guard roster to sweep, for a question no entry answers differently today. #1205 may be the first entry that does. diff --git a/docs/design/decisions/README.md b/docs/design/decisions/README.md index 7afecda98..7dc9878ae 100644 --- a/docs/design/decisions/README.md +++ b/docs/design/decisions/README.md @@ -33,7 +33,6 @@ Entry conventions: - [H8 — a salutation ending the given part](H8-salutation-ending-the-given-part.md) - [H9 — the title phrase](H9-title-phrase.md) - [H10 — a title written as a run of letters](H10-title-written-as-a-run-of-letters.md) -- [H11 — a one-letter title against the initial it spells](H11-one-letter-title-against-the-initial-it-spells.md) ## Particles & surname prefixes (P) diff --git a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md b/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md deleted file mode 100644 index c66337fff..000000000 --- a/docs/design/rules/H11-one-letter-title-against-the-initial-it-spells.md +++ /dev/null @@ -1,48 +0,0 @@ -# H11 — a one-letter title against the initial it spells - -**When:** a one-letter word the title vocabulary holds stands in a name, as the Burmese honorific U does under a Burmese choice in "U Thein Sein". - -**Then:** a one-letter word written with its period is an initial and not a title, where the letter has a capital, whatever title the same letter spells and wherever the word stands; written bare, it is the title. - -- **A single letter with a capital cut from a word at its full stops is an initial too**, so a word of initials, or a name glued to an initial at its full stop, is no title for holding the letter. - ``` - "Grant, U.S." [my] → given="U." - "U.Thein Sein" [my] → given="U." - "Dr.U. Smith" [my] → given="U." - ``` - -**Because:** a one-letter title is spelled with the same letter as an initial, and the full stop is what tells them apart. An initial is an abbreviation and is written with one; an honorific written as one letter is a whole word and is written bare as a rule, as the Burmese U is in the names #1231 measured, while U. is the initial of Ulysses or Ursula. A letter of a script without capitals is outside the rule: the full stop is how such a title is written, as the Bengali ড. (doctor) is. - -``` -"U. S. Grant" [my] → given="U." -"John U. Smith" [my] → middle="U." -"Smith, U." [my] → given="U." -"U. Smith, Ed" [my] → suffix="Ed" -"Vice U. Smith" [my] → given="Vice" -"John (U.) Smith" [my] → middle="U." -"U Thein Sein" [my] → title="U" · boundary -"ড. রহিম উদ্দিন" → title="ড." · boundary -``` - -**Accepted:** - -- A Korean name opening with the surname U, written bare, reads the surname as the title under a Burmese choice, as any name opening with the bare letter does there. - ``` - "U Min Ho" [my] → title="U" - ``` -- A Burmese U written with a full stop reads as the given name under a Burmese choice, the writing being an initial's. - ``` - "U. Thein Aung" [my] → given="U." - ``` -- A word holding the letter beside a title cut from it at its full stop is a title for the title it holds, not for the letter. - ``` - "U.Daw Smith" [my] → title="U.Daw" - ``` -- A letter written with a fullwidth full stop is no initial (T5), so it keeps its title reading. - ``` - "U. Smith" [my] → title="U." - ``` - ---- -**Signal:** shape: a one-letter word written with its full stop, in a script with capitals -**history:** decisions/H11 · **implemented:** nameparser/_lexicon.py, nameparser/_pipeline/_classify.py, nameparser/_pipeline/_vocab.py, nameparser/_pipeline/_segment.py, nameparser/_pipeline/_script_segment.py diff --git a/docs/design/rules/README.md b/docs/design/rules/README.md index 403358047..55d887a8f 100644 --- a/docs/design/rules/README.md +++ b/docs/design/rules/README.md @@ -125,7 +125,6 @@ Terms the rules use without defining them each time, each with the rule that def - [H8 — a salutation ending the given part](H8-salutation-ending-the-given-part.md) - [H9 — the title phrase](H9-title-phrase.md) - [H10 — a title written as a run of letters](H10-title-written-as-a-run-of-letters.md) -- [H11 — a one-letter title against the initial it spells](H11-one-letter-title-against-the-initial-it-spells.md) ## [Particles & surname prefixes (P)](P-particles-and-surname-prefixes.md) diff --git a/docs/languages.rst b/docs/languages.rst index 63fd4dc66..c1429978e 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1216,13 +1216,7 @@ The pack keeps them name words: 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``. ``U`` written with its full -stop stays an initial, as it is in ``U. S. Grant``: - -.. doctest:: - - >>> burmese.parse("U. S. Grant").given - 'U.' +written in capitals keeps a final ``DO``. On 2,990 names of people from Myanmar, from sanctions and politically exposed persons lists and from Wikidata, the honorific read as the @@ -1241,8 +1235,6 @@ What the pack leaves as it is ``Thant``, as a title and one name word reads in any name. - **Military and religious styles** (``Bogyoke``, ``Sayadaw``) are read as given names, as by default. -- **U with a full stop.** ``U.`` is read as an initial, so a Burmese - name written ``U. Thein Aung`` gives given ``U.``. - **Burmese script.** The pack reads Latin letters only; ``ဦး`` and ``ဒေါ်`` have no reading yet. @@ -1252,7 +1244,9 @@ When not to use it The pack is for lists of Burmese names. On other names it costs the nine words' particle readings, which Dutch, Portuguese, Italian, French, Spanish, Filipino and Māori family names hold (``de`` and -``del`` are kept), and the credential DO, so keep it to a parser of its +``del`` are kept), and the credential DO. And it reads ``U`` opening a +name as the honorific however it is written, so an initial ``U.`` +opening a Western name becomes the title. Keep it to a parser of its own for the Burmese names in your data: .. doctest:: @@ -1261,6 +1255,9 @@ own for the Burmese names in your data: '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 diff --git a/docs/release_log.rst b/docs/release_log.rst index 9c999e52e..28635ab61 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -7,7 +7,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``): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` + - **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.`` opening a name becomes the title: keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` - **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.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` diff --git a/nameparser/AGENTS.md b/nameparser/AGENTS.md index 1b74c7b28..daa38f078 100644 --- a/nameparser/AGENTS.md +++ b/nameparser/AGENTS.md @@ -36,10 +36,6 @@ The second was in what the grids compared: they compared ambiguity KINDS, so a r A test that uses only the listed spelling of a word class walks only the vocabulary path, and the shape path is a separate branch that can be missing while every test passes. When a change touches a word class, test one spelling from each path. Each subsection below is a class where a path was missed, with the PR that found it; add a new class here when a review finds one (root AGENTS.md's Workflow section says how). -### A veto on a vocabulary set reaches every reader of the set - -A rule that narrows what a vocabulary set claims (P7's one-letter particle, H11's one-letter title) narrows it only where a reader asks it, and a set has many readers that test membership on their own: #1231's H11 was first asked at classify's tag and the period-joined chunks, and two review rounds found eleven more readers of the title sets still claiming `U.` under `locales.MY` (the comma count, the title phrase, T8's glued-stop tests, the set-apart clause, C2's third part, the Thai glued-title walk, a title run's addressing, the group suggester), each with its own input (`U. Smith, Ed` reversed). Before calling a veto done, grep every read of the set (`git grep -nE '_sets\.(titles|titles_ambiguous|...)' nameparser/` and the `titles = ...` bindings), ask the veto at each one whose answer the vetoed word can move or say why not, and hold it with an invariant over two inputs (a lexicon holding the word against one that does not) whose grid holds a shape for each reader, with a recorded control: tests/v2/pipeline/test_classify.py's `_H11_ROWS` is the worked one. - ### Roman numerals Roman numerals are the sharpest case: `ii`, `iii` and `iv` are suffix vocabulary; `i` and `v` are vocabulary too but initial-shaped, so `is_suffix_piece` vetoes them and only the numeral fork reads them; and `vi` through `x` are in no list at all, read by the fork's shape test alone (checked 2026-10-04 against `Lexicon.default()`) -- which stops at `x`: `_vocab._ROMAN` matches I to X, so `John Smith XI` reads `XI` as a name word (re-checked 2026-10-07, #614's /simplify, which found a docstring claiming "any length"). diff --git a/nameparser/_lexicon.py b/nameparser/_lexicon.py index 8bc968dc7..ceddd17a5 100644 --- a/nameparser/_lexicon.py +++ b/nameparser/_lexicon.py @@ -156,30 +156,6 @@ def _spells_an_initial(n: str, text: str) -> bool: return len(n) == 1 and text[-1] == "." -# rules/H11: "a one-letter word written with its period is an initial -# and not a title, where the letter has a capital" -def _spells_a_cased_initial(n: str, text: str) -> bool: - """Whether `text`, folded to `n`, is one letter with a capital - written with a full stop ('U.', 'h.', the 'U.' of 'U.S.' cut at its - stops): an initial whatever title the letter also spells (#1231). - A letter of a script without case ('ড.', the Bengali doctor) keeps - its title reading, the full stop being how that title is written. - `n` is `_normalize(text)`, so its edge stops are gone and a full - stop left in `text` beside a one-letter `n` is one of them; and it - is lower case, so a letter with a capital is one that upper-cases - to something else. - - Every reader of the title vocabulary whose answer such a word can - move asks it, after its membership hit and its own `len(n) != 1` - test at C level, so only a one-letter title pays the frame: - classify's tags, the period-joined derivation's chunks, the - set-apart clause's kind, the glued-stop cut and T8's tests of the - word before a glued one, the glued-title walk, the comma count, the - title phrase, C2's third part, a title run's addressing and the - group suggester (decisions/H11 names the reads left out).""" - return len(n) == 1 and "." in text and n.upper() != n - - def _fold_words(words: Iterable[str]) -> list[str]: """The words of a title run, folded for storage and lookup. @@ -266,22 +242,12 @@ def _run_addresses_by_given(words: Iterable[str], The vocabulary is passed in rather than read off a default: a caller's own Lexicon is the one that has to be consulted, and this module is where Lexicon is defined.""" - words = list(words) folded = _fold_words(words) if not folded: # every word folded away, so there is no key and no last word: # the joined spelling built "" here, which matched nothing return False - last = folded[-1] - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" -- the - # last word a connective chained into the run ('Mr. and Q. Smith') - # addresses nothing; the length test first, so a run of longer - # words pays no frame - if len(last) == 1 and _spells_a_cased_initial( - last, next(w for w in reversed(words) if _normalize(w) == last)): - return " ".join(folded) in vocabulary - return " ".join(folded) in vocabulary or last in vocabulary + return " ".join(folded) in vocabulary or folded[-1] in vocabulary def _reject_buffer(value: object, label: str, plural: str) -> None: diff --git a/nameparser/_pipeline/_classify.py b/nameparser/_pipeline/_classify.py index 539aaba5b..25e17f1f2 100644 --- a/nameparser/_pipeline/_classify.py +++ b/nameparser/_pipeline/_classify.py @@ -97,7 +97,7 @@ class (rules/S12). import unicodedata -from nameparser._lexicon import _normalize, _spells_a_cased_initial, _spells_an_initial +from nameparser._lexicon import _normalize, _spells_an_initial from nameparser._policy import CapsSuffixes from nameparser._pipeline._state import ( AGNOMEN_TAG, AMBIGUOUS_ACRONYM_TAG, AMBIGUOUS_WORD_TAG, COMMA_STRIP, CREDENTIAL_WORD_TAG, @@ -173,15 +173,7 @@ def _tags_for(token: WorkToken, n: str, state: ParseState, tags = set(token.tags) if marker_tag is not None: tags.add(marker_tag) - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" -- for - # every title tag below; the length and set tests first, at C level, - # so only a one-letter title pays the frame, not every initial (the - # tags below read sets inside these two) - initial = (len(n) == 1 - and (n in lex._sets.titles or n in lex._sets.titles_ambiguous) - and _spells_a_cased_initial(n, token.text)) - if n in lex._sets.titles and not initial: + if n in lex._sets.titles: tags.add("vocab:title") # rules/H5: "a title the vocabulary lists whole with a period # inside it chains without a final one" -- marked here, where @@ -200,18 +192,17 @@ def _tags_for(token: WorkToken, n: str, state: ParseState, elif ("." in n and n.replace(".", "") in lex._sets.dotted_titles and is_dotted_title(token.text, n, lex)): tags.add(DOTTED_TITLE_TAG) - if n in lex._sets.given_name_titles and not initial: + if n in lex._sets.given_name_titles: tags.add("vocab:given-title") # rules/H5: "a title that may be a given name is title vocabulary # there where its title reading is written short" -- marked here, # where the sets are at hand, so the chain reads a tag if (n in lex._sets.title_abbreviations - and n in lex._sets.titles_ambiguous and not initial): + and n in lex._sets.titles_ambiguous): tags.add(TRAILING_TITLE_TAG) # rules/H8: "the word joins the title field" -- tagged only where the # word is a title too, so an entry outside `titles` is inert - if (n in lex._sets.after_given_titles and n in lex._sets.titles - and not initial): + if n in lex._sets.after_given_titles and n in lex._sets.titles: tags.add("vocab:after-given-title") if suffix_as_written(n, token.text, lex): tags.add("vocab:suffix") @@ -604,11 +595,6 @@ def classify(state: ParseState) -> ParseState: n = folded[i] if n not in lex._sets.titles_ambiguous and n not in lex._sets.title_modifiers: continue - # rules/H11: "a one-letter word written with its period is - # an initial and not a title, where the letter has a - # capital" -- so no fork between title and name either - if len(n) == 1 and _spells_a_cased_initial(n, written[i].text): - continue if n in lex._sets.titles_ambiguous and n not in lex._sets.titles: tags = tags | {TITLE_AMBIGUOUS_TAG} if title: diff --git a/nameparser/_pipeline/_script_segment.py b/nameparser/_pipeline/_script_segment.py index a610d0137..1d3590ddc 100644 --- a/nameparser/_pipeline/_script_segment.py +++ b/nameparser/_pipeline/_script_segment.py @@ -90,7 +90,7 @@ import unicodedata from collections.abc import Callable, Sequence -from nameparser._lexicon import FULL_STOPS, _normalize, _spells_a_cased_initial +from nameparser._lexicon import FULL_STOPS, _normalize import nameparser._pipeline._comma as _comma from nameparser._pipeline._classify import classify from nameparser._pipeline._state import ( @@ -556,15 +556,10 @@ def _all_titles(text: str, titles: frozenset[str]) -> bool: written apart, which the site walk passes over; a word holding a name ('ดร.สมชาย') is a site, never passed over.""" n = _normalize(text) - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" -- and - # so is such a letter between the stops; the length test first if n in titles: - return len(n) != 1 or not _spells_a_cased_initial(n, text) + return True chunks = [c for c in n.split(".") if c] - return bool(chunks) and all( - c in titles and (len(c) != 1 or not _spells_a_cased_initial(c, ".")) - for c in chunks) + return bool(chunks) and all(c in titles for c in chunks) # rules/W6: "a title the vocabulary marks to peel, glued to the start of @@ -1003,12 +998,8 @@ def _a_name_before(texts: Sequence[str], state: ParseState) -> bool: if _normalize(before) in sets.conjunctions: return False last = _normalize(texts[-1]) - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" - if ((last in sets.titles or last in sets.titles_ambiguous - or last in sets.title_modifiers or last in sets.title_styles) - and (len(last) != 1 - or not _spells_a_cased_initial(last, texts[-1]))): + if (last in sets.titles or last in sets.titles_ambiguous + or last in sets.title_modifiers or last in sets.title_styles): return False return (period_joined_vocab(texts[-1], state.lexicon) != "title" or bool(glued_cuts(texts[-1], state.lexicon))) @@ -1033,10 +1024,7 @@ def _a_word_to_spare(texts: Sequence[str], state: ParseState) -> bool: St.Clair', 'Dr. A.Smith').""" sets = state.lexicon._sets lexicon = state.lexicon - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" - return any(((n := _normalize(before)) not in sets.titles - or len(n) == 1 and _spells_a_cased_initial(n, before)) + return any(_normalize(before) not in sets.titles and (period_joined_vocab(before, lexicon) != "title" or glued_cuts(before, lexicon)) for before in texts) diff --git a/nameparser/_pipeline/_segment.py b/nameparser/_pipeline/_segment.py index 139e07dae..c76fc21e1 100644 --- a/nameparser/_pipeline/_segment.py +++ b/nameparser/_pipeline/_segment.py @@ -34,7 +34,7 @@ """ from __future__ import annotations -from nameparser._lexicon import _normalize, _spells_a_cased_initial +from nameparser._lexicon import _normalize from nameparser._pipeline._pieces import own_words from nameparser._pipeline._state import ( ParseState, PendingAmbiguity, Structure, comma_bucket, copy_with, @@ -162,12 +162,8 @@ def titles_and_suffixes(seg: tuple[int, ...]) -> bool: # reads as the title, as classify tags it (decisions/C10) titles = state.lexicon._sets.titles cores = glued_cores(state.policy.extra_suffix_delimiters) - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" rest = tuple([i for i in seg - if ((n := _normalize(t := state.tokens[i].text)) - not in titles - or len(n) == 1 and _spells_a_cased_initial(n, t)) + if _normalize(t := state.tokens[i].text) not in titles and ("." not in t or period_joined_vocab(t, state.lexicon) != "title") diff --git a/nameparser/_pipeline/_vocab.py b/nameparser/_pipeline/_vocab.py index 091cf5ced..425a21bbd 100644 --- a/nameparser/_pipeline/_vocab.py +++ b/nameparser/_pipeline/_vocab.py @@ -56,7 +56,7 @@ from nameparser._lexicon import ( FULL_STOPS, Lexicon, _HYPHEN_CHARS, _VOCAB_FIELDS, _normalize, - _spells_a_cased_initial, _spells_an_initial, + _spells_an_initial, ) from nameparser._policy import ( CapsSuffixes, Policy, Script, _CASELESS_LETTERS, _EAST_ASIAN_SCRIPTS, @@ -575,11 +575,8 @@ def set_apart_kind(word: str, lexicon: Lexicon, # the period test asked at C level first (decisions/S3, #1131) joined = ("." in folded and folded not in sets.titles and acronym not in sets.suffix_acronyms) - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" -- '(U.)' - title = folded in sets.titles and ( - len(folded) != 1 or not _spells_a_cased_initial(folded, bare) - ) or joined and period_joined_title(bare, lexicon) + title = folded in sets.titles or joined and period_joined_title( + bare, lexicon) if joined and not title and period_joined_credential(bare, lexicon): # rules/S3: "a joined word holding a member is a member itself" # -- 'Msc.Ed' as 'MA/PhD', settled by S13's position (#1138) @@ -1009,11 +1006,7 @@ def _claimed_after_the_stop(w: str, lexicon: Lexicon) -> bool: unambiguous title or suffix word, and so no name (rules/T8): the one test `glued_cuts` and `glued_saint_cut` ask of it.""" sets = lexicon._sets - # rules/H11: "single letter with a capital cut from a word at its - # full stops is an initial too" -- the word after a glued stop is cut - # at it ('Dr.U.') - return w in sets.titles and ( - len(w) != 1 or not _spells_a_cased_initial(w, ".")) or ( + return w in sets.titles or ( w in sets.suffix_acronyms and w not in sets.suffix_acronyms_ambiguous) or ( (w in sets.suffix_words or w in sets.credential_words) @@ -1230,12 +1223,9 @@ def is_title_chunk(chunk: str, lexicon: Lexicon) -> bool: word, `glued_saint_cut`).""" sets = lexicon._sets n = _normalize(chunk) - # rules/H11: "single letter with a capital cut from a word at its - # full stops is an initial too" -- a chunk read before its full stop return n not in sets.saint_particles and ( n in sets.titles or n in sets.titles_ambiguous - or n in sets.title_modifiers or n in sets.title_styles) and ( - len(n) != 1 or not _spells_a_cased_initial(n, ".")) + or n in sets.title_modifiers or n in sets.title_styles) def is_dotted_title(text: str, n: str, lexicon: Lexicon) -> bool: @@ -1702,13 +1692,8 @@ def period_joined_title(text: str, lexicon: Lexicon) -> bool: one of which is title vocabulary ('Lt.Gov', 'Lt.Col'; not 'Dr.PhD' or 'St.John').""" chunks = [_normalize(c) for c in text.split(".") if c] - titles = lexicon._sets.titles - # rules/H11: "single letter with a capital cut from a word at its - # full stops is an initial too" -- a chunk is cut at a full stop, so it - # is written with one; the length test first, at C level return len(chunks) >= 2 and all( - c in titles and (len(c) != 1 or not _spells_a_cased_initial(c, ".")) - for c in chunks) + c in lexicon._sets.titles for c in chunks) def _is_suffix_strict_n(n: str, text: str, lexicon: Lexicon, @@ -1918,11 +1903,7 @@ class by shape for the first time (measured regression, #516 if glued_saint_cut(text, lexicon) is not None: return None chunks = [_normalize(c) for c in text.split(".") if c] - titles = lexicon._sets.titles - # rules/H11: "single letter with a capital cut from a word at its - # full stops is an initial too" -- as in `period_joined_title` - if any(c in titles and (len(c) != 1 or not _spells_a_cased_initial(c, ".")) - for c in chunks): + if any(c in lexicon._sets.titles for c in chunks): return "title" if period_joined_credential(text, lexicon): return "suffix" @@ -2564,21 +2545,14 @@ def title_readings(texts: Sequence[str], folded: Sequence[str], # a word in titles is a title wherever it stands, whatever else it # is listed as; one of titles_ambiguous alone is listed as a title # to its neighbours and read by its phrase - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" -- read - # as no title here, nor by its phrase below - initial = [len(n) == 1 and (n in titles or n in contested) - and _spells_a_cased_initial(n, text) - for n, text in zip(folded, texts)] - reading = [(n in titles or n in contested) and not vetoed - for n, vetoed in zip(folded, initial)] + reading = [n in titles or n in contested for n in folded] if titled is not None: reading = [r or t for r, t in zip(reading, titled)] listed = list(reading) phrases = lexicon._sets.title_phrases last = len(folded) - 1 for i, n in enumerate(folded): - if n in titles or n not in contested or n in modifiers or initial[i]: + if n in titles or n not in contested or n in modifiers: continue prev = folded[i - 1] if i else None nxt = folded[i + 1] if i < last else None @@ -2705,11 +2679,7 @@ def name_word_count(texts: Sequence[str], lexicon: Lexicon, else title_readings(texts, folded, lexicon, head=True)) for i, n in enumerate(folded): text = texts[i] - # rules/H11: "a one-letter word written with its period is an - # initial and not a title, where the letter has a capital" - title = (n in lexicon._sets.titles - and (len(n) != 1 or not _spells_a_cased_initial(n, text)) - if titled is None else titled[i]) + title = n in lexicon._sets.titles if titled is None else titled[i] if title and i in dotted: # a title only opening the part (behind any titles), and only # with a title, listed or by H2's shape, behind it and a word @@ -2720,9 +2690,6 @@ def name_word_count(texts: Sequence[str], lexicon: Lexicon, nxt = i + 1 title = (lead is None and nxt < len(folded) and ((folded[nxt] in lexicon._sets.titles - and (len(folded[nxt]) != 1 - or not _spells_a_cased_initial( - folded[nxt], texts[nxt])) if titled is None else titled[nxt]) or is_title_shaped(texts[nxt], lexicon)) and nxt + 1 < len(folded)) diff --git a/nameparser/_suggest.py b/nameparser/_suggest.py index a1438f1c8..89fc0ea1e 100644 --- a/nameparser/_suggest.py +++ b/nameparser/_suggest.py @@ -68,7 +68,7 @@ from types import MappingProxyType from typing import TYPE_CHECKING, cast -from ._lexicon import Lexicon, _normalize, _spells_a_cased_initial +from ._lexicon import Lexicon, _normalize from ._pipeline._state import COMMA_CHARS from ._pipeline._post_rules import _listed_suffix from ._pipeline._vocab import ( @@ -249,13 +249,9 @@ def _a_listed_name(word: str) -> bool: def _is_leading_title(word: str, lexicon: Lexicon) -> bool: """A word the lexicon lists as a title, or one rules/H2's shape - reads as a title at the head of a name (`Prof.`, `Insp.`), save a - one-letter one written with its period, which the parse reads as an - initial (rules/H11).""" - n = _normalize(word) + reads as a title at the head of a name (`Prof.`, `Insp.`).""" return not _a_listed_name(word) and ( - n in lexicon._sets.titles - and (len(n) != 1 or not _spells_a_cased_initial(n, word)) + _normalize(word) in lexicon._sets.titles or is_title_shaped(word, lexicon)) diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index 03c905aac..ca77da6af 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -15,12 +15,13 @@ 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. ``U.`` with its full stop stays an initial -(``U. S. Grant``), a one-letter word with a capital written with its -period being no title in any lexicon (rules/H11); a Burmese ``U.`` -written so (``U. Thein Aung``) reads as the given name. A title and one name word -reads the word as the family name, as everywhere (rules/H1), so ``U -Thant`` gives family ``Thant``. +read positionally. The title vocabulary reads ``U.`` with its full +stop as it reads ``U``, wherever it reads a title, so a Western +initial opening a name is the title under the pack too (``U. S. +Grant`` gives title ``U.``, given ``S.``), the accepted cost and the +reason to keep the pack to Burmese names; a ``U.`` inside a name stays +an initial. A title and one name word reads the word as the family +name, as everywhere (rules/H1), so ``U Thant`` gives family ``Thant``. Left as name words: the honorifics ``Ko``, ``Ma`` and ``Maung``, which are also name syllables (``Maung Maung Kyaw``), and the ethnic prefixes diff --git a/nameparser/vocab/my.toml b/nameparser/vocab/my.toml index 7f1abb286..754a40a40 100644 --- a/nameparser/vocab/my.toml +++ b/nameparser/vocab/my.toml @@ -6,7 +6,7 @@ salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1 [[word]] 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: the full stop keeps U. an initial under the pack too, a one-letter word with a capital written with its period being no title (rules/H11). 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., which the pack reads as the given name); 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)" } +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 takes as the title where it opens a name under the pack (U. S. Grant), 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 = "ဂျူနီယာ" diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 59cc1fdbc..47572fb59 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1077,13 +1077,21 @@ def _check_cjk_shape_purity(self) -> None: 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_keeps_u_with_its_full_stop_an_initial", + Case("the_burmese_pack_reads_u_with_its_full_stop_as_the_title", + "U. Thein Sein", + {"title": "U.", "given": "Thein", "family": "Sein"}, + locale="my", classification="feat(#1231)", + notes="the title vocabulary reads the honorific written with its " + "full stop as it reads it bare; 1.4.0 through 3.1.0 read " + "given 'U.', middle 'Thein'"), + Case("the_burmese_pack_reads_an_initial_u_opening_a_name_as_the_title", "U. S. Grant", - {"given": "U.", "middle": "S.", "family": "Grant"}, - locale="my", classification="parity", - notes="a one-letter cased word written with its period (rules/H11) " - "is an initial, never a title; the issue's simulated lexicon " - "read title 'U.' on master; 1.4.0 reads the same fields"), + {"title": "U.", "given": "S.", "family": "Grant"}, + locale="my", classification="feat(#1231)", + notes="the accepted reading, decided 2026-11-19 " + "(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"}, diff --git a/tests/v2/pipeline/test_classify.py b/tests/v2/pipeline/test_classify.py index b85dee47b..e1106b0c3 100644 --- a/tests/v2/pipeline/test_classify.py +++ b/tests/v2/pipeline/test_classify.py @@ -865,165 +865,3 @@ def test_the_surname_unit_agreement_test_sees_the_initial_veto( monkeypatch.setattr(_vocab, "_spells_an_initial", lambda n, text: False) assert _surname_unit_disagreements() == ["Ó.", "ó.", "ณ."] - - -#: A caller's one-letter title in a cased script (rules/H11), each name -#: with the reading the title gives written bare, the initial written -#: with its period, and the letter cut from a word at its full stops -_ONE_LETTER_TITLE = Parser(lexicon=Lexicon.default().add("q", kind="salutation") - .add("ü", kind="salutation")) - - -@pytest.mark.parametrize("text, title, given", [ - ("Q Smith", "Q", ""), - ("Ü Smith", "Ü", ""), - ("Q. Smith", "", "Q."), - ("q. smith", "", "q."), - ("Ü. Smith", "", "Ü."), - ("Q. R. Smith", "", "Q."), - ("Q.R. Smith", "", "Q."), - ("Smith, Q.R.", "", "Q."), - ("Q.John Smith", "", "Q."), - ("Smith, Q.", "", "Q."), - ("Smith, Q", "Q", ""), -]) -def test_a_one_letter_title_written_with_its_period_is_an_initial( - text: str, title: str, given: str) -> None: - # #1231: the period, not the letter, decides, for any lexicon - name = _ONE_LETTER_TITLE.parse(text) - assert (name.title, name.given) == (title, given) - - -def test_the_one_letter_title_veto_needs_a_letter_with_a_capital() -> None: - # the Bengali doctor is written with its full stop: no capital, no veto - assert Parser().parse("ড. রহিম উদ্দিন").title == "ড." - assert _classify_module._spells_a_cased_initial("q", "Q.") - assert _classify_module._spells_a_cased_initial("κ", "Κ.") - assert not _classify_module._spells_a_cased_initial("ড", "ড.") - assert not _classify_module._spells_a_cased_initial("q", "Q") - - -@pytest.mark.parametrize("kind, props", [ - # every title reading a caller can write on the letter - ("salutation", {}), - ("salutation", {"after_given": True}), - ("nobility", {"addresses": "given"}), - ("style", {}), - ("military", {"abbreviation": True}), -]) -@pytest.mark.parametrize("text", [ - "Q. Smith", "Smith, John Q.", "Q. of Smith", "Vice Q. Smith", - "Q. Smith, Ed", -]) -def test_the_veto_reaches_every_kind_of_title_reading( - kind: str, props: dict[str, object], text: str) -> None: - parser = Parser(lexicon=Lexicon.default().add("q", kind=kind, **props)) - name = parser.parse(text) - assert not name.title - assert name.as_dict() == Parser().parse(text).as_dict() - - -def test_the_veto_reaches_a_title_that_may_be_a_given_name() -> None: - # a title reading beside a given one compiles into the ambiguous - # titles, read by the title phrase (rules/H9), which reports no fork - # for the initial; the control lexicon holds the given name alone - parser = Parser(lexicon=Lexicon.default().add("q", kind="office") - .add("q", kind="given")) - control = Parser(lexicon=Lexicon.default().add("q", kind="given")) - for text in ("Q. of Smith", "Vice Q. Smith", "Q. Smith", "Dr. Q. Smith", - "Q.John Smith", "(Q.) Smith"): - got, want = parser.parse(text), control.parse(text) - assert got.as_dict() == want.as_dict(), text - assert [a.kind for a in got.ambiguities] == [ - a.kind for a in want.ambiguities], text - - -def test_a_run_ending_in_an_initial_addresses_no_given_name() -> None: - # the last word of a title run a connective chained an initial into - # addresses nothing (rules/H1's run, read by its last word) - parser = Parser(lexicon=Lexicon.default().add( - "q", kind="nobility", addresses="given")) - assert parser.parse("Mr. and Q. Smith").as_dict() == Parser().parse( - "Mr. and Q. Smith").as_dict() - assert parser.parse("Mr. and Q Smith").given == "Smith" - - -def test_the_veto_reaches_a_greek_capital() -> None: - parser = Parser(lexicon=Lexicon.default().add("κ", kind="salutation")) - assert parser.parse("Κ. Παπαδόπουλος").given == "Κ." - assert parser.parse("Κ Παπαδόπουλος").title == "Κ" - - -def test_the_one_letter_title_veto_is_what_keeps_the_initial( - monkeypatch: pytest.MonkeyPatch) -> None: - # negative controls for the tag and the chunk: with the veto off in - # classify, the dotted letter is the title; with it off in _vocab, - # a word of initials holding it is a period-joined title - monkeypatch.setattr(_classify_module, "_spells_a_cased_initial", - lambda n, text: False) - assert _ONE_LETTER_TITLE.parse("Q. Smith").title == "Q." - monkeypatch.undo() - monkeypatch.setattr(_vocab, "_spells_a_cased_initial", lambda n, text: False) - assert _ONE_LETTER_TITLE.parse("Smith, Q.R.").title == "Q.R." - - -#: rules/H11's two-input invariant: under a lexicon holding the one-letter -#: title `q`, a name holding Q written with its full stop reads exactly as -#: under the default, which holds no such title, in every comma shape, -#: every order and every reader of the title vocabulary (the comma count, -#: the title phrase, the glued stop, the set-apart clause, C2's third -#: part), the shapes #1231's review found reading it as a title -_H11_SHAPES = [ - "{q} S. Grant", "John {q} Smith", "Smith, John {q}", "Smith, {q}", - "{q} Smith", ", {q} Smith", "{q} Smith, Ed", "{q} Smith, Ma", - "Smith {q}, Ed", "Vice {q} Smith", "Vice {q} Smith, Ed", - "Associate {q} Smith", "Smith, John, {q}", "John Smith, Jr., {q}", - "Dr. {q} Smith", "Dr.{q} Smith", "John Smith Dr.{q}", "John ({q}) Smith", - "({q}) Smith", "John Smith ({q})", 'John "{q}" Smith', "{q} van Berg, Ed", - "JOHN {q} SMITH", "{q} Smith, Jr.", - # the fix commit's review: the glued words T8 divides, read by its - # own title tests, and the Thai glued-title walk past a title - "Juan dela {q} Sta.Maria", "{q} J.Smith", "Mr. {q} A.Smith", - "{q} A.Brown, PhD", "{q} นายสมชาย", "Mr. and {q} Smith", -] -_H11_SPELLINGS = ["Q.", "q.", "Q.R.", "Q.John"] -_H11_ROWS = [(shape.format(q=q), order) - for shape in _H11_SHAPES for q in _H11_SPELLINGS - for order in ("given", "family", "family-given-last")] -#: The recorded negative control: rows of the grid that read otherwise -#: with the veto answering no at every reader, measured 2026-11-19 -#: (re-take it when the grid moves) -_H11_UNGUARDED_EFFECT = 279 - - -def _h11_differences() -> int: - from nameparser._policy import ( - FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST, GIVEN_FIRST) - orders = {"given": GIVEN_FIRST, "family": FAMILY_FIRST, - "family-given-last": FAMILY_FIRST_GIVEN_LAST} - moved = 0 - for text, order in _H11_ROWS: - policy = Policy(name_order=orders[order]) - with_q = Parser(policy=policy, lexicon=Lexicon.default().add( - "q", kind="salutation")).parse(text) - without = Parser(policy=policy).parse(text) - moved += (with_q.as_dict() != without.as_dict() - or [a.kind for a in with_q.ambiguities] - != [a.kind for a in without.ambiguities]) - return moved - - -def test_a_one_letter_title_with_its_period_reads_as_no_title_at_all() -> None: - assert len(_H11_ROWS) == 360 - assert _h11_differences() == 0 - - -def test_the_h11_invariant_fails_with_the_veto_off( - monkeypatch: pytest.MonkeyPatch) -> None: - from nameparser import _lexicon - from nameparser._pipeline import _script_segment, _segment - for module in (_lexicon, _classify_module, _vocab, _segment, - _script_segment): - monkeypatch.setattr(module, "_spells_a_cased_initial", - lambda n, text: False) - assert _h11_differences() == _H11_UNGUARDED_EFFECT diff --git a/tests/v2/test_layering.py b/tests/v2/test_layering.py index 1cdfc00ea..b802ec081 100644 --- a/tests/v2/test_layering.py +++ b/tests/v2/test_layering.py @@ -887,9 +887,7 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: a listed title, its `sets =` binding and the two title sets it #: reads, 200 -> 203; the 3.1 simplify pass folding T8's two copies #: of the unambiguous title-or-suffix test after a glued stop into -#: `_vocab._claimed_after_the_stop`, 203 -> 198; #1231's rules/H11 -#: veto in classify, asking the two title sets before its frame, -#: 198 -> 200); +#: `_vocab._claimed_after_the_stop`, 203 -> 198); #: the tools' first 20 are 18 #: attribute loads, every tool scanned, and config_diff.py's #: `sets =` binding and the roster `getattr` through it (its @@ -911,7 +909,7 @@ def test_the_check_finds_a_tool_read_through_an_alias( #: `_lexicon._fields_of` from 4i-b until 4i-c retired it. #: A reader added through `_sets` moves these, and they are re-taken #: then: they count what the check would refuse with the move undone. -_UNGUARDED_READS = {"library": 200, "tools": 28} +_UNGUARDED_READS = {"library": 198, "tools": 28} def test_the_check_refuses_every_read_4i_a_moved() -> None: diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 0272e5847..8142121e1 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -806,42 +806,27 @@ def test_my_reads_the_honorific_in_every_comma_shape( assert (name.title, name.given, name.family) == (title, given, family) -@pytest.mark.parametrize("order", [GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) -@pytest.mark.parametrize("text", [ - # U written with its full stop is an initial under the pack (rules/H11), - # in every comma shape, joined to the next initial or the - # next name at its full stop, and in a name of one case - "U. S. Grant", "U.S. Grant", "Grant, U. S.", "Grant, U.S.", "U. Grant", - "John U. Smith", "Smith, John U.", "Smith, U.", ", U. Smith", - "U.Thein Sein", "U. Thein Sein", "U. S. GRANT", "u. s. grant", - "U.S. District Judge Jane Roe", "Dr. U. Smith", - # #1231's review: the comma count, the title phrase, the glued stop, - # the set-apart clause and C2's third part - "U. Smith, Ed", "U. Smith, Ma", "Smith U., Ed", "Vice U. Smith", - "Vice U.Thein Smith, Ed", "Smith, John, U.", "John Smith, Jr., U.", - "Dr.U. Smith", "John Smith Dr.U.", "John (U.) Smith", "(U.) Smith", - 'John "U." Smith', +@pytest.mark.parametrize("text, title, given, middle, family", [ + # the accepted reading, decided 2026-11-19 (decisions/vocabulary- + # collisions, the #1231 entry): the title vocabulary reads U written + # with its full stop as the honorific under the pack, wherever it + # reads a title, so a Western initial U. opening a name is the title + # there -- the reason the docs give not to apply the pack to a mixed + # list. A U. inside the name is an initial, as by default + ("U. Thein Sein", "U.", "Thein", "", "Sein"), + ("Sein, U. Thein", "U.", "Thein", "", "Sein"), + ("U. S. Grant", "U.", "S.", "", "Grant"), + ("U. Smith, Ed", "U.", "Ed", "", "Smith"), + ("Grant, U.S.", "U.S.", "", "", "Grant"), + ("U.S. Grant", "", "U.", "S.", "Grant"), + ("John U. Smith", "", "John", "U.", "Smith"), + ("Smith, John U.", "", "John", "U.", "Smith"), ]) -def test_my_keeps_u_written_with_its_full_stop_an_initial( - text: str, order: tuple[Role, Role, Role]) -> None: - base = Parser(policy=Policy(name_order=order)) - packed = parser_for(locales.MY, base=base).parse(text) - default = base.parse(text) - assert packed.as_dict() == default.as_dict() - assert [a.kind for a in packed.ambiguities] == [ - a.kind for a in default.ambiguities] - assert "U." not in packed.title.upper().split() - - -def test_my_suggests_as_the_default_over_names_opening_with_u_dotted() -> None: - # the group suggester reads past a leading title as the parse does, - # so `U.` is a given name to it under the pack too (rules/H11) - names = ["U. Wang Xiaoming", "U. Zhang Wei", "U. Li Na", "U. Liu Yang", - "U. Chen Jie", "U. Wang Fang"] - # the evidence, below the first line, which names the base parser - packed, default = (str(p.suggest(names)).split("\n", 1)[1] - for p in (_require_packed("my"), Parser())) - assert packed == default +def test_my_reads_u_written_with_its_full_stop_as_the_title_vocabulary_does( + text: str, title: str, given: str, middle: str, family: str) -> None: + name = _require_packed("my").parse(text) + assert (name.title, name.given, name.middle, name.family) == ( + title, given, middle, family) def test_my_differs_from_the_default_only_through_its_words() -> None: From 5de2639bb89e7f405cedd41a4c642181c59a348d Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 11:52:50 -0800 Subject: [PATCH 07/13] Record the U. decision and re-take #1231's figures at the pack's final state (#1231) decisions/vocabulary-collisions: a Standing clause and a bullet record that U. is read as the title vocabulary reads it under the pack, decided 2026-11-19, reversing working answer (3), with the reason and what the drafted rule had required; the population re-taken (154 moved, 152 fixed, 0 broken; 2,835 to 2,987 of 2,990), the committed corpora (279 of 7,644, the U. and period-joined costs named), and the Accepted bullet's U. and J.u.n.i.o.r. costs. The snapshot and the rules corpus differ from master by rules/H1's U Thant example alone. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/vocabulary-collisions.md | 11 ++++++----- tools/differential/corpus_rules.jsonl | 15 --------------- tools/differential/snapshot.jsonl | 14 -------------- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 25be5551a..ce5571fd4 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 — 2026-11-19 #1231. +- `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 it under the pack, an initial `U.` opening a name included (`U. S. Grant` → title 'U.'), which no rule vetoes — 2026-11-19 #1231. ## Log @@ -100,10 +100,11 @@ 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, which rules/H11 states as a shape (decisions/H11); (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, each opening 4 names or fewer in the population below. +- 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, each opening 4 names or fewer in the population below. - **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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial opening a Western name with it, `U. S. Grant` → title 'U.', given 'S.' (`U.S. Grant` keeps its initials, rules/H10 giving the run back). 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. - - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. 153 names move, 151 from a misreading to the intended reading (holding `u` 70, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,986 under the pack (99.9%); the four it misses are that string, two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default, and one name opening with `U.`, which rules/H11 reads as an initial (decisions/H11's Accepted). The first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - - **The cost to names that are not Burmese**, measured on this branch (2026-11-19). at the fix commit `31738f17`, `config_diff.py diff default plain:MY --committed`: 273 of 7,656 names move, 5 of them opening with `U` or `Daw` (`Daw Thida`, `U Kyaw Win`, and three rule examples this change adds, the Korean `U Min Ho` among them) and 268 others, `van` 130, `da` 20, `do` 19 (the credential among them), `la` 11, `di` 6, `du` 5; the first count, before `do`'s credential left and the rule examples were added, 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%); 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 bare `U` opening a name is the title, a Korean surname `U` included (rules/H11's Accepted); a title and one name word gives the family a word a Burmese name does not hold as a family name (rules/H1). + - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. + - **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, commit `f29a4da6` on master `6560abde`, `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` opening a name is the title, bare or written with its full stop, 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 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. diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index 757d7e5a9..44575a273 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -375,7 +375,6 @@ "Dr.MD Smith" "Dr.McDonald Jones" "Dr.Smith" -"Dr.U. Smith" "Dr.med. Lukas Mayer" "Duke of Edinburgh" "Dumas VI MD, Ed" @@ -455,7 +454,6 @@ "Grace Smith" "Graf Lambsdorff, Otto" "Grand Duke of Tuscany" -"Grant, U.S." "Greve Anna" "Greve Smith, Anna" "Greve, Anna" @@ -755,7 +753,6 @@ "John (NP-C) Smith" "John (Sr) Smith" "John (Sr.) Smith" -"John (U.) Smith" "John . Smith" "John A B Smith" "John Dean Smith" @@ -1065,7 +1062,6 @@ "John Smith-Jones" "John Smith-Jones, MD-PhD" "John Smith, Jr." -"John U. Smith" "John V" "John V, Dr." "John W Ingram V" @@ -1706,7 +1702,6 @@ "Smith, Sgt Major" "Smith, Sir" "Smith, Sr." -"Smith, U." "Smith, U.S. Senator John" "Smith, V; MD" "Smith, Van V" @@ -1745,13 +1740,7 @@ "Torres Sánchez-Cid Andrés" "Treadwell, U.S. District Judge Marc" "Ts. Dr. Norziha Che Him" -"U Min Ho" "U Thant" -"U Thein Sein" -"U. S. Grant" -"U. Smith, Ed" -"U. Thein Aung" -"U.Daw Smith" "U.S. District Judge Marc Thomas Treadwell" "U.S. Grant" "U.S. Grant Smith, John" @@ -1761,12 +1750,10 @@ "U.S. Senator Smith, Ed" "U.S. Senator Smith, John" "U.S. and U.K. Ambassador Jane Doe" -"U.Thein Sein" "URSULA VON DER LEYEN" "US Senator John Smith" "Uddin, Mr Md" "Uddin, Mr Md Karim" -"U. Smith" "VAN DER BERG, JAN" "VAN DER WALT" "VAN GOGH VINCENT" @@ -1783,7 +1770,6 @@ "Van der Walt" "Van née Jones" "Vega, Juan de la" -"Vice U. Smith" "Vice Yu. Petrov" "Vincent van Gogh van Beethoven" "W. Russell (Jr.) Withers" @@ -2025,7 +2011,6 @@ "शर्मा, राम बाबू" "श्री कृष्ण श्रेष्ठ" "এম. আবদুল লতিফ" -"ড. রহিম উদ্দিন" "প্রকৌশলী. Sen" "ਐਮ. ਸਿੰਘ" "ஔவையார் கண்ணன்" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 7c25a2c39..f5150b4a0 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -1049,7 +1049,6 @@ {"name": "Dr.MD Smith", "title": "Dr.MD", "family": "Smith", "initials": "S.", "capitalized_force": "Dr.Md Smith"} {"name": "Dr.McDonald Jones", "title": "Dr.", "given": "McDonald", "family": "Jones", "initials": "M. J."} {"name": "Dr.Smith", "title": "Dr.", "family": "Smith", "initials": "S."} -{"name": "Dr.U. Smith", "title": "Dr.", "given": "U.", "family": "Smith", "initials": "U. S."} {"name": "Dr.med. Lukas Mayer", "title": "Dr.med.", "given": "Lukas", "family": "Mayer", "initials": "L. M.", "capitalized_force": "Dr.Med. Lukas Mayer"} {"name": "Dr.philol. Laima Kristīne Eva Sofija van den Volfa Bērziņa-Kalniņa", "title": "Dr.philol.", "given": "Laima", "middle": "Kristīne Eva Sofija", "family": "van den Volfa Bērziņa-Kalniņa", "initials": "L. K. E. S. V. B.", "capitalized_force": "Dr.Philol. Laima Kristīne Eva Sofija van den Volfa Bērziņa-Kalniņa"} {"name": "Dra. Andréia da Silva", "title": "Dra.", "given": "Andréia", "family": "da Silva", "initials": "A. S."} @@ -1388,7 +1387,6 @@ {"name": "Grandmaison, Louis de", "given": "Louis", "family": "de Grandmaison", "initials": "L. G."} {"name": "Granger Hermione", "order": "FAMILY_FIRST", "given": "Hermione", "family": "Granger", "initials": "H. G."} {"name": "Granger, Hermione", "given": "Hermione", "family": "Granger", "initials": "H. G."} -{"name": "Grant, U.S.", "given": "U.", "middle": "S.", "family": "Grant", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (shape)"], "initials": "U. S. G."} {"name": "Gregorio Chillón de la Fuente", "given": "Gregorio", "middle": "Chillón", "family": "de la Fuente", "initials": "G. C. F."} {"name": "Gregorio Modrego Casaus", "given": "Gregorio", "middle": "Modrego", "family": "Casaus", "initials": "G. M. C."} {"name": "Grettir Björnsson", "given": "Grettir", "family": "Björnsson", "initials": "G. B."} @@ -2027,7 +2025,6 @@ {"name": "John (NP-C) Smith", "given": "John", "family": "Smith", "suffix": "NP-C", "initials": "J. S."} {"name": "John (Sr) Smith", "given": "John", "family": "Smith", "suffix": "Sr", "initials": "J. S.", "generation": "Sr"} {"name": "John (Sr.) Smith", "given": "John", "family": "Smith", "suffix": "Sr.", "initials": "J. S.", "generation": "Sr."} -{"name": "John (U.) Smith", "given": "John", "middle": "U.", "family": "Smith", "initials": "J. U. S."} {"name": "John . Smith", "given": "John", "middle": ".", "family": "Smith", "initials": "J. .. S."} {"name": "John A B Smith", "given": "John", "middle": "A B", "family": "Smith", "initials": "J. A. B. S."} {"name": "John A. Doe", "given": "John", "middle": "A.", "family": "Doe", "initials": "J. A. D."} @@ -2414,7 +2411,6 @@ {"name": "John Smith-Jones", "given": "John", "family": "Smith-Jones", "initials": "J. S."} {"name": "John Smith-Jones, MD-PhD", "given": "John", "family": "Smith-Jones", "suffix": "MD-PhD", "initials": "J. S."} {"name": "John Smith, Jr.", "given": "John", "family": "Smith", "suffix": "Jr.", "initials": "J. S.", "generation": "Jr."} -{"name": "John U. Smith", "given": "John", "middle": "U.", "family": "Smith", "initials": "J. U. S."} {"name": "John V", "given": "John", "family": "V", "ambiguities": ["ORDER", "SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: generation as suffix (vocabulary)"], "initials": "J. V."} {"name": "John V, Dr.", "title": "Dr.", "given": "John", "family": "V", "ambiguities": ["ORDER", "SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: generation as suffix (vocabulary)"], "initials": "J. V."} {"name": "John V. Smith", "given": "John", "middle": "V.", "family": "Smith", "initials": "J. V. S."} @@ -4186,7 +4182,6 @@ {"name": "Smith, Sgt Major", "title": "Sgt Major", "family": "Smith", "initials": "S."} {"name": "Smith, Sir", "title": "Sir", "given": "Smith", "initials": "S."} {"name": "Smith, Sr.", "family": "Smith", "suffix": "Sr.", "initials": "S.", "generation": "Sr."} -{"name": "Smith, U.", "given": "U.", "family": "Smith", "initials": "U. S."} {"name": "Smith, U.S. Senator John", "title": "U.S. Senator", "given": "John", "family": "Smith", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (shape)"], "initials": "J. S."} {"name": "Smith, V; MD", "given": "V;", "family": "Smith", "suffix": "MD", "initials": "V. S."} {"name": "Smith, Van V", "given": "Van", "family": "Smith", "suffix": "V", "initials": "V. S.", "generation": "V"} @@ -4373,13 +4368,8 @@ {"name": "Tschurtschenthaler, Anton von", "given": "Anton", "family": "von Tschurtschenthaler", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: name as middle (declared)"], "initials": "A. T."} {"name": "Tunde Seun Okeke", "given": "Tunde", "middle": "Seun", "family": "Okeke", "initials": "T. S. O."} {"name": "U Kyaw Win", "given": "U", "middle": "Kyaw", "family": "Win", "initials": "U. K. W."} -{"name": "U Min Ho", "given": "U", "middle": "Min", "family": "Ho", "initials": "U. M. H."} {"name": "U Thant", "given": "U", "family": "Thant", "initials": "U. T."} -{"name": "U Thein Sein", "given": "U", "middle": "Thein", "family": "Sein", "initials": "U. T. S."} {"name": "U. S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} -{"name": "U. Smith, Ed", "given": "U.", "family": "Smith", "suffix": "Ed", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as given (declared)"], "initials": "U. S.", "capitalized_force": "U. Smith, ED"} -{"name": "U. Thein Aung", "given": "U.", "middle": "Thein", "family": "Aung", "initials": "U. T. A."} -{"name": "U.Daw Smith", "given": "U.", "middle": "Daw", "family": "Smith", "initials": "U. D. S."} {"name": "U.S. District Judge Marc Thomas Treadwell", "title": "U.S. District Judge", "given": "Marc", "middle": "Thomas", "family": "Treadwell", "initials": "M. T. T."} {"name": "U.S. Grant", "given": "U.", "middle": "S.", "family": "Grant", "initials": "U. S. G."} {"name": "U.S. Grant Smith, John", "given": "John", "family": "U.S. Grant Smith", "initials": "J. U. S. G. S."} @@ -4389,7 +4379,6 @@ {"name": "U.S. Senator Smith, Ed", "title": "U.S. Senator", "given": "Ed", "family": "Smith", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: credential as suffix (vocabulary)"], "initials": "E. S."} {"name": "U.S. Senator Smith, John", "title": "U.S. Senator", "given": "John", "family": "Smith", "initials": "J. S."} {"name": "U.S. and U.K. Ambassador Jane Doe", "given": "U.S. and U.K.", "middle": "Ambassador Jane", "family": "Doe", "initials": "U. S. U. K. A. J. D."} -{"name": "U.Thein Sein", "given": "U.", "middle": "Thein", "family": "Sein", "initials": "U. T. S."} {"name": "UNILEVER LTD", "given": "UNILEVER", "family": "LTD", "initials": "U. L.", "capitalized": "Unilever Ltd"} {"name": "URSULA VON DER LEYEN", "given": "URSULA", "family": "VON DER LEYEN", "initials": "U. L.", "capitalized": "Ursula von der Leyen"} {"name": "US Magistrate Judge T Michael Putnam", "title": "US Magistrate Judge", "given": "T", "middle": "Michael", "family": "Putnam", "initials": "T. M. P.", "capitalized_force": "Us Magistrate Judge T Michael Putnam"} @@ -4420,7 +4409,6 @@ {"name": "Ursula von der Leyen geb. Albrecht", "given": "Ursula", "family": "von der Leyen", "maiden": "Albrecht", "initials": "U. L."} {"name": "Uxía", "given": "Uxía", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "U."} {"name": "Uxía", "order": "FAMILY_FIRST", "given": "Uxía", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "U."} -{"name": "U. Smith", "given": "U.", "family": "Smith", "initials": "U. S."} {"name": "VAN DER BERG, JAN", "given": "JAN", "family": "VAN DER BERG", "initials": "J. B.", "capitalized": "Jan van der Berg"} {"name": "VAN DER WALT", "given": "VAN", "family": "DER WALT", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: particle as family (vocabulary)"], "initials": "V. W.", "capitalized": "Van der Walt"} {"name": "VAN GOGH VINCENT", "given": "VAN", "middle": "GOGH", "family": "VINCENT", "ambiguities": ["PARTICLE_OR_GIVEN"], "alternatives": ["PARTICLE_OR_GIVEN: particle as family (vocabulary)"], "initials": "V. G. V.", "capitalized": "Van Gogh Vincent"} @@ -4478,7 +4466,6 @@ {"name": "Velasquez y Garcia, Juan Q., Jr.", "given": "Juan", "middle": "Q.", "family": "Velasquez y Garcia", "suffix": "Jr.", "initials": "J. Q. V. G.", "generation": "Jr."} {"name": "Velasquez y Garcia, Juan, Jr.", "given": "Juan", "family": "Velasquez y Garcia", "suffix": "Jr.", "initials": "J. V. G.", "generation": "Jr."} {"name": "Venerable Ananda", "title": "Venerable", "family": "Ananda", "initials": "A."} -{"name": "Vice U. Smith", "given": "Vice", "middle": "U.", "family": "Smith", "initials": "V. U. S."} {"name": "Vice Yu. Petrov", "given": "Vice", "middle": "Yu.", "family": "Petrov", "initials": "V. Y. P."} {"name": "Vicente Becerra Vaca", "given": "Vicente", "middle": "Becerra", "family": "Vaca", "initials": "V. B. V."} {"name": "Vicente Gómez Mier", "given": "Vicente", "middle": "Gómez", "family": "Mier", "initials": "V. G. M."} @@ -6536,7 +6523,6 @@ {"name": "জুহি চাওলা", "given": "জুহি", "family": "চাওলা", "initials": "জ. চ."} {"name": "জেনদায়া", "given": "জেনদায়া", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "জ."} {"name": "জেনদায়া", "order": "FAMILY_FIRST", "given": "জেনদায়া", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "জ."} -{"name": "ড. রহিম উদ্দিন", "title": "ড.", "given": "রহিম", "family": "উদ্দিন", "initials": "র. উ."} {"name": "দেবী শর্মা", "given": "দেবী", "family": "শর্মা", "initials": "দ. শ."} {"name": "নগেন বৰা", "given": "নগেন", "family": "বৰা", "initials": "ন. ব."} {"name": "নমিতা বৰুৱা", "given": "নমিতা", "family": "বৰুৱা", "initials": "ন. ব."} From 07d4264f595d10f470623ac9e737d5507805a88c Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 12:09:52 -0800 Subject: [PATCH 08/13] Record the pack's costs the last review found (#1231) The final review found the record narrower than what the pack does. U. is the title wherever the title vocabulary reads one, after a family comma (Smith, U., the given name lost), in brackets, in Grant, U.S. and glued to a title, and Daw. ending a name, not only opening it; and a removed particle opening the family before a comma lets a short given name after it read as a credential (Van Buren, Ed). The decisions entry, my.py, docs/languages.rst and docs/locales.rst now say so, tests pin Smith, U., John (U.) Smith and the comma cost, and a rotator holds the trailing Daw.; nameparser/vocab/AGENTS.md's "A reading taken out" names the comma shape. Decisions 6 and 15 of decisions/vocabulary-model name both removing packs. Corrected: Thakin opens 7 names, Mg reads a title in 10, the committed count's tree, and rules/H1's bullet credits the title's addressing, not position. Co-Authored-By: Claude Opus 5.5 --- .../design/decisions/vocabulary-collisions.md | 12 ++++----- docs/design/decisions/vocabulary-model.md | 4 +-- .../rules/H1-title-and-one-name-word.md | 2 +- docs/languages.rst | 27 ++++++++++++------- docs/locales.rst | 6 ++--- nameparser/locales/my.py | 12 +++++---- nameparser/vocab/AGENTS.md | 2 +- tests/v2/test_locales.py | 18 +++++++++++++ 8 files changed, 55 insertions(+), 28 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index ce5571fd4..3ccdffb57 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 it under the pack, an initial `U.` opening a name included (`U. S. Grant` → title 'U.'), 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` 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 it under the pack, wherever that vocabulary reads a title, an initial included (`U. S. Grant` → title 'U.', `Smith, U.` → title 'U.', no given name), which no rule vetoes — 2026-11-19 #1231. ## Log @@ -100,11 +100,11 @@ 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, each opening 4 names or fewer in the population below. +- 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` and `Sayadaw` none. - **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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial opening a Western name with it, `U. S. Grant` → title 'U.', given 'S.' (`U.S. Grant` keeps its initials, rules/H10 giving the run back). 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). + - **`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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial with it wherever the title vocabulary reads a title: opening a Western name (`U. S. Grant` → title 'U.', given 'S.'), alone after a family comma, where the given name is lost (`Smith, U.` and `Kim, U` → title, no given name; FEC writes the letter after a comma 320 times in 351), 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.'), as `Daw.` reads as a title ending the name (`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. - - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 18 names (`Mg Htoo` → title 'Mg'), #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - - **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, commit `f29a4da6` on master `6560abde`, `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` opening a name is the title, bare or written with its full stop, 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 title and one name word gives the family a word a Burmese name does not hold as a family name (rules/H1). + - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 10 names (`Mg Htoo` → title 'Mg'), the same by default, #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. + - **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` is the title wherever the title vocabulary reads one, 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 opening the family before a comma no longer keeps a short given name 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; `Da Silva, Ed`), the shape nameparser/vocab/AGENTS.md's "A reading taken out" names, found by the PR's last review, 3 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. diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 802ed4e3b..6a6c0ab88 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -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 one pack, 2026-11-05 #1108, below: `locales.VI`'s fragment removes readings of Vietnamese syllables where vi.toml holds none.) + 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.) 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 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.) + 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.) 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/rules/H1-title-and-one-name-word.md b/docs/design/rules/H1-title-and-one-name-word.md index 9f2899d06..5a4970a6d 100644 --- a/docs/design/rules/H1-title-and-one-name-word.md +++ b/docs/design/rules/H1-title-and-one-name-word.md @@ -78,7 +78,7 @@ "Anna Greve" → family="Greve" "Greve, Anna" → family="Greve" ``` -- A Burmese name of an honorific and one name word gives the word to the family under a Burmese choice, though a Burmese name holds no family name: the position reads it as any other name's last word (#1231). +- A Burmese name of an honorific and one name word gives the word to the family under a Burmese choice, though a Burmese name holds no family name: the honorific addresses by the family name as a salutation does, so the word is its family name here as after any such title (#1231). ``` "U Thant" [my] → family="Thant" ``` diff --git a/docs/languages.rst b/docs/languages.rst index c1429978e..7aa84e493 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1241,13 +1241,20 @@ 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 the -nine words' particle readings, which Dutch, Portuguese, Italian, -French, Spanish, Filipino and Māori family names hold (``de`` and -``del`` are kept), and the credential DO. And it reads ``U`` opening a -name as the honorific however it is written, so an initial ``U.`` -opening a Western name becomes the title. Keep it to a parser of its -own for the Burmese names in your data: +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, but ``de la`` loses its ``la``). + Where one opens the family name before a comma, a short given name + 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, + wherever a title is read, so an initial ``U.`` opening a name or the + part after a comma is the title (``Smith, U.`` gives no given name). + +Keep it to a parser of its own for the Burmese names in your data: .. doctest:: @@ -1261,7 +1268,7 @@ own for the Burmese names in your data: 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 it lowers the share read -right in both from 94% to 83% in the Netherlands and from 95% to 89% in -Belgium. A Korean name opening with the surname ``U`` written bare +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 opening with the surname ``U`` written bare reads ``U`` as the title under the pack. diff --git a/docs/locales.rst b/docs/locales.rst index 4672bba02..2b2f726ae 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -147,9 +147,9 @@ shape covers much: - ``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 where ``U`` - or ``Daw`` opens the name, follows a title opening it, or opens the - part after a comma. + 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. .. warning:: diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index ca77da6af..2a3d42ab7 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -17,10 +17,11 @@ 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``, wherever it reads a title, so a Western -initial opening a name is the title under the pack too (``U. S. -Grant`` gives title ``U.``, given ``S.``), the accepted cost and the -reason to keep the pack to Burmese names; a ``U.`` inside a name stays -an initial. A title and one name word reads the word as the family +initial is the title under the pack too where it opens a name or the +part after a comma, or stands in brackets (``U. S. Grant`` gives title +``U.``, given ``S.``; ``Smith, U.`` gives 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``. Left as name words: the honorifics ``Ko``, ``Ma`` and ``Maung``, which @@ -38,7 +39,8 @@ 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 the credential DO +and ``Kiri Te Kanawa`` lose theirs, and ``Van Buren, Ed`` reads ``Ed`` +as a credential, its given name lost) and the credential DO (``Jane Doe, DO`` gives given ``DO``), the measured cost in the decisions entry. diff --git a/nameparser/vocab/AGENTS.md b/nameparser/vocab/AGENTS.md index 62885d02a..17226620b 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). 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 opening the family before a comma in the grid too: it had kept a short given name after the comma from reading as a credential, and #1231's `locales.MY` read `Van Buren, Ed` given 'Van', suffix 'Ed', found only by its last review. 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/tests/v2/test_locales.py b/tests/v2/test_locales.py index 8142121e1..d2dd4b830 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -751,6 +751,21 @@ def put_back(removal: tuple[str, str] | None) -> Parser: assert len(my.parse(text).family.split()) == 1, text +@pytest.mark.parametrize("text, given, family, suffix", [ + # the accepted cost of a removed particle opening the family before a + # comma: it no longer keeps a short given name 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"), +]) +def test_my_costs_a_given_name_after_a_particle_and_a_comma( + 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"] == "Ed" + + @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 @@ -819,6 +834,8 @@ def test_my_reads_the_honorific_in_every_comma_shape( ("U. Smith, Ed", "U.", "Ed", "", "Smith"), ("Grant, U.S.", "U.S.", "", "", "Grant"), ("U.S. Grant", "", "U.", "S.", "Grant"), + ("Smith, U.", "U.", "", "", "Smith"), + ("John (U.) Smith", "U.", "John", "", "Smith"), ("John U. Smith", "", "John", "U.", "Smith"), ("Smith, John U.", "", "John", "U.", "Smith"), ]) @@ -2185,6 +2202,7 @@ def _default_corpus() -> list[str]: "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) ] # 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 From fa2d5fca42ac212948f889c83cde65628716a216 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 12:18:52 -0800 Subject: [PATCH 09/13] Correct the round-four findings in #1231's record (#1231) docs/languages.rst no longer says de la loses its la (it reads as by default save ending the given part after a family comma). The comma cost counts 4 committed names and reaches a given part of initials (De La Cruz, M.J. K.L.), now a test row; the vocab AGENTS.md lesson asks for both. An initial U. behind a title is the title too (Dr. U. Smith), in my.py, languages.rst, the decisions entry and a test row. The FEC figure is replaced by a recipe that counts the names the pack moves (22 of 409). A test comment no longer contradicts its row, rules/H1's bullet credits the title being no given-name title, and Sayadaw's 9 names are written after the name. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/vocabulary-collisions.md | 6 +++--- docs/design/rules/H1-title-and-one-name-word.md | 2 +- docs/languages.rst | 12 +++++++----- nameparser/locales/my.py | 8 +++++--- nameparser/vocab/AGENTS.md | 2 +- tests/v2/test_locales.py | 10 ++++++---- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 3ccdffb57..0d38c8e35 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -100,11 +100,11 @@ 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` and `Sayadaw` none. +- 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. - **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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial with it wherever the title vocabulary reads a title: opening a Western name (`U. S. Grant` → title 'U.', given 'S.'), alone after a family comma, where the given name is lost (`Smith, U.` and `Kim, U` → title, no given name; FEC writes the letter after a comma 320 times in 351), 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.'), as `Daw.` reads as a title ending the name (`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). + - **`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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial with it wherever the title vocabulary reads a title: opening a Western name (`U. S. Grant` → title 'U.', given 'S.'), alone after a family comma or behind another title, where the given name is lost (`Smith, U.` and `Kim, U` → title, no given name; `Dr. U. Smith` → title 'Dr. U.'; among FEC's names, 22 of the 409 holding `U` or `U.` as a word move under the pack, `config_diff.py diff default plain:MY --local fec-individuals --match '(^|[\s,.(])[Uu]\.?([\s,.)]|$)'`, 2026-11-19), 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.'), as `Daw.` reads as a title ending the name (`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. - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 10 names (`Mg Htoo` → title 'Mg'), the same by default, #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - **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` is the title wherever the title vocabulary reads one, 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 opening the family before a comma no longer keeps a short given name 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; `Da Silva, Ed`), the shape nameparser/vocab/AGENTS.md's "A reading taken out" names, found by the PR's last review, 3 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). + - **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` is the title wherever the title vocabulary reads one, 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. diff --git a/docs/design/rules/H1-title-and-one-name-word.md b/docs/design/rules/H1-title-and-one-name-word.md index 5a4970a6d..3a44cd0be 100644 --- a/docs/design/rules/H1-title-and-one-name-word.md +++ b/docs/design/rules/H1-title-and-one-name-word.md @@ -78,7 +78,7 @@ "Anna Greve" → family="Greve" "Greve, Anna" → family="Greve" ``` -- A Burmese name of an honorific and one name word gives the word to the family under a Burmese choice, though a Burmese name holds no family name: the honorific addresses by the family name as a salutation does, so the word is its family name here as after any such title (#1231). +- A Burmese name of an honorific and one name word gives the word to the family under a Burmese choice, though a Burmese name holds no family name: the honorific is no given-name title, so the word is the family name here as after any title that is none (#1231). ``` "U Thant" [my] → family="Thant" ``` diff --git a/docs/languages.rst b/docs/languages.rst index 7aa84e493..efe32839d 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1245,14 +1245,16 @@ 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, but ``de la`` loses its ``la``). - Where one opens the family name before a comma, a short given name - after it can read as a credential, the given name lost (``Van Buren, - Ed`` gives suffix ``Ed``). + (``de`` and ``del`` keep theirs, and ``de la`` reads as by default + save where it ends the given part after a family comma). 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, wherever a title is read, so an initial ``U.`` opening a name or the - part after a comma is the title (``Smith, U.`` gives no given name). + part after a comma, or standing behind a title, is the title + (``Smith, U.`` and ``Dr. U. Smith`` give no given name). Keep it to a parser of its own for the Burmese names in your data: diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index 2a3d42ab7..bbc65bd85 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -18,8 +18,9 @@ read positionally. The title vocabulary reads ``U.`` with its full stop as it reads ``U``, wherever it reads a title, so a Western initial is the title under the pack too where it opens a name or the -part after a comma, or stands in brackets (``U. S. Grant`` gives title -``U.``, given ``S.``; ``Smith, U.`` gives no given name), the accepted +part after a comma, stands behind another title, is glued to one or +stands in brackets (``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``. @@ -40,7 +41,8 @@ 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) and the credential DO +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. diff --git a/nameparser/vocab/AGENTS.md b/nameparser/vocab/AGENTS.md index 17226620b..065da4126 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 opening the family before a comma in the grid too: it had kept a short given name after the comma from reading as a credential, and #1231's `locales.MY` read `Van Buren, Ed` given 'Van', suffix 'Ed', found only by its last review. 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` 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/tests/v2/test_locales.py b/tests/v2/test_locales.py index d2dd4b830..f3682e80e 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -752,18 +752,19 @@ def put_back(removal: tuple[str, str] | None) -> Parser: @pytest.mark.parametrize("text, given, family, suffix", [ - # the accepted cost of a removed particle opening the family before a - # comma: it no longer keeps a short given name after the comma from + # 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."), ]) def test_my_costs_a_given_name_after_a_particle_and_a_comma( 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"] == "Ed" + assert _default_parse(text)["given"] @pytest.mark.parametrize("text, middle, family", [ @@ -827,7 +828,7 @@ def test_my_reads_the_honorific_in_every_comma_shape( # with its full stop as the honorific under the pack, wherever it # reads a title, so a Western initial U. opening a name is the title # there -- the reason the docs give not to apply the pack to a mixed - # list. A U. inside the name is an initial, as by default + # list. A bare U. between two name words is an initial, as by default ("U. Thein Sein", "U.", "Thein", "", "Sein"), ("Sein, U. Thein", "U.", "Thein", "", "Sein"), ("U. S. Grant", "U.", "S.", "", "Grant"), @@ -836,6 +837,7 @@ def test_my_reads_the_honorific_in_every_comma_shape( ("U.S. Grant", "", "U.", "S.", "Grant"), ("Smith, U.", "U.", "", "", "Smith"), ("John (U.) Smith", "U.", "John", "", "Smith"), + ("Dr. U. Smith", "Dr. U.", "", "", "Smith"), ("John U. Smith", "", "John", "U.", "Smith"), ("Smith, John U.", "", "John", "U.", "Smith"), ]) From f69a93ec198d455fbfe7954e80d3cbd66793cd2d Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 12:24:24 -0800 Subject: [PATCH 10/13] State #1231's costs in general terms, with examples (#1231) Round five found each list of positions still short. The docs, my.py, my.toml, the release log and the decisions entry now say U. is the title wherever the parser reads a title, with examples, and that only a bare U. between two name words stays an initial; docs/languages.rst says de la reads as by default in Juan de la Cruz and can read otherwise in other shapes, and that Sayadaw is a name word as by default. The FEC figure counts names holding U as a word only (16 of 351 move, 3 losing their given name), its regex no longer matching U chunks inside joined words. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/vocabulary-collisions.md | 2 +- docs/languages.rst | 14 ++++++++------ docs/release_log.rst | 2 +- nameparser/locales/my.py | 11 +++++------ nameparser/vocab/my.toml | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 0d38c8e35..055450b75 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -102,7 +102,7 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - 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. - **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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial with it wherever the title vocabulary reads a title: opening a Western name (`U. S. Grant` → title 'U.', given 'S.'), alone after a family comma or behind another title, where the given name is lost (`Smith, U.` and `Kim, U` → title, no given name; `Dr. U. Smith` → title 'Dr. U.'; among FEC's names, 22 of the 409 holding `U` or `U.` as a word move under the pack, `config_diff.py diff default plain:MY --local fec-individuals --match '(^|[\s,.(])[Uu]\.?([\s,.)]|$)'`, 2026-11-19), 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.'), as `Daw.` reads as a title ending the name (`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). + - **`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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial with it wherever the title vocabulary reads a title: 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.'), as `Daw.` reads as a title ending the name (`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. - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 10 names (`Mg Htoo` → title 'Mg'), the same by default, #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - **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. diff --git a/docs/languages.rst b/docs/languages.rst index efe32839d..adb5b085f 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1234,7 +1234,8 @@ What the pack leaves as it is - **An honorific and one word.** ``U Thant`` gives title ``U``, family ``Thant``, as a title and one name word reads in any name. - **Military and religious styles** (``Bogyoke``, ``Sayadaw``) are read - as given names, as by default. + as name words, as by default (``Ledi Sayadaw`` gives family + ``Sayadaw``). - **Burmese script.** The pack reads Latin letters only; ``ဦး`` and ``ဒေါ်`` have no reading yet. @@ -1245,16 +1246,17 @@ 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, and ``de la`` reads as by default - save where it ends the given part after a family comma). Where one + (``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, - wherever a title is read, so an initial ``U.`` opening a name or the - part after a comma, or standing behind a title, is the title - (``Smith, U.`` and ``Dr. U. Smith`` give no given name). + wherever the parser reads a title, so an initial ``U.`` in such a + place is the title (``Smith, U.`` and ``Dr. U. Smith`` give no given + name); only a bare ``U.`` between two name words stays an initial. Keep it to a parser of its own for the Burmese names in your data: diff --git a/docs/release_log.rst b/docs/release_log.rst index 28635ab61..1c89d9a9b 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -7,7 +7,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.`` opening a name becomes the title: keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` + - **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.`` wherever a title is read becomes the title (``Smith, U.`` gives no given name): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231` - **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.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index bbc65bd85..07d73d4f2 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -17,12 +17,11 @@ 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``, wherever it reads a title, so a Western -initial is the title under the pack too where it opens a name or the -part after a comma, stands behind another title, is glued to one or -stands in brackets (``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 +initial in such a place is 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``. Left as name words: the honorifics ``Ko``, ``Ma`` and ``Maung``, which diff --git a/nameparser/vocab/my.toml b/nameparser/vocab/my.toml index 754a40a40..9369e1d7a 100644 --- a/nameparser/vocab/my.toml +++ b/nameparser/vocab/my.toml @@ -6,7 +6,7 @@ salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1 [[word]] 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 takes as the title where it opens a name under the pack (U. S. Grant), 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)" } +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 takes as the title under the pack wherever the parser reads a title (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 = "ဂျူနီယာ" From 87a7a55872efb7c1215033df6d16408a26700834 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 12:28:13 -0800 Subject: [PATCH 11/13] Correct three wordings round six found in #1231's docs (#1231) docs/languages.rst: a U. among or ending the given names stays an initial (Smith, John U.), not only one between two name words; a Korean surname U reads as the title written with no comma (U Minjun), not after one (U, Minjun). docs/locales.rst's table row says the pack reads U and Daw as titles wherever a title is read. Co-Authored-By: Claude Opus 5.5 --- docs/languages.rst | 8 +++++--- docs/locales.rst | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/languages.rst b/docs/languages.rst index adb5b085f..e2bcc329a 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1256,7 +1256,8 @@ The pack is for lists of Burmese names. On other names it costs: - **An initial U.** ``U`` is the honorific however it is written, wherever the parser reads a title, so an initial ``U.`` in such a place is the title (``Smith, U.`` and ``Dr. U. Smith`` give no given - name); only a bare ``U.`` between two name words stays an initial. + name); a ``U.`` among or ending the given names stays an initial + (``John U. Smith``, ``Smith, John U.``). Keep it to a parser of its own for the Burmese names in your data: @@ -1274,5 +1275,6 @@ 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 opening with the surname ``U`` written bare -reads ``U`` as the title under the pack. +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. diff --git a/docs/locales.rst b/docs/locales.rst index 2b2f726ae..dc1358baf 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -301,7 +301,7 @@ says which parts each pack is made of. * - ``my`` - Burmese - Chooses ``my``, which reads the honorifics ``U`` and ``Daw`` - opening a name as titles, and keeps the syllables ``San``, + as titles wherever a title is read, 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`` From 32f1d8c0db86312c9af80c330f36152903bb0641 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 12:32:55 -0800 Subject: [PATCH 12/13] Make #1231's statements of where U. is a title examples, not rules (#1231) Round seven found "wherever a title is read" false in the other direction: a U. ending a name, and U or Daw ending the given part after a family comma, stay name words. docs/locales.rst's row now gives an example, and docs/languages.rst, my.py, my.toml, the release log and the decisions entry say an initial U. can be the title, with examples on both sides, claiming no complete list. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/vocabulary-collisions.md | 6 +++--- docs/languages.rst | 9 ++++----- docs/locales.rst | 2 +- docs/release_log.rst | 2 +- nameparser/locales/my.py | 4 ++-- nameparser/vocab/my.toml | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 055450b75..30cac5460 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 it under the pack, wherever that vocabulary reads a title, an initial included (`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` 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. ## Log @@ -102,9 +102,9 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - 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. - **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, wherever the title vocabulary reads a title: `U. Thein Sein` → title 'U.', and an initial with it wherever the title vocabulary reads a title: 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.'), as `Daw.` reads as a title ending the name (`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). + - **`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.'), as `Daw.` reads as a title ending the name (`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. - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 10 names (`Mg Htoo` → title 'Mg'), the same by default, #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - **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` is the title wherever the title vocabulary reads one, 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). + - **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. diff --git a/docs/languages.rst b/docs/languages.rst index e2bcc329a..e832f872c 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1253,11 +1253,10 @@ The pack is for lists of Burmese names. On other names it costs: 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, - wherever the parser reads a title, so an initial ``U.`` in such a - place is the title (``Smith, U.`` and ``Dr. U. Smith`` give no given - name); a ``U.`` among or ending the given names stays an initial - (``John U. Smith``, ``Smith, John U.``). +- **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: diff --git a/docs/locales.rst b/docs/locales.rst index dc1358baf..4e204dfe3 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -301,7 +301,7 @@ says which parts each pack is made of. * - ``my`` - Burmese - Chooses ``my``, which reads the honorifics ``U`` and ``Daw`` - as titles wherever a title is read, and keeps the syllables ``San``, + 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`` diff --git a/docs/release_log.rst b/docs/release_log.rst index 1c89d9a9b..fe4ee790c 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -7,7 +7,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.`` wherever a title is read becomes 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.** ``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` - **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.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` diff --git a/nameparser/locales/my.py b/nameparser/locales/my.py index 07d73d4f2..6d6cf95bc 100644 --- a/nameparser/locales/my.py +++ b/nameparser/locales/my.py @@ -16,8 +16,8 @@ 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``, wherever it reads a title, so a Western -initial in such a place is the title under the pack too (``U. S. +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 diff --git a/nameparser/vocab/my.toml b/nameparser/vocab/my.toml index 9369e1d7a..946929bef 100644 --- a/nameparser/vocab/my.toml +++ b/nameparser/vocab/my.toml @@ -6,7 +6,7 @@ salutation = { default = false, gender = "f", native = "ဒေါ်", issue = 1 [[word]] 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 takes as the title under the pack wherever the parser reads a title (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)" } +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 = "ဂျူနီယာ" From 87561898d9493e3db9cf222524bc07fb2f6a64bd Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 12:35:55 -0800 Subject: [PATCH 13/13] Fix the last two U. statements round eight found (#1231) The test comment over the accepted U. readings no longer claims "wherever it reads a title", and the decisions entry's list of places says a U. ending the name stays a name word, where Daw. reads as the title, instead of likening the two. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/vocabulary-collisions.md | 2 +- tests/v2/test_locales.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/design/decisions/vocabulary-collisions.md b/docs/design/decisions/vocabulary-collisions.md index 30cac5460..11e33255a 100644 --- a/docs/design/decisions/vocabulary-collisions.md +++ b/docs/design/decisions/vocabulary-collisions.md @@ -102,7 +102,7 @@ Elsewhere: C-i reaches the titles through a `given` reading, which makes a title - 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. - **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.'), as `Daw.` reads as a title ending the name (`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). + - **`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. - **The population**, rebuilt by the issue's recipe in a scratch folder, nothing cached or committed (2026-11-19): OpenSanctions' `sanctions` and `peps` collections' `targets.simple.csv` (CC BY-NC 4.0), every `Person` with `mm` among its countries, its name and each alias, beside Wikidata's English labels of humans with Myanmar citizenship (P27 = Q836) and a Burmese label (CC0, by SPARQL); 3,205 distinct strings, 2,990 kept as clean Latin names (ASCII, no brackets, no `of`, no `a.k.a.`), where the issue's 2026-11-08 count was 2,989. Read by a scratch probe parsing each under `Parser()` and `parser_for(locales.MY)`, the intended reading being the issue's: an opening `U` or `Daw` the title, the last word (before a comma, the part before it; after a roman numeral, the word before it) the family. `config_diff.py` reads only the committed and the local corpora, so the probe stands in for it. At the pack's final state (`U.` read as the title vocabulary reads it), 154 names move, 152 from a misreading to the intended reading (holding `u` 71, `san` 39, `daw` 26, `la` 7, `van`, `te` and `da` 2 each, `do`, `le` and `du` 1 each) and none the other way; one moves between two right readings (`Sir U Thwin`, title 'Sir' and given 'U' to title 'Sir U') and one between two wrong ones (two names in one string, each opening with `Daw`). The intended reading, an honorific written with a full stop counting as the honorific, holds for 2,835 of the 2,990 by default (94.8%) and 2,987 under the pack (99.9%); the three it misses are that string and two names ending in `Ra` read as the credential RA (`Khar Ra`), the same by default. While that rule stood, the one name opening with `U.` read as given 'U.' under the pack (2,986), and the first count, taken before the PR's design review, read a leading `U.` as right whatever the parse made of it (2,836 and 2,987). The probe's intended reading cannot see a title that takes a name word: `Mg`, Maung written short, reads as en.toml's military `MG` in 10 names (`Mg Htoo` → title 'Mg'), the same by default, #1232's. Of 456 names on one university's staff lists the issue's 2026-11-19 comment counted 322 opening with `Daw` or `U`, every one misread by default; that list was read once and is not cached. - **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. diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index f3682e80e..182f4ffd4 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -825,10 +825,10 @@ def test_my_reads_the_honorific_in_every_comma_shape( @pytest.mark.parametrize("text, title, given, middle, family", [ # the accepted reading, decided 2026-11-19 (decisions/vocabulary- # collisions, the #1231 entry): the title vocabulary reads U written - # with its full stop as the honorific under the pack, wherever it - # reads a title, so a Western initial U. opening a name is the title - # there -- the reason the docs give not to apply the pack to a mixed - # list. A bare U. between two name words is an initial, as by default + # with its full stop as it reads U under the pack, so a Western + # initial U. can be the title, as these rows show -- the reason the + # docs give not to apply the pack to a mixed list. A bare U. between + # two name words is an initial, as by default ("U. Thein Sein", "U.", "Thein", "", "Sein"), ("Sein, U. Thein", "U.", "Thein", "", "Sein"), ("U. S. Grant", "U.", "S.", "", "Grant"),