diff --git a/README.rst b/README.rst index 00e677c54..9df84fee3 100644 --- a/README.rst +++ b/README.rst @@ -184,7 +184,7 @@ the patronymic in Russian. See `Locale packs >>> ivan.given, ivan.patronymic, ivan.family ('Иван', 'Петрович', 'Сидоров') >>> locales.available() # every pack that ships - ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'my', 'ne', 'nl', 'pt', 'pt_br', 'pt_pt', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') + ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'ms', 'my', 'ne', 'nl', 'pt', 'pt_br', 'pt_pt', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') When a reading is wrong for your data ------------------------------------- diff --git a/docs/design/decisions/salutation-titles.md b/docs/design/decisions/salutation-titles.md index 0f975b23e..52b8a1efa 100644 --- a/docs/design/decisions/salutation-titles.md +++ b/docs/design/decisions/salutation-titles.md @@ -7,7 +7,7 @@ Closes #606 (#662 later added owura and bapak, its bullet below, and #847 cllr). - A word that addresses or ranks a person and is written in FRONT of the name ships as a title unless it is borne as an ordinary name in the leading position, the position test of vocabulary-collisions' C-i, TITLES having no ambiguous subset to mark a collision in, so the only answers are ship and do not ship — 2026-10-04 #606. - One exception to C-i, for TITLES alone: a word borne as a name only RARELY as the first word of one ships on the precedent of `graf` (`herra`, `batoni`, `hrabia`, `kreivi` and the rest of the graf class, each with its counts on its title reading's `note`), and no word in the particle or suffix sets, and no later title, takes it without its own counts — 2026-10-04 #606. - The cost falls on a name that BEGINS with such a word: `Greve Anna` reads title 'Greve', family 'Anna' and `Herra Wijaya` title 'Herra', family 'Wijaya'; a declared `FAMILY_FIRST` does not help (`Hrabia Anna` reads title 'Hrabia' under it); the family comma keeps the word as the family where no name word stands behind it (`Hrabia, Anna` reads given 'Anna', family 'Hrabia', and so does `Hrabia Jr., Anna`), while a name word behind it makes it the title by H6 (`Hrabia Nowak, Anna` reads title 'Hrabia', family 'Nowak'); a name that ends in the word keeps it (`Gladys Knight`, `Knight, Gladys` read family 'Knight'), unless a period follows it (`Gladys Knight.` reads title 'Knight.', family 'Gladys', by H5, accepted rather than prevented) — 2026-10-04 #606. -- Words judged a COMMON leading-position name stay out (`thiru`, `puan`, `pan`, `rodina`, and `ông` and its pair `bà`), and words with no evidence either way are not shipped (`gróf`, `cik`, `paron`, `tikin`), each an `excluded` entry in its language's file, and Latin `janab`, whose exclusion was removed on 2026-11-03 with no evidence to refuse it by either (decisions/indic-honorifics, #345) (`uv run python tools/vocab/query.py --excluded title --issue 606`) — 2026-10-04 #606. `pan` alone has since become a `salutation` reading written `default = false` in cs.toml and pl.toml, which a Czech or Polish choice turns on and the default does not read — 2026-10-30 #753, phase 3f. +- Words judged a COMMON leading-position name stay out (`thiru`, `puan`, `pan`, `rodina`, and `ông` and its pair `bà`), and words with no evidence either way are not shipped (`gróf`, `cik`, `paron`, `tikin`), each an `excluded` entry in its language's file, and Latin `janab`, whose exclusion was removed on 2026-11-03 with no evidence to refuse it by either (decisions/indic-honorifics, #345) (`uv run python tools/vocab/query.py --excluded title --issue 606`) — 2026-10-04 #606. `pan` alone has since become a `salutation` reading written `default = false` in cs.toml and pl.toml, which a Czech or Polish choice turns on and the default does not read — 2026-10-30 #753, phase 3f. `puan` and `cik` have since become `salutation` readings written `default = false` in ms.toml, which `locales.MS` turns on, `cik` verified there as Miss — 2026-11-19 #1179. - Accents are not folded, so `paní` and `härra` match only their accented spellings (`Paní Nováková` reads title 'Paní', `Pani Anna` reads given 'Pani'); folding the lexicon would turn both into collisions, and whoever proposes it re-argues the entry — 2026-10-04 #606. - `gravos` was dropped, not excluded, since nothing showed it is the Greek word for Count; `κόμης`, a Greek surname written first in official lists, is neither added nor excluded, and adding it is a decision still to make — 2026-10-04 #606. - `knt` (Knight, beside `kt`) is a suffix acronym with a `Knt` case mask: `Mary Knt` reads suffix 'Knt' — 2026-10-04 #606. @@ -19,13 +19,15 @@ Closes #606 (#662 later added owura and bapak, its bullet below, and #847 cllr). - `owura` (Akan) and `bapak` (Indonesian) are titles, on counts under 100 US Census bearers each and none found on Wikidata, and `malam` (Hausa) and `bay` (Turkish) are excluded, each an `excluded` entry with its counts — 2026-10-17 #662. - 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. + 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 - A job or a degree written out after the name and a comma (`Nadir Qassoumi, Bachelor`) is an `occupation` title, and a word that qualifies one (`Medical Doctor`, `Clinical Research Coordinator`) a `modifier`, in English, word by word on the counts on each entry; as a title the word is claimed in front of a name too, so a surname that mostly qualifies a head is listed as a modifier, which claims none alone (`head`, `child`), and the surnames listed as heads ship on the graf exception with their counts (`masters`, `student`, `bachelor`, `degree`): the 2026-11-19 #1457 entry lists the 58 words, the words refused, and the costs taken — 2026-11-19 #1457. A degree's possessive (`master's`, `bachelor's`, `doctor's`, each also with the typographic apostrophe) is a `modifier`: after a comma it is the title alone or before its head, and opening a name it is the title only before a head (`Master's degree Nadir Qassoumi`), never alone (`Master's Nadir` keeps given 'Master's' given-first, family 'Master's' under a family-first order, as before) — 2026-11-19 #1487. ## Log -- 2026-10-04 #606 (its family-comma remedy superseded in part by #701, decisions/H6) — SALUTATIONS, OFFICES AND RANKS FOR THE LANGUAGES TITLES HAD NONE FOR: the undated bullets below, through the measurement. +- 2026-10-04 #606 (its family-comma remedy superseded in part by #701, decisions/H6; its exclusions of `pan` by 2026-10-30 #753, phase 3f, and of `puan` and `cik` by 2026-11-19 #1179, each a reading off by default, below) — SALUTATIONS, OFFICES AND RANKS FOR THE LANGUAGES TITLES HAD NONE FOR: the undated bullets below, through the measurement. - **The graf class, decided (Derek, 2026-10-04).** A word borne as a name, but RARELY as the first word of one, ships anyway, on the precedent of graf, which shipped though Steffi Graf exists. This is a judgment on each word's incidence in the leading position — the position C-i asks about — and not a rule, and it is an EXCEPTION to C-i rather than an application of it: C-i is an iff with no threshold, and herra, batoni, hrabia and kreivi were measured as borne in that position, so C-i says do not ship them (TITLES having no ambiguous subset to mark them in). What the exception adds is a weighing C-i does not make, a small measured incidence against the benefit of the title reading, and it is scoped to TITLES and to the words this entry names. It licenses nothing in the particle or suffix sets, and a later TITLES word that wants it is argued on its own counts. The title claim acts only in front, so most bearers are untouched in the forms they write: `Gladys Knight` and `Knight, Gladys` keep family Knight. The cost falls on a name that BEGINS with the word, the cost `Graf Steffi` already paid: `Greve Anna` reads title Greve, family Anna, and a given name is lost the same way, `Herra Wijaya` reading title Herra, family Wijaya. Declaring `FAMILY_FIRST` does not help, since the title claim is read before the order (`Hrabia Anna` reads title Hrabia under it); the family comma does. Two further limits, both pre-existing: a trailing period makes the word the title by rules/H5 (`Gladys Knight.` reads title `Knight.`, as `Mary Jane King.` does), and every word this entry adds widens that rule's reach, H5 claiming any listed title behind a period. Accepted rather than prevented, and stated at rules/H1's Accepted clause. The issue proposed the class for three words — greve (Scandinavian Count), graaf (Dutch Count), knight. The spot-check the issue asked for (forebears.io, 2026-10-04, worldwide counts rounded) found ten more of its "no known collision" words borne, and Derek extended the decision to all of them rather than excluding them: herra, batoni, ponas, counsel, ponia, the Filipino ginoo, ginang and binibini, and two whose registers often write the surname first, hrabia and kreivi. Each word's counts are on the `note` of its title reading in one of its files (herra's in fi.toml), a note beginning "borne" (`uv run python tools/vocab/query.py --issue 606 --kind title`; this bullet held them until 2026-10-19, #750). Those last two, and the given-name uses of herra and batoni, are the leading-position bearers this class accepts, and were decided on with their counts in hand. The line is NOT reproducible from this record, and that is said rather than hidden: the accepted side was counted, while the excluded side — thiru, puan, pan, rodina, ông/bà — was judged from general knowledge of each word, as #606 drafted it, with no count taken (the count source refused further lookups the same day). Each was judged a COMMON leading-position name, against counts in the hundreds on the accepted side; gróf was excluded for want of any evidence at all. Each refusal is an `excluded` entry in its language's file (`uv run python tools/vocab/query.py --excluded title --issue 606`). Whoever decides κόμης or the next salutation should count the excluded words first, and is free to find the line in a different place. Those notes are where a sweep meets the decision as it meets the word (the `# borne` comment in titles.py until 2026-10-18). - **Accents are not folded, and two words depend on it.** `_lexicon._normalize` lowercases and composes NFC and does nothing else to letters, so paní and härra cannot match Pani or Harra (the counts are on their notes). Accent-folding the lexicon would turn both into collisions; whoever proposes it re-argues this entry. frú depends on nothing: the unaccented fru (Swedish/Danish Mrs) already ships, so the Cameroonian surname Fru (its count on fru's note in sv.toml) already reads as a title in `Fru Anna` and did before this entry; that pre-existing collision is recorded here rather than argued, being no part of #606. @@ -74,3 +76,11 @@ Elsewhere: `justice` and `marshal`, excluded here as common leading-position nam - **Collisions.** No name reading: US Census folds the apostrophe (`Masters` 23,533, `Bachelors` and `Doctors` under 100), and `masters` keeps its own reading (`Masters, John` family 'Masters'). `Doctor`, a listed title, is a different word and reads as before; a surname with an apostrophe (`O'Master`) and a possessive ending a name (`Nadir Master's`, family) do not move. - **MEASURED** against master `13cf07cd` (2026-11-19, py3.11), `tools/differential/measure.py --base`: 30 steps, two moving, `ctgov-contacts` 183 entries and `ctgov-officials` 98, 274 distinct names (`master's` 167, `bachelor's` 73, `doctor's` 34; the #1457 entry's 166 for `master's` counts parts after a comma, and the 167th name writes it with no comma before it, `Master's Degree Candidate`); `fec-individuals` and every other local corpus, the committed snapshot and the CLDR and GND records move none. Each moved name was read: 258 now read the name before the comma apart with the possessive in the title (`master's` 160, `bachelor's` 64, `doctor's` 34): 251 the base read reversed, and 7 it read apart already, the possessive moving out of the suffix into the title with the name fields kept (`Nadir Qassoumi, MD, Master's degree`), one of them leaving the field it was written with in the suffix (`…, MD, Master's in epi` → title "Master's", suffix 'MD, in epi'). 16 read wrong as they did before, the name before the comma still the family: a field written after `in` or `of` (10, `Master's Degree in Medicine` → given 'in'), a field written bare (1, `Master's Nursing`), a word cut short or misspelled (4, `Bachelor's deg`, `Master's Stu`, `bachelor's physical thrapy`), and one part holding no name. None reads worse in its name fields. Two shapes that are no person's name, probed rather than found in the corpora, move too: a label with no comma (`Master's degree` → title "Master's", family 'degree', reporting `title-or-name`) and a possessive before `of` (`Master's of Science Nadir` → title "Master's of Science"). - Recompute: `uv run python tools/differential/measure.py --base `; the moved names are the entries listed in its ctgov steps, each classed by reading it. + +- **2026-11-19 #1179 — MALAY TITLES UNDER A MALAY CHOICE: `puan`, `cik`, `ustaz`, `ustazah` AND `cikgu` ARE READ BY `locales.MS`; `tuan` IS NOT.** Malaysian lists write a salutation or a teacher's title in front of a name, and the default reads it as the given name (`Puan Siti binti Ahmad` given 'Puan'). Each is a reading written `default = false` in ms.toml, so the default does not move, and the new pack `locales.MS`, a choice of `ms` and nothing else (a public addition), turns them on. SUPERSEDES: the 2026-10-04 #606 exclusions of `puan` and `cik`, which ms.toml's readings replace; `puan` stays off by default, as #606 decided. + - **THE COUNTS** (`tools/name_usage.py --boxes --country MY`, 2026-11-19; each on its word's note): of Malaysia's election candidates (`my-candidates`, 3,077 distinct names in capitals), 70 open with `USTAZ`, 40 with `CIKGU`, 3 with `USTAZAH`, 2 with `CIK GU`, 1 with `PUAN` (`PUAN SRI`); the 2015 King's birthday honours list, as #1179 measured it on 2026-11-08 and not rebuilt here (a newspaper's text), holds `Puan` in 295 title runs of 1,504, `Cik` in 11, before women's names, which verifies `cik` as Miss, #606's open question. As names: `puan` in ORCID's given box 8 times among Indonesia's 252,703 holders and once among Malaysia's 62,996, the reason it stays off by default; `cik` 8 given and 2 family among Malaysia's, a hereditary prefix in Kelantan too; `ustaz`, `ustazah` and `cikgu` in no Malaysian box. + - **`tuan` IS LEFT OUT, the issue's second open question answered by the counts.** Malaysians who file their own names write it first as the hereditary prefix, repeated before the father's name (`Tuan Aminah binti Tuan Yusof`): ORCID's and PatentsView's Malaysian records open with it 22 times, every one in the given box, and the 5 Malaysian records writing it after `bin` or `binti` hold it as a name word; my-candidates opens with it 3 times, 2 of them `TUAN GURU`. As a salutation under the choice (`config_diff.py score`, all boxes agreeing) it moved ORCID MY from 76.72% to 76.70% and PatentsView MY from 90.56% to 90.50%, and the Vietnamese records of ORCID (68.51% → 67.98%), PatentsView (90.26% → 89.04%) and Companies House (73.43% → 71.95%), `Tuan` being a Vietnamese given name. Reading only the honours lists' `Tuan` would need a rule that reads a `Tuan` repeated later in the name, not vocabulary; none is proposed. + - **PLAIN, NOT STRICT** (the rule in nameparser/locales/AGENTS.md). A strict choice of `ms` against the plain one, all boxes agreeing: ORCID MY 76.72% → 76.16%, PatentsView MY 90.56% → 90.59%, Companies House's Malaysians 83.69% → 84.59%; on my-candidates 110 of 3,077 names and on `my_parliament` 8 of 292 move, most of them `Abdul` losing ar.toml's bound reading (`Abdul Hadi bin Awang` given 'Abdul', middle 'Hadi') and English titles (`Lawyer`, `Associate`) becoming name words, beside `meng` and `bt` losing their credential readings. Malaysian lists mix Malay, Chinese and Indian names, so the pack is the plain choice and removes nothing. + - **MEASURED** (`config_diff.py diff default plain:MS`, 2026-11-19): my-candidates 117 of 3,077 names move, each a word above becoming the title (`USTAZ` 69, `CIKGU` 41, `USTAZAH` 4, `CIK` 2, `PUAN` 1; accepted: the two `CIK GU`, cikgu written in two words, reading given 'GU', and `PUAN SRI BIBI SHARLIZA`, the wife of a Tan Sri, reading given 'SRI' until `Puan Sri` is a title, #1180); `opensanctions-parliaments` 2 of 26,400, `CIK UJANG` and Indonesia's `PUAN MAHARANI`, the cost of choosing the pack for Indonesian names; the committed corpora none and ClinicalTrials.gov 1 of 713,175 (`Puan Jue`). Scored against the boxes of ORCID's, PatentsView's and Companies House's Malaysian, Indonesian, Singaporean and Vietnamese records, no group's share moves. + - **WEIGHED AND KEPT: positional H1, and `after_given` on `puan` and `cik`.** A Malay title addresses by the given name, so a title and one name word could read the word as the given name (`addresses = "given"`, as th.toml's titles do); it is not set, as `encik`, and my.toml's `u` and `daw` set it not, `Cikgu Zakri` reading family 'Zakri' by rules/H1, and setting it on `encik` would move the default. `puan` and `cik` carry `after_given`, as `encik` and hi.toml's salutations do, so `Ahmad, Siti Puan` reads title 'Puan' under the pack (rules/H8). + - **`Abdul`'s join (#1464)** is left to the change building it; once it lands as a property of the bound word, an ms.toml reading of `abdul` written `default = false` would let this pack turn it on, copying every other file's vocabulary reading of the word with it, as my.toml's `lt` copies its credential (decisions/vocabulary-collisions, the 2026-11-19 #1483 entry). diff --git a/docs/design/decisions/vocabulary-exclusions.md b/docs/design/decisions/vocabulary-exclusions.md index f4f056f21..23c1e8ed0 100644 --- a/docs/design/decisions/vocabulary-exclusions.md +++ b/docs/design/decisions/vocabulary-exclusions.md @@ -59,7 +59,7 @@ Excluded (Lexicon.honorific_tails — a glued tail peels only if it could never Excluded (TITLES): -- The per-word refusals are data since #750 (2026-10-19): each word refused a title reading — the Indic ঠাকুর/ठाकुर, कुमारी/কুমারী, बेगम/বেগম, शेख/শেখ, आचार्य and राजा/रानी (#343, #344), and #606's ông/bà, thiru, puan, pan, rodina, gróf, cik, paron, tikin, marshal and justice, #662's malam (Derek's decline) and bay, #660's shehu, and #789's wm (2026-10-22) — is an `excluded` entry in its language's file with its reason, and with its counts as name readings where they were taken. `uv run python tools/vocab/query.py --excluded title` lists them. A contributor who adds one back meets the reason as a build error. +- The per-word refusals are data since #750 (2026-10-19): each word refused a title reading — the Indic ঠাকুর/ठाकुर, कुमारी/কুমারী, बेगम/বেগম, शेख/শেখ, आचार्य and राजा/रानी (#343, #344), and #606's ông/bà, thiru, puan, pan, rodina, gróf, cik, paron, tikin, marshal and justice, #662's malam (Derek's decline) and bay, #660's shehu, #1179's tuan (2026-11-19), and #789's wm (2026-10-22) — is an `excluded` entry in its language's file (save `pan`, `puan` and `cik`, each since a reading off by default for a language's choice to turn on, decisions/salutation-titles' 2026-10-30 #753, phase 3f and 2026-11-19 #1179 entries) with its reason, and with its counts as name readings where they were taken. `uv run python tools/vocab/query.py --excluded title` lists them. A contributor who adds one back meets the reason as a build error. - shehu's counts do not settle a graf-class weighing, and must not be read as if they did: its one leading-position figure, the Wikidata given-name count on its entry, is a lower bound (Shagari's own entry has no given-name statement), and its other counts are family-name bearers, a position C-i does not ask about. The evidence that Shehu leads a name is not a count. It is Shagari himself, and CLDR's Hausa sample data, whose six renderings carrying the word all file it as the given name (`grep '"given": "Shehu"' tools/differential/cldr_fields.jsonl`). It arrived with an early bulk import (1a51555f) and was never put to C-i before #660. Whoever re-argues it counts Hausa given-name use first; the accepted cost is the honorific use, `Shehu Abubakar` reading given Shehu as any untitled name does, and the reading belongs in an opt-in pack if anyone asks for it. malam is the opposite case: CLDR's Hausa data files Malam as the title (`grep '"title": "Malam"' tools/differential/cldr_fields.jsonl`), so its refusal is a decline on the counts, not a shehu-style removal. - The class-level half of the Indic refusals stays here: the divergence on शेख/শেখ is deliberate and is the sri/shri case run backwards — the Latin sheikh cluster SHIPS as given-name titles for the Arabic addressing form, while the Indic spellings name the family. Since 2026-10-27 the Latin spellings but `shaykh` are titles only inside a title phrase (decisions/H9), so at the head of a name `Shekh Ahmed` and `शेख अहमद` both read the word as the given name, and the divergence stands only where a style, a modifier or `of` makes the Latin word a title, or a period does at the front by rules/H2's shape (`Sheikh. Ahmed` reads title 'Sheikh.', `शेख. अहमद` given 'शेख.'). shehu's removal moved three CLDR corpus names (`Shehu Muhammed`, `Muhammed, Shehu`, `Modibbo, Shehu Bello`), all three now agreeing with CLDR on every role (moves: `uv run python tools/differential/snapshot.py --since v2.4.1`). - The trailing-position rule that must NOT be adopted, and 2026-09-08 says what the line is: TITLES holds hundreds of words in no suffix set, at least nineteen of them ordinary English surnames (king, judge, bishop, baron, sheriff, ...; `king` has since left TITLES, a title only inside a title phrase by decisions/H9's #752 phase 2j, so `Mary Jane King.` now reads family 'King.', while `Mary Jane Pope.` still reads title 'Pope.'), so a blanket "vocabulary outranks position in the trailing slot" reading would turn "Mary Jane King" into title="King" with the family name gone. The leading half of this argument is AGENTS.md's "Titles permanently shadow first names" gotcha, whose example is Dean; this is the trailing half, and it shadows the family name rather than the given (#316). What #316 settled is that the prohibition is on BARE words: "Mary Jane King" still reads family King, while "John Smith Prof." reads title Prof. **The second half of that argument is RETRACTED 2026-09-09**, in review of the docs commit: "a period-marked trailing word being one nobody writes as a surname" claimed the period keeps the collision out of the trailing slot, and it does not. Measured on the branch tree — "Mary Jane King." reads title "King.", given Mary, family Jane, the family name shadowed exactly as the bare reading would have shadowed it, and "John Smith Judge." reads title "Judge." The reach is the vocabulary rather than a handful: of the 746 titles in no suffix set, 627 read as a trailing title once a period is written behind them, and every one of the 119 that do not is kept out by the abbreviation SHAPE — a digit, a hyphen, an apostrophe, or a script whose letters carry combining marks (rules/H2 records that half) — no plain ASCII-letter title missing at all. So king, judge, bishop, baron and sheriff ARE reachable in the trailing slot; what the prohibition above buys is the bare spelling and nothing more. The period is a WRITING convention the rule can read, not evidence about the word, and reading it is an ACCEPTED COST under the premise that the input is a name (rules.md H Background): someone who ends a name with a period-marked word has written an abbreviation. rules/H5 carries it as an Accepted clause with "Mary Jane King." as the executable example. (Since 2026-10-26 `king` is a title only inside a title phrase, decisions/H9, #752 phase 2j: "Mary Jane King." reads family "King." and the surnames this paragraph names are pope, judge, bishop, baron and sheriff, rules/H5's example "Mary Jane Pope.".) Recompute the reach with `L = Parser().lexicon; ws = [w for w in L.titles - L.suffix_acronyms - L.suffix_words if " " not in w]; len([w for w in ws if parse("Mary Jane %s." % w).title])` against `len(ws)` — 627 of 746 on 2026-09-09 — the digits move as the vocabulary grows and neither argument does. See #H5. (Since 2026-11-06, decisions/H5's #1116 entry, a hyphen or a period inside the word no longer keeps a word out: 718 of 820 reach the trailing slot, 688 before, the 30 added including whole hyphenated words as well as abbreviations (`co-founder`, `senior-judge`, `singer-songwriter`, `priv.-doz`, `sig.ra`), and the recipe reads `Parser().lexicon._sets` since 3.0's 4i-b. Of the 102 still kept out, 35 hold a digit, 5 an apostrophe and 54 combining marks, and 8 are kept out by what the list above does not name: a slash (`mag/judge`), the Hebrew geresh and gershayim (`ד"ר`, `פרופ׳`), and the single letter `ড`.) The bare prohibition has one exception since #835 (decisions/H8): a listed salutation ending the given part after a family comma is the title, the comma having marked the surname's place and the salutations borne as names being excluded. diff --git a/docs/languages.rst b/docs/languages.rst index c399c3fe1..12af98a5c 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -19,7 +19,7 @@ subset with its own parser, or pass several packs to ``parser_for``: The sections below cover Czech, Slovak, Slovenian and Croatian names, Spanish and Portuguese titles and family names, romanized Indic titles, Vietnamese, Mongolian and Thai names, Maghrebi, Amazigh, Hebrew and -Dutch particles, and Burmese names. Other languages are described where their mechanism is: +Dutch particles, and Burmese and Malay names. Other languages are described where their mechanism is: - **East Slavic patronymics** (``ru``): :ref:`east-slavic-patronymics`. - **Turkic patronymic markers** (``tr_az``): @@ -1430,3 +1430,79 @@ Minjun`` keeps it as the family name. Chosen strictly, the pack also reads a run of initials holding ``U`` as the title (``U.S. Grant`` gives title ``U.S.``, family ``Grant``). Keep the pack to a parser of its own for the Burmese names in your data. + +.. _malay-names: + +Malay names +----------- + +Turn on ``locales.MS`` when your data is Malaysian names, Malay ones +written with the titles Malaysian lists put in front of them. ``ms`` is +the language tag of Malay (Burmese is ``my``, :ref:`burmese-names`). + +A Malay name has no family name either: a given name, then ``bin`` +(son of) or ``binti`` (daughter of) and the father's name, which the +default reads as the family already. What the pack adds is the words +written before the name. ``Encik`` (Mr.) is a title by default; the +pack reads ``Puan`` (Mrs.), ``Cik`` (Miss), ``Ustaz`` and ``Ustazah`` +(a religious teacher) and ``Cikgu`` (teacher) as titles too: + +.. doctest:: + + >>> parse("Puan Siti binti Ahmad").given + 'Puan' + >>> malay = parser_for(locales.MS) + >>> siti = malay.parse("Puan Siti binti Ahmad") + >>> siti.title, siti.given, siti.family + ('Puan', 'Siti', 'binti Ahmad') + >>> hafiz = malay.parse("USTAZ HAFIZ BIN OMAR") + >>> hafiz.title, hafiz.given, hafiz.family + ('USTAZ', 'HAFIZ', 'BIN OMAR') + +Each is off by default, because a name elsewhere is written with it or +because only Malaysian lists write it: ``Puan`` is an Indonesian given +name, so the default keeps ``Puan Maharani``'s given name, and the pack +does not. Choose the pack +for Malaysian lists, not Indonesian ones. + +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`). + +What the pack leaves as it is +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Tuan`` (Mr., Sir) stays a name word. Malaysians who file their own +names write it first as a hereditary prefix, repeated before the +father's name, and a Vietnamese given name is written so too: + +.. doctest:: + + >>> aminah = malay.parse("Tuan Aminah binti Tuan Yusof") + >>> 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``). +``bt``, written short for ``binti``, stays a credential (Baronet), as +by default; :doc:`customize` shows how to remove it. + +Plain, not strict +~~~~~~~~~~~~~~~~~ + +Choose the pack plainly. Malaysian lists mix Malay, Chinese and Indian +names with English and Arabic titles, and a strict choice of ``ms`` +reads only the words of ``ms`` and those shared by every language, so +it drops ``Abdul``'s join and English titles such as ``Sir``: it matches the boxes of 76.16% of ORCID's +Malaysian holders, against 76.72% for the plain choice (measured +2026-11-19). + diff --git a/docs/locales.rst b/docs/locales.rst index 605ba0b9f..972eab04e 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -144,6 +144,8 @@ shape covers much: the order moves every name a family comma does not fix, and its titles and removed readings reach the comma names too. - ``mn`` may read any name written wholly in Cyrillic differently. +- ``ms`` may read any name holding ``Puan``, ``Cik``, ``Ustaz``, + ``Ustazah`` or ``Cikgu`` 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 @@ -186,7 +188,7 @@ look one up dynamically by its lowercase code with .. doctest:: >>> locales.available() - ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'my', 'ne', 'nl', 'pt', 'pt_br', 'pt_pt', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') + ('ar', 'bn', 'cs', 'es', 'es_ar', 'ga', 'gd', 'he', 'hi', 'hr', 'ja', 'mn', 'ms', 'my', 'ne', 'nl', 'pt', 'pt_br', 'pt_pt', 'ru', 'sk', 'sl', 'tr_az', 'vi', 'zh') >>> locales.get("ru") is locales.RU True @@ -296,6 +298,13 @@ says which parts each pack is made of. name last, so the father's name, written first, is the family. See :ref:`Mongolian names `. - ``Батын Сүхээ`` → family ``Батын``, given ``Сүхээ`` + * - ``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 + :ref:`malay-names`. + - ``Puan Siti binti Ahmad`` → title ``Puan`` * - ``my`` - Burmese - Chooses ``my``, which reads the honorifics ``U`` and ``Daw`` @@ -391,8 +400,8 @@ says what it can change: - Chooses a language - Policy fields - Word list - * - ``ar``, ``bn``, ``ga``, ``gd``, ``he``, ``hi``, ``hr``, ``nl``, - ``pt``, ``sl`` + * - ``ar``, ``bn``, ``ga``, ``gd``, ``he``, ``hi``, ``hr``, ``ms``, + ``nl``, ``pt``, ``sl`` - yes - none - none diff --git a/docs/release_log.rst b/docs/release_log.rst index 90ac27379..c11d2c22e 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,6 +4,7 @@ Release Log nameparser 3.2 is under development. + - **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` - **Change Parser.suggest() to read where a Russian-style patronymic stands as a vote on the order, and add Signal.PATRONYMIC_POSITION, the signal that casts it.** ``Parser().suggest(["Sidorov Ivan Petrovich", "Volkov Pavel Sergeevich", "Orlova Anna Ivanovna", "Zaitsev Oleg Nikolaevich", "Belova Vera Andreevna"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=...)``, where 3.1.0 gave the rule with the given-first order, which misread any name of two words in such a list (``Sidorov Ivan`` gave family ``Ivan``); a patronymic in the middle votes given-first. :issue:`1447` - **Fix ud inside a South Asian compound name, which read as a credential and took the rest of the name.** ``parse("NADIR ZIA UD DIN")`` gives middle ``ZIA UD``, family ``DIN``, as 1.4.0 through 2.3.0 did, where 2.4.0 through 3.1.0 gave family ``ZIA``, suffix ``UD DIN``; ``UD`` alone after a name and a comma now reads as initials (``Anke Vissering, UD`` gives given ``UD``, family ``Anke Vissering``, where 1.4.0 through 3.1.0 gave suffix ``UD``). ``bt`` stays a credential: for Malay names remove it, as :doc:`customize` shows. :issue:`1467` - **Fix the surname1 and surname2 views, which left a family of two surnames whole before a family comma, opening with a particle, or behind a given name a particle completes.** Under ``two_family_names``, as ``locales.ES``, ``ES_AR``, ``CS``, ``SK``, ``PT_BR`` and ``PT_PT`` turn it on, ``parser_for(locales.ES).parse("García Márquez, Gabriel")`` gives surname1 ``García``, surname2 ``Márquez``, as ``Gabriel García Márquez`` does, where 3.0.0 through 3.1.0 gave surname1 ``García Márquez``, surname2 ``''``. No field moves; a family joined by ``y`` or written as one hyphenated word stays whole, and so, where 3.0.0 through 3.1.0 divided them, do a lone particle and the word after it under a family-first order (``Van Gogh``) and a Turkic father's name with its marker; with ``capitals_as_family`` on too, the family the capitals name is divided. :issue:`1456`, :issue:`1479` diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 2f70eab50..94ade71d6 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -583,6 +583,8 @@ ('ciccio', (('it', 'familiar', (('short_for', ('francesco',)),)),)), ('cie', (('en', 'credential', ()),)), ('cig', (('en', 'credential', ()),)), + ('cik', (('ms', 'salutation', (('after_given', True), ('default', False))),)), + ('cikgu', (('ms', 'occupation', (('default', False),)),)), ('cindy', (('en', 'familiar', (('short_for', ('cynthia',)),)),)), ('cip', (('en', 'credential', ()),)), ('cipm', (('en', 'credential', ()),)), @@ -2306,6 +2308,7 @@ ('pta', (('en', 'credential', ()),)), ('pta/l', (('en', 'credential', ()),)), ('ptech', (('en', 'credential', (('cased', 'PTech'),)),)), + ('puan', (('ms', 'salutation', (('after_given', True), ('default', False))),)), ('publisher', (('en', 'occupation', ()),)), ('pursuivant', (('en', 'office', ()),)), ('pv2', (('en', 'military', ()),)), @@ -2774,6 +2777,8 @@ ('usmc', (('en', 'credential', ()),)), ('usn', (('en', 'credential', ()),)), ('usnr', (('en', 'credential', ()),)), + ('ustaz', (('ms', 'religious', (('default', False),)),)), + ('ustazah', (('ms', 'religious', (('default', False), ('same_as', 'ustaz'))),)), ('uxc', (('en', 'credential', ()),)), ('uxmc', (('en', 'credential', ()),)), ('uí', (('ga', 'clan', (('cased', 'Uí'), ('default', False), ('same_as', 'ó'))),)), diff --git a/nameparser/locales/__init__.py b/nameparser/locales/__init__.py index ddbaa83a8..809a95d02 100644 --- a/nameparser/locales/__init__.py +++ b/nameparser/locales/__init__.py @@ -35,6 +35,7 @@ "HR": ("nameparser.locales.hr", "HR"), "JA": ("nameparser.locales.ja", "JA"), "MN": ("nameparser.locales.mn", "MN"), + "MS": ("nameparser.locales.ms", "MS"), "MY": ("nameparser.locales.my", "MY"), "NE": ("nameparser.locales.ne", "NE"), "NL": ("nameparser.locales.nl", "NL"), diff --git a/nameparser/locales/ms.py b/nameparser/locales/ms.py new file mode 100644 index 000000000..b0fe35e36 --- /dev/null +++ b/nameparser/locales/ms.py @@ -0,0 +1,45 @@ +"""The Malay locale pack (#1179): a choice of the language ``ms``, and +nothing else. The choice turns on the readings nameparser/vocab/ms.toml +writes ``default = false``: the salutations ``Puan`` (Mrs.) and ``Cik`` +(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. + +``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 +the father's name (``Tuan Aminah binti Tuan Yusof``), where honours +lists write it as the salutation (decisions/salutation-titles, the 2026-11-19 +#1179 entry). + +The pack is a plain choice, not a strict one: Malaysian lists mix +Malay, Chinese and Indian names with English and Arabic titles, and a +strict choice of ``ms`` drops the readings other languages' files give +them (``abdul``'s bound reading, English titles such as ``Sir`` and +``Lawyer``), so it reads Malaysia's ORCID holders worse than the +default (the same entry). + +Data sources: the counts on each reading in ms.toml +(tools/name_usage.py; Malaysia's election candidates and ORCID's, +PatentsView's and Companies House's Malaysian records). The pack +carries no lexicon fragment and no policy patch. + +Declared deviations (mechanisms.md#LOCALE-PACKS-PURE-DATA): a +vocabulary pack's deviations are derived, not declared -- the words +whose compiled readings its choice changes +(``_reading_index.changed_words``), which the non-interference gate in +tests/v2/test_locales.py reads -- so this module defines no DEVIATES. +""" +from __future__ import annotations + +from nameparser._lexicon import Lexicon +from nameparser._locale import Locale + +MS = Locale( + code="ms", + lexicon=Lexicon.empty(), + languages=frozenset({"ms"}), +) diff --git a/nameparser/vocab/ms.toml b/nameparser/vocab/ms.toml index dae963183..b2462a9f9 100644 --- a/nameparser/vocab/ms.toml +++ b/nameparser/vocab/ms.toml @@ -2,7 +2,7 @@ schema = 1 [[word]] text = "cik" -excluded = { salutation = { reason = "Malay Miss: unverified, so not shipped", issue = 606, decided = 2026-10-04 } } +salutation = { default = false, gender = "f", issue = [606, 1179], decided = 2026-11-19, after_given = true, expands = "Miss, before a woman's name: \"Cik Siti binti Ahmad\"", note = "#606 left it out as unverified; the 2015 honours list writes it before women's names 11 times of 1,504 (#1179). Also a hereditary prefix borne as a name in Kelantan, and so read by a Malay choice only: ORCID's Malaysian holders write it first in 2 records, one with it in the given box as a name (Cik Rohaida), one with it alone in the given box (the salutation typed in); the given box 8 and family box 2 of 62,996 Malaysian holders; my-candidates 2, both CIK GU, cikgu written in two words (tools/name_usage.py --boxes --country MY, 2026-11-19)" } [[word]] text = "encik" @@ -10,12 +10,31 @@ salutation = { issue = 606, gender = "m", after_given = true } [[word]] text = "puan" -excluded = { salutation = { reason = "Malay Mrs., and an Indonesian given name (Puan Maharani)", issue = 606, decided = 2026-10-04 } } +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)" } + +[[word]] +text = "tuan" +[word.excluded.salutation] +reason = "Mr., Sir, written before a name in official lists: the 2015 honours list, a newspaper's text and the only evidence of the salutation, holds it in 39 title runs of 1,504 (#1179); left out even under a Malay choice, being the hereditary prefix Malaysians file as part of the name, repeated before the father's (Tuan Aminah binti Tuan Yusof): 16 ORCID and 6 PatentsView Malaysian records open with it, 22 of 22 in the given box, my-candidates' 3,077 distinct names open with it 3 times, 2 of them the phrase TUAN GURU, 5 of 5 Malaysian names write it after bin, and the given box holds it 52 times and the family box 44 of 62,996 Malaysian ORCID holders; and a Vietnamese given name (Tuấn), in ORCID's given box 760 times among 46,170 Vietnamese holders. As a salutation under the Malay choice it moved ORCID MY from 76.72% to 76.70%, PatentsView MY 90.56% to 90.50%, and the Vietnamese records of ORCID, PatentsView and Companies House down 0.5 to 1.5 points (config_diff.py score, 2026-11-19)" +issue = 1179 +decided = 2026-11-19 + +[[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" } + +[[word]] +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 = "sultan" nobility = {} +[[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" } + [[word]] text = "a/l" [word.patronymic] diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 5b9e6b267..312ce4986 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -1107,6 +1107,43 @@ def _check_cjk_shape_purity(self) -> None: notes="the mid-name cost that keeps ten off by default " "(rules/P2's Accepted); 1.4.0 through 3.1.0 read middle " "'Ten'"), + # #1179: the Malay pack. Each row's notes checked against the 1.4.0 + # and 3.1.0 wheels on 2026-11-19; on master, where no `ms` pack + # exists, every row fails + Case("the_malay_pack_reads_puan_as_the_title", + "Puan Siti binti Ahmad", + {"title": "Puan", "given": "Siti", "family": "binti Ahmad"}, + locale="ms", classification="feat(#1179)", + notes="3.1.0 read given 'Puan', middle 'Siti'; 1.4.0 read given " + "'Puan', middle 'Siti binti', family 'Ahmad'"), + Case("the_malay_pack_reads_cik_as_the_title", + "Cik Nadia binti Rahman", + {"title": "Cik", "given": "Nadia", "family": "binti Rahman"}, + locale="ms", classification="feat(#1179)", + notes="3.1.0 read given 'Cik', middle 'Nadia'; 1.4.0 read given " + "'Cik', middle 'Nadia binti', family 'Rahman'"), + Case("the_malay_pack_reads_ustaz_in_capitals_as_the_title", + "USTAZ HAFIZ BIN OMAR", + {"title": "USTAZ", "given": "HAFIZ", "family": "BIN OMAR"}, + locale="ms", classification="feat(#1179)", + notes="1.4.0 through 3.1.0 read given 'USTAZ', middle 'HAFIZ'"), + Case("the_malay_pack_reads_cikgu_as_the_title", + "Cikgu Ahmad bin Ali", + {"title": "Cikgu", "given": "Ahmad", "family": "bin Ali"}, + locale="ms", classification="feat(#1179)", + notes="1.4.0 through 3.1.0 read given 'Cikgu', middle 'Ahmad'"), + Case("the_malay_pack_reads_the_salutation_after_a_family_comma", + "Ahmad, Puan Siti", + {"title": "Puan", "given": "Siti", "family": "Ahmad"}, + locale="ms", classification="feat(#1179)", + notes="1.4.0 through 3.1.0 read given 'Puan', middle 'Siti'"), + Case("the_malay_pack_leaves_the_hereditary_tuan_a_name_word", + "Tuan Aminah binti Tuan Yusof", + {"given": "Tuan", "middle": "Aminah", "family": "binti Tuan Yusof"}, + locale="ms", classification="feat(#1179)", + 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'"), # #1231: the Burmese pack. Burmese names have no family name, so the # last word lands in family by position. Each row's notes checked # against the 1.4.0, 2.0.0, 2.4.0, 2.8.2 and 3.1.0 wheels on diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 79151d312..c7ebca3e8 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -119,10 +119,10 @@ def test_locales_get_and_available() -> None: assert locales.get("ru") is locales.RU assert set(locales.available()) == { "ar", "bn", "cs", "es", "es_ar", "ga", "gd", "he", "hi", "hr", "ja", "mn", - "my", "ne", "nl", "pt", "pt_br", "pt_pt", "ru", "sk", "sl", "tr_az", "vi", "zh"} + "ms", "my", "ne", "nl", "pt", "pt_br", "pt_pt", "ru", "sk", "sl", "tr_az", "vi", "zh"} with pytest.raises( KeyError, - match="ar, bn, cs, es, es_ar, ga, gd, he, hi, hr, ja, mn, my, ne, nl, pt, pt_br, pt_pt, ru, sk, sl, tr_az, vi, zh"): + match="ar, bn, cs, es, es_ar, ga, gd, he, hi, hr, ja, mn, ms, my, ne, nl, pt, pt_br, pt_pt, ru, sk, sl, tr_az, vi, zh"): locales.get("xx") # the segmenter FACTORY is not a locale: it is an ordinary function # on the package, so it must not appear among the codes @@ -427,6 +427,97 @@ def test_sushri_is_the_title_only_under_a_strict_hindi_choice() -> None: "Her Excellency Sushri") +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 + 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"} + + +@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"), + ("PUAN SITI AMINAH", "PUAN", "SITI", "AMINAH"), + ("Cik Nadia binti Rahman", "Cik", "Nadia", "binti Rahman"), + ("Ustaz Hafiz bin Omar", "Ustaz", "Hafiz", "bin Omar"), + ("USTAZAH ZAINAB ISMAIL", "USTAZAH", "ZAINAB", "ISMAIL"), + ("Cikgu Ahmad bin Ali", "Cikgu", "Ahmad", "bin Ali"), + ("Encik Ahmad bin Ali", "Encik", "Ahmad", "bin Ali"), # by default too + ("Dr. Puan Siti Aminah", "Dr. Puan", "Siti", "Aminah"), + ("Ahmad, Puan Siti", "Puan", "Siti", "Ahmad"), + # a salutation ending the given part after a family comma (rules/H8), + # as Encik reads by default + ("Ahmad, Siti Puan", "Puan", "Siti", "Ahmad"), + ("Rahman, Nadia Cik", "Cik", "Nadia", "Rahman"), + ("Hafiz Omar Ustaz.", "Ustaz.", "Hafiz", "Omar"), +]) +def test_ms_reads_the_malay_titles(text: str, title: str, given: str, + family: str) -> None: + name = _require_packed("ms").parse(text) + assert (name.title, name.given, name.family) == (title, given, family) + if title != "Encik": + assert parse(text).title != title, text # the default does not + + +@pytest.mark.parametrize("text", [ + # tuan stays a name word under the choice: the hereditary prefix, + # repeated before the father's name, and a Vietnamese given name + # (decisions/salutation-titles, the 2026-11-19 #1179 entry) + "Tuan Aminah binti Tuan Yusof", + "Ahmad bin Tuan Ismail", + "Tuan Nguyen", + "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", +]) +def test_ms_leaves_these_as_the_default_reads_them(text: str) -> None: + assert _require_packed("ms").parse(text).as_dict() == _default_parse(text) + + +def test_ms_reads_the_indonesian_puan_as_the_title() -> None: + # the accepted cost of choosing the pack for Indonesian names + # (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_is_plain_since_strict_drops_other_languages_readings() -> None: + # why the pack is a plain choice (decisions/salutation-titles, the + # 2026-11-19 #1179 entry): a strict choice of ms drops ar.toml's + # bound reading of Abdul, so the given name loses its second word + text = "Abdul Rahman bin Ali" + assert _require_packed("ms").parse(text).given == "Abdul Rahman" + assert _default_parse(text)["given"] == "Abdul Rahman" + strict = parser_for(locales.MS, strict=True).parse(text) + assert (strict.given, strict.middle) == ("Abdul", "Rahman") + + +@pytest.mark.parametrize("text", ["Puan Maharani", "Tuan Nguyen", + "Nguyen Van Tuan", "Cik Rohaida Hak"]) +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 + # but ms.toml holds any of its words, so these hold while the default + # does) + indonesian = parser_for(Locale(code="id", lexicon=Lexicon.empty(), + languages=frozenset({"id"}))) + assert indonesian.parse(text).as_dict() == _default_parse(text) + assert _require_packed("vi").parse(text).title == "" + assert parse(text).title == "" + + @pytest.mark.parametrize("text, middle", [ ("Maria de Fátima Costa", "de Fátima"), ("MARIA DE FATIMA COSTA", "DE FATIMA"), @@ -2293,6 +2384,25 @@ def _default_corpus() -> list[str]: "Thein Sein Daw.", # daw, dotted, ending the name (rules/H5) "Sir U Kyaw Win", # u behind a title ] +# ms (#1179): the words the choice turns on, across these positions: at +# the head, in each case, behind a listed title, after a family comma, +# ending the given part after one (rules/H8), alone after a comma, and +# dotted at the end of the name (rules/H5) +_ROTATORS["ms"] = [ + "Puan Siti binti Ahmad", # puan + "PUAN SITI AMINAH", # puan, in one case + "Ahmad, Puan Siti", # puan after a family comma + "Cik Nadia binti Rahman", # cik + "Dr. Cik Nadia Rahman", # cik behind a listed title + "Ustaz Hafiz bin Omar", # ustaz + "Hafiz Omar, Ustaz", # ustaz alone after a comma + "USTAZAH ZAINAB", # ustazah, in one case + "Cikgu Ahmad bin Ali", # cikgu + "CIKGU ZAKRI", # cikgu with one name word (rules/H1) + "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) +] # hi and bn: each romanized title at the head, in each case, behind a # listed title, after a family comma and before one (rules/H6); a dotted # one where it ends the given part after a family comma (rules/H8) or diff --git a/tools/differential/cldr_agreement.py b/tools/differential/cldr_agreement.py index d0be82d99..dd0216206 100644 --- a/tools/differential/cldr_agreement.py +++ b/tools/differential/cldr_agreement.py @@ -164,7 +164,7 @@ "ga": "GA", "gd": "GD", "pt": "PT_BR", "es": "ES", # hi_Latn is the romanized Hindi the pack's Latin readings are for "hi": "HI", "hi_Latn": "HI", "bn": "BN", "vi": "VI", - "mn": "MN", "ar": "AR", "he": "HE", "nl": "NL", + "mn": "MN", "ar": "AR", "he": "HE", "nl": "NL", "ms": "MS", # CLDR's my file is in Burmese script, which the pack's # Latin readings do not reach "my": "MY"} diff --git a/tools/differential/cldr_agreement_locales.json b/tools/differential/cldr_agreement_locales.json index 4fa909478..684ef29f0 100644 --- a/tools/differential/cldr_agreement_locales.json +++ b/tools/differential/cldr_agreement_locales.json @@ -1305,6 +1305,120 @@ }, "text": "Цэцэг Дорж" }, + "ms/foreignFull/givenFirst": { + "surname1_base": { + "expected": "Bruhel", + "got": "Bruhel Domingo" + }, + "surname2": { + "expected": "Domingo", + "got": "" + }, + "text": "Prof. Dr. Ada Cornelia Martina von Bruhel Domingo MD DDS" + }, + "ms/nativeFull/givenFirst": { + "family": { + "expected": "Syed A Ismail Petra", + "got": "Petra" + }, + "family_base": { + "expected": "Ismail Petra", + "got": "Petra" + }, + "family_particles": { + "expected": "Syed A", + "got": "" + }, + "given_names": { + "expected": "Syed Abd Aziz", + "got": "Syed Abd Aziz Syed A Ismail" + }, + "surname1_base": { + "expected": "Ismail", + "got": "Petra" + }, + "surname1_particles": { + "expected": "Syed A", + "got": "" + }, + "surname2": { + "expected": "Petra", + "got": "" + }, + "text": "Tn. Syed Abd Aziz Syed A Ismail Petra MP" + }, + "ms/nativeFull/sorting": { + "family": { + "expected": "Ismail Syed A", + "got": "Ismail" + }, + "family_particles": { + "expected": "Syed A", + "got": "" + }, + "given_names": { + "expected": "Syed Abd Aziz", + "got": "Syed Aziz Syed A" + }, + "suffix": { + "expected": "", + "got": "Abd" + }, + "surname1_particles": { + "expected": "Syed A", + "got": "" + }, + "text": "Ismail, Syed Abd Aziz Syed A" + }, + "ms/nativeFull/surnameFirst": { + "family": { + "expected": "Syed A Ismail", + "got": "Syed" + }, + "family_base": { + "expected": "Ismail", + "got": "Syed" + }, + "family_particles": { + "expected": "Syed A", + "got": "" + }, + "given_names": { + "expected": "Syed Abd Aziz", + "got": "A Ismail Syed Abd Aziz" + }, + "surname1_base": { + "expected": "Ismail", + "got": "Syed" + }, + "surname1_particles": { + "expected": "Syed A", + "got": "" + }, + "text": "Syed A Ismail Syed Abd Aziz MP" + }, + "ms/nativeGGS/givenFirst": { + "family": { + "expected": "Syed Hassan", + "got": "Hassan" + }, + "given_names": { + "expected": "Syed Sadiq", + "got": "Syed Sadiq Syed" + }, + "text": "Syed Sadiq Syed Hassan" + }, + "ms/nativeGGS/surnameFirst": { + "family": { + "expected": "Syed Hassan", + "got": "Syed" + }, + "given_names": { + "expected": "Syed Sadiq", + "got": "Hassan Syed Sadiq" + }, + "text": "Syed Hassan Syed Sadiq" + }, "my/foreignFull/givenFirst": { "family": { "expected": "ဝူစ်တာ ဗွန် ဝူစ်တာ ဘရူ",