From 7adf0a034d689a5d531c91e74c8fd1c37d3f7409 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 12:07:57 -0800 Subject: [PATCH 1/3] Read the Malaysian honours Datuk, Dato', Datin and Hajah as titles, and Tun, Haji, Tan Sri and Puan Sri under locales.MS (#1180) Datuk, Dato' (with either apostrophe), Datin and Hajah are titles by default in ms.toml, each addressing the given name as Sir does (rules/H1). Tun, Haji, the bare Dato and the phrases Tan Sri and Puan Sri are titles written default = false, which locales.MS turns on: each word is a name elsewhere. Tan and Sri get given readings in mul.toml, so each title is gated (rules/H9) and read only in its phrase. The build refused a phrase whose two halves are both off by default. Its attaches check now admits a partner whose title reading is off by default in the reading's own file, where the reading is off by default too, and still refuses a partner with no title reading or one another file's choice turns on (decisions/vocabulary-model, 2026-11-21 #1180). Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/salutation-titles.md | 7 ++ docs/design/decisions/vocabulary-model.md | 2 + .../rules/H1-title-and-one-name-word.md | 1 + docs/languages.rst | 58 +++++++-- docs/locales.rst | 8 +- docs/release_log.rst | 1 + nameparser/config/_compiled.py | 11 ++ nameparser/config/_index.py | 12 +- nameparser/locales/ms.py | 17 ++- nameparser/vocab/README.md | 2 +- nameparser/vocab/ms.toml | 42 ++++++- nameparser/vocab/mul.toml | 8 ++ tests/v2/cases.py | 117 ++++++++++++++++++ tests/v2/test_locales.py | 57 +++++++-- tests/v2/test_vocab.py | 21 +++- tools/vocab/build.py | 20 ++- 16 files changed, 346 insertions(+), 38 deletions(-) diff --git a/docs/design/decisions/salutation-titles.md b/docs/design/decisions/salutation-titles.md index 3942d1f50..54cbdec66 100644 --- a/docs/design/decisions/salutation-titles.md +++ b/docs/design/decisions/salutation-titles.md @@ -20,6 +20,7 @@ Closes #606 (#662 later added owura and bapak, its bullet below, and #847 cllr). - The Italian abbreviated salutations and letter-heading honorifics whose letters after the full stop are the word's own ending ship as titles with `cased` masks: `sig.ra`, `sig.na`, `dott.ssa`, `prof.ssa`, `gent.mo`, `gent.ma`, `gent.le`, `ill.mo`, `ill.ma`, `ch.mo`, `ch.ma`, `preg.mo`, `preg.ma` (`Dott.ssa Anna Bianchi` reads title 'Dott.ssa', given 'Anna'; `SIG.RA MARIA ROSSI` repairs to 'Sig.ra Maria Rossi'); the bare `sig` and `ing` are excluded as given names, their period-marked spellings already titles by H2's shape, except `Ing.` after a full name and a comma, which is the ambiguous credential decisions/suffix-acronym-collisions lists (#848) — 2026-10-22 #840. - `puan` and `cik` (salutations), `ustaz` and `ustazah` (`religious`) and `cikgu` (`occupation`) are titles written `default = false` in ms.toml, which `locales.MS`, a pack choosing `ms` and nothing else, turns on; `tuan` stays out under that choice too, an `excluded` entry, being the hereditary prefix Malaysians file as part of the name and a Vietnamese given name; the pack is a plain choice, a strict one reading Malaysian lists worse — 2026-11-19 #1179. +- The Malaysian honours `datuk`, `dato'` (and `dato’`, the typographic apostrophe), `datin` (`nobility`) and `hajah` (`religious`) are titles by default, each addressing the given name as `sir` does (rules/H1), on no bearer found leading a name but one; `tun`, `haji`, the bare `dato` and the phrases `Tan Sri` and `Puan Sri` (rules/H9, `tan` and `puan` attaching to `sri`, `tan` and `sri` each gated by mul.toml's `given` reading) are titles written `default = false` in ms.toml, which `locales.MS` turns on, each word being a name elsewhere; `Sri` and `Seri` written behind a head honour stay name words (#1334) — 2026-11-21 #1180. Elsewhere: `justice` and `marshal`, excluded here as common leading-position names, are titles only inside a title phrase since 2026-10-25 and 2026-10-26 (`Chief Justice John Roberts` reads title 'Chief Justice' and `Field Marshal Bernard Montgomery` title 'Field Marshal', `Justice Smith` and `Marshal Yanda` the given name) — decisions/H9's 2026-10-25 #752, phase 2i entry; decisions/H9's 2026-10-26 #752, phase 2i (Derek) entry. - A Persian title is a plain title that addresses the family name (`دکتر رضایی` reads family), written in fa.toml, and an Arabic title typed with Persian yeh and kaf is a `same_as` spelling of ar.toml's, listed rather than folded; the words that open real Persian family names (`شیخ`, `حاج`, `حاجی`, `آقا`) stay out — 2026-11-10 #1151 @@ -87,3 +88,9 @@ Elsewhere: `justice` and `marshal`, excluded here as common leading-position nam - 2026-11-20 #966 — RANKS WRITTEN WITH A HYPHEN ARE TITLES: EIGHT, THEN FIVE MORE ON REVIEW. `vice-admiral`, `rear-admiral`, `vice-marshal`, `air-marshal`, `lieutenant-colonel`, `lieutenant-general`, `major-general` and `brigadier-general` join en.toml as `military` readings, `co-chair` the precedent for an entry holding a hyphen: tokenize keeps a hyphenated word whole, so `Air Vice-Marshal Ann Reed` read given 'Air', middle 'Vice-Marshal Ann', the spaced rank's phrase never reaching it, and reads title 'Air Vice-Marshal' now, the modifier `air` finding its head after it (rules/H9). Each reads as its spaced twin does at the head, after a family comma and after a second comma, under all three orders, save where the twin is two words: a bare rank ending a name stays a name word either way (`John Smith Vice-Admiral` keeps it one family word), and after a second comma `vice-marshal`, `air-marshal` and `major-general` report no comma fork where their spaced twins do, the twin holding a title that may be a given name (`marshal`, `major`, rules/H9) and the hyphenated word holding none (`Smith, John, Major General` reports `comma-structure`, `Smith, John, Major-General` nothing). None of the eight is borne as a name in any source tools/name_usage.py reads. Measured 2026-11-20 against master `cb5088a9` with `uv run python tools/differential/measure.py --base `: govuk-people moves 6, every one `Air Vice-Marshal` gaining the title, and no other local corpus moves (ukec-individuals 0 of 15,214). DECLINED: splitting a hyphenated word at its hyphen to find a title in it, which would reach every hyphenated name holding a title word (`Smith-Major`) and every hyphenated rank the vocabulary does not list; listing the ranks reaches the shape written, and an unlisted one stays a name word, as before. - **Five more, added on the PR's review** (2026-11-20): `field-marshal`, `lieutenant-commander`, `wing-commander`, `chief-marshal` (`Air Chief-Marshal`) and `sergeant-major`, the British ranks the review found still read as name words. Each reads as its spaced twin does at the head, after a family comma and after a second comma, save the same two shapes: a bare rank ending a name, and after a second comma no comma fork where the twin holds a title that may be a given name (`marshal`, `wing`, `major`). None is borne as a name in any source tools/name_usage.py reads, and none moves a name in govuk-people (0 of 6,021) or ukec-individuals (0 of 15,214), measured against the eight with `uv run python tools/differential/snapshot.py --local --base `. - **Where no twin is promised:** a rank that is the whole part before a family comma (`Field-Marshal, Ann` gives family 'Field-Marshal', `Field Marshal, Ann` title 'Field', family 'Marshal'), a rank written alone, and a rank ending a name with a full stop (`John Smith Wing-Commander.` gives title 'Wing-Commander.', the spaced twin title 'Commander.', family 'Wing') read otherwise than the spaced words, which split there; the first eight read the same way (the PR's review, 2026-11-20). +- **2026-11-21 #1180 — MALAYSIAN HONOURS: `datuk`, `dato'`, `datin` AND `hajah` ARE TITLES BY DEFAULT; `tun`, `haji`, THE BARE `dato`, `Tan Sri` AND `Puan Sri` UNDER `locales.MS`.** Malaysian names in official use open with a run of honours, and 1.4.0 through 3.1.0 read the first as the given name (`Datuk Ahmad bin Ali` given 'Datuk', middle 'Ahmad'). Decided 2026-11-21 on the issue's scope: the honours as titles, each addressing the given name as `sir` does (rules/H1), so `Datuk Ahmad` gives given 'Ahmad'. `datuk`, `dato'` and `datin` are `nobility`, `hajah` and `haji` `religious`, as `ustaz` is: not `style`, whose words make a phrase with a title that may be a given name behind them (`Hajah Sri Wahyuni` would read title 'Hajah Sri', rules/H9). + - **THE COUNTS** (`tools/name_usage.py --no-wikidata --boxes --country MY`, 2026-11-21, ORCID's 24,990,909 holders and PatentsView's 5,508,446 inventors; each on its word's note). On by default, none borne leading a name but `hajah` once: `datuk` ORCID given box 4 (none Malaysian) and family 3, PatentsView given 2 (both Malaysian, the honour typed in); `dato'` ORCID given 7 (Malaysia 4) and family 3; `datin` ORCID given 13 (Malaysia 1) and family 2; `hajah` ORCID given 32 (Brunei 3, 28 with no country), PatentsView given 2, and one Companies House filer who bears it as her given name (below). Off by default: `tun` ORCID given 241 (Myanmar 30, China 21) and family 395, US Census 2010 1,908; `haji` given 232 and family 1,178, US SSA 105+ births (decisions/indic-honorifics left its title wanting a choice, 2026-11-19 #1469); the bare `dato` an Italian surname (US Census 2010 633, ORCID family 68) and a Georgian given name (ORCID's 4 Georgian regressions below); `tan` ORCID given 2,867 and family 20,353, US SSA 597+; `sri` ORCID given 7,047, US SSA 109+. The 2015 King's birthday honours list, as #1180 measured it on 2026-11-08 and not rebuilt here, misses `Dato'` in 32 runs of 1,504 names, `Datuk` 23, `Datin` 23, `Haji` 40, `Hajah` 16, `Tun` 1 and `Puan Sri` 1. + - **THE PHRASES.** `tan` and `sri` hold a `given` reading in mul.toml, so each title is gated (rules/H9) and a title only in a phrase: `tan` and `puan` attach to `sri`. Alone each stays a name word under the pack (`Tan Chee Chai` given 'Tan', `Sri Mulyani` given 'Sri'), reporting `title-or-name`. The build refused a phrase whose two halves are both off by default; it admits one written in one file since this day (decisions/vocabulary-model, the 2026-11-21 #1180 entry, which records why the alternative, `sri`'s title on by default, was declined). By default no phrase is compiled and no `tan`, `sri` or `puan` title. + - **MEASURED** against master `488ea605`, py3.11, `tools/differential/local_agreement.py SOURCE --base ` (and `--locale ms`), `snapshot.py --local SOURCE --base ` and `config_diff.py diff --local SOURCE default plain:MS` in both trees. By default: my-candidates 174 of 3,077 distinct names move, each an honour at the head now the title (`DATO' AZAMI` given 'AZAMI'), none wrong; ORCID 0 fixed, 0 broken, 3 changed (an honour typed into the given box, now the title); PatentsView 0 broken, 1 title typed in; Companies House 1 regression, `Hajah` (below); opensanctions-parliaments, nepal-candidates and the committed snapshot no move. Under `locales.MS`, against the pack on master: ORCID 26 regressions (`haji` 17, Tanzania 8, Ethiopia 3 and one each in six other countries; `tun` 5, Myanmar 4 and a Burmese name in Malaysia, `TUN AUNG`; the bare `dato` 4, Georgia 3), 19 more titles typed in read as the title, 2 fewer; Companies House 36 (`haji` 30, 20 of them British filers and 4 Pakistani; `tun` 2; the bare `dato` 1, Georgian; `hajah` 1, the default's; and 2 where the filer typed the honours into the forename box, read right); PatentsView 4 (2 of them honours typed into the given box, read right). On my-candidates the pack reads 248 names differently from the default, where master's reads 117: 197 a title in the role fields (`ustaz` 72, `cikgu` 45, `haji` 37, `dato` 29, `Tan Sri` 6, `ustazah` 5, `cik` 2, `Puan Sri` 1), and 51 the same roles with a new `title-or-name` report (36 Chinese names written family first with `TAN`, 14 `DATO' SRI`). + - **ACCEPTED.** By default, a woman whose given name is Hajah reads it as the title (`Miss Hajah Conteh`, a Companies House filer, title 'Miss Hajah'). Under the pack: a Chinese surname `Tun` after a salutation (`Encik Tun Yoke Wah` title 'Encik Tun'), as #1180 found in the honours list; the citation `Haji A` (title 'Haji', given 'A'); the surname `Tan` before a given name `Sri` (`Tan Sri Wahyuni` title 'Tan Sri'); `Sri` behind a style (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9); the bare `Dato` of an Italian or Georgian name (`Dato Mario`); and the `title-or-name` report on every name opening with `Tan` or `Sri`, the cost of a gated title, which by default reports nothing. + - **LEFT OUT**, each the issue's: `Sri` and `Seri` behind a head honour (`Dato' Sri`, `Datuk Seri`, which read given 'Sri'), `Laks. Muda` and `Prof. Madya`, the qualifier written after its head (#1334); `YB`, `YM` and `YA`, two capitals, the shape of paired initials (#1205); the police ranks `ASP`, `ACP`, `DSP`, `SAC` and `DCP`; the service designations `TUDM` and `TLDM`. Found here and not changed: under the pack `Dato' Ustaz Idris` reads family 'Idris', the run addressing as its last title, `ustaz`, does, by the family (#1179's reading). diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 862306459..9dd9deeb7 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -60,6 +60,7 @@ The vocabulary was a set of base sets plus marker subsets (`particles` and `part - `und.toml` holds only `bon` and `dí`, of unrecorded origin, their particle readings refused (below) and their name readings kept; every other word, the credentials, conjunctions, bound given names and birth markers included, is in a language file or in `mul.toml` — 2026-10-19 #749; 2026-10-20 #751, the conjunctions. - `md` lists the five long spellings of Muhammad its Bangladeshi holders write first, `muhammad`, `mohammad`, `mohammed`, `muhammed` and `mohamed`, leaving out `mohamad` (1); `mohd` and `moh` list `muhammad`, `mohamad`, `mohammad`, `mohammed` and `mohamed` — 2026-11-14 #1383 `md` ALSO LISTS. - A `given` reading carrying `same_as`, a name written short, marks no clash with a suffix reading: an acronym or a gated suffix word beside it stays unambiguous, the parse reading the short form through rules/H2's yielding at the head of a name and the match through its listed spellings, never through the words-to-spare count the markers gate (`md`, Muhammad written short and the medical degree); a plain name reading on the same word still marks the clash (`ma`). A `same_as` is a text or a list of texts — 2026-11-13 #1383. The exemption is the suffix markers' alone: beside a title or a particle, which stand at the head of a name as a given name does, the short form still marks the clash (a title read only inside a phrase, a particle that may be a given name), and it gates no agnomen, check 11 refusing an agnomen whose only name reading is written short; `ReadingProperties.marks_a_clash` is the one statement of the test, read by the compile, the build and `Lexicon` — 2026-11-14 #1383 THE REVIEW. +- A title reading written `default = false` may attach to a word whose title reading is written `default = false` in the same file, the one choice of that file turning on both halves of the phrase; a partner no file turns on, or one only another file's choice turns on, is refused by the build, as a partner off by default beside a reading on by default is — 2026-11-21 #1180. Not standing: the plans the classifications carried out, phase 1's mechanical conversion of the unclassified categories into `und.toml` (2026-10-18 #737) and the shared readings left in place until their categories were classified (2026-10-19 #749), both done by 2026-10-20 #751, the conjunctions; and #747's reason for exempting `und.toml`, its entries keeping the Python lists' order for its vetting comments to point along (2026-10-19 #747), overtaken once it held two entries and no such comment. @@ -636,3 +637,4 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis ACCEPTED: a person whose given name is `Shri`, or opens with it, reads the salutation under the pack: `Verma, Shri` gives title 'Shri' and no given name, `Shri Mehra` title 'Shri', family 'Mehra', and `Shri Lal Mehra` given 'Lal'. Nothing written tells `Shri Lal`, a given name of two words, from `Shri Ravi`, the salutation before one. A narrower reading, the title only with two or more name words behind it, keeps `Shri Mehra` and loses the 202 Sansad spellings written `Shri Gopalan`, so it was not taken. NOT `after_given` (rules/H8): rules/H8 leaves out a salutation borne as a given name, since a middle name may be one, and decisions/H8 left the Devanagari `श्री` out on that doubt; `shri` is borne as one, and the roll never asks for the property. in_sansad writes the salutation in two shapes, before the given name after a family comma (`Verma, Shri Ravi`, 653 of opensanctions-parliaments' distinct names) and after a full name and a comma (`Ravi Verma, Shri`), both read as the title without it, and holds no `Family, Given Shri`. Measured against the same reading carrying the property, the recipe below moves 2 names, both reading better without it: an FEC filer whose given name of two words ends in the word (`FAMILY, GIVEN SHRI`), whom the property read as given 'GIVEN' and title 'SHRI', and a Sansad spelling with the salutation in brackets (`(Shri) Ravi Kumar`), which the property left the nickname and which reads as the title without it. So `Verma, Ravi Shri` keeps middle 'Shri' under the pack, as `वर्मा, रवि श्री` keeps middle 'श्री', and the word records the refusal (`excluded = { after_given = ... }` on its entry); the dotted `Verma, Ravi Shri.` is the title by rules/H5's trailing vocabulary, as `Shri.` ending a name is. Recompute: the command above from a checkout of this change; the 2 moves the property makes with `'expr:Parser(lexicon=parser_for(locales.HI).lexicon.remove("shri", kind="salutation").add("shri", kind="salutation", after_given=True), policy=parser_for(locales.HI).policy)'` in place of the first configuration; the person counts from `raw.jsonl`'s in_sansad rows, their `entity` kept where `name` holds `shri` as a word, and where it opens with it (a bracket allowed); the in_sansad figure with `--local opensanctions-parliaments --group in_sansad` and no `--match`; each moved name read from `--readings `, the two configurations' first field compared line by line. +- 2026-11-21 #1180 — A PHRASE MAY BE WRITTEN WHOLLY OFF BY DEFAULT IN ONE FILE. `Tan Sri` and `Puan Sri`, Malaysian honours, are phrases rules/H9 reads, `tan` and `puan` attaching to `sri`, each a title off by default in ms.toml for `locales.MS` (decisions/salutation-titles, the same day's entry). The build refused them: `attaches` had to name a word with a title reading ON by default, and `sri` holds none, hi.toml excluding it as a salutation and the exclusion refusing every title kind of a reading on by default. Decided 2026-11-21, B over A. A: turn `sri`'s title on by default, gated by mul.toml's `given` reading, and narrow hi.toml's exclusion. It moved no corpus name (0 of the 597 local-corpus names holding `sri`, `config_diff.py diff --local all --match '(?i)(^|[\s,.])sri([\s,.]|$)' default 'expr:Parser(lexicon=Lexicon.default().add("sri", kind="given").add("sri", kind="nobility", addresses="given"))'`, master `488ea605`), but it moved the default to satisfy a tool rule, and a style before the word makes a phrase there (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9). B: the build check admits a partner whose title reading is off by default in the reading's own file, where the reading is off by default too, so the default compiles no phrase and holds no `sri` title (`nameparser/config/_compiled.py` holds no `tan`, `sri` or `puan`), and the one choice of the file turns both on. The check still refuses a partner with no title reading and one another file's choice turns on, each a mutation in tests/v2/test_vocab.py. A caller's `Lexicon.add` had no such check and gets none: a phrase naming no title word compiles to nothing, an inert entry (AGENTS.md, invariants guard harm, not no-ops), and under a choice the compile builds a phrase only from the title words the chosen pool holds. 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 3a44cd0be..98e1f646d 100644 --- a/docs/design/rules/H1-title-and-one-name-word.md +++ b/docs/design/rules/H1-title-and-one-name-word.md @@ -36,6 +36,7 @@ "Dr. Sir John" → given="John" "His Excellency Lord Duncan" → family="Duncan" "Her Royal Highness Princess Anne" → given="Anne" +"Datuk Ahmad" → given="Ahmad" "Sir John" → given="John" · boundary ``` diff --git a/docs/languages.rst b/docs/languages.rst index 7e3828095..6681435d6 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1560,17 +1560,47 @@ name, so the default keeps ``Puan Maharani``'s given name, and the pack does not. Choose the pack for Malaysian lists, not Indonesian ones. +The honours ``Datuk``, ``Dato'`` and ``Datin`` and the pilgrim's +``Hajah`` are titles by default, each naming the given name as ``Sir`` +does. The pack adds the honours that are names elsewhere: ``Tun``, a +Chinese and Burmese name; ``Haji``, a given name and a surname; +``Dato`` written without its apostrophe, an Italian surname and a +Georgian given name; and the phrases ``Tan Sri`` and ``Puan Sri``: + +.. doctest:: + + >>> ahmad = parse("Datuk Ahmad bin Ali") + >>> ahmad.title, ahmad.given, ahmad.family + ('Datuk', 'Ahmad', 'bin Ali') + >>> parse("Tan Sri Muhyiddin Yassin").given + 'Tan' + >>> yassin = malay.parse("Tan Sri Muhyiddin Yassin") + >>> yassin.title, yassin.given, yassin.family + ('Tan Sri', 'Muhyiddin', 'Yassin') + >>> malay.parse("Haji Abdul Hadi Awang").title + 'Haji' + +``Tan``, the commonest Chinese surname in Malaysia, and ``Sri``, a given +name, are titles only in their phrases: alone each stays the given +name, and the pack reports the title it might be, so a Chinese name +written family first reports one under the pack (``Tan Chee Chai`` +gives given ``Tan`` and a ``title-or-name`` report). A ``Sri`` that is a +given name behind the surname ``Tan`` reads as the phrase +(``Tan Sri Wahyuni`` gives title ``Tan Sri``). + On Malaysia's election candidates, 3,077 distinct names written in -capitals, the pack reads 117 differently from the default, each a title -the default read as the given name: ``USTAZ`` 69, ``CIKGU`` 41, -``USTAZAH`` 4, ``CIK`` 2 and ``PUAN`` 1. The two ``CIK`` are ``Cikgu`` -written in two words (``CIK GU``), and read given ``GU``, and the -``PUAN`` opens ``Puan Sri``, the wife of a Tan Sri, and reads given -``SRI`` until the phrase is a title (:issue:`1180`). Among the records ORCID, PatentsView and -Companies House hold of Malaysians, Indonesians, Singaporeans and -Vietnamese, each split into boxes by the person or the filer, the share -whose boxes the parse matches does not move (measured 2026-11-19, -:issue:`1179`). +capitals, the default reads 174 honours at the head of a name as the +title (``DATO'`` 101, ``DATUK`` 69), and the pack reads 248 differently +from the default. 197 of them read a title the default read as the +given name: ``USTAZ`` 72, ``CIKGU`` 45, ``HAJI`` 37, ``DATO`` 29, +``TAN SRI`` 6, ``USTAZAH`` 5, ``CIK`` 2 and ``PUAN SRI`` 1. The two +``CIK`` are ``Cikgu`` written in two words (``CIK GU``), and read given +``GU``. The other 51 read the same and add a report: 36 Chinese names +written family first with ``TAN``, 14 ``DATO' SRI``. Among the records +ORCID, PatentsView and Companies House hold of Malaysians, Indonesians +and Singaporeans, each split into boxes by the person or the filer, the +share whose boxes the parse matches moves by at most 0.1 point under +the pack (measured 2026-11-21, :issue:`1179`, :issue:`1180`). What the pack leaves as it is ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1585,9 +1615,11 @@ father's name, and a Vietnamese given name is written so too: >>> aminah.title, aminah.given, aminah.family ('', 'Tuan', 'binti Tuan Yusof') -``Dato'``, ``Datuk``, ``Tan Sri`` and ``Haji`` are not titles yet -(:issue:`1180`), and a title written after one stays a name word -(``Dato' Ustaz Idris`` gives given ``Dato'``, middle ``Ustaz``). +``Sri`` and ``Seri`` written behind a head honour, as its qualifier, +stay name words (``Datuk Seri Anwar Ibrahim`` gives title ``Datuk``, +given ``Seri``), and so do ``YB``, ``YM`` and ``YA`` and the police +ranks (:issue:`1180`). ``Haji`` inside the father's name is a name word +(``Ahmad bin Haji Abdullah`` gives family ``bin Haji Abdullah``). ``bt``, written short for ``binti``, stays a credential (Baronet), as by default; :doc:`customize` shows how to remove it. diff --git a/docs/locales.rst b/docs/locales.rst index 0bbb84bfd..0a35d46cf 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -145,7 +145,8 @@ shape covers much: titles and removed readings reach the comma names too. - ``mn`` may read any name written wholly in Cyrillic differently. - ``ms`` may read any name holding ``Puan``, ``Cik``, ``Ustaz``, - ``Ustazah`` or ``Cikgu`` as a word differently. + ``Ustazah``, ``Cikgu``, ``Tun``, ``Haji``, ``Dato``, ``Tan`` or ``Sri`` + as a word differently. - ``my`` may read any name holding ``U`` or ``Daw`` as a word differently, with or without its full stop, or ``U`` as a letter of a word joined by full stops. Chosen strictly, it may read any name @@ -301,8 +302,9 @@ says which parts each pack is made of. * - ``ms`` - Malay: Malaysian titles - Chooses ``ms``, which reads the salutations ``Puan`` (Mrs.) and - ``Cik`` (Miss), and ``Ustaz``, ``Ustazah`` and ``Cikgu``, as - titles, where the default reads a name word. See + ``Cik`` (Miss), ``Ustaz``, ``Ustazah`` and ``Cikgu``, and the + honours ``Tun``, ``Haji``, ``Dato``, ``Tan Sri`` and ``Puan Sri``, + as titles, where the default reads a name word. See :ref:`malay-names`. - ``Puan Siti binti Ahmad`` → title ``Puan`` * - ``my`` diff --git a/docs/release_log.rst b/docs/release_log.rst index 421f58c8c..9c9d92200 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,6 +4,7 @@ Release Log nameparser 3.2 is under development. + - **Add the Malaysian honours Datuk, Dato', Datin and Hajah as titles, and Tun, Haji, Tan Sri and Puan Sri under locales.MS.** ``parse("Datuk Ahmad bin Ali")`` gives title ``Datuk``, given ``Ahmad``, where 1.4.0 through 3.1.0 gave given ``Datuk``, middle ``Ahmad``; ``parser_for(locales.MS).parse("Tan Sri Muhyiddin Yassin")`` gives title ``Tan Sri``. Under the pack, Tan and Sri alone stay name words with a ``title-or-name`` report (``Tan Chee Chai``), and Sri written behind another honour stays a name word (``Datuk Seri Anwar Ibrahim`` gives given ``Seri``). :issue:`1180` - **Add Brazilian Portuguese familiar forms, found in the names Brazil's election candidates put on the ballot.** With ``familiar-form`` accepted, ``Tião Alves`` / ``Sebastião Alves`` and ``Cida Silva`` / ``Aparecida Silva`` are consistent, where 3.1.0 read a conflict. They are filed under ``pt-BR``, so a strict choice of another language leaves them out, and one name spelled two ways (``Elizangela`` / ``Elisangela``) is not among them. :issue:`1495` - **Add the Czech and Slovak post-nominals DiS., DrSc. and ArtD. as credentials.** ``parse("Jan Novák, DiS.")`` gives suffix ``DiS.``, where 1.4.0 through 3.1.0 gave title ``DiS.``; DiS., which is also a surname, reads as the credential after a full name and a comma, and written as ``DiS.`` or ``Dis`` it stays a name word at the end of a name of mixed case without one (``Jan Novák DiS.``), while a surname written ``DIS`` there reads as the credential (``Jan DIS``). :issue:`969` - **Add credentials: BCh, BChir and BMBCh, the Nigerian marks mni, fwc, fsi, fnse, psc and ndc, and the Hong Kong and Singapore honours GBM, GBS, SBS, BBS and BBM.** ``parse("Jane Doe, BCh")`` gives suffix ``BCh``, where 1.4.0 through 3.1.0 gave given ``BCh``, family ``Jane Doe``. A word spelling one of them after a one-word family name and a comma, or ending a name, reads as the credential (``Bello, MNI``). :issue:`1361`, :issue:`1228`, :issue:`1182` diff --git a/nameparser/config/_compiled.py b/nameparser/config/_compiled.py index 5040b4569..39f7865bc 100644 --- a/nameparser/config/_compiled.py +++ b/nameparser/config/_compiled.py @@ -16,8 +16,13 @@ 'cheikh', 'consort', 'dame', + 'datin', + "dato'", + 'dato’', + 'datuk', 'father', 'guru', + 'hajah', 'king', 'lama', 'maid', @@ -522,6 +527,10 @@ "d'affaires", 'dame', 'dancer', + 'datin', + "dato'", + 'dato’', + 'datuk', 'dbqh', 'dcn', 'degree', @@ -669,6 +678,7 @@ 'guitarist', 'guru', 'gysgt', + 'hajah', 'hajji', 'head', 'headman', @@ -4916,6 +4926,7 @@ 'cwo-3': ('cwo3',), 'cwo-4': ('cwo4',), 'cwo-5': ('cwo5',), + 'dato’': ("dato'",), 'dbqh': ('đbqh',), 'dcn': ('deacon',), 'dir': ('director',), diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 37c1754dd..d7dcd6320 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -964,6 +964,11 @@ ('dario', (('pt-BR', 'familiar', (('short_for', ('darinho',)),)),)), ('darya', (('ru', 'spelling', (('spelling_of', ('daria',)),)),)), ('das', (('pt', 'preposition', ()),)), + ('datin', (('ms', 'nobility', (('addresses', 'given'),)),)), + ('dato', (('ms', 'nobility', (('addresses', 'given'), ('default', False), ('same_as', "dato'"))),)), + ("dato'", (('ms', 'nobility', (('addresses', 'given'),)),)), + ('dato’', (('ms', 'nobility', (('addresses', 'given'), ('same_as', "dato'"))),)), + ('datuk', (('ms', 'nobility', (('addresses', 'given'),)),)), ('dave', (('en', 'familiar', (('short_for', ('david',)),)),)), ('david', (('pt-BR', 'familiar', (('short_for', ('davizinho',)),)),)), ('daw', (('my', 'salutation', (('default', False),)),)), @@ -1584,6 +1589,8 @@ ('gysgt', (('en', 'military', ()),)), ('gyöngyi', (('hu', 'familiar', (('short_for', ('gyöngyike',)),)), ('ro', 'familiar', (('short_for', ('gyöngyike',)),)))), ('gê', (('pt-BR', 'familiar', (('short_for', ('geralda', 'geraldo')),)),)), + ('hajah', (('ms', 'religious', (('addresses', 'given'),)),)), + ('haji', (('ms', 'religious', (('addresses', 'given'), ('default', False))),)), ('hajji', (('ar', 'style', ()),)), ('hajni', (('hu', 'familiar', (('short_for', ('hajnalka',)),)),)), ('hakim', (('ar', 'familiar', (('short_for', ('abdulhakim',)),)), ('mul', 'familiar', (('short_for', ('abdelhakim',)),)))), @@ -2887,7 +2894,7 @@ ('pta', (('en', 'credential', ()),)), ('pta/l', (('en', 'credential', ()),)), ('ptech', (('en', 'credential', (('cased', 'PTech'),)),)), - ('puan', (('ms', 'salutation', (('after_given', True), ('default', False))),)), + ('puan', (('ms', 'salutation', (('after_given', True), ('attaches', ('sri',)), ('default', False))),)), ('publisher', (('en', 'occupation', ()),)), ('pursuivant', (('en', 'office', ()),)), ('pv2', (('en', 'military', ()),)), @@ -3271,6 +3278,7 @@ ('sra', (('es', 'salutation', (('after_given', True), ('same_as', 'señora'))), ('es', 'family', ()), ('pt', 'salutation', (('after_given', True), ('same_as', 'senhora'))))), ('srdjan', (('mul', 'spelling', (('spelling_of', ('srdan',)),)),)), ('sres', (('es', 'salutation', (('after_given', True), ('same_as', 'señores'))),)), + ('sri', (('ms', 'nobility', (('addresses', 'given'), ('default', False))), ('mul', 'given', ()))), ('srta', (('es', 'salutation', (('after_given', True), ('same_as', 'señorita'))),)), ('srtas', (('es', 'salutation', (('after_given', True), ('same_as', 'señoritas'))),)), ('sscp', (('en', 'credential', ()),)), @@ -3351,6 +3359,7 @@ ('tami', (('mul', 'familiar', (('short_for', ('tamar',)),)),)), ('tamiro', (('pt-BR', 'familiar', (('short_for', ('altamiro',)),)),)), ('tammy', (('en', 'familiar', (('short_for', ('tamara',)),)),)), + ('tan', (('ms', 'nobility', (('addresses', 'given'), ('attaches', ('sri',)), ('default', False))), ('mul', 'given', ()))), ('tania', (('en', 'familiar', (('short_for', ('tatiana',)),)), ('pt-BR', 'familiar', (('short_for', ('taninha',)),)), ('ru', 'familiar', (('short_for', ('tetiana',)),)), ('uk', 'familiar', (('short_for', ('tetiana',)),)))), ('tanja', (('mul', 'spelling', (('spelling_of', ('tania',)),)), ('sr', 'familiar', (('short_for', ('tatjana',)),)))), ('tanya', (('en', 'familiar', (('short_for', ('tatyana', 'tetyana')),)), ('ru', 'familiar', (('short_for', ('tatiana', 'tatyana')),)))), @@ -3481,6 +3490,7 @@ ('tsarina', (('ru', 'nobility', ()),)), ('tsgt', (('en', 'military', ()),)), ('tte', (('es', 'military', ()),)), + ('tun', (('ms', 'nobility', (('addresses', 'given'), ('default', False))),)), ('tunde', (('mul', 'familiar', (('short_for', ('babatunde',)),)),)), ('tunica', (('pt-BR', 'familiar', (('short_for', ('antonia',)),)),)), ('tunico', (('pt-BR', 'familiar', (('short_for', ('antonio',)),)),)), diff --git a/nameparser/locales/ms.py b/nameparser/locales/ms.py index b0fe35e36..895c0e020 100644 --- a/nameparser/locales/ms.py +++ b/nameparser/locales/ms.py @@ -4,10 +4,19 @@ (Miss), the religious teachers' titles ``Ustaz`` and ``Ustazah``, and ``Cikgu`` (teacher), each then a title at the head of a name: ``Puan Siti binti Ahmad`` gives title ``Puan``, given ``Siti`` where the -default gives given ``Puan``. ``Encik`` (Mr.) is a title by default -already. Each is off by default because a word of it is a name -elsewhere (``Puan``, an Indonesian given name, as in ``Puan Maharani``) -or is written so only in Malaysian lists. +default gives given ``Puan``. It turns on the honours too (#1180): +``Tun``, ``Haji``, ``Dato`` written without its apostrophe, and the +phrases ``Tan Sri`` and ``Puan Sri``, each a title addressing the given +name (``Tan Sri Ahmad bin Ali`` gives title ``Tan Sri``, given +``Ahmad``). ``Encik`` (Mr.) and the honours ``Datuk``, ``Dato'``, +``Datin`` and ``Hajah`` are titles by default already. Each is off by +default because a word of it is a name elsewhere (``Puan``, an +Indonesian given name, as in ``Puan Maharani``; ``Tun`` and ``Tan``, +Chinese surnames; ``Haji``, a given name and a surname; ``Dato``, an +Italian surname) or is written so only in Malaysian lists. ``Tan`` and +``Sri`` alone stay name words under the pack, each a title only in its +phrase (rules/H9), so a name opening with either reports the title it +might be (``Tan Chee Chai`` reads given ``Tan``). ``Tuan`` is left a name word under the pack too: Malaysians who file their own names write it first as the hereditary prefix, repeated before diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index 20ed0fe5a..357194b0e 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -185,7 +185,7 @@ A property is **behavioral** when it compiles into a set and so changes how name | Property | Type | Applies to | Unwritten | Effect | |---|---|---|---|---| | `addresses` | behavioral | `title` | `"family"` | `"given"` adds the word to `GIVEN_NAME_TITLES`: `Sir John` reads `John` as the given name ([rules/H1](../../docs/design/rules/H1-title-and-one-name-word.md), a title and one name word) | -| `attaches` | behavioral | `title` | none | `TITLE_PHRASES`: the title kinds, or the title words, this word stands before in a title phrase, a list (`chief = { attaches = ["office", "military"] }`, `sergeant = { attaches = ["major"] }`, a word where a kind would reach too far; a name that is also a kind of another category names the word, `pope = { attaches = ["saint"] }`, `saint` being a particle kind too, as `family` is a name kind and a modifier title word), compiled into the two-word phrases it makes with each title word of those kinds and each word named (`chief justice`, `sergeant major`); a title that may be a given name on either side of one is a title there ([rules/H9](../../docs/design/rules/H9-title-phrase.md), the title phrase) | +| `attaches` | behavioral | `title` | none | `TITLE_PHRASES`: the title kinds, or the title words, this word stands before in a title phrase, a list (`chief = { attaches = ["office", "military"] }`, `sergeant = { attaches = ["major"] }`, a word where a kind would reach too far; a name that is also a kind of another category names the word, `pope = { attaches = ["saint"] }`, `saint` being a particle kind too, as `family` is a name kind and a modifier title word), compiled into the two-word phrases it makes with each title word of those kinds and each word named (`chief justice`, `sergeant major`); a title that may be a given name on either side of one is a title there ([rules/H9](../../docs/design/rules/H9-title-phrase.md), the title phrase). A word named must have a title reading on by default, or, where the reading naming it is written `default = false`, one in the same file, which the one choice of that file turns on with it (`puan` and `sri` in ms.toml, `Puan Sri`, #1180); a title reading another file's choice alone turns on is refused, since no single choice would hold the phrase | | `after_given` | behavioral | `title` | false | `AFTER_GIVEN_TITLES`, on a `salutation` reading only: written bare at the end of the given part after a family comma, the word is the title, as in `Doe, Jane Mrs` ([rules/H8](../../docs/design/rules/H8-salutation-ending-the-given-part.md), a salutation ending the given part). A salutation borne as a given name or a surname is left out with an exclusion of the property, its counts beside it (`goodman`, `herr`), since a middle name may be either | | `abbreviation` | behavioral | `title` | false | `TITLE_ABBREVIATIONS`: true says the title reading is written short (`maj`, Major; `gen`, General). On a title that may be a given name ([rules/H9](../../docs/design/rules/H9-title-phrase.md)) it makes the word, written with its period at the end of the name, the trailing title, as in `SMITH, JOHN B. MAJ.` ([rules/H5](../../docs/design/rules/H5-trailing-title-run.md), the trailing title run), and on a style it makes the article before it the word's phrase partner, as in `The Hon John Smith` under a Chinese choice ([rules/H9](../../docs/design/rules/H9-title-phrase.md)); on any other title it changes nothing, H5 reading every listed title there already. `expands` names the full form and compiles to nothing | | `acronym` | behavioral | `suffix` | true for `credential`, false for every other kind | true: `SUFFIX_ACRONYMS`, matched with every period removed (`M.D.` is `md`); false: `SUFFIX_WORDS`, and a credential's `CREDENTIAL_WORDS`, a credential written as a word | diff --git a/nameparser/vocab/ms.toml b/nameparser/vocab/ms.toml index b2462a9f9..4acd4ae09 100644 --- a/nameparser/vocab/ms.toml +++ b/nameparser/vocab/ms.toml @@ -10,7 +10,7 @@ salutation = { issue = 606, gender = "m", after_given = true } [[word]] text = "puan" -salutation = { default = false, gender = "f", issue = [606, 1179], decided = 2026-11-19, after_given = true, expands = "Mrs., Madam: \"Puan Siti binti Ahmad\"", note = "off by default, an Indonesian given name (Puan Maharani), as #606 left it out: ORCID's given box 8 Indonesian holders of 252,703 and 1 Malaysian of 62,996; on under a Malay choice, the 2015 honours list writing it in the title run of 295 of 1,504 names (#1179); my-candidates 1, PUAN SRI, the wife of a Tan Sri, which reads given SRI until the phrase is a title (#1180) (tools/name_usage.py --boxes --country MY, 2026-11-19)" } +salutation = { default = false, gender = "f", issue = [606, 1179, 1180], decided = 2026-11-19, after_given = true, attaches = ["sri"], expands = "Mrs., Madam: \"Puan Siti binti Ahmad\"", note = "off by default, an Indonesian given name (Puan Maharani), as #606 left it out: ORCID's given box 8 Indonesian holders of 252,703 and 1 Malaysian of 62,996; on under a Malay choice, the 2015 honours list writing it in the title run of 295 of 1,504 names (#1179); my-candidates 1, PUAN SRI, the wife of a Tan Sri, a phrase rules/H9 reads under the choice, puan attaching to sri (#1180) (tools/name_usage.py --boxes --country MY, 2026-11-19)" } [[word]] text = "tuan" @@ -19,6 +19,14 @@ reason = "Mr., Sir, written before a name in official lists: the 2015 honours li issue = 1179 decided = 2026-11-19 +[[word]] +text = "hajah" +religious = { addresses = "given", gender = "f", issue = 1180, decided = 2026-11-21, expands = "a woman who has made the Hajj: \"Hajah Siti binti Ahmad\"", note = "the 2015 King's birthday honours list writes it in 16 title runs the vocabulary missed of 1,504 names (#1180, 2026-11-08); as a name, ORCID's given box 32 (Brunei 3, Indonesia 1, none from Malaysia, 28 with no country) and family box 1, PatentsView's given box 2 (Brunei 1), the honorific typed in; US Census 2010 under 100, SSA under 5 a year (tools/name_usage.py --boxes --country MY, 2026-11-21)" } + +[[word]] +text = "haji" +religious = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, expands = "one who has made the Hajj: \"Haji Ahmad bin Ali\"", note = "off by default, a given name and a surname: US SSA 105+ births, US Census 2010 1,608, ORCID's given box 232 (Iraq 20, Pakistan 15, Malaysia 10) and family box 1,178 (Iran 156, Iraq 72, Brunei 50, Malaysia 37), PatentsView's given box 24 and family box 43 (tools/name_usage.py --boxes --country MY, 2026-11-21); the 2015 honours list writes it in 40 title runs the vocabulary missed of 1,504 names (#1180). A title at the head only: inside a father's name (bin Haji Abdullah) it stays a name word" } + [[word]] text = "ustaz" religious = { default = false, gender = "m", issue = 1179, decided = 2026-11-19, expands = "a religious teacher: \"Ustaz Ahmad\"", note = "70 of my-candidates' 3,077 distinct names open with USTAZ, 3 more after DATO' or DATUK; ORCID's given box holds it once (China), none in Malaysia's 62,996 holders, PatentsView none, Wikidata none (tools/name_usage.py --boxes --country MY, 2026-11-19); off by default, the Arabic word being written so in Malay and Indonesian alone" } @@ -27,10 +35,42 @@ religious = { default = false, gender = "m", issue = 1179, decided = 2026-11-19, text = "ustazah" religious = { default = false, gender = "f", issue = 1179, decided = 2026-11-19, same_as = "ustaz", expands = "a woman religious teacher", note = "3 of my-candidates' 3,077 distinct names open with USTAZAH, 2 more after DR or DATO'; ORCID's family box holds it once (Indonesia), and no bearer in PatentsView or Wikidata (2026-11-19)" } +[[word]] +text = "datin" +nobility = { addresses = "given", gender = "f", issue = 1180, decided = 2026-11-21, expands = "the wife of a Datuk or Dato': \"Datin Siti binti Ahmad\"", note = "the 2015 King's birthday honours list writes it in 23 title runs the vocabulary missed of 1,504 names (#1180, 2026-11-08); as a name, ORCID's given box 13 (Malaysia 1) and family box 2, PatentsView's family box 3 (US); US Census 2010 under 100, SSA under 5 a year (tools/name_usage.py --boxes --country MY, 2026-11-21)" } + +[[word]] +text = "dato'" +nobility = { addresses = "given", issue = 1180, decided = 2026-11-21, expands = "a federal or state honour, written so in most states: \"Dato' Ahmad bin Ali\"", note = "the 2015 King's birthday honours list writes it in 32 title runs the vocabulary missed of 1,504 names (#1180, 2026-11-08); as a name, ORCID's given box 7 (Malaysia 4) and family box 3 (Malaysia 2), the honour typed in, PatentsView none (tools/name_usage.py --boxes --country MY, 2026-11-21)" } + +[[word]] +text = "dato" +nobility = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, same_as = "dato'", note = "dato' written without its apostrophe, as lists in capitals and forms that refuse the character write it; off by default, being an Italian surname that Italian lists write first: US Census 2010 633, ORCID's family box 68 (Italy 13, Philippines 5) and given box 21, PatentsView's family box 17 (tools/name_usage.py --boxes, 2026-11-21)" } + +[[word]] +text = "dato’" +nobility = { addresses = "given", issue = 1180, decided = 2026-11-21, same_as = "dato'", note = "dato' written with the typographic apostrophe, which the vocabulary does not fold into the straight one, so it is listed beside it as fr.toml lists d’ beside d'" } + +[[word]] +text = "datuk" +nobility = { addresses = "given", issue = 1180, decided = 2026-11-21, expands = "a federal or state honour, addressing the given name: \"Datuk Ahmad bin Ali\"", note = "the 2015 King's birthday honours list writes it in 23 title runs the vocabulary missed of 1,504 names (#1180, 2026-11-08); as a name, ORCID's given box 4 (NL 1, none from Malaysia) and family box 3 of 24,990,909 holders, PatentsView's given box 2, both Malaysian, the honour typed in; US Census 2010 under 100, SSA under 5 a year (tools/name_usage.py --boxes --country MY, 2026-11-21)" } + +[[word]] +text = "sri" +nobility = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, note = "a title only behind tan or puan, in the phrases Tan Sri and Puan Sri (rules/H9, the title phrase), mul.toml's given reading gating it: alone it is an Indonesian and Indian given name (Sri Mulyani). Written behind a head honour as its qualifier (Dato' Sri, Datuk Seri) it stays a name word, the qualifier-after-head question being #1334's" } + [[word]] text = "sultan" nobility = {} +[[word]] +text = "tan" +nobility = { default = false, addresses = "given", attaches = ["sri"], issue = 1180, decided = 2026-11-21, note = "a title only in the phrase Tan Sri, the second highest federal honour (rules/H9, the title phrase), mul.toml's given reading gating it: alone it is the commonest Chinese surname in Malaysia and Singapore, and stays a name word (Tan Chee Chai)" } + +[[word]] +text = "tun" +nobility = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, expands = "the highest federal honour: \"Tun Ahmad bin Ali\"", note = "off by default, a Chinese and Burmese name: ORCID's given box 241 (Myanmar 30, China 21, Malaysia 9) and family box 395 (Myanmar 47, Malaysia 7), PatentsView's given box 53 and family box 22, US Census 2010 1,908 (tools/name_usage.py --boxes --country MY, 2026-11-21); the 2015 honours list writes it once, and once as the surname of a man addressed Encik (#1180)" } + [[word]] text = "cikgu" occupation = { default = false, issue = 1179, decided = 2026-11-19, expands = "teacher, written before a teacher's name: \"Cikgu Ahmad\"", note = "40 of my-candidates' 3,077 distinct names open with CIKGU (CIKGU ZAKRI), 7 more after DATO' or DATUK, and 2 write it CIK GU; no bearer in ORCID's or PatentsView's Malaysian boxes, Wikidata or Nepal's candidates (tools/name_usage.py --boxes --country MY, 2026-11-19); off by default since only Malaysian lists write it" } diff --git a/nameparser/vocab/mul.toml b/nameparser/vocab/mul.toml index f04c82824..aacea8778 100644 --- a/nameparser/vocab/mul.toml +++ b/nameparser/vocab/mul.toml @@ -155,6 +155,14 @@ given = { same_as = "muhammad", note = "Muhammad written short, in Indonesia, Sy text = "mohd" given = { us_ssa = 87, wikidata = 363, as_of = 2026-11-06, same_as = ["muhammad", "mohamad", "mohammad", "mohammed", "mohamed"], note = "Muhammad written short, in Malaysia, Brunei, Singapore and India: ORCID given boxes 8,594 (Malaysia 2,739, India 1,468), PatentsView 304; US SSA male births; Wikidata is a lower bound (Malaysia 276); written with its period at the head of a name (Mohd. Shameem), it read as a title by the leading-abbreviation shape (#1115). The long spellings it stands for are those written where it is: the first words of Malaysia's ORCID given boxes are muhammad 1,971, mohamad 627, mohammad 433, mohamed 183 and mohammed 164, and muhammed 12, a Turkish spelling (Turkey 2,544) left out (the first word of each ORCID given box by the record's country, 2026-11-14 (decisions/vocabulary-model, 2026-11-14 #1383))" } +[[word]] +text = "sri" +given = { us_ssa = 109, as_of = 2026-11-21, note = "an Indonesian and Indian given name (Sri Mulyani): ORCID's given box 7,047 (Indonesia 1,951, India 888, Malaysia 23) and family box 1,009, PatentsView's given box 355 (tools/name_usage.py --boxes --country MY, 2026-11-21). It gates ms.toml's title, a title only behind tan or puan (rules/H9), so a name opening with Sri reads it as the given name and reports the title it might be (#1180)" } + +[[word]] +text = "tan" +given = { us_ssa = 597, as_of = 2026-11-21, note = "a Vietnamese given name (Tân) as well as the commonest Chinese surname of Malaysia and Singapore: ORCID's given box 2,867 (China 400, Vietnam 308, Malaysia 115) and family box 20,353, PatentsView's given box 475 and family box 3,720 (tools/name_usage.py --boxes --country MY, 2026-11-21). It gates ms.toml's title, a title only in the phrase Tan Sri (rules/H9), so a name opening with Tan reads it as the given name and reports the title it might be (#1180)" } + [[word]] text = "dis" family = { note = "the surname Dis: ORCID family boxes 14 (5 with a country, BR, CZ, FI, NL and US 1 each; 9 with none), given boxes 6; PatentsView family boxes 6 (US 4, NL 2); US Census 2010 under 100 and SSA under 5 a year (2026-11-20). It gates cs.toml's and sk.toml's credential DiS, so a name of mixed case ending in the surname written Dis keeps it (rules/S4, S6); written DIS in a name of mixed case it reads as the credential even with no word to spare (Jan DIS), and in a name written in one case with a word to spare (PETR JAN DIS), #969" } diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 4963e250b..9736ae3e2 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1155,6 +1155,123 @@ def _check_cjk_shape_purity(self) -> None: notes="tuan is no title under the pack (decisions/salutation-" "titles, the 2026-11-19 #1179 entry); 3.1.0 reads it " "so; 1.4.0 read middle 'Aminah binti Tuan', family 'Yusof'"), + # #1180: the Malaysian honours. Datuk, Dato', Datin and Hajah are + # titles by default; Tun, Haji and the bare Dato only under the + # Malay pack (decisions/salutation-titles, the 2026-11-21 #1180 + # entry). Notes checked against the 1.4.0 and 3.1.0 wheels on + # 2026-11-21 + Case("datuk_opening_a_name_is_the_title", + "Datuk Ahmad bin Ali", + {"title": "Datuk", "given": "Ahmad", "family": "bin Ali"}, + classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Datuk', middle 'Ahmad'"), + Case("datuk_in_capitals_opening_a_name_is_the_title", + "DATUK AHMAD BIN ALI", + {"title": "DATUK", "given": "AHMAD", "family": "BIN ALI"}, + classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'DATUK', middle 'AHMAD'"), + Case("dato_with_its_apostrophe_opening_a_name_is_the_title", + "Dato' Ahmad bin Ali", + {"title": "Dato'", "given": "Ahmad", "family": "bin Ali"}, + classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given \"Dato'\", middle 'Ahmad'"), + Case("dato_with_the_typographic_apostrophe_is_the_title", + "Dato\u2019 Ahmad bin Ali", + {"title": "Dato\u2019", "given": "Ahmad", "family": "bin Ali"}, + classification="feat(#1180)", + notes="the typographic apostrophe is not folded, so the " + "spelling is listed beside dato'; 1.4.0 through 3.1.0 " + "read given 'Dato\u2019', middle 'Ahmad'"), + Case("datin_opening_a_name_is_the_title", + "Datin Siti binti Ahmad", + {"title": "Datin", "given": "Siti", "family": "binti Ahmad"}, + classification="feat(#1180)", + notes="3.1.0 read given 'Datin', middle 'Siti'; 1.4.0 read " + "given 'Datin', middle 'Siti binti', family 'Ahmad'"), + Case("hajah_opening_a_name_is_the_title", + "Hajah Siti binti Ahmad", + {"title": "Hajah", "given": "Siti", "family": "binti Ahmad"}, + classification="feat(#1180)", + notes="3.1.0 read given 'Hajah', middle 'Siti'; 1.4.0 read " + "given 'Hajah', middle 'Siti binti', family 'Ahmad'"), + Case("datuk_after_a_family_comma_is_the_title", + "Ali, Datuk Ahmad", + {"title": "Datuk", "given": "Ahmad", "family": "Ali"}, + classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Datuk', middle 'Ahmad'"), + Case("seri_behind_datuk_stays_a_name_word", + "Datuk Seri Anwar Ibrahim", + {"title": "Datuk", "given": "Seri", "middle": "Anwar", + "family": "Ibrahim"}, + classification="feat(#1180)", + notes="Seri qualifies the honour before it and is a given name " + "too, the qualifier-after-head question left to #1334; " + "1.4.0 through 3.1.0 read given 'Datuk', middle 'Seri " + "Anwar'"), + Case("the_bare_dato_stays_a_name_word_by_default", + "Dato Mario Rossi", + {"given": "Dato", "middle": "Mario", "family": "Rossi"}, + notes="dato without its apostrophe is an Italian surname, and a " + "title only under the Malay pack"), + Case("haji_stays_a_name_word_by_default", + "Haji Abdul Hadi Awang", + {"given": "Haji", "middle": "Abdul Hadi", "family": "Awang"}, + notes="a given name and a surname, so the title wants a choice " + "(decisions/indic-honorifics, the 2026-11-19 #1469 entry)"), + Case("the_malay_pack_reads_haji_as_the_title", + "Haji Abdul Hadi Awang", + {"title": "Haji", "given": "Abdul Hadi", "family": "Awang"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Haji', middle 'Abdul " + "Hadi'"), + Case("the_malay_pack_keeps_haji_in_the_fathers_name", + "Ahmad bin Haji Abdullah", + {"given": "Ahmad", "family": "bin Haji Abdullah"}, + locale="ms", + notes="a title is read at the head of the name only"), + Case("the_malay_pack_reads_tun_before_dr_as_the_title", + "Tun Dr. Mahathir bin Mohamad", + {"title": "Tun Dr.", "given": "Mahathir", "family": "bin Mohamad"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Tun', middle 'Dr. " + "Mahathir'"), + Case("the_malay_pack_reads_the_surname_tun_after_a_salutation_as_a_title", + "Encik Tun Yoke Wah", + {"title": "Encik Tun", "given": "Yoke", "family": "Wah"}, + locale="ms", classification="feat(#1180)", + notes="the accepted cost: Tun is also a Chinese surname, which " + "is why the title wants the pack (decisions/salutation-" + "titles, the 2026-11-21 #1180 entry); 3.1.0 read title " + "'Encik', given 'Tun'; 1.4.0 read given 'Encik', middle " + "'Tun Yoke'"), + Case("tan_sri_stays_a_name_by_default", + "Tan Sri Muhyiddin Yassin", + {"given": "Tan", "middle": "Sri Muhyiddin", "family": "Yassin"}, + notes="Tan is a surname and Sri a given name, each a title only " + "in the phrase, which the Malay pack turns on"), + Case("the_malay_pack_reads_tan_sri_as_the_title", + "Tan Sri Muhyiddin Yassin", + {"title": "Tan Sri", "given": "Muhyiddin", "family": "Yassin"}, + locale="ms", classification="feat(#1180)", + notes="a phrase rules/H9 reads, tan attaching to sri; 1.4.0 " + "through 3.1.0 read given 'Tan', middle 'Sri Muhyiddin'"), + Case("the_malay_pack_reads_puan_sri_as_the_title", + "Puan Sri Norainee Abdullah", + {"title": "Puan Sri", "given": "Norainee", "family": "Abdullah"}, + locale="ms", classification="feat(#1180)", + notes="3.1.0 read title 'Puan', given 'Sri', middle 'Norainee'; " + "1.4.0 read given 'Puan', middle 'Sri Norainee'"), + Case("the_malay_pack_reads_tan_alone_as_the_given_name", + "Tan Chee Chai", + {"given": "Tan", "middle": "Chee", "family": "Chai"}, + locale="ms", ambiguities=("title-or-name",), + notes="the commonest Chinese surname in Malaysia, a title only " + "before sri (rules/H9); it now reports title-or-name"), + Case("the_malay_pack_reads_the_bare_dato_as_the_title", + "Dato Ahmad bin Ali", + {"title": "Dato", "given": "Ahmad", "family": "bin Ali"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Dato', middle 'Ahmad'"), # #1469: the religious honorifics written before a name in Pakistan # and Bangladesh. Qari, Moulana, Alhaj and Alhajj are titles by # default; Hafiz, Maulana and Haji, borne as given names, and Syed diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 378c22cc9..e5aa173da 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -459,19 +459,28 @@ def test_sushri_is_the_title_only_under_a_strict_hindi_choice() -> None: def test_ms_pack_contents() -> None: # #1179: nothing but a choice of ms, which turns on ms.toml's - # `default = false` readings and changes no other word + # `default = false` readings and changes no other word; #1180 added + # the honours and the two phrases they make from nameparser._reading_index import changed_words, selected assert locales.MS == Locale(code="ms", lexicon=Lexicon.empty(), languages=frozenset({"ms"})) assert not hasattr(locales.MS, "DEVIATES") assert changed_words(selected(locales.MS.languages)) == { - "puan", "cik", "ustaz", "ustazah", "cikgu"} + "puan", "cik", "ustaz", "ustazah", "cikgu", "tun", "haji", "dato", + "tan", "sri", "tan sri", "puan sri"} @pytest.mark.parametrize("text, title, given, family", [ ("Puan Siti binti Ahmad", "Puan", "Siti", "binti Ahmad"), - # Hajah is no title yet (#1180), so it is read as the given name - ("Puan Hajah Siti binti Ahmad", "Puan", "Hajah", "binti Ahmad"), + # Hajah is a title by default since #1180, and joins the run + ("Puan Hajah Siti binti Ahmad", "Puan Hajah", "Siti", "binti Ahmad"), + ("Haji Abdul Hadi Awang", "Haji", "Abdul Hadi", "Awang"), + ("Tun Dr. Mahathir bin Mohamad", "Tun Dr.", "Mahathir", "bin Mohamad"), + ("Tan Sri Muhyiddin Yassin", "Tan Sri", "Muhyiddin", "Yassin"), + ("TAN SRI MUHYIDDIN YASSIN", "TAN SRI", "MUHYIDDIN", "YASSIN"), + ("Yassin, Tan Sri Muhyiddin", "Tan Sri", "Muhyiddin", "Yassin"), + ("Puan Sri Aminah Yusof", "Puan Sri", "Aminah", "Yusof"), + ("Dato Ahmad bin Ali", "Dato", "Ahmad", "bin Ali"), ("PUAN SITI AMINAH", "PUAN", "SITI", "AMINAH"), ("Cik Nadia binti Rahman", "Cik", "Nadia", "binti Rahman"), ("Ustaz Hafiz bin Omar", "Ustaz", "Hafiz", "bin Omar"), @@ -504,9 +513,13 @@ def test_ms_reads_the_malay_titles(text: str, title: str, given: str, "Nguyen Van Tuan", # a salutation as a name word inside a name keeps its place "Ali Puan", - # Dato' is not a title yet (#1180), so a title written after it - # stays a name word, as by default - "Dato' Ustaz Idris", + # Haji inside the father's name stays a name word (#1180) + "Ahmad bin Haji Abdullah", + "Siti binti Haji Ali", + # Sri behind a head honour stays a name word, the + # qualifier-after-head question left to #1334 + "Datuk Seri Anwar Ibrahim", + "Dato' Sri Abu Samah bin Nordin", ]) def test_ms_leaves_these_as_the_default_reads_them(text: str) -> None: assert _require_packed("ms").parse(text).as_dict() == _default_parse(text) @@ -517,10 +530,25 @@ def test_ms_reads_the_indonesian_puan_as_the_title() -> None: # (decisions/salutation-titles, the 2026-11-19 #1179 entry) name = _require_packed("ms").parse("Puan Maharani") assert (name.title, name.given, name.family) == ("Puan", "", "Maharani") - # and Puan Sri, the wife of a Tan Sri, reads Sri as the given name - # until the phrase is a title (#1180) - sri = _require_packed("ms").parse("Puan Sri Aminah Yusof") - assert (sri.title, sri.given) == ("Puan", "Sri") + + + +def test_ms_reads_tan_and_sri_as_name_words_outside_their_phrases() -> None: + # each is a title only in its phrase (rules/H9, #1180): alone it is + # the given name, reporting the title it might be, and the default + # reads no phrase and reports nothing + malay = _require_packed("ms") + for text in ("Tan Chee Chai", "Sri Mulyani"): + name = malay.parse(text) + assert name.title == "" and name.given == text.split()[0] + assert [a.kind.value for a in name.ambiguities] == ["title-or-name"] + assert parse(text).ambiguities == () + # the accepted costs (decisions/salutation-titles, the 2026-11-21 + # #1180 entry): Sri as a given name behind the surname Tan, and Sri + # behind a style, which makes a phrase (rules/H9) + assert malay.parse("Tan Sri Wahyuni").title == "Tan Sri" + assert malay.parse("Hon. Sri Mulyani").title == "Hon. Sri" + assert parse("Tan Sri Wahyuni").title == "" def test_ms_is_plain_since_strict_drops_other_languages_readings() -> None: @@ -2443,6 +2471,13 @@ def _default_corpus() -> list[str]: "Ahmad, Siti Puan", # puan ending the given part (H8) "Rahman, Nadia Cik", # cik ending the given part (H8) "Hafiz Omar Ustaz.", # ustaz, dotted, ending the name (H5) + # #1180's honours + "Tun Ahmad bin Ali", # tun + "HAJI AHMAD", # haji, in one case (rules/H1) + "Ali, Haji Ahmad", # haji after a family comma + "Dato Ahmad bin Ali", # dato without its apostrophe + "Tan Sri Muhyiddin Yassin", # tan sri + "Puan Sri Aminah Yusof", # puan sri ] # hi and bn: each romanized title at the head, in each case, behind a # listed title, after a family comma and before one (rules/H6); a dotted diff --git a/tests/v2/test_vocab.py b/tests/v2/test_vocab.py index 47c4cbf5f..ad4f41714 100644 --- a/tests/v2/test_vocab.py +++ b/tests/v2/test_vocab.py @@ -32,7 +32,7 @@ from tests.checkout import require_checkout -from nameparser import parse +from nameparser import locales, parse, parser_for from nameparser._lexicon import Lexicon from ._differential_fixtures import load_by_path @@ -485,6 +485,12 @@ def _w(body: str) -> str: ("attaches-a-suffix-kind", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { attaches = ["credential"] }')}, "attaches names 'credential', which is not a title kind"), ("attaches-the-generic-kind", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { attaches = ["title"] }')}, "attaches names 'title', which is not a title kind"), ("attaches-a-word-with-no-title-reading", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { attaches = ["zzq"] }')}, "attaches names 'zzq', which is no title kind and no title word"), + # an off-by-default reading may name a partner off by default in its + # own file (#1180), but not one with no title reading at all, nor one + # whose title only another file's choice turns on: no single choice + # would hold the phrase + ("attaches-off-by-default-a-word-with-no-title-reading", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { default = false, attaches = ["zzq"] }')}, "attaches names 'zzq', which is no title kind and no title word on by default or in en.toml"), + ("attaches-off-by-default-a-partner-another-file-turns-on", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { default = false, attaches = ["zzq"] }'), "fr.toml": _w('[[word]]\ntext = "zzq"\noffice = { default = false }')}, "attaches names 'zzq', which is no title kind and no title word on by default or in en.toml"), ("attaches-on-a-suffix", {"en.toml": _w('[[word]]\ntext = "phd"\ncredential = { attaches = ["office"] }')}, "unknown key 'attaches'"), ("attaches-differs-between-files", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { attaches = ["military"] }'), "fr.toml": _w('[[word]]\ntext = "chief"\noffice = {}')}, "attaches"), ("reserved-separators", {"th.toml": _w('[[word]]\ntext = "นาย"\nsalutation = { separators = [] }')}, "reserved, unbuilt, for 3.x"), @@ -1582,6 +1588,19 @@ def test_attaches_may_name_a_title_word_that_is_also_another_kind() -> None: assert c["TITLE_PHRASES"] == frozenset({"zzq saint"}) +def test_an_off_by_default_phrase_may_name_a_partner_off_by_default_in_its_file() -> None: + # the case the check admits since #1180: both readings off by + # default in one file, so the default holds no phrase and the one + # choice of that file turns both on (ms.toml's puan and sri) + c = _compile({"en.toml": _w( + '[[word]]\ntext = "zzq"\nnobility = { default = false, attaches = ["zzr"] }\n\n' + '[[word]]\ntext = "zzr"\nnobility = { default = false }')}) + assert c["TITLE_PHRASES"] == frozenset() + assert "puan sri" not in Lexicon.default()._sets.title_phrases + malay = parser_for(locales.MS).lexicon._sets.title_phrases + assert {"puan sri", "tan sri"} <= malay + + @pytest.mark.parametrize("saint", [ "", '[[word]]\ntext = "saint"\nreligious = { default = false }\n\n'], ids=["no-title-word", "title-reading-off"]) diff --git a/tools/vocab/build.py b/tools/vocab/build.py index cd774c085..253d040ef 100644 --- a/tools/vocab/build.py +++ b/tools/vocab/build.py @@ -1383,6 +1383,18 @@ def check_pool(pool: Pool) -> None: # else the phrase it asks for can never be made title_words = {t for t, rs in live.items() if any(r.category == "title" for r in rs)} + # a reading written `default = false` may also name a word whose + # title reading is off by default IN ITS OWN FILE, the one choice of + # that file turning both on (`puan` and `sri` in ms.toml, #1180); a + # partner switched on by another file's choice alone, or by none, + # makes a phrase no single choice holds + own_titles = {(r.file, r.text) for r in pool.readings + if r.category == "title"} + + def partner(r: Reading, k: str) -> bool: + return k in title_words or ( + not r.on_by_default and (r.file, k) in own_titles) + # a name that is a kind of another category, or the generic # 'title', is refused unless it is also a title word: 'pope' # attaches to the word 'saint', which names a particle kind too, @@ -1391,14 +1403,16 @@ def check_pool(pool: Pool) -> None: for r in pool.readings: for k in r.props.get("attaches", ()) if r.category == "title" else (): if (k in CATEGORY and (CATEGORY[k] != "title" or k == "title") - and k not in title_words): + and not partner(r, k)): raise VocabError( f"{r.where()}: attaches names {k!r}, which is not a " f"title kind or a title word; the kinds: " f"{sorted(t for t, c in CATEGORY.items() if c == 'title' and t != 'title')}") - if k not in CATEGORY and k not in title_words: + if k not in CATEGORY and not partner(r, k): raise VocabError(f"{r.where()}: attaches names {k!r}, which " - f"is no title kind and no title word") + f"is no title kind and no title word" + + ("" if r.on_by_default else + f" on by default or in {r.file}")) # 9: a bound given name that is also a particle must be one that may # be given -- the bound join reads it as a given name. Lexicon raises From 2eedc7b9eadac769d1ab5ad2a494d85154bc043e Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 12:25:21 -0800 Subject: [PATCH 2/3] Fix the review findings: the pack's costs, the build check's rows, and the records (#1180) The decisions entry read the default's my-candidates moves as all right; it now says which words behind an honour are still not the given name and that rules/P12's abdul loses a word to the peel. Under the pack it records the given name Tun and Haji, a style before Tan or Sri (Hon. Tan Ah Kow), and the phrase cut short, and reads the Companies House Haji records as the box-scoring artifact #1469 found. Its breakdowns now add up. The build check gets mutation rows for a partner with only a name reading in the file, a partner off by default beside a reading on by default, and the kind-name branch, a test of the admitted case under a choice, and the file hint on the kind-name branch too. Case rows pin the accepted costs, the comma shapes and the spellings; locale tests pin both family-first orders and the other choices. The #1179 and #1180 release bullets are one; indic-honorifics records haji under the pack; the rules corpus and snapshot take the new H1 example. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/indic-honorifics.md | 1 + docs/design/decisions/salutation-titles.md | 8 +- docs/design/decisions/vocabulary-model.md | 2 +- docs/languages.rst | 17 ++- docs/migrate.rst | 5 +- docs/release_log.rst | 5 +- nameparser/locales/ms.py | 13 ++- nameparser/vocab/README.md | 2 +- nameparser/vocab/ms.toml | 4 +- nameparser/vocab/mul.toml | 4 +- tests/v2/cases.py | 128 +++++++++++++++++++-- tests/v2/test_locales.py | 26 ++++- tests/v2/test_vocab.py | 38 +++++- tools/differential/corpus_rules.jsonl | 1 + tools/differential/snapshot.jsonl | 1 + tools/vocab/build.py | 10 +- 16 files changed, 219 insertions(+), 46 deletions(-) diff --git a/docs/design/decisions/indic-honorifics.md b/docs/design/decisions/indic-honorifics.md index 1add6e800..d84d2795d 100644 --- a/docs/design/decisions/indic-honorifics.md +++ b/docs/design/decisions/indic-honorifics.md @@ -74,4 +74,5 @@ Open: #514 (whether the Tibetan prefix titles Tulku, Khenpo, Geshe, Kyabje and J - UNDER A STRICT CHOICE (`parser_for(locales.BN, strict=True)`, and HI's and MS's) the four read as the given name again, ar.toml not being chosen, as `mufti` and `hajji` already do. - THE NAME WORDS: `syed`, `mian`, `chaudhry` and `makhdoom` open far more names as a given name or a surname than as an honorific, and the boxes agree with today's reading, so no reading is written for them. - MEASURED (`tools/differential/measure.py --base `, master `34771e2d`): the committed snapshot, CLDR and GND agreement and every local corpus but four read as master did. JRC-Names moved 55 names (`qari` 53, `alhaj` 1, `moulana` 1), opensanctions-parliaments 2 (`moulana`, both `pk_na_members`), orcid-researchers 7 and psc-individuals 10 (`qari` 5, `moulana` 3, `alhaj` 2): in every one the word left the given name for the title, the words after it reading as a name without it (where one name word was left, in 14 names, 12 of two words and 2 written behind `Mr`, it is the family, rules/H1: `Qari Khan` → title 'Qari', family 'Khan'), save the byline above and two of orcid-researchers' that open with `Lama`, an Arabic given name that is also a listed title (rules/H1's renunciate class): one written `Lama Alhaj` and a surname, which master read title 'Lama', given 'Alhaj', now reads title 'Lama Alhaj' and the surname as the family, and one holding `Lama` and `Alhajj` and nothing else keeps title 'Lama', given 'Alhajj' and now reports `title-or-name`, its one name word being title vocabulary. Neither reading is the filer's; the cost is `lama`'s, which master paid already. Scored against the filers' boxes, psc-individuals loses 10 records, each a forename box holding the honorific (behind `Mr` in the title box in nine), and orcid-researchers moves 3; JRC-Names reads 8 persons' spellings apart that master read alike, the spellings with the title against those without it. my-candidates, FEC and ClinicalTrials.gov move nothing. +- 2026-11-21 #1180 — `haji` IS A TITLE UNDER `locales.MS`. ms.toml writes it a `religious` reading `default = false`, which the Malay pack turns on, plain or strict (`parser_for(locales.MS, strict=True).parse("Haji Abdul Hadi Awang")` gives title 'Haji'), so the #1469 entry's strict-choice bullet holds for BN and HI and no longer for MS; the default is unchanged (decisions/salutation-titles, the 2026-11-21 #1180 entry). diff --git a/docs/design/decisions/salutation-titles.md b/docs/design/decisions/salutation-titles.md index 54cbdec66..96ba2455d 100644 --- a/docs/design/decisions/salutation-titles.md +++ b/docs/design/decisions/salutation-titles.md @@ -89,8 +89,8 @@ Elsewhere: `justice` and `marshal`, excluded here as common leading-position nam - **Five more, added on the PR's review** (2026-11-20): `field-marshal`, `lieutenant-commander`, `wing-commander`, `chief-marshal` (`Air Chief-Marshal`) and `sergeant-major`, the British ranks the review found still read as name words. Each reads as its spaced twin does at the head, after a family comma and after a second comma, save the same two shapes: a bare rank ending a name, and after a second comma no comma fork where the twin holds a title that may be a given name (`marshal`, `wing`, `major`). None is borne as a name in any source tools/name_usage.py reads, and none moves a name in govuk-people (0 of 6,021) or ukec-individuals (0 of 15,214), measured against the eight with `uv run python tools/differential/snapshot.py --local --base `. - **Where no twin is promised:** a rank that is the whole part before a family comma (`Field-Marshal, Ann` gives family 'Field-Marshal', `Field Marshal, Ann` title 'Field', family 'Marshal'), a rank written alone, and a rank ending a name with a full stop (`John Smith Wing-Commander.` gives title 'Wing-Commander.', the spaced twin title 'Commander.', family 'Wing') read otherwise than the spaced words, which split there; the first eight read the same way (the PR's review, 2026-11-20). - **2026-11-21 #1180 — MALAYSIAN HONOURS: `datuk`, `dato'`, `datin` AND `hajah` ARE TITLES BY DEFAULT; `tun`, `haji`, THE BARE `dato`, `Tan Sri` AND `Puan Sri` UNDER `locales.MS`.** Malaysian names in official use open with a run of honours, and 1.4.0 through 3.1.0 read the first as the given name (`Datuk Ahmad bin Ali` given 'Datuk', middle 'Ahmad'). Decided 2026-11-21 on the issue's scope: the honours as titles, each addressing the given name as `sir` does (rules/H1), so `Datuk Ahmad` gives given 'Ahmad'. `datuk`, `dato'` and `datin` are `nobility`, `hajah` and `haji` `religious`, as `ustaz` is: not `style`, whose words make a phrase with a title that may be a given name behind them (`Hajah Sri Wahyuni` would read title 'Hajah Sri', rules/H9). - - **THE COUNTS** (`tools/name_usage.py --no-wikidata --boxes --country MY`, 2026-11-21, ORCID's 24,990,909 holders and PatentsView's 5,508,446 inventors; each on its word's note). On by default, none borne leading a name but `hajah` once: `datuk` ORCID given box 4 (none Malaysian) and family 3, PatentsView given 2 (both Malaysian, the honour typed in); `dato'` ORCID given 7 (Malaysia 4) and family 3; `datin` ORCID given 13 (Malaysia 1) and family 2; `hajah` ORCID given 32 (Brunei 3, 28 with no country), PatentsView given 2, and one Companies House filer who bears it as her given name (below). Off by default: `tun` ORCID given 241 (Myanmar 30, China 21) and family 395, US Census 2010 1,908; `haji` given 232 and family 1,178, US SSA 105+ births (decisions/indic-honorifics left its title wanting a choice, 2026-11-19 #1469); the bare `dato` an Italian surname (US Census 2010 633, ORCID family 68) and a Georgian given name (ORCID's 4 Georgian regressions below); `tan` ORCID given 2,867 and family 20,353, US SSA 597+; `sri` ORCID given 7,047, US SSA 109+. The 2015 King's birthday honours list, as #1180 measured it on 2026-11-08 and not rebuilt here, misses `Dato'` in 32 runs of 1,504 names, `Datuk` 23, `Datin` 23, `Haji` 40, `Hajah` 16, `Tun` 1 and `Puan Sri` 1. + - **THE COUNTS** (`tools/name_usage.py --no-wikidata --boxes --country MY`, 2026-11-21, ORCID's 24,990,909 holders and PatentsView's 5,508,446 inventors; each on its word's note). On by default, none borne leading a name but `hajah` once: `datuk` ORCID given box 4 (none Malaysian) and family 3, PatentsView given 2 (both Malaysian, the honour typed in); `dato'` ORCID given 7 (Malaysia 4) and family 3; `datin` ORCID given 13 (Malaysia 1) and family 2; `hajah` ORCID given 32 (Brunei 3, 28 with no country), PatentsView given 2, and one Companies House filer who bears it as her given name (below). Off by default: `tun` ORCID given 241 (Myanmar 30, China 21) and family 395, US Census 2010 1,908; `haji` given 232 and family 1,178, US SSA 105+ births (decisions/indic-honorifics left its title wanting a choice, 2026-11-19 #1469); the bare `dato` an Italian surname (US Census 2010 633, ORCID family 68) and a Georgian given name (ORCID's given box 3 in Georgia, and 3 of the regressions below); `tan` ORCID given 2,867 and family 20,353, US SSA 597+; `sri` ORCID given 7,047, US SSA 109+. The 2015 King's birthday honours list, as #1180 measured it on 2026-11-08 and not rebuilt here, misses `Dato'` in 32 runs of 1,504 names, `Datuk` 23, `Datin` 23, `Haji` 40, `Hajah` 16, `Tun` 1 and `Puan Sri` 1. - **THE PHRASES.** `tan` and `sri` hold a `given` reading in mul.toml, so each title is gated (rules/H9) and a title only in a phrase: `tan` and `puan` attach to `sri`. Alone each stays a name word under the pack (`Tan Chee Chai` given 'Tan', `Sri Mulyani` given 'Sri'), reporting `title-or-name`. The build refused a phrase whose two halves are both off by default; it admits one written in one file since this day (decisions/vocabulary-model, the 2026-11-21 #1180 entry, which records why the alternative, `sri`'s title on by default, was declined). By default no phrase is compiled and no `tan`, `sri` or `puan` title. - - **MEASURED** against master `488ea605`, py3.11, `tools/differential/local_agreement.py SOURCE --base ` (and `--locale ms`), `snapshot.py --local SOURCE --base ` and `config_diff.py diff --local SOURCE default plain:MS` in both trees. By default: my-candidates 174 of 3,077 distinct names move, each an honour at the head now the title (`DATO' AZAMI` given 'AZAMI'), none wrong; ORCID 0 fixed, 0 broken, 3 changed (an honour typed into the given box, now the title); PatentsView 0 broken, 1 title typed in; Companies House 1 regression, `Hajah` (below); opensanctions-parliaments, nepal-candidates and the committed snapshot no move. Under `locales.MS`, against the pack on master: ORCID 26 regressions (`haji` 17, Tanzania 8, Ethiopia 3 and one each in six other countries; `tun` 5, Myanmar 4 and a Burmese name in Malaysia, `TUN AUNG`; the bare `dato` 4, Georgia 3), 19 more titles typed in read as the title, 2 fewer; Companies House 36 (`haji` 30, 20 of them British filers and 4 Pakistani; `tun` 2; the bare `dato` 1, Georgian; `hajah` 1, the default's; and 2 where the filer typed the honours into the forename box, read right); PatentsView 4 (2 of them honours typed into the given box, read right). On my-candidates the pack reads 248 names differently from the default, where master's reads 117: 197 a title in the role fields (`ustaz` 72, `cikgu` 45, `haji` 37, `dato` 29, `Tan Sri` 6, `ustazah` 5, `cik` 2, `Puan Sri` 1), and 51 the same roles with a new `title-or-name` report (36 Chinese names written family first with `TAN`, 14 `DATO' SRI`). - - **ACCEPTED.** By default, a woman whose given name is Hajah reads it as the title (`Miss Hajah Conteh`, a Companies House filer, title 'Miss Hajah'). Under the pack: a Chinese surname `Tun` after a salutation (`Encik Tun Yoke Wah` title 'Encik Tun'), as #1180 found in the honours list; the citation `Haji A` (title 'Haji', given 'A'); the surname `Tan` before a given name `Sri` (`Tan Sri Wahyuni` title 'Tan Sri'); `Sri` behind a style (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9); the bare `Dato` of an Italian or Georgian name (`Dato Mario`); and the `title-or-name` report on every name opening with `Tan` or `Sri`, the cost of a gated title, which by default reports nothing. - - **LEFT OUT**, each the issue's: `Sri` and `Seri` behind a head honour (`Dato' Sri`, `Datuk Seri`, which read given 'Sri'), `Laks. Muda` and `Prof. Madya`, the qualifier written after its head (#1334); `YB`, `YM` and `YA`, two capitals, the shape of paired initials (#1205); the police ranks `ASP`, `ACP`, `DSP`, `SAC` and `DCP`; the service designations `TUDM` and `TLDM`. Found here and not changed: under the pack `Dato' Ustaz Idris` reads family 'Idris', the run addressing as its last title, `ustaz`, does, by the family (#1179's reading). + - **MEASURED** against master `488ea605`, py3.11, `tools/differential/local_agreement.py SOURCE --base ` (and with `--locale ms`, whose figures compare the pack in this tree with master's pack), `snapshot.py --local SOURCE --base `, and `config_diff.py diff --local SOURCE default plain:MS` run in each tree (the pack against the default in that tree). By default: my-candidates 174 of 3,077 distinct names move, each now reading an honour as the title (`DATO'` first 101, `DATUK` 69, `DATIN` and `HAJAH` 1 each, and 2 with `DATO'` behind `PROF.` or `UST.`). The word behind the honour is then the given name, which is the person's in most (`DATO' AZAMI` given 'AZAMI') and not where a word the default does not read stands there: a qualifier (given 'SERI' 23, 'SRI' 14, 'WIRA' 5, #1334) or a title off by default (given 'HAJI' 11, 'HJ' 3, 'CIKGU' 4, 'USTAZ' 3); and peeling the honour leaves `ABDUL` short of rules/P12's four name words (`DATO' RADHI ABDUL RAZAK` family 'ABDUL RAZAK' → 'RAZAK', middle 'ABDUL', 2 names), the reading the name has without the honour. ORCID 0 fixed, 0 broken, 3 changed (an honour typed into the given box, now the title); PatentsView 0 broken, 1 title typed in; Companies House 1 regression, `Hajah` (below); opensanctions-parliaments, nepal-candidates and the committed snapshot no move. Under `locales.MS`, against master's pack: ORCID 26 regressions (`haji` 17, Tanzania 8, Ethiopia 3 and one each in six other countries; `tun` 5, Myanmar 4 and a Burmese name in Malaysia, `TUN AUNG`; the bare `dato` 4, Georgia 3), 14 changed, 6 of them a Burmese, Singaporean or Thai given name Tun read as the title (a name shaped `Tun Tun Hla`, title 'Tun Tun', given 'Hla'), and 19 more counted as a title typed into the given box, 10 of which are such a given name Tun (Singapore 4, Myanmar 3) and 9 `Haji`, with 2 fewer (a name shaped `Dr. Haji Ali`, losing the given name Haji); Companies House 36 (`haji` 30, 20 of them British filers and 4 Pakistani, most the honour typed into the forename box, which a box score counts as a miss, decisions/indic-honorifics' #1469 entry; `tun` 2, given names; the bare `dato` 1, Georgian; `hajah` 1, the default's; and 2 where the filer typed the honours into the forename box, one read right and one, `Tan Sri Dato Seri …`, reading given 'Seri', #1334's shape); PatentsView 4 (2 a given name Tun, 2 honours typed into the given box, read right). On my-candidates the pack reads 248 names differently from the default, where master's reads 117: 197 a title in the role fields (`ustaz` 72, `cikgu` 45, `haji` 37, `dato` 29, `Tan Sri` 6, `ustazah` 5, `cik` 2, `Puan Sri` 1), and 51 the same roles with a new `title-or-name` report (36 Chinese names written family first with `TAN`, 14 `DATO' SRI`, 1 `DATO' TAN`). No local corpus name has a style before `Tan` or `Sri` under the pack. + - **ACCEPTED.** By default, a woman whose given name is Hajah reads it as the title (one Companies House filer, a name shaped `Miss Hajah Kamara`, title 'Miss Hajah'), and peeling an honour leaves a name its reading without the honour (rules/P12's `abdul`, above). Under the pack: a given name or surname `Tun` opening a name, Burmese, Chinese or Singaporean (`Tun Tun Hla` title 'Tun Tun', given 'Hla'; `Encik Tun Yoke Wah` title 'Encik Tun', as #1180 found in the honours list); a given name `Haji` opening one (`Haji Juma` given 'Juma') and the citation `Haji A` (title 'Haji', given 'A'); the surname `Tan` before a given name `Sri` (`Tan Sri Wahyuni` title 'Tan Sri'); a style before `Tan` or `Sri`, which makes a phrase (`Hon. Tan Ah Kow` title 'Hon. Tan', `Hon. Sri Mulyani` title 'Hon. Sri', rules/H9; a strict choice keeps given 'Tan' and 'Sri', dropping en.toml's style), the cost option A would have put in the default (decisions/vocabulary-model, the same day's entry), paid here under the pack alone; the phrase cut short, which leaves its first half a title as `Field Marshal` does by default (`Tan Sri` alone title 'Tan', given 'Sri'; `Tan Sri, Muhyiddin` title 'Tan', family 'Sri'); the bare `Dato` of an Italian or Georgian name (`Dato Mario`); and the `title-or-name` report on `Tan` or `Sri` wherever no phrase takes it, opening a name or behind another title (`Tan Chee Chai`, `Dato' Sri Ahmad`), the cost of a gated title, which by default reports nothing. + - **LEFT OUT**, each the issue's: `Sri` and `Seri` behind a head honour (`Dato' Sri`, `Datuk Seri`, which read given 'Sri'), `Laks. Muda` and `Prof. Madya`, the qualifier written after its head (#1334); `YB`, `YM` and `YA`, two capitals, the shape of paired initials (#1205); the police ranks `ASP`, `ACP`, `DSP`, `SAC` and `DCP`; the service designations `TUDM` and `TLDM`; the apostrophes `‘` (U+2018) and `ʼ` (U+02BC), which no local corpus writes after `Dato` (nor `’`, listed as the brief asked, 2026-11-21). Found here and not changed: under the pack `Dato' Ustaz Idris` reads family 'Idris', the run addressing as its last title, `ustaz`, does, by the family (#1179's reading). diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 9dd9deeb7..8433f5136 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -637,4 +637,4 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis ACCEPTED: a person whose given name is `Shri`, or opens with it, reads the salutation under the pack: `Verma, Shri` gives title 'Shri' and no given name, `Shri Mehra` title 'Shri', family 'Mehra', and `Shri Lal Mehra` given 'Lal'. Nothing written tells `Shri Lal`, a given name of two words, from `Shri Ravi`, the salutation before one. A narrower reading, the title only with two or more name words behind it, keeps `Shri Mehra` and loses the 202 Sansad spellings written `Shri Gopalan`, so it was not taken. NOT `after_given` (rules/H8): rules/H8 leaves out a salutation borne as a given name, since a middle name may be one, and decisions/H8 left the Devanagari `श्री` out on that doubt; `shri` is borne as one, and the roll never asks for the property. in_sansad writes the salutation in two shapes, before the given name after a family comma (`Verma, Shri Ravi`, 653 of opensanctions-parliaments' distinct names) and after a full name and a comma (`Ravi Verma, Shri`), both read as the title without it, and holds no `Family, Given Shri`. Measured against the same reading carrying the property, the recipe below moves 2 names, both reading better without it: an FEC filer whose given name of two words ends in the word (`FAMILY, GIVEN SHRI`), whom the property read as given 'GIVEN' and title 'SHRI', and a Sansad spelling with the salutation in brackets (`(Shri) Ravi Kumar`), which the property left the nickname and which reads as the title without it. So `Verma, Ravi Shri` keeps middle 'Shri' under the pack, as `वर्मा, रवि श्री` keeps middle 'श्री', and the word records the refusal (`excluded = { after_given = ... }` on its entry); the dotted `Verma, Ravi Shri.` is the title by rules/H5's trailing vocabulary, as `Shri.` ending a name is. Recompute: the command above from a checkout of this change; the 2 moves the property makes with `'expr:Parser(lexicon=parser_for(locales.HI).lexicon.remove("shri", kind="salutation").add("shri", kind="salutation", after_given=True), policy=parser_for(locales.HI).policy)'` in place of the first configuration; the person counts from `raw.jsonl`'s in_sansad rows, their `entity` kept where `name` holds `shri` as a word, and where it opens with it (a bracket allowed); the in_sansad figure with `--local opensanctions-parliaments --group in_sansad` and no `--match`; each moved name read from `--readings `, the two configurations' first field compared line by line. -- 2026-11-21 #1180 — A PHRASE MAY BE WRITTEN WHOLLY OFF BY DEFAULT IN ONE FILE. `Tan Sri` and `Puan Sri`, Malaysian honours, are phrases rules/H9 reads, `tan` and `puan` attaching to `sri`, each a title off by default in ms.toml for `locales.MS` (decisions/salutation-titles, the same day's entry). The build refused them: `attaches` had to name a word with a title reading ON by default, and `sri` holds none, hi.toml excluding it as a salutation and the exclusion refusing every title kind of a reading on by default. Decided 2026-11-21, B over A. A: turn `sri`'s title on by default, gated by mul.toml's `given` reading, and narrow hi.toml's exclusion. It moved no corpus name (0 of the 597 local-corpus names holding `sri`, `config_diff.py diff --local all --match '(?i)(^|[\s,.])sri([\s,.]|$)' default 'expr:Parser(lexicon=Lexicon.default().add("sri", kind="given").add("sri", kind="nobility", addresses="given"))'`, master `488ea605`), but it moved the default to satisfy a tool rule, and a style before the word makes a phrase there (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9). B: the build check admits a partner whose title reading is off by default in the reading's own file, where the reading is off by default too, so the default compiles no phrase and holds no `sri` title (`nameparser/config/_compiled.py` holds no `tan`, `sri` or `puan`), and the one choice of the file turns both on. The check still refuses a partner with no title reading and one another file's choice turns on, each a mutation in tests/v2/test_vocab.py. A caller's `Lexicon.add` had no such check and gets none: a phrase naming no title word compiles to nothing, an inert entry (AGENTS.md, invariants guard harm, not no-ops), and under a choice the compile builds a phrase only from the title words the chosen pool holds. +- 2026-11-21 #1180 — A PHRASE MAY BE WRITTEN WHOLLY OFF BY DEFAULT IN ONE FILE. `Tan Sri` and `Puan Sri`, Malaysian honours, are phrases rules/H9 reads, `tan` and `puan` attaching to `sri`, each a title off by default in ms.toml for `locales.MS` (decisions/salutation-titles, the same day's entry). The build refused them: `attaches` had to name a word with a title reading ON by default, and `sri` holds none, hi.toml excluding it as a salutation and the exclusion refusing every title kind of a reading on by default. Decided 2026-11-21, B over A. A: turn `sri`'s title on by default, gated by mul.toml's `given` reading, and narrow hi.toml's exclusion. It moved no corpus name (0 of the 597 local-corpus names holding `sri`, `config_diff.py diff --local all --match '(?i)(^|[\s,.])sri([\s,.]|$)' default 'expr:Parser(lexicon=Lexicon.default().add("sri", kind="given").add("sri", kind="nobility", addresses="given"))'`, master `488ea605`), but it moved the default to satisfy a tool rule, and a style before the word makes a phrase there (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9). B: the build check admits a partner whose title reading is off by default in the reading's own file, where the reading is off by default too, so the default compiles no phrase and holds no `sri` title (`nameparser/config/_compiled.py` holds no `tan`, `sri` or `puan`), and the one choice of the file turns both on. The check still refuses a partner with no title reading, one with only a name reading in the file, one another file turns on, even where a choice of the reading's file selects that file too (`pt.toml` under `pt-BR`, narrower than the reason needs, so a phrase's two halves stand in one file), and a partner off by default beside a reading on by default, each a mutation in tests/v2/test_vocab.py. Option B pays A's style cost under the pack alone (`Hon. Sri Mulyani`, and `Hon. Tan Ah Kow` title 'Hon. Tan'), recorded in decisions/salutation-titles' entry. A caller's `Lexicon.add` had no such check and gets none: a phrase naming no title word compiles to nothing, an inert entry (AGENTS.md, invariants guard harm, not no-ops), and under a choice the compile builds a phrase only from the title words the chosen pool holds. diff --git a/docs/languages.rst b/docs/languages.rst index 6681435d6..b3fb9b463 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -1561,8 +1561,8 @@ does not. Choose the pack for Malaysian lists, not Indonesian ones. The honours ``Datuk``, ``Dato'`` and ``Datin`` and the pilgrim's -``Hajah`` are titles by default, each naming the given name as ``Sir`` -does. The pack adds the honours that are names elsewhere: ``Tun``, a +``Hajah`` are titles by default, each addressing the given name, as +``Sir`` does. The pack adds the honours that are names elsewhere: ``Tun``, a Chinese and Burmese name; ``Haji``, a given name and a surname; ``Dato`` written without its apostrophe, an Italian surname and a Georgian given name; and the phrases ``Tan Sri`` and ``Puan Sri``: @@ -1586,17 +1586,22 @@ name, and the pack reports the title it might be, so a Chinese name written family first reports one under the pack (``Tan Chee Chai`` gives given ``Tan`` and a ``title-or-name`` report). A ``Sri`` that is a given name behind the surname ``Tan`` reads as the phrase -(``Tan Sri Wahyuni`` gives title ``Tan Sri``). +(``Tan Sri Wahyuni`` gives title ``Tan Sri``), and so does either word +behind a style (``Hon. Tan Ah Kow`` gives title ``Hon. Tan``). On Malaysia's election candidates, 3,077 distinct names written in -capitals, the default reads 174 honours at the head of a name as the -title (``DATO'`` 101, ``DATUK`` 69), and the pack reads 248 differently +capitals, the default reads an honour as the title in 174 names +(``DATO'`` 103, ``DATUK`` 69, ``DATIN`` 1, ``HAJAH`` 1); the word behind +it is then the given name, which for a qualifier of the honour (``DATO' +SRI``, ``DATUK SERI``) or a title the default does not read (``HAJI``, +``CIKGU``) is still not the person's. The pack reads 248 differently from the default. 197 of them read a title the default read as the given name: ``USTAZ`` 72, ``CIKGU`` 45, ``HAJI`` 37, ``DATO`` 29, ``TAN SRI`` 6, ``USTAZAH`` 5, ``CIK`` 2 and ``PUAN SRI`` 1. The two ``CIK`` are ``Cikgu`` written in two words (``CIK GU``), and read given ``GU``. The other 51 read the same and add a report: 36 Chinese names -written family first with ``TAN``, 14 ``DATO' SRI``. Among the records +written family first with ``TAN``, 14 ``DATO' SRI`` and 1 ``DATO' +TAN``. Among the records ORCID, PatentsView and Companies House hold of Malaysians, Indonesians and Singaporeans, each split into boxes by the person or the filer, the share whose boxes the parse matches moves by at most 0.1 point under diff --git a/docs/migrate.rst b/docs/migrate.rst index 471c1d547..b0bb9ab96 100644 --- a/docs/migrate.rst +++ b/docs/migrate.rst @@ -2394,8 +2394,9 @@ Religious titles before a name ``Qari``, ``Moulana``, ``Alhaj`` and ``Alhajj``, written before a name in Pakistan and Bangladesh, are titles, where 1.4 through 3.1 read them as the given name. ``Hafiz``, ``Hafez``, ``Haji`` and the spelling -``Maulana`` are still read as given names, since many people bear them -as names: +``Maulana`` are still read as given names by default, since many people +bear them as names (``locales.MS`` reads ``Haji`` as a title, +:ref:`malay-names`): .. doctest:: diff --git a/docs/release_log.rst b/docs/release_log.rst index 9c9d92200..3ddc45cd8 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,7 +4,6 @@ Release Log nameparser 3.2 is under development. - - **Add the Malaysian honours Datuk, Dato', Datin and Hajah as titles, and Tun, Haji, Tan Sri and Puan Sri under locales.MS.** ``parse("Datuk Ahmad bin Ali")`` gives title ``Datuk``, given ``Ahmad``, where 1.4.0 through 3.1.0 gave given ``Datuk``, middle ``Ahmad``; ``parser_for(locales.MS).parse("Tan Sri Muhyiddin Yassin")`` gives title ``Tan Sri``. Under the pack, Tan and Sri alone stay name words with a ``title-or-name`` report (``Tan Chee Chai``), and Sri written behind another honour stays a name word (``Datuk Seri Anwar Ibrahim`` gives given ``Seri``). :issue:`1180` - **Add Brazilian Portuguese familiar forms, found in the names Brazil's election candidates put on the ballot.** With ``familiar-form`` accepted, ``Tião Alves`` / ``Sebastião Alves`` and ``Cida Silva`` / ``Aparecida Silva`` are consistent, where 3.1.0 read a conflict. They are filed under ``pt-BR``, so a strict choice of another language leaves them out, and one name spelled two ways (``Elizangela`` / ``Elisangela``) is not among them. :issue:`1495` - **Add the Czech and Slovak post-nominals DiS., DrSc. and ArtD. as credentials.** ``parse("Jan Novák, DiS.")`` gives suffix ``DiS.``, where 1.4.0 through 3.1.0 gave title ``DiS.``; DiS., which is also a surname, reads as the credential after a full name and a comma, and written as ``DiS.`` or ``Dis`` it stays a name word at the end of a name of mixed case without one (``Jan Novák DiS.``), while a surname written ``DIS`` there reads as the credential (``Jan DIS``). :issue:`969` - **Add credentials: BCh, BChir and BMBCh, the Nigerian marks mni, fwc, fsi, fnse, psc and ndc, and the Hong Kong and Singapore honours GBM, GBS, SBS, BBS and BBM.** ``parse("Jane Doe, BCh")`` gives suffix ``BCh``, where 1.4.0 through 3.1.0 gave given ``BCh``, family ``Jane Doe``. A word spelling one of them after a one-word family name and a comma, or ending a name, reads as the credential (``Bello, MNI``). :issue:`1361`, :issue:`1228`, :issue:`1182` @@ -19,9 +18,9 @@ Release Log - **Add familiar forms in Central and Eastern European and Balkan languages, found in Wikidata.** With ``familiar-form`` accepted, ``Erzsi Nagy`` / ``Erzsébet Nagy`` and ``Jára Novák`` / ``Jaroslav Novák`` are consistent, where 3.1.0 read a conflict, Czech and Hungarian gaining the most; the Russian, Ukrainian, Belarusian, Bulgarian and most Serbian pairs are written in Cyrillic, so a name romanized in Latin letters does not reach them. :issue:`1387` - **Read a second name written after @ or urf as the nickname.** ``parse("Rahim @ Jaki bin Osman")`` gives given ``Rahim``, nickname ``Jaki``, family ``bin Osman``, where 1.4.0 through 3.1.0 gave middle ``@ Jaki``; the alias runs to a patronymic particle, another marker or a comma, and a one-word alias before the family name takes the family name with it (``Rahim @ Jaki Osman`` gives no family name). ``alias`` and ``aka`` are read so only where you add them (``Lexicon.add("aka", kind="alias_marker")``); an ``@`` glued to a word is part of it. :issue:`1164` - **Fix an Arabic-script name written with الدين or الله second, which read as two names.** ``parse("نور الدين سامر حداد")`` gives given ``نور الدين``, where 1.4.0 through 3.1.0 gave given ``نور``, middle ``الدين سامر``; ending the name the pair is the family name, and ``الدین``, ``اله`` and ``اللہ`` read the same way; a name of two name words keeps them apart. ``Lexicon.add`` accepts a new kind, ``bound_second``, for such a word. :issue:`1072` - - **Add Qari, Moulana, Alhaj and Alhajj as titles, the religious titles written before a name in Pakistan and Bangladesh.** ``parse("Qari Ahmed Khan")`` gives title ``Qari``, given ``Ahmed``, where 1.4.0 through 3.1.0 gave given ``Qari``, middle ``Ahmed``. ``Hafiz``, ``Hafez``, ``Haji`` and the spelling ``Maulana``, often borne as given names, still read as the given name. :issue:`1469` + - **Add Qari, Moulana, Alhaj and Alhajj as titles, the religious titles written before a name in Pakistan and Bangladesh.** ``parse("Qari Ahmed Khan")`` gives title ``Qari``, given ``Ahmed``, where 1.4.0 through 3.1.0 gave given ``Qari``, middle ``Ahmed``. ``Hafiz``, ``Hafez``, ``Haji`` and the spelling ``Maulana``, often borne as given names, still read as the given name by default (``locales.MS`` reads ``Haji`` as a title). :issue:`1469` - **Fix Abdel, Abd and Abou past the first word of a name, which read as a middle name of their own.** ``parse("Tariq Abdel Aziz")`` gives family ``Abdel Aziz``, where 1.4.0 through 3.1.0 gave middle ``Abdel``, family ``Aziz``. ``Abdul`` joins only in a name of four words or more, titles and suffixes not counted, so ``Tariq Abdul Aziz`` keeps middle ``Abdul``; and after a family comma ``Abd`` before a name word is no longer the credential ABD. :issue:`1464` - - **Add locales.MS, a Malay pack, which reads Malaysian titles written before a name: Puan, Cik, Ustaz, Ustazah and Cikgu.** ``parser_for(locales.MS).parse("Puan Siti binti Ahmad")`` gives title ``Puan``, given ``Siti``, family ``binti Ahmad``, where the default, as 1.4.0 through 3.1.0, gives given ``Puan``; ``Tuan`` stays a name word, being a hereditary prefix and a Vietnamese given name, and the pack reads the Indonesian given name ``Puan`` as the title too (``Puan Maharani``): keep it to Malaysian names. See :ref:`malay-names`. :issue:`1179` + - **Add locales.MS, a Malay pack, and read the Malaysian honours Datuk, Dato', Datin and Hajah as titles.** ``parse("Datuk Ahmad bin Ali")`` gives title ``Datuk``, given ``Ahmad``, where 1.4.0 through 3.1.0 gave given ``Datuk``, middle ``Ahmad``; ``parser_for(locales.MS)`` also reads Puan, Cik, Ustaz, Ustazah, Cikgu, Tun, Haji and the phrases Tan Sri and Puan Sri as titles (``Puan Siti binti Ahmad`` gives title ``Puan``, where the default gives given ``Puan``). Keep the pack to Malaysian names: it reads the Indonesian given name ``Puan`` and the Burmese given name ``Tun`` as titles (``Puan Maharani``); ``Tuan``, a hereditary prefix, stays a name word, and so do ``Tan`` and ``Sri`` outside their phrase, each with a ``title-or-name`` report. See :ref:`malay-names`. :issue:`1179`, :issue:`1180` - **Change Parser.suggest() to suggest two_family_names for a list whose names end in two family names, and add Signal.FIRST_SURNAME, the signal that votes for it.** ``Parser().suggest(["María García López", "Juan Pérez Ruiz", "Ana Martínez Soto"]).patch`` gives ``PolicyPatch(two_family_names=True)``, where 3.1.0 suggested nothing; it is weighed only where the list's order is given-first, and lists measured from Argentina, Brazil and Portugal are rarely or never suggested it. ``NameEvidence.votes`` may now hold ``True`` or ``False``, the switch's value a name votes for. :issue:`1452` - **Fix Arabic titles written short, which read as the given name, and stop giving initials for Arabic-script names.** ``parse("د. أحمد علي حسن")`` gives title ``د.``, given ``أحمد``, where 1.4.0 through 3.1.0 gave given ``د.``; ``أ.د.``, ``م.م.``, a title glued to the name and the ranks ``اللواء`` and ``المستشار`` read as titles too, and ``initials()`` gives nothing for a word in Arabic script, as for Thai and Burmese, nor does the name match read its letter as an initial. A title written with a slash for its full stop reads as the title too, in any script (``د/ أحمد``, ``Dr/Jane Smith``), where 1.4.0 through 3.1.0 read the given name. :issue:`1149` - **Change Parser.suggest() to read where a Russian-style patronymic stands as a vote on the order, and add Signal.PATRONYMIC_POSITION, the signal that casts it.** ``Parser().suggest(["Sidorov Ivan Petrovich", "Volkov Pavel Sergeevich", "Orlova Anna Ivanovna", "Zaitsev Oleg Nikolaevich", "Belova Vera Andreevna"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=...)``, where 3.1.0 gave the rule with the given-first order, which misread any name of two words in such a list (``Sidorov Ivan`` gave family ``Ivan``); a patronymic in the middle votes given-first. :issue:`1447` diff --git a/nameparser/locales/ms.py b/nameparser/locales/ms.py index 895c0e020..4e3ee4805 100644 --- a/nameparser/locales/ms.py +++ b/nameparser/locales/ms.py @@ -12,11 +12,14 @@ ``Datin`` and ``Hajah`` are titles by default already. Each is off by default because a word of it is a name elsewhere (``Puan``, an Indonesian given name, as in ``Puan Maharani``; ``Tun`` and ``Tan``, -Chinese surnames; ``Haji``, a given name and a surname; ``Dato``, an -Italian surname) or is written so only in Malaysian lists. ``Tan`` and -``Sri`` alone stay name words under the pack, each a title only in its -phrase (rules/H9), so a name opening with either reports the title it -might be (``Tan Chee Chai`` reads given ``Tan``). +Chinese surnames; ``Sri``, an Indonesian and Indian given name; +``Haji``, a given name and a surname; ``Dato``, an Italian surname and +a Georgian given name) or is written so only in Malaysian lists. ``Tan`` and +``Sri`` are each a title only in its phrase (rules/H9), so a name +opening with either and no phrase stays a name word under the pack and +reports the title it might be (``Tan Chee Chai`` reads given ``Tan``); +a style before either makes a phrase of its own (``Hon. Tan Ah Kow`` +gives title ``Hon. Tan``). ``Tuan`` is left a name word under the pack too: Malaysians who file their own names write it first as the hereditary prefix, repeated before diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index 357194b0e..38e314960 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -185,7 +185,7 @@ A property is **behavioral** when it compiles into a set and so changes how name | Property | Type | Applies to | Unwritten | Effect | |---|---|---|---|---| | `addresses` | behavioral | `title` | `"family"` | `"given"` adds the word to `GIVEN_NAME_TITLES`: `Sir John` reads `John` as the given name ([rules/H1](../../docs/design/rules/H1-title-and-one-name-word.md), a title and one name word) | -| `attaches` | behavioral | `title` | none | `TITLE_PHRASES`: the title kinds, or the title words, this word stands before in a title phrase, a list (`chief = { attaches = ["office", "military"] }`, `sergeant = { attaches = ["major"] }`, a word where a kind would reach too far; a name that is also a kind of another category names the word, `pope = { attaches = ["saint"] }`, `saint` being a particle kind too, as `family` is a name kind and a modifier title word), compiled into the two-word phrases it makes with each title word of those kinds and each word named (`chief justice`, `sergeant major`); a title that may be a given name on either side of one is a title there ([rules/H9](../../docs/design/rules/H9-title-phrase.md), the title phrase). A word named must have a title reading on by default, or, where the reading naming it is written `default = false`, one in the same file, which the one choice of that file turns on with it (`puan` and `sri` in ms.toml, `Puan Sri`, #1180); a title reading another file's choice alone turns on is refused, since no single choice would hold the phrase | +| `attaches` | behavioral | `title` | none | `TITLE_PHRASES`: the title kinds, or the title words, this word stands before in a title phrase, a list (`chief = { attaches = ["office", "military"] }`, `sergeant = { attaches = ["major"] }`, a word where a kind would reach too far; a name that is also a kind of another category names the word, `pope = { attaches = ["saint"] }`, `saint` being a particle kind too, as `family` is a name kind and a modifier title word), compiled into the two-word phrases it makes with each title word of those kinds and each word named (`chief justice`, `sergeant major`); a title that may be a given name on either side of one is a title there ([rules/H9](../../docs/design/rules/H9-title-phrase.md), the title phrase). A word named must have a title reading on by default, or, where the reading naming it is written `default = false`, one in the same file, which the one choice of that file turns on with it (`puan` and `sri` in ms.toml, `Puan Sri`, #1180); a title reading only another file turns on is refused, even one a choice of the reading's file also selects (`pt.toml` under `pt-BR`), so the two halves of such a phrase are written in one file | | `after_given` | behavioral | `title` | false | `AFTER_GIVEN_TITLES`, on a `salutation` reading only: written bare at the end of the given part after a family comma, the word is the title, as in `Doe, Jane Mrs` ([rules/H8](../../docs/design/rules/H8-salutation-ending-the-given-part.md), a salutation ending the given part). A salutation borne as a given name or a surname is left out with an exclusion of the property, its counts beside it (`goodman`, `herr`), since a middle name may be either | | `abbreviation` | behavioral | `title` | false | `TITLE_ABBREVIATIONS`: true says the title reading is written short (`maj`, Major; `gen`, General). On a title that may be a given name ([rules/H9](../../docs/design/rules/H9-title-phrase.md)) it makes the word, written with its period at the end of the name, the trailing title, as in `SMITH, JOHN B. MAJ.` ([rules/H5](../../docs/design/rules/H5-trailing-title-run.md), the trailing title run), and on a style it makes the article before it the word's phrase partner, as in `The Hon John Smith` under a Chinese choice ([rules/H9](../../docs/design/rules/H9-title-phrase.md)); on any other title it changes nothing, H5 reading every listed title there already. `expands` names the full form and compiles to nothing | | `acronym` | behavioral | `suffix` | true for `credential`, false for every other kind | true: `SUFFIX_ACRONYMS`, matched with every period removed (`M.D.` is `md`); false: `SUFFIX_WORDS`, and a credential's `CREDENTIAL_WORDS`, a credential written as a word | diff --git a/nameparser/vocab/ms.toml b/nameparser/vocab/ms.toml index 4acd4ae09..883e39c99 100644 --- a/nameparser/vocab/ms.toml +++ b/nameparser/vocab/ms.toml @@ -25,7 +25,7 @@ religious = { addresses = "given", gender = "f", issue = 1180, decided = 2026-11 [[word]] text = "haji" -religious = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, expands = "one who has made the Hajj: \"Haji Ahmad bin Ali\"", note = "off by default, a given name and a surname: US SSA 105+ births, US Census 2010 1,608, ORCID's given box 232 (Iraq 20, Pakistan 15, Malaysia 10) and family box 1,178 (Iran 156, Iraq 72, Brunei 50, Malaysia 37), PatentsView's given box 24 and family box 43 (tools/name_usage.py --boxes --country MY, 2026-11-21); the 2015 honours list writes it in 40 title runs the vocabulary missed of 1,504 names (#1180). A title at the head only: inside a father's name (bin Haji Abdullah) it stays a name word" } +religious = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, expands = "one who has made the Hajj: \"Haji Ahmad bin Ali\"", note = "off by default, a given name and a surname: US SSA 105+ births, US Census 2010 1,608, ORCID's given box 232 (Iraq 20, Pakistan 15, Malaysia 10) and family box 1,178 (Iran 156, Iraq 72, Brunei 50, Malaysia 37), PatentsView's given box 24 and family box 43 (tools/name_usage.py --boxes --country MY, 2026-11-21); the 2015 honours list writes it in 40 title runs the vocabulary missed of 1,504 names (#1180). Inside a father's name (bin Haji Abdullah) it stays a name word" } [[word]] text = "ustaz" @@ -57,7 +57,7 @@ nobility = { addresses = "given", issue = 1180, decided = 2026-11-21, expands = [[word]] text = "sri" -nobility = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, note = "a title only behind tan or puan, in the phrases Tan Sri and Puan Sri (rules/H9, the title phrase), mul.toml's given reading gating it: alone it is an Indonesian and Indian given name (Sri Mulyani). Written behind a head honour as its qualifier (Dato' Sri, Datuk Seri) it stays a name word, the qualifier-after-head question being #1334's" } +nobility = { default = false, addresses = "given", issue = 1180, decided = 2026-11-21, note = "a title only behind tan or puan, in the phrases Tan Sri and Puan Sri (rules/H9, the title phrase), mul.toml's given reading gating it: alone it is an Indonesian and Indian given name (Sri Mulyani). Written behind a head honour as its qualifier (Dato' Sri) it stays a name word, reporting the title it might be, the qualifier-after-head question being #1334's" } [[word]] text = "sultan" diff --git a/nameparser/vocab/mul.toml b/nameparser/vocab/mul.toml index aacea8778..93c937134 100644 --- a/nameparser/vocab/mul.toml +++ b/nameparser/vocab/mul.toml @@ -157,11 +157,11 @@ given = { us_ssa = 87, wikidata = 363, as_of = 2026-11-06, same_as = ["muhammad" [[word]] text = "sri" -given = { us_ssa = 109, as_of = 2026-11-21, note = "an Indonesian and Indian given name (Sri Mulyani): ORCID's given box 7,047 (Indonesia 1,951, India 888, Malaysia 23) and family box 1,009, PatentsView's given box 355 (tools/name_usage.py --boxes --country MY, 2026-11-21). It gates ms.toml's title, a title only behind tan or puan (rules/H9), so a name opening with Sri reads it as the given name and reports the title it might be (#1180)" } +given = { us_ssa = 109, as_of = 2026-11-21, note = "an Indonesian and Indian given name (Sri Mulyani): ORCID's given box 7,047 (Indonesia 1,951, India 888, Malaysia 23) and family box 1,009, PatentsView's given box 355 (tools/name_usage.py --boxes --country MY, 2026-11-21). It gates ms.toml's title, a title only behind tan or puan (rules/H9), so under a Malay choice a name opening with Sri reads it as the given name and reports the title it might be, and by default reports nothing (#1180)" } [[word]] text = "tan" -given = { us_ssa = 597, as_of = 2026-11-21, note = "a Vietnamese given name (Tân) as well as the commonest Chinese surname of Malaysia and Singapore: ORCID's given box 2,867 (China 400, Vietnam 308, Malaysia 115) and family box 20,353, PatentsView's given box 475 and family box 3,720 (tools/name_usage.py --boxes --country MY, 2026-11-21). It gates ms.toml's title, a title only in the phrase Tan Sri (rules/H9), so a name opening with Tan reads it as the given name and reports the title it might be (#1180)" } +given = { us_ssa = 597, as_of = 2026-11-21, note = "a Vietnamese given name (Tân) as well as the commonest Chinese surname of Malaysia and Singapore: ORCID's given box 2,867 (China 400, Vietnam 308, Malaysia 115) and family box 20,353, PatentsView's given box 475 and family box 3,720 (tools/name_usage.py --boxes --country MY, 2026-11-21). It gates ms.toml's title, a title only in the phrase Tan Sri (rules/H9), so under a Malay choice a name opening with Tan reads it as the given name and reports the title it might be, and by default reports nothing (#1180)" } [[word]] text = "dis" diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 9736ae3e2..381f32dd2 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1156,8 +1156,8 @@ def _check_cjk_shape_purity(self) -> None: "titles, the 2026-11-19 #1179 entry); 3.1.0 reads it " "so; 1.4.0 read middle 'Aminah binti Tuan', family 'Yusof'"), # #1180: the Malaysian honours. Datuk, Dato', Datin and Hajah are - # titles by default; Tun, Haji and the bare Dato only under the - # Malay pack (decisions/salutation-titles, the 2026-11-21 #1180 + # titles by default; Tun, Haji, the bare Dato and the phrases Tan + # Sri and Puan Sri only under the Malay pack (decisions/salutation-titles, the 2026-11-21 #1180 # entry). Notes checked against the 1.4.0 and 3.1.0 wheels on # 2026-11-21 Case("datuk_opening_a_name_is_the_title", @@ -1204,10 +1204,10 @@ def _check_cjk_shape_purity(self) -> None: {"title": "Datuk", "given": "Seri", "middle": "Anwar", "family": "Ibrahim"}, classification="feat(#1180)", - notes="Seri qualifies the honour before it and is a given name " - "too, the qualifier-after-head question left to #1334; " - "1.4.0 through 3.1.0 read given 'Datuk', middle 'Seri " - "Anwar'"), + notes="seri is unlisted, so the word behind the honour is the " + "given name; reading a qualifier written after its head is " + "#1334's question; 1.4.0 through 3.1.0 read given 'Datuk', " + "middle 'Seri Anwar'"), Case("the_bare_dato_stays_a_name_word_by_default", "Dato Mario Rossi", {"given": "Dato", "middle": "Mario", "family": "Rossi"}, @@ -1228,7 +1228,7 @@ def _check_cjk_shape_purity(self) -> None: "Ahmad bin Haji Abdullah", {"given": "Ahmad", "family": "bin Haji Abdullah"}, locale="ms", - notes="a title is read at the head of the name only"), + notes="a title inside the father's name is a name word"), Case("the_malay_pack_reads_tun_before_dr_as_the_title", "Tun Dr. Mahathir bin Mohamad", {"title": "Tun Dr.", "given": "Mahathir", "family": "bin Mohamad"}, @@ -1259,14 +1259,124 @@ def _check_cjk_shape_purity(self) -> None: "Puan Sri Norainee Abdullah", {"title": "Puan Sri", "given": "Norainee", "family": "Abdullah"}, locale="ms", classification="feat(#1180)", - notes="3.1.0 read title 'Puan', given 'Sri', middle 'Norainee'; " - "1.4.0 read given 'Puan', middle 'Sri Norainee'"), + notes="1.4.0 through 3.1.0 read given 'Puan', middle 'Sri " + "Norainee'"), Case("the_malay_pack_reads_tan_alone_as_the_given_name", "Tan Chee Chai", {"given": "Tan", "middle": "Chee", "family": "Chai"}, locale="ms", ambiguities=("title-or-name",), notes="the commonest Chinese surname in Malaysia, a title only " "before sri (rules/H9); it now reports title-or-name"), + Case("datuk_before_a_family_comma_is_the_title", + "Datuk Ali, Ahmad", + {"title": "Datuk", "given": "Ahmad", "family": "Ali"}, + classification="feat(#1180)", + notes="rules/H6's vocabulary peel; 1.4.0 through 3.1.0 read " + "family 'Datuk Ali'"), + Case("datuk_alone_before_a_family_comma_stays_the_family", + "Datuk, Ahmad", + {"given": "Ahmad", "family": "Datuk"}, + notes="rules/H6 stops at a title with no name word behind it"), + Case("dato_with_the_typographic_apostrophe_in_capitals_is_the_title", + "DATO\u2019 AHMAD", + {"title": "DATO\u2019", "given": "AHMAD"}, + classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'DATO\u2019', family " + "'AHMAD'"), + Case("the_bare_dato_with_a_period_is_the_title_by_its_shape", + "Dato. Ali", + {"title": "Dato.", "family": "Ali"}, + notes="rules/H2's shape, a title addressing the family; under the " + "Malay pack the listed word addresses the given name"), + Case("datuk_dotted_ending_a_name_is_the_title", + "Ahmad bin Ali Datuk.", + {"title": "Datuk.", "given": "Ahmad", "family": "bin Ali"}, + classification="feat(#1180)", + notes="rules/H5's trailing vocabulary; 1.4.0 through 3.1.0 read " + "family 'bin Ali Datuk.'"), + Case("a_given_name_hajah_after_a_salutation_reads_the_title", + "Miss Hajah Kamara", + {"title": "Miss Hajah", "given": "Kamara"}, + classification="feat(#1180)", + notes="the accepted cost of hajah by default " + "(decisions/salutation-titles, the 2026-11-21 #1180 entry); " + "1.4.0 through 3.1.0 read given 'Hajah', family 'Kamara'"), + Case("the_malay_pack_reads_haji_before_a_family_comma_as_the_title", + "Haji Awang, Abdul Hadi", + {"title": "Haji", "given": "Abdul Hadi", "family": "Awang"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read family 'Haji Awang'"), + Case("the_malay_pack_reads_haji_after_a_family_comma_as_the_title", + "Ali, Haji Ahmad", + {"title": "Haji", "given": "Ahmad", "family": "Ali"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Haji', middle 'Ahmad'"), + Case("the_malay_pack_reads_haji_in_lower_case_as_the_title", + "haji ali bin abu", + {"title": "haji", "given": "ali", "family": "bin abu"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'haji', middle 'ali'"), + Case("the_malay_pack_reads_tan_sri_after_an_empty_comma", + ", Tan Sri Muhyiddin", + {"title": "Tan Sri", "given": "Muhyiddin"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Tan', middle 'Sri " + "Muhyiddin'"), + Case("the_malay_pack_reads_tan_sri_with_a_period", + "Tan Sri. Ali", + {"title": "Tan Sri.", "given": "Ali"}, + locale="ms", classification="feat(#1180)", + notes="1.4.0 through 3.1.0 read given 'Tan', middle 'Sri.'"), + Case("the_malay_pack_reads_the_bare_dato_with_a_period_by_the_given_name", + "Dato. Ali", + {"title": "Dato.", "given": "Ali"}, + locale="ms", classification="feat(#1180)", + notes="the listed word addresses the given name (rules/H1); 1.4.0 " + "through 3.1.0 read title 'Dato.', family 'Ali', by " + "rules/H2's shape"), + Case("the_malay_pack_reads_haji_before_an_initial_as_the_title", + "Haji A", + {"title": "Haji", "given": "A"}, + locale="ms", classification="feat(#1180)", + notes="the accepted cost of the citation shape, a surname Haji " + "and an initial; 3.1.0 read given 'Haji', family 'A' and " + "reported the order; 1.4.0 read given 'Haji', family 'A'"), + Case("the_malay_pack_reads_the_bare_dato_of_another_name_as_the_title", + "Dato Mario", + {"title": "Dato", "given": "Mario"}, + locale="ms", classification="feat(#1180)", + notes="the accepted cost: an Italian surname and a Georgian given " + "name; 1.4.0 through 3.1.0 read given 'Dato', family " + "'Mario'"), + Case("the_malay_pack_reads_tan_behind_a_style_as_the_title", + "Hon. Tan Ah Kow", + {"title": "Hon. Tan", "given": "Ah", "family": "Kow"}, + locale="ms", classification="feat(#1180)", + notes="the accepted cost: a style before a title that may be a " + "given name makes a phrase (rules/H9); 1.4.0 through 3.1.0 " + "read title 'Hon.', given 'Tan'"), + Case("the_malay_pack_reads_tan_sri_alone_as_title_and_given_name", + "Tan Sri", + {"title": "Tan", "given": "Sri"}, + locale="ms", classification="feat(#1180)", ambiguities=("title-or-name",), + notes="the phrase with no name behind it: rules/H1 gives the one " + "name word to the given name, as Field Marshal reads by " + "default; 1.4.0 through 3.1.0 read given 'Tan', family " + "'Sri'"), + Case("the_malay_pack_cuts_tan_sri_at_a_comma", + "Tan Sri, Muhyiddin", + {"title": "Tan", "given": "Muhyiddin", "family": "Sri"}, + locale="ms", classification="feat(#1180)", + notes="rules/H6 peels the gated Tan and leaves Sri the family, as " + "Associate Dean, Jones reads by default; 1.4.0 through " + "3.1.0 read family 'Tan Sri'"), + Case("the_malay_pack_reads_a_lone_name_after_dato_and_ustaz_as_the_family", + "Dato' Ustaz Idris", + {"title": "Dato' Ustaz", "family": "Idris"}, + locale="ms", classification="feat(#1180)", + notes="the run addresses as its last title, ustaz, does: by the " + "family (#1179's reading); 1.4.0 through 3.1.0 read given " + "\"Dato'\", middle 'Ustaz'"), Case("the_malay_pack_reads_the_bare_dato_as_the_title", "Dato Ahmad bin Ali", {"title": "Dato", "given": "Ahmad", "family": "bin Ali"}, diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index e5aa173da..f47da5eab 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -532,7 +532,6 @@ def test_ms_reads_the_indonesian_puan_as_the_title() -> None: assert (name.title, name.given, name.family) == ("Puan", "", "Maharani") - def test_ms_reads_tan_and_sri_as_name_words_outside_their_phrases() -> None: # each is a title only in its phrase (rules/H9, #1180): alone it is # the given name, reporting the title it might be, and the default @@ -549,6 +548,25 @@ def test_ms_reads_tan_and_sri_as_name_words_outside_their_phrases() -> None: assert malay.parse("Tan Sri Wahyuni").title == "Tan Sri" assert malay.parse("Hon. Sri Mulyani").title == "Hon. Sri" assert parse("Tan Sri Wahyuni").title == "" + # a strict choice drops en.toml's style, so no phrase is made there + strict = parser_for(locales.MS, strict=True) + assert strict.parse("Hon. Sri Mulyani").given == "Sri" + + +@pytest.mark.parametrize("order", [FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +@pytest.mark.parametrize("text, title, family", [ + ("Tan Sri Muhyiddin Yassin", "Tan Sri", "Muhyiddin"), + ("Haji Ahmad Ali", "Haji", "Ahmad"), + ("Tan Chee Chai", "", "Tan"), +]) +def test_ms_peels_the_honours_before_a_family_first_order( + order: tuple[Role, Role, Role], text: str, title: str, + family: str) -> None: + # the title run is read first and the order lays out the rest + # (#1180), so a Chinese name written family first keeps its surname + base = Parser(policy=Policy(name_order=order)) + name = parser_for(locales.MS, base=base).parse(text) + assert (name.title, name.family) == (title, family) def test_ms_is_plain_since_strict_drops_other_languages_readings() -> None: @@ -563,7 +581,10 @@ def test_ms_is_plain_since_strict_drops_other_languages_readings() -> None: @pytest.mark.parametrize("text", ["Puan Maharani", "Tuan Nguyen", - "Nguyen Van Tuan", "Cik Rohaida Hak"]) + "Nguyen Van Tuan", "Cik Rohaida Hak", + # #1180's words + "Sri Mulyani", "Tan Chee Chai", "Tun Aung", + "Haji Ali", "Tan Sri Ali"]) def test_ms_words_move_no_indonesian_or_vietnamese_choice(text: str) -> None: # puan is an Indonesian given name: the default keeps it, and so do a # choice of id and one of vi, neither of which reads ms.toml (no file @@ -574,6 +595,7 @@ def test_ms_words_move_no_indonesian_or_vietnamese_choice(text: str) -> None: assert indonesian.parse(text).as_dict() == _default_parse(text) assert _require_packed("vi").parse(text).title == "" assert parse(text).title == "" + assert parse(text).ambiguities == () @pytest.mark.parametrize("text, middle", [ diff --git a/tests/v2/test_vocab.py b/tests/v2/test_vocab.py index ad4f41714..ff7ef9dcb 100644 --- a/tests/v2/test_vocab.py +++ b/tests/v2/test_vocab.py @@ -491,6 +491,14 @@ def _w(body: str) -> str: # would hold the phrase ("attaches-off-by-default-a-word-with-no-title-reading", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { default = false, attaches = ["zzq"] }')}, "attaches names 'zzq', which is no title kind and no title word on by default or in en.toml"), ("attaches-off-by-default-a-partner-another-file-turns-on", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { default = false, attaches = ["zzq"] }'), "fr.toml": _w('[[word]]\ntext = "zzq"\noffice = { default = false }')}, "attaches names 'zzq', which is no title kind and no title word on by default or in en.toml"), + ("attaches-off-by-default-a-partner-with-only-a-name-reading-in-its-file", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { default = false, attaches = ["zzq"] }\n\n[[word]]\ntext = "zzq"\ngiven = { note = "x" }')}, "attaches names 'zzq', which is no title kind and no title word on by default or in en.toml"), + # the case the narrower check refused that matters most: a reading on + # by default naming a partner off by default, in the same file; the + # end anchor holds that no hint about the file is given + ("attaches-a-partner-off-by-default-beside-a-reading-on-by-default", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { attaches = ["zzq"] }\n\n[[word]]\ntext = "zzq"\noffice = { default = false }')}, "attaches names 'zzq', which is no title kind and no title word$"), + # the same two halves through the kind-name branch: 'saint' names a + # particle kind too, and its title only another file turns on + ("attaches-off-by-default-a-kind-name-another-file-turns-on", {"en.toml": _w('[[word]]\ntext = "zzq"\nreligious = { default = false, attaches = ["saint"] }'), "fr.toml": _w('[[word]]\ntext = "saint"\nreligious = { default = false }')}, "attaches names 'saint', which is not a title kind or a title word on by default or in en.toml"), ("attaches-on-a-suffix", {"en.toml": _w('[[word]]\ntext = "phd"\ncredential = { attaches = ["office"] }')}, "unknown key 'attaches'"), ("attaches-differs-between-files", {"en.toml": _w('[[word]]\ntext = "chief"\noffice = { attaches = ["military"] }'), "fr.toml": _w('[[word]]\ntext = "chief"\noffice = {}')}, "attaches"), ("reserved-separators", {"th.toml": _w('[[word]]\ntext = "นาย"\nsalutation = { separators = [] }')}, "reserved, unbuilt, for 3.x"), @@ -1588,14 +1596,32 @@ def test_attaches_may_name_a_title_word_that_is_also_another_kind() -> None: assert c["TITLE_PHRASES"] == frozenset({"zzq saint"}) -def test_an_off_by_default_phrase_may_name_a_partner_off_by_default_in_its_file() -> None: +@pytest.mark.parametrize("partner", ["zzr", "saint"]) +def test_an_off_by_default_phrase_may_name_a_partner_off_by_default_in_its_file( + partner: str) -> None: # the case the check admits since #1180: both readings off by # default in one file, so the default holds no phrase and the one - # choice of that file turns both on (ms.toml's puan and sri) - c = _compile({"en.toml": _w( - '[[word]]\ntext = "zzq"\nnobility = { default = false, attaches = ["zzr"] }\n\n' - '[[word]]\ntext = "zzr"\nnobility = { default = false }')}) - assert c["TITLE_PHRASES"] == frozenset() + # choice of that file turns both on (ms.toml's puan and sri); a + # choice of another file turns on neither. Through both branches of + # the check: a plain word, and 'saint', which names a kind too + entries = sorted([ + (partner, '{ default = false }'), + ("zzq", f'{{ default = false, attaches = ["{partner}"] }}')]) + files = { + "en.toml": _w("\n\n".join( + f'[[word]]\ntext = "{t}"\nreligious = {r}' for t, r in entries)), + "fr.toml": _w('[[word]]\ntext = "zzs"\nreligious = {}')} + assert _compile(files)["TITLE_PHRASES"] == frozenset() + rows = build.index_rows(build.load(files)) + ri = sys.modules[type(rows[0]).__module__] + assert ri.compile_readings(ri.choose(rows, frozenset({"en"})))[ + "TITLE_PHRASES"] == frozenset({f"zzq {partner}"}) + assert ri.compile_readings(ri.choose(rows, frozenset({"fr"})))[ + "TITLE_PHRASES"] == frozenset() + + +def test_the_malay_pack_compiles_its_phrases_and_the_default_none() -> None: + # the shipped witness of the case above assert "puan sri" not in Lexicon.default()._sets.title_phrases malay = parser_for(locales.MS).lexicon._sets.title_phrases assert {"puan sri", "tan sri"} <= malay diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index 63edcc2e9..ac2e800c9 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -263,6 +263,7 @@ "DUPONT Mary Ann" "DUPONT Mary y" "DUT.RA MARIA SILVA" +"Datuk Ahmad" "Davis Royce, Ed" "De La Cruz, Ed" "De La Cruz, M.J. K.L." diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index ab282d6f9..099554684 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -764,6 +764,7 @@ {"name": "Danarto", "given": "Danarto", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "D."} {"name": "Daniel Ayala Pérez", "given": "Daniel", "middle": "Ayala", "family": "Pérez", "initials": "D. A. P."} {"name": "Daniel Bautista Rocha", "given": "Daniel", "middle": "Bautista", "family": "Rocha", "initials": "D. B. R."} +{"name": "Datuk Ahmad", "title": "Datuk", "given": "Ahmad", "initials": "A."} {"name": "David Ben Gurion", "given": "David", "middle": "Ben", "family": "Gurion", "initials": "D. B. G."} {"name": "David arap Kirui", "given": "David", "middle": "arap", "family": "Kirui", "initials": "D. a. K.", "capitalized_force": "David Arap Kirui"} {"name": "David zu Sonnegg von Ungnad von Weissenwolf", "given": "David", "middle": "zu Sonnegg von Ungnad", "family": "von Weissenwolf", "initials": "D. S. U. W."} diff --git a/tools/vocab/build.py b/tools/vocab/build.py index 253d040ef..23ca6293c 100644 --- a/tools/vocab/build.py +++ b/tools/vocab/build.py @@ -1386,8 +1386,9 @@ def check_pool(pool: Pool) -> None: # a reading written `default = false` may also name a word whose # title reading is off by default IN ITS OWN FILE, the one choice of # that file turning both on (`puan` and `sri` in ms.toml, #1180); a - # partner switched on by another file's choice alone, or by none, - # makes a phrase no single choice holds + # partner switched on only by another file's readings is refused, + # even one a choice of this file also selects (pt.toml under pt-BR): + # the two halves of the phrase are written in one file own_titles = {(r.file, r.text) for r in pool.readings if r.category == "title"} @@ -1406,7 +1407,10 @@ def partner(r: Reading, k: str) -> bool: and not partner(r, k)): raise VocabError( f"{r.where()}: attaches names {k!r}, which is not a " - f"title kind or a title word; the kinds: " + f"title kind or a title word" + + ("" if r.on_by_default else + f" on by default or in {r.file}") + + "; the kinds: " f"{sorted(t for t, c in CATEGORY.items() if c == 'title' and t != 'title')}") if k not in CATEGORY and not partner(r, k): raise VocabError(f"{r.where()}: attaches names {k!r}, which " From 81e3da89cfd90775e7476b43b48e6faa7b1a08b0 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 12:37:01 -0800 Subject: [PATCH 3/3] Fix the second review's findings: the #1469 line, two counts, a case note and the release bullet (#1180) indic-honorifics' new line said the #1469 strict-choice bullet no longer held under MS; that bullet is about qari, moulana, alhaj and alhajj, which still read as given names there, and only haji, which it left out of every choice, moved. ORCID's changed records hold 7 given names Tun, not 6; PatentsView's three more are recorded. The Hon. Tan cost is the pack's own, only Hon. Sri being option A's. The style claim names the five corpora read. The merged release bullet keeps the Sri and Seri limit and one example. A case note compared Tan Sri with Field Marshal the wrong way, and three names from private records are replaced with invented ones. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/indic-honorifics.md | 2 +- docs/design/decisions/salutation-titles.md | 4 ++-- docs/design/decisions/vocabulary-model.md | 2 +- docs/release_log.rst | 2 +- tests/v2/cases.py | 7 +++---- tests/v2/test_locales.py | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/design/decisions/indic-honorifics.md b/docs/design/decisions/indic-honorifics.md index d84d2795d..4b86b8886 100644 --- a/docs/design/decisions/indic-honorifics.md +++ b/docs/design/decisions/indic-honorifics.md @@ -74,5 +74,5 @@ Open: #514 (whether the Tibetan prefix titles Tulku, Khenpo, Geshe, Kyabje and J - UNDER A STRICT CHOICE (`parser_for(locales.BN, strict=True)`, and HI's and MS's) the four read as the given name again, ar.toml not being chosen, as `mufti` and `hajji` already do. - THE NAME WORDS: `syed`, `mian`, `chaudhry` and `makhdoom` open far more names as a given name or a surname than as an honorific, and the boxes agree with today's reading, so no reading is written for them. - MEASURED (`tools/differential/measure.py --base `, master `34771e2d`): the committed snapshot, CLDR and GND agreement and every local corpus but four read as master did. JRC-Names moved 55 names (`qari` 53, `alhaj` 1, `moulana` 1), opensanctions-parliaments 2 (`moulana`, both `pk_na_members`), orcid-researchers 7 and psc-individuals 10 (`qari` 5, `moulana` 3, `alhaj` 2): in every one the word left the given name for the title, the words after it reading as a name without it (where one name word was left, in 14 names, 12 of two words and 2 written behind `Mr`, it is the family, rules/H1: `Qari Khan` → title 'Qari', family 'Khan'), save the byline above and two of orcid-researchers' that open with `Lama`, an Arabic given name that is also a listed title (rules/H1's renunciate class): one written `Lama Alhaj` and a surname, which master read title 'Lama', given 'Alhaj', now reads title 'Lama Alhaj' and the surname as the family, and one holding `Lama` and `Alhajj` and nothing else keeps title 'Lama', given 'Alhajj' and now reports `title-or-name`, its one name word being title vocabulary. Neither reading is the filer's; the cost is `lama`'s, which master paid already. Scored against the filers' boxes, psc-individuals loses 10 records, each a forename box holding the honorific (behind `Mr` in the title box in nine), and orcid-researchers moves 3; JRC-Names reads 8 persons' spellings apart that master read alike, the spellings with the title against those without it. my-candidates, FEC and ClinicalTrials.gov move nothing. -- 2026-11-21 #1180 — `haji` IS A TITLE UNDER `locales.MS`. ms.toml writes it a `religious` reading `default = false`, which the Malay pack turns on, plain or strict (`parser_for(locales.MS, strict=True).parse("Haji Abdul Hadi Awang")` gives title 'Haji'), so the #1469 entry's strict-choice bullet holds for BN and HI and no longer for MS; the default is unchanged (decisions/salutation-titles, the 2026-11-21 #1180 entry). +- 2026-11-21 #1180 — `haji` IS A TITLE UNDER `locales.MS`. ms.toml writes it a `religious` reading `default = false`, which the Malay pack turns on, plain or strict (`parser_for(locales.MS, strict=True).parse("Haji Abdul Hadi Awang")` gives title 'Haji'), where the #1469 entry left it out of every choice; that entry's strict-choice bullet, about qari, moulana, alhaj and alhajj, still holds under MS (`Qari Ahmed Khan` given 'Qari'), and the default is unchanged (decisions/salutation-titles, the 2026-11-21 #1180 entry). diff --git a/docs/design/decisions/salutation-titles.md b/docs/design/decisions/salutation-titles.md index 96ba2455d..4a7fe06f6 100644 --- a/docs/design/decisions/salutation-titles.md +++ b/docs/design/decisions/salutation-titles.md @@ -91,6 +91,6 @@ Elsewhere: `justice` and `marshal`, excluded here as common leading-position nam - **2026-11-21 #1180 — MALAYSIAN HONOURS: `datuk`, `dato'`, `datin` AND `hajah` ARE TITLES BY DEFAULT; `tun`, `haji`, THE BARE `dato`, `Tan Sri` AND `Puan Sri` UNDER `locales.MS`.** Malaysian names in official use open with a run of honours, and 1.4.0 through 3.1.0 read the first as the given name (`Datuk Ahmad bin Ali` given 'Datuk', middle 'Ahmad'). Decided 2026-11-21 on the issue's scope: the honours as titles, each addressing the given name as `sir` does (rules/H1), so `Datuk Ahmad` gives given 'Ahmad'. `datuk`, `dato'` and `datin` are `nobility`, `hajah` and `haji` `religious`, as `ustaz` is: not `style`, whose words make a phrase with a title that may be a given name behind them (`Hajah Sri Wahyuni` would read title 'Hajah Sri', rules/H9). - **THE COUNTS** (`tools/name_usage.py --no-wikidata --boxes --country MY`, 2026-11-21, ORCID's 24,990,909 holders and PatentsView's 5,508,446 inventors; each on its word's note). On by default, none borne leading a name but `hajah` once: `datuk` ORCID given box 4 (none Malaysian) and family 3, PatentsView given 2 (both Malaysian, the honour typed in); `dato'` ORCID given 7 (Malaysia 4) and family 3; `datin` ORCID given 13 (Malaysia 1) and family 2; `hajah` ORCID given 32 (Brunei 3, 28 with no country), PatentsView given 2, and one Companies House filer who bears it as her given name (below). Off by default: `tun` ORCID given 241 (Myanmar 30, China 21) and family 395, US Census 2010 1,908; `haji` given 232 and family 1,178, US SSA 105+ births (decisions/indic-honorifics left its title wanting a choice, 2026-11-19 #1469); the bare `dato` an Italian surname (US Census 2010 633, ORCID family 68) and a Georgian given name (ORCID's given box 3 in Georgia, and 3 of the regressions below); `tan` ORCID given 2,867 and family 20,353, US SSA 597+; `sri` ORCID given 7,047, US SSA 109+. The 2015 King's birthday honours list, as #1180 measured it on 2026-11-08 and not rebuilt here, misses `Dato'` in 32 runs of 1,504 names, `Datuk` 23, `Datin` 23, `Haji` 40, `Hajah` 16, `Tun` 1 and `Puan Sri` 1. - **THE PHRASES.** `tan` and `sri` hold a `given` reading in mul.toml, so each title is gated (rules/H9) and a title only in a phrase: `tan` and `puan` attach to `sri`. Alone each stays a name word under the pack (`Tan Chee Chai` given 'Tan', `Sri Mulyani` given 'Sri'), reporting `title-or-name`. The build refused a phrase whose two halves are both off by default; it admits one written in one file since this day (decisions/vocabulary-model, the 2026-11-21 #1180 entry, which records why the alternative, `sri`'s title on by default, was declined). By default no phrase is compiled and no `tan`, `sri` or `puan` title. - - **MEASURED** against master `488ea605`, py3.11, `tools/differential/local_agreement.py SOURCE --base ` (and with `--locale ms`, whose figures compare the pack in this tree with master's pack), `snapshot.py --local SOURCE --base `, and `config_diff.py diff --local SOURCE default plain:MS` run in each tree (the pack against the default in that tree). By default: my-candidates 174 of 3,077 distinct names move, each now reading an honour as the title (`DATO'` first 101, `DATUK` 69, `DATIN` and `HAJAH` 1 each, and 2 with `DATO'` behind `PROF.` or `UST.`). The word behind the honour is then the given name, which is the person's in most (`DATO' AZAMI` given 'AZAMI') and not where a word the default does not read stands there: a qualifier (given 'SERI' 23, 'SRI' 14, 'WIRA' 5, #1334) or a title off by default (given 'HAJI' 11, 'HJ' 3, 'CIKGU' 4, 'USTAZ' 3); and peeling the honour leaves `ABDUL` short of rules/P12's four name words (`DATO' RADHI ABDUL RAZAK` family 'ABDUL RAZAK' → 'RAZAK', middle 'ABDUL', 2 names), the reading the name has without the honour. ORCID 0 fixed, 0 broken, 3 changed (an honour typed into the given box, now the title); PatentsView 0 broken, 1 title typed in; Companies House 1 regression, `Hajah` (below); opensanctions-parliaments, nepal-candidates and the committed snapshot no move. Under `locales.MS`, against master's pack: ORCID 26 regressions (`haji` 17, Tanzania 8, Ethiopia 3 and one each in six other countries; `tun` 5, Myanmar 4 and a Burmese name in Malaysia, `TUN AUNG`; the bare `dato` 4, Georgia 3), 14 changed, 6 of them a Burmese, Singaporean or Thai given name Tun read as the title (a name shaped `Tun Tun Hla`, title 'Tun Tun', given 'Hla'), and 19 more counted as a title typed into the given box, 10 of which are such a given name Tun (Singapore 4, Myanmar 3) and 9 `Haji`, with 2 fewer (a name shaped `Dr. Haji Ali`, losing the given name Haji); Companies House 36 (`haji` 30, 20 of them British filers and 4 Pakistani, most the honour typed into the forename box, which a box score counts as a miss, decisions/indic-honorifics' #1469 entry; `tun` 2, given names; the bare `dato` 1, Georgian; `hajah` 1, the default's; and 2 where the filer typed the honours into the forename box, one read right and one, `Tan Sri Dato Seri …`, reading given 'Seri', #1334's shape); PatentsView 4 (2 a given name Tun, 2 honours typed into the given box, read right). On my-candidates the pack reads 248 names differently from the default, where master's reads 117: 197 a title in the role fields (`ustaz` 72, `cikgu` 45, `haji` 37, `dato` 29, `Tan Sri` 6, `ustazah` 5, `cik` 2, `Puan Sri` 1), and 51 the same roles with a new `title-or-name` report (36 Chinese names written family first with `TAN`, 14 `DATO' SRI`, 1 `DATO' TAN`). No local corpus name has a style before `Tan` or `Sri` under the pack. - - **ACCEPTED.** By default, a woman whose given name is Hajah reads it as the title (one Companies House filer, a name shaped `Miss Hajah Kamara`, title 'Miss Hajah'), and peeling an honour leaves a name its reading without the honour (rules/P12's `abdul`, above). Under the pack: a given name or surname `Tun` opening a name, Burmese, Chinese or Singaporean (`Tun Tun Hla` title 'Tun Tun', given 'Hla'; `Encik Tun Yoke Wah` title 'Encik Tun', as #1180 found in the honours list); a given name `Haji` opening one (`Haji Juma` given 'Juma') and the citation `Haji A` (title 'Haji', given 'A'); the surname `Tan` before a given name `Sri` (`Tan Sri Wahyuni` title 'Tan Sri'); a style before `Tan` or `Sri`, which makes a phrase (`Hon. Tan Ah Kow` title 'Hon. Tan', `Hon. Sri Mulyani` title 'Hon. Sri', rules/H9; a strict choice keeps given 'Tan' and 'Sri', dropping en.toml's style), the cost option A would have put in the default (decisions/vocabulary-model, the same day's entry), paid here under the pack alone; the phrase cut short, which leaves its first half a title as `Field Marshal` does by default (`Tan Sri` alone title 'Tan', given 'Sri'; `Tan Sri, Muhyiddin` title 'Tan', family 'Sri'); the bare `Dato` of an Italian or Georgian name (`Dato Mario`); and the `title-or-name` report on `Tan` or `Sri` wherever no phrase takes it, opening a name or behind another title (`Tan Chee Chai`, `Dato' Sri Ahmad`), the cost of a gated title, which by default reports nothing. + - **MEASURED** against master `488ea605`, py3.11, `tools/differential/local_agreement.py SOURCE --base ` (and with `--locale ms`, whose figures compare the pack in this tree with master's pack), `snapshot.py --local SOURCE --base `, and `config_diff.py diff --local SOURCE default plain:MS` run in each tree (the pack against the default in that tree). By default: my-candidates 174 of 3,077 distinct names move, each now reading an honour as the title (`DATO'` first 101, `DATUK` 69, `DATIN` and `HAJAH` 1 each, and 2 with `DATO'` behind `PROF.` or `UST.`). The word behind the honour is then the given name, which is the person's in most (`DATO' AZAMI` given 'AZAMI') and not where a word the default does not read stands there: a qualifier (given 'SERI' 23, 'SRI' 14, 'WIRA' 5, #1334) or a title off by default (given 'HAJI' 11, 'HJ' 3, 'CIKGU' 4, 'USTAZ' 3); and peeling the honour leaves `ABDUL` short of rules/P12's four name words (`DATO' RADHI ABDUL RAZAK` family 'ABDUL RAZAK' → 'RAZAK', middle 'ABDUL', 2 names), the reading the name has without the honour. ORCID 0 fixed, 0 broken, 3 changed (an honour typed into the given box, now the title); PatentsView 0 broken, 1 title typed in; Companies House 1 regression, `Hajah` (below); opensanctions-parliaments, nepal-candidates and the committed snapshot no move. Under `locales.MS`, against master's pack: ORCID 26 regressions (`haji` 17, Tanzania 8, Ethiopia 3 and one each in six other countries; `tun` 5, Myanmar 4 and a Burmese name in Malaysia; the bare `dato` 4, Georgia 3), 14 changed, 7 of them a Burmese, Singaporean or Thai given name Tun read as the title (a name shaped `Tun Tun Hla`, title 'Tun Tun', given 'Hla'), and 19 more counted as a title typed into the given box, 10 of which are such a given name Tun (Singapore 4, Myanmar 3) and 9 `Haji`, with 2 fewer (a name shaped `Dr. Haji Ali`, losing the given name Haji); Companies House 36 (`haji` 30, 20 of them British filers and 4 Pakistani, most the honour typed into the forename box, which a box score counts as a miss, decisions/indic-honorifics' #1469 entry; `tun` 2, given names; the bare `dato` 1, Georgian; `hajah` 1, the default's; and 2 where the filer typed the honours into the forename box, one read right and one, `Tan Sri Dato Seri …`, reading given 'Seri', #1334's shape); PatentsView 4 (2 a given name Tun, 2 honours typed into the given box, read right), and 3 more given names Tun counted as a title typed in. On my-candidates the pack reads 248 names differently from the default, where master's reads 117: 197 a title in the role fields (`ustaz` 72, `cikgu` 45, `haji` 37, `dato` 29, `Tan Sri` 6, `ustazah` 5, `cik` 2, `Puan Sri` 1), and 51 the same roles with a new `title-or-name` report (36 Chinese names written family first with `TAN`, 14 `DATO' SRI`, 1 `DATO' TAN`). None of the five local corpora config_diff read has a name with a style before `Tan` or `Sri` (a salutation before the phrase, `Mr Tan Sri …`, is no such style). + - **ACCEPTED.** By default, a woman whose given name is Hajah reads it as the title (one Companies House filer, a name shaped `Miss Hajah Kamara`, title 'Miss Hajah'), and peeling an honour leaves a name its reading without the honour (rules/P12's `abdul`, above). Under the pack: a given name or surname `Tun` opening a name, Burmese, Chinese or Singaporean (`Tun Tun Hla` title 'Tun Tun', given 'Hla'; `Encik Tun Yoke Wah` title 'Encik Tun', as #1180 found in the honours list); a given name `Haji` opening one (`Haji Juma` given 'Juma') and the citation `Haji A` (title 'Haji', given 'A'); the surname `Tan` before a given name `Sri` (`Tan Sri Wahyuni` title 'Tan Sri'); a style before `Tan` or `Sri`, which makes a phrase (`Hon. Tan Ah Kow` title 'Hon. Tan', `Hon. Sri Mulyani` title 'Hon. Sri', rules/H9; a strict choice keeps given 'Tan' and 'Sri', dropping en.toml's style), the `Hon. Sri` half being the cost option A would have put in the default (decisions/vocabulary-model, the same day's entry), paid here under the pack alone, and the `Hon. Tan` half the pack's own; the phrase cut short, which leaves its first half a title as `Field Marshal` does by default (`Tan Sri` alone title 'Tan', given 'Sri'; `Tan Sri, Muhyiddin` title 'Tan', family 'Sri'); the bare `Dato` of an Italian or Georgian name (`Dato Mario`); and the `title-or-name` report on `Tan` or `Sri` wherever no phrase takes it, opening a name or behind another title (`Tan Chee Chai`, `Dato' Sri Ahmad`), the cost of a gated title, which by default reports nothing. - **LEFT OUT**, each the issue's: `Sri` and `Seri` behind a head honour (`Dato' Sri`, `Datuk Seri`, which read given 'Sri'), `Laks. Muda` and `Prof. Madya`, the qualifier written after its head (#1334); `YB`, `YM` and `YA`, two capitals, the shape of paired initials (#1205); the police ranks `ASP`, `ACP`, `DSP`, `SAC` and `DCP`; the service designations `TUDM` and `TLDM`; the apostrophes `‘` (U+2018) and `ʼ` (U+02BC), which no local corpus writes after `Dato` (nor `’`, listed as the brief asked, 2026-11-21). Found here and not changed: under the pack `Dato' Ustaz Idris` reads family 'Idris', the run addressing as its last title, `ustaz`, does, by the family (#1179's reading). diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 8433f5136..186f25900 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -637,4 +637,4 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis ACCEPTED: a person whose given name is `Shri`, or opens with it, reads the salutation under the pack: `Verma, Shri` gives title 'Shri' and no given name, `Shri Mehra` title 'Shri', family 'Mehra', and `Shri Lal Mehra` given 'Lal'. Nothing written tells `Shri Lal`, a given name of two words, from `Shri Ravi`, the salutation before one. A narrower reading, the title only with two or more name words behind it, keeps `Shri Mehra` and loses the 202 Sansad spellings written `Shri Gopalan`, so it was not taken. NOT `after_given` (rules/H8): rules/H8 leaves out a salutation borne as a given name, since a middle name may be one, and decisions/H8 left the Devanagari `श्री` out on that doubt; `shri` is borne as one, and the roll never asks for the property. in_sansad writes the salutation in two shapes, before the given name after a family comma (`Verma, Shri Ravi`, 653 of opensanctions-parliaments' distinct names) and after a full name and a comma (`Ravi Verma, Shri`), both read as the title without it, and holds no `Family, Given Shri`. Measured against the same reading carrying the property, the recipe below moves 2 names, both reading better without it: an FEC filer whose given name of two words ends in the word (`FAMILY, GIVEN SHRI`), whom the property read as given 'GIVEN' and title 'SHRI', and a Sansad spelling with the salutation in brackets (`(Shri) Ravi Kumar`), which the property left the nickname and which reads as the title without it. So `Verma, Ravi Shri` keeps middle 'Shri' under the pack, as `वर्मा, रवि श्री` keeps middle 'श्री', and the word records the refusal (`excluded = { after_given = ... }` on its entry); the dotted `Verma, Ravi Shri.` is the title by rules/H5's trailing vocabulary, as `Shri.` ending a name is. Recompute: the command above from a checkout of this change; the 2 moves the property makes with `'expr:Parser(lexicon=parser_for(locales.HI).lexicon.remove("shri", kind="salutation").add("shri", kind="salutation", after_given=True), policy=parser_for(locales.HI).policy)'` in place of the first configuration; the person counts from `raw.jsonl`'s in_sansad rows, their `entity` kept where `name` holds `shri` as a word, and where it opens with it (a bracket allowed); the in_sansad figure with `--local opensanctions-parliaments --group in_sansad` and no `--match`; each moved name read from `--readings `, the two configurations' first field compared line by line. -- 2026-11-21 #1180 — A PHRASE MAY BE WRITTEN WHOLLY OFF BY DEFAULT IN ONE FILE. `Tan Sri` and `Puan Sri`, Malaysian honours, are phrases rules/H9 reads, `tan` and `puan` attaching to `sri`, each a title off by default in ms.toml for `locales.MS` (decisions/salutation-titles, the same day's entry). The build refused them: `attaches` had to name a word with a title reading ON by default, and `sri` holds none, hi.toml excluding it as a salutation and the exclusion refusing every title kind of a reading on by default. Decided 2026-11-21, B over A. A: turn `sri`'s title on by default, gated by mul.toml's `given` reading, and narrow hi.toml's exclusion. It moved no corpus name (0 of the 597 local-corpus names holding `sri`, `config_diff.py diff --local all --match '(?i)(^|[\s,.])sri([\s,.]|$)' default 'expr:Parser(lexicon=Lexicon.default().add("sri", kind="given").add("sri", kind="nobility", addresses="given"))'`, master `488ea605`), but it moved the default to satisfy a tool rule, and a style before the word makes a phrase there (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9). B: the build check admits a partner whose title reading is off by default in the reading's own file, where the reading is off by default too, so the default compiles no phrase and holds no `sri` title (`nameparser/config/_compiled.py` holds no `tan`, `sri` or `puan`), and the one choice of the file turns both on. The check still refuses a partner with no title reading, one with only a name reading in the file, one another file turns on, even where a choice of the reading's file selects that file too (`pt.toml` under `pt-BR`, narrower than the reason needs, so a phrase's two halves stand in one file), and a partner off by default beside a reading on by default, each a mutation in tests/v2/test_vocab.py. Option B pays A's style cost under the pack alone (`Hon. Sri Mulyani`, and `Hon. Tan Ah Kow` title 'Hon. Tan'), recorded in decisions/salutation-titles' entry. A caller's `Lexicon.add` had no such check and gets none: a phrase naming no title word compiles to nothing, an inert entry (AGENTS.md, invariants guard harm, not no-ops), and under a choice the compile builds a phrase only from the title words the chosen pool holds. +- 2026-11-21 #1180 — A PHRASE MAY BE WRITTEN WHOLLY OFF BY DEFAULT IN ONE FILE. `Tan Sri` and `Puan Sri`, Malaysian honours, are phrases rules/H9 reads, `tan` and `puan` attaching to `sri`, each a title off by default in ms.toml for `locales.MS` (decisions/salutation-titles, the same day's entry). The build refused them: `attaches` had to name a word with a title reading ON by default, and `sri` holds none, hi.toml excluding it as a salutation and the exclusion refusing every title kind of a reading on by default. Decided 2026-11-21, B over A. A: turn `sri`'s title on by default, gated by mul.toml's `given` reading, and narrow hi.toml's exclusion. It moved no corpus name (0 of the 597 local-corpus names holding `sri`, `config_diff.py diff --local all --match '(?i)(^|[\s,.])sri([\s,.]|$)' default 'expr:Parser(lexicon=Lexicon.default().add("sri", kind="given").add("sri", kind="nobility", addresses="given"))'`, master `488ea605`), but it moved the default to satisfy a tool rule, and a style before the word makes a phrase there (`Hon. Sri Mulyani` title 'Hon. Sri', rules/H9). B: the build check admits a partner whose title reading is off by default in the reading's own file, where the reading is off by default too, so the default compiles no phrase and holds no `sri` title (`nameparser/config/_compiled.py` holds no `tan`, `sri` or `puan`), and the one choice of the file turns both on. The check still refuses a partner with no title reading, one with only a name reading in the file, one another file turns on, and a partner off by default beside a reading on by default, each a mutation in tests/v2/test_vocab.py; the other-file refusal holds even where a choice of the reading's file selects that file too (`pt.toml` under `pt-BR`), narrower than the reason needs, so a phrase's two halves stand in one file. Option B pays A's style cost under the pack alone (`Hon. Sri Mulyani`), beside the pack's own for `tan` (`Hon. Tan Ah Kow` title 'Hon. Tan'), both recorded in decisions/salutation-titles' entry. A caller's `Lexicon.add` had no such check and gets none: a phrase naming no title word compiles to nothing, an inert entry (AGENTS.md, invariants guard harm, not no-ops), and under a choice the compile builds a phrase only from the title words the chosen pool holds. diff --git a/docs/release_log.rst b/docs/release_log.rst index 3ddc45cd8..c6400ee8f 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -20,7 +20,7 @@ Release Log - **Fix an Arabic-script name written with الدين or الله second, which read as two names.** ``parse("نور الدين سامر حداد")`` gives given ``نور الدين``, where 1.4.0 through 3.1.0 gave given ``نور``, middle ``الدين سامر``; ending the name the pair is the family name, and ``الدین``, ``اله`` and ``اللہ`` read the same way; a name of two name words keeps them apart. ``Lexicon.add`` accepts a new kind, ``bound_second``, for such a word. :issue:`1072` - **Add Qari, Moulana, Alhaj and Alhajj as titles, the religious titles written before a name in Pakistan and Bangladesh.** ``parse("Qari Ahmed Khan")`` gives title ``Qari``, given ``Ahmed``, where 1.4.0 through 3.1.0 gave given ``Qari``, middle ``Ahmed``. ``Hafiz``, ``Hafez``, ``Haji`` and the spelling ``Maulana``, often borne as given names, still read as the given name by default (``locales.MS`` reads ``Haji`` as a title). :issue:`1469` - **Fix Abdel, Abd and Abou past the first word of a name, which read as a middle name of their own.** ``parse("Tariq Abdel Aziz")`` gives family ``Abdel Aziz``, where 1.4.0 through 3.1.0 gave middle ``Abdel``, family ``Aziz``. ``Abdul`` joins only in a name of four words or more, titles and suffixes not counted, so ``Tariq Abdul Aziz`` keeps middle ``Abdul``; and after a family comma ``Abd`` before a name word is no longer the credential ABD. :issue:`1464` - - **Add locales.MS, a Malay pack, and read the Malaysian honours Datuk, Dato', Datin and Hajah as titles.** ``parse("Datuk Ahmad bin Ali")`` gives title ``Datuk``, given ``Ahmad``, where 1.4.0 through 3.1.0 gave given ``Datuk``, middle ``Ahmad``; ``parser_for(locales.MS)`` also reads Puan, Cik, Ustaz, Ustazah, Cikgu, Tun, Haji and the phrases Tan Sri and Puan Sri as titles (``Puan Siti binti Ahmad`` gives title ``Puan``, where the default gives given ``Puan``). Keep the pack to Malaysian names: it reads the Indonesian given name ``Puan`` and the Burmese given name ``Tun`` as titles (``Puan Maharani``); ``Tuan``, a hereditary prefix, stays a name word, and so do ``Tan`` and ``Sri`` outside their phrase, each with a ``title-or-name`` report. See :ref:`malay-names`. :issue:`1179`, :issue:`1180` + - **Add locales.MS, a Malay pack, and read the Malaysian honours Datuk, Dato', Datin and Hajah as titles.** ``parse("Datuk Ahmad bin Ali")`` gives title ``Datuk``, given ``Ahmad``, where 1.4.0 through 3.1.0 gave given ``Datuk``, middle ``Ahmad``; ``parser_for(locales.MS)`` also reads Puan, Cik, Ustaz, Ustazah, Cikgu, Tun, Haji and the phrases Tan Sri and Puan Sri as titles. Keep the pack to Malaysian names: it reads the Indonesian given name ``Puan`` and the Burmese given name ``Tun`` as titles (``Puan Maharani``); ``Tuan``, a hereditary prefix and a Vietnamese given name, stays a name word, and so do ``Tan`` and ``Sri`` outside their phrase, each with a ``title-or-name`` report. ``Sri`` or ``Seri`` written behind another honour stays a name word, by default and under the pack (``Datuk Seri Anwar Ibrahim`` gives given ``Seri``). See :ref:`malay-names`. :issue:`1179`, :issue:`1180` - **Change Parser.suggest() to suggest two_family_names for a list whose names end in two family names, and add Signal.FIRST_SURNAME, the signal that votes for it.** ``Parser().suggest(["María García López", "Juan Pérez Ruiz", "Ana Martínez Soto"]).patch`` gives ``PolicyPatch(two_family_names=True)``, where 3.1.0 suggested nothing; it is weighed only where the list's order is given-first, and lists measured from Argentina, Brazil and Portugal are rarely or never suggested it. ``NameEvidence.votes`` may now hold ``True`` or ``False``, the switch's value a name votes for. :issue:`1452` - **Fix Arabic titles written short, which read as the given name, and stop giving initials for Arabic-script names.** ``parse("د. أحمد علي حسن")`` gives title ``د.``, given ``أحمد``, where 1.4.0 through 3.1.0 gave given ``د.``; ``أ.د.``, ``م.م.``, a title glued to the name and the ranks ``اللواء`` and ``المستشار`` read as titles too, and ``initials()`` gives nothing for a word in Arabic script, as for Thai and Burmese, nor does the name match read its letter as an initial. A title written with a slash for its full stop reads as the title too, in any script (``د/ أحمد``, ``Dr/Jane Smith``), where 1.4.0 through 3.1.0 read the given name. :issue:`1149` - **Change Parser.suggest() to read where a Russian-style patronymic stands as a vote on the order, and add Signal.PATRONYMIC_POSITION, the signal that casts it.** ``Parser().suggest(["Sidorov Ivan Petrovich", "Volkov Pavel Sergeevich", "Orlova Anna Ivanovna", "Zaitsev Oleg Nikolaevich", "Belova Vera Andreevna"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=...)``, where 3.1.0 gave the rule with the given-first order, which misread any name of two words in such a list (``Sidorov Ivan`` gave family ``Ivan``); a patronymic in the middle votes given-first. :issue:`1447` diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 381f32dd2..2e1dbc8ef 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1359,10 +1359,9 @@ def _check_cjk_shape_purity(self) -> None: "Tan Sri", {"title": "Tan", "given": "Sri"}, locale="ms", classification="feat(#1180)", ambiguities=("title-or-name",), - notes="the phrase with no name behind it: rules/H1 gives the one " - "name word to the given name, as Field Marshal reads by " - "default; 1.4.0 through 3.1.0 read given 'Tan', family " - "'Sri'"), + notes="the phrase with no name behind it leaves its first half a " + "title, as Field Marshal does by default (title 'Field'); " + "1.4.0 through 3.1.0 read given 'Tan', family 'Sri'"), Case("the_malay_pack_cuts_tan_sri_at_a_comma", "Tan Sri, Muhyiddin", {"title": "Tan", "given": "Muhyiddin", "family": "Sri"}, diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index f47da5eab..459c250d8 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -583,8 +583,8 @@ def test_ms_is_plain_since_strict_drops_other_languages_readings() -> None: @pytest.mark.parametrize("text", ["Puan Maharani", "Tuan Nguyen", "Nguyen Van Tuan", "Cik Rohaida Hak", # #1180's words - "Sri Mulyani", "Tan Chee Chai", "Tun Aung", - "Haji Ali", "Tan Sri Ali"]) + "Sri Mulyani", "Tan Chee Chai", "Tun Hla", + "Haji Juma", "Tan Sri Ali"]) def test_ms_words_move_no_indonesian_or_vietnamese_choice(text: str) -> None: # puan is an Indonesian given name: the default keeps it, and so do a # choice of id and one of vi, neither of which reads ms.toml (no file