From 09e45852fd568d0b1fda65886fcbbbe4a7e57f6b Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 22:19:55 -0800 Subject: [PATCH 1/5] Read two family names under locales.HR and locales.SL, as CS and SK do (#1190) hr.toml and sl.toml gain a [rules] table turning on two_family_names (rules/O6), compiled into each pack's policy patch, and each pack declares DEVIATES through the shared two-family-names declaration. The default does not move. With no given-name list, a second given name is read as a family name, as under CS and SK (decisions/O6, 2026-11-21). Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/O6-two-family-names.md | 18 +- docs/design/decisions/deviates-registry.md | 1 + docs/design/decisions/vocabulary-model.md | 2 +- docs/languages.rst | 47 +++-- docs/locales.rst | 6 +- docs/migrate.rst | 24 +++ docs/release_log.rst | 3 +- nameparser/config/_rules.py | 2 + nameparser/locales/hr.py | 37 +++- nameparser/locales/sl.py | 37 +++- nameparser/vocab/hr.toml | 5 + nameparser/vocab/sl.toml | 5 + tests/v2/test_locales.py | 68 ++++++-- tests/v2/test_vocab.py | 4 +- .../differential/cldr_agreement_locales.json | 163 +++++++++++++++++- tools/vocab/build.py | 2 +- 16 files changed, 363 insertions(+), 61 deletions(-) diff --git a/docs/design/decisions/O6-two-family-names.md b/docs/design/decisions/O6-two-family-names.md index 29bed381f..567553cc0 100644 --- a/docs/design/decisions/O6-two-family-names.md +++ b/docs/design/decisions/O6-two-family-names.md @@ -6,7 +6,7 @@ - `locales.ES` turns the switch on, carrying the Spanish given-name list beside it, one pack for Spain and Latin America alike, Argentina's own pack, `locales.ES_AR`, aside, decided in chat — 2026-10-30 #753, phase 3g. - `locales.PT`, the pack chosen by language, leaves the switch off whatever list exists, being chosen for Angolan and Mozambican names too, which lose under it; `locales.PT_BR` and a Portugal pack, `locales.PT_PT`, turn it on, each country's own file (`pt-BR.toml`, `pt-PT.toml`, the second holding no word until decisions/P10's 2026-11-19 #1189 entry gave it Portugal's own readings) writing the `[rules]` table `pt.toml` does not, and both carry one Portuguese given-name list — 2026-11-19 #1453. - `locales.ES_AR` is `locales.ES` with a longer list, INE's tables cut at 5,000 words of at least half given-name use: it chooses `es-AR`, which selects es.toml, and reads es.toml's `[rules]`, so the switch stays on; it names its language's table, no table inheriting another's (a country writing a rule its language does not writes a table of its own, 2026-11-19 #1453) — 2026-11-04 #1061 (Derek). -- `locales.CS` and `locales.SK` turn the switch on with no given-name list, a net gain in every real population measured (CLDR's fictional renderings lose), two given names the recorded cost; `locales.SL` and `locales.HR` leave it off, decided in chat — 2026-10-30 #753, phase 3f amended. +- `locales.CS` and `locales.SK` turn the switch on with no given-name list, a net gain in every real population measured (CLDR's fictional renderings lose), two given names the recorded cost — 2026-10-30 #753, phase 3f amended; `locales.HR` and `locales.SL` turn it on the same way, with the same cost and no list, the two parliaments and ORCID the evidence — 2026-11-21 #1190. - Both family names stay in `family` through 2.x; a second-surname field is the RFC's Phase 4 output model (docs/design/vocabulary-model-rfc.md, "The rules a pack can choose"), and a pack may later switch this rule on — 2026-10-24 #754; landed as the `surname2` view, `family` keeping both, 2026-10-29 #754, sub-phase 4d. - The family's words are counted as P1's fold counts them, a connective join and a hyphen counting as their words, so a family already holding two keeps what it has; the word taken must count as one, a hyphenated word counting as one there unless it writes given names (each part a listed given name or an initial), and be no initial written alone — 2026-10-24 #754; 2026-11-03 #959 (Derek). - A name its script (W4) reads in an order other than the declared `name_order` is left alone; where the two agree it is read like any other — 2026-10-24 #754. @@ -305,3 +305,19 @@ - **Measured** 2026-11-20 on the branch against a checkout of master `89ec747c`. `local_agreement.py orcid-researchers --base --locale es_ar`, every country (1,823,708 records scored under the pack): 407 records fixed, 96 broken, 22 changed. By the word moved: `grace` 256 fixed / 4 broken, `mahdi` 142 / 24, `cheikh` 7 / 15 (a word Maghrebi surnames open, `CHEIKH MOUSSA`), and the words leaving at the cutoff 2 / 53 (`rehan` 24, `shamim` 22, `zakarya` 5, `wenjie` 2); in the Spanish-speaking countries, 3 fixed and none broken. `--locale es`: 2 fixed, 14 broken, every break `rim` (`Young Rim Oh`), none in a Spanish-speaking country. `config_diff.py score` over every group of `--languages es` in ORCID, PatentsView and PSC, the master lists (loaded from the checkout through an `expr:` spec) against the new: locales.ES_AR 1 record fixed in ORCID Chile and 1 in Paraguay, 1 broken of PSC's 6,089 Spanish filers, every other group unchanged; locales.ES unchanged in every group to two decimals. ORCID holds no `emerita` record moved. - **Accepted:** the moves outside the Spanish-speaking countries, mostly Arabic, South Asian and Korean given names, the cost a caller who chose a Spanish pack accepts for names it was not chosen for (decided 2026-11-20); and locales.ES's `rim`, which the tool's own cutoff drops. - Recompute: `uv run --with openpyxl --with xlrd python tools/es_given_names.py --list es-AR` (and `--list es`) against the cached INE tables, then the two commands above with `--base `, the `expr:` spec building `parser_for(Locale(code=..., lexicon=Lexicon(given_names=), policy=locales.ES_AR.policy, languages=frozenset({'es-AR'})))`. +- 2026-11-21 #1190 — `locales.HR` AND `locales.SL` TURN THE SWITCH ON, WITH NO GIVEN-NAME LIST, AS `locales.CS` AND `locales.SK` DO. Decided 2026-11-21. A Croatian or Slovenian woman who keeps her surname beside her husband's writes the two without a hyphen, as a Czech or Slovak one does (`Ana Puž Kukuljan`), the shape the default reads as a middle name. hr.toml and sl.toml each gain `[rules]` `two_family_names = true`, compiled into the pack's policy patch (`PACK_RULES` in tools/vocab/build.py gains `hr` and `sl`), and each pack declares `DEVIATES` through `_locale.deviates_by_two_family_names` (decisions/deviates-registry's entry of this date). The default does not move. Supersedes the 2026-10-30 phase 3f amended entry's "`SL` and `HR` read one family name, no population of theirs measured", and answers #1190's two questions: the CS and SK cost is accepted here too, with no given-name list (none is published for either whole population), and the two parliaments and ORCID are enough, no further local corpus needed. + - **Measured** on master `6ff048fe`, each pack against itself with the switch off (`config_diff.py score plain:HR 'plain:HR@two_family_names=1' plain:SL 'plain:SL@two_family_names=1' plain:CS --group HR --group SI --group Croatian --group Slovenian --cap 20000`, run in that checkout; ORCID's extract of 2025-10-17, PatentsView's and PSC's fetches as cached on 2026-11-21). `HR`, `SL` and `CS` score alike on every row, so the switch is what moves them. All boxes agreeing: + + | Population | Records | Off → on | Fixed | Broken | + |---|---:|---|---:|---:| + | ORCID, country HR | 15,547 | 88.44% → 98.46% | 1,757 | 200 | + | ORCID, country SI | 7,801 | 90.45% → 97.63% | 723 | 163 | + | PatentsView, country HR | 879 | 92.04% → 91.58% | 20 | 24 | + | PatentsView, country SI | 1,752 | 88.24% → 87.39% | 22 | 37 | + | PSC, Croatian | 479 | 97.49% → 97.29% | 11 | 12 | + | PSC, Slovenian | 277 | 95.31% → 95.67% | 10 | 9 | + + ORCID's `name` is composed from its two boxes, given first, so a two-word family box always reaches the parser as two trailing words: the ORCID gain is the boxes' own split, not a check that people write their names that way. The parliaments are the independent check, display names written by each chamber: of the Croatian Sabor's 149 members (OpenSanctions `hr_sabor`, `opensanctions-parliaments` as cached on 2026-11-21) the family is right for 140 with the switch off and 148 with it on, 9 fixed and 1 broken; of the Slovenian National Assembly's 90 (`si_dz_rs`), 84 and 89, 6 fixed and 1 broken. Every three-word name in either chamber moves, and every break is a member with two given names. Read by hand: the two chambers hold no other name of three or more words, and every two-word or hyphenated name reads the same either way. + - **Accepted:** a name with two given names reads the second as a family name (`Janez Jože Novak` gives family 'Jože Novak'), as under CS and SK, the cost the PatentsView dip holds; CLDR's fictional `hr` and `sl` renderings with two given names lose too (`cldr_agreement_locales.json` re-recorded: 4 `hr` and 8 `sl` renderings move, each one taking a second word into the family, a second given name given first or the first given name family first, and none of them agreeing after). Open: a Croatian or Slovenian given-name list, which would lift the cost as the Spanish and Portuguese lists do; none was looked for past #1190. + - **Swept** under all three `name_order`s, comparing each pack with `CS` on the same 25 shapes (no comma, a full name, one word and nothing before a comma, a hyphenated pair, a particle, a suffix, a title, three and four words, an initial in the middle): HR, SL and CS read all 75 alike, so the two packs differ from CS by vocabulary alone. `Ana M. Kukuljan` keeps middle 'M.' under every order but the family-first ones, where it reads as the default does; a family comma stands O6 down. A strict choice of either reads as the plain one (`two_family_names` on, the patch beside the choice). + - Recompute: the `score` command above in a checkout of the base, and `config_diff.py diff 'plain:HR@two_family_names=0' plain:HR --local opensanctions-parliaments --group hr_sabor --readings ` (and `SL` with `si_dz_rs`) in this tree, each moved name judged by hand. diff --git a/docs/design/decisions/deviates-registry.md b/docs/design/decisions/deviates-registry.md index de6fecfed..590cd513d 100644 --- a/docs/design/decisions/deviates-registry.md +++ b/docs/design/decisions/deviates-registry.md @@ -17,3 +17,4 @@ Open: none in this file. - 2026-11-05 #1087 — THE TWO-FAMILY-NAMES DECLARATION COUNTS BY THE SCRIPT TABLE. `_locale._letter_runs` counted a run twice when its first character's Unicode name began `CJK`, `HANGUL`, `HIRAGANA` or `KATAKANA`, a second definition of East Asian text beside `_policy._SCRIPT_RANGES`, which every script-conditional rule reads. It now asks `_script_matcher` over the table, so a run W1 can divide is one the declaration counts twice. Moved first, before the table held the conjoining jamo, the declaration would have dropped decomposed `김. 민준` (#1083's refused candidate, which measured 4 of 6,731 names moving); with HANGUL widened (decisions/nfd-shapes, same date), 3 of the 6,738 distinct corpus texts moved (measured 2026-11-05, every distinct name `tools/differential/snapshot.py` reads, the comparator the character-name test run beside the table in one script), each gaining a declaration, the safe direction: `ヤマダ タロウ`, `タナカ. John` and `タロウ·ヤマダ`, halfwidth katakana the name test did not count. None lost one. Over all of Unicode (version 14, Python 3.11), the letters the name test counted and the table does not are the compatibility jamo, the katakana phonetic extensions, and the supplementary plane's Minnan tone kana and archaic and small kana, which no rule classifies and W1 never divides, so a run of them counts once correctly; the table adds 々, 〆 and the halfwidth katakana. `test_the_two_family_names_declaration_counts_by_the_script_table` in tests/v2/test_locales.py holds the rows with both former definitions' answers as recorded controls. - 2026-11-12 #1237 — A CHOICE THAT CHANGES NO WORD, BESIDE A PATCH, IS RECORDED AS INERT. `locales.MN` chooses `mn`, whose readings are all on by default, beside a Cyrillic script order its patch carries in code (decisions/W4's 2026-11-12 #1237 entry), so its derived surface is empty. The phase 3f refusal is unchanged, since it reads only a pack that is nothing but its choice, and MN declares `DEVIATES` for its patch, which the gate reads; `test_choice_rotators_cover_every_changed_word` and `test_a_choice_word_rotator_is_moved_by_the_choice_alone` skip a pack listed in tests/v2/test_locales.py's `_INERT_CHOICES`, and `test_an_inert_choice_changes_no_word` fails the day such a choice changes a word, so the pack leaves the set and its rotators name the word. decisions/vocabulary-model's 2026-11-12 #1237 entry. - 2026-11-16 #1254 — `locales.NE` IS NO LONGER NOTHING BUT A CHOICE. The 2026-10-29 #753 phase 3b line named it the first pack the contract test refuses a `DEVIATES` on; decisions/O8's 2026-11-11 #1254 entry gave it rules/O8's `initials_as_family` from `ne.toml`'s `[rules]`, so it now declares a hand `DEVIATES` for the patch, as `CS` and `SK` do for theirs. NE has left the packs that are nothing but a choice. Found by the 3.1 release sweep. +- 2026-11-21 #1190 — `locales.HR` AND `locales.SL` ARE NO LONGER NOTHING BUT A CHOICE. Each gains rules/O6's patch from its file's `[rules]` table (decisions/O6's entry of this date), so each leaves the choice packs and declares `DEVIATES` for the patch's part as `locales.CS` and `locales.SK` do since the 2026-10-30 phase 3f amended entry: the shared `_locale.deviates_by_two_family_names`, which `test_cs_and_sk_pack_contents` now holds all five packs' declarations to. Their `ml` rotators became `Horvat ml.` and `Novak ml.`, since the three-word `Ivan Horvat ml.` and `Janez Novak ml.` are moved by the patch alone, which `test_a_choice_word_rotator_is_moved_by_the_choice_alone` refuses; each pack gains the patch's rotators, CS's and SK's shapes. diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 6b0bb5ad0..1a6bb43c8 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -388,7 +388,7 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis - **Measured** 2026-10-30 on `40675146` plus this change, Python 3.11.17. Committed corpora, `snapshot.py --languages TAG`, entries moved (held only by `corpus_cldr.jsonl` among them): `cs` 17 (6), `sk` 15 (4), `sl` 15 (4), `hr` 15 (4), `pl` 11 (2). Fifteen of each are `st` and `ml` moves, 3c's fourteen and rules/S11's new `[cs]` example `Jiří Dienstbier st.`, which this change adds to the rules corpus; cs and pl add `Pan Tomasz Nowak` and `Pan Nowak Tomasz Jan` (under `FAMILY_FIRST`), both now reading title `Pan`; pl's other 9 are its conjunction `i`, which choosing pl already moved. The CLDR locale view, newly recorded for the four packs in `cldr_agreement_locales.json`: whole renderings agreeing cs 14/24, sk 15/24, sl 16/24, hr 18/24, default and pack alike; the pack moves two sl renderings and no other, each `ml.` from family to suffix (`g. Janez Peter Novak ml., univ. dipl. inž.`, family `Novak`), both still disagreeing elsewhere. Local corpora against the base's default readings (`snapshot.py --local SOURCE --base --languages TAG`), counted by the first changed word each moved name holds: `ctgov-officials` cs 178 (st 69, mudr 44, pan 17, drsc 15 and 2 `Dr. Sc.`, phdr 12, rndr 7, pharmdr 6, ml 3, and one each of paeddr, mddr, mvdr), sk 161 (the same less pan), sl and hr 72 (st 69, ml 3); `orcid-researchers` cs 245 (st 124, pan 46, phdr 16, ml 14, mudr 11, judr 8, drsc 6, mga 5, paeddr 5, rndr 4, roz 3, and one each of thdr, pharmdr, bca), sk 191, sl and hr 138 (st 124, ml 14). Read by kind: the titles and `drsc` are fixes wherever they move a field (`Denisa Wilkes, MUDr` stops reversing, `Christian Salmon, DrSc` keeps its given name, `Prof. MUDr.` reads one title run); every `pan` move is a Chinese name read with a title (`PAN DAI` → title `PAN`), no Czech salutation among them; `roz` fixes one (`Lenka Šenkárová (roz. Veverková)` → maiden `Veverková`) and costs two given names `Roz` (`ELLA ROZ PERRY` → maiden `PERRY`); `st` is 3c's (Saint names, and `PhD St.`, a PhD student, read as the generation). The fielded scores, `local_agreement.read` over the records of the four countries: ORCID's 56,808 records from CZ, SK, SI and HR agree 52,239 under the default and 52,240 under cs and sk (`dr.sc. Sara Soldo`, HR, fixed), unchanged under sl and hr; PSC's 3,578 Czech, Slovak, Slovenian and Croatian filers agree 3,505 under every pack, cs and sk fixing `Mudr Jozef Stec` and moving `Mr Judr Branislav Fridich`, whose filer typed `Judr` in the forename box. The same run over `psc-individuals`: cs 416 (st 395, pan 16, mudr 2, and one each of judr, mvdr and roz, `Miss Naila Roz Roz` → maiden `Roz`), sk 399, sl 395 (all st; hr not run, its choice changing the same two words the same way); `tse-donors` cs 9 (st 5, roz 2, pan 2, `PAN SHISHEN` → title `PAN`); `ukec-individuals` cs 9 (st 8, and `Victor MGA Killearn`, only its forced case repair moving, `MGA` → `MgA`). Recompute: the commands above, and `uv run python -c "from nameparser import _reading_index as ri; print(sorted(ri.changed_words(ri.selected(['cs']))))"` for each tag's words. - **Found, not changed:** a gated generation behind a particle run after a family comma stays in the given part unreported, `Novák, Freiherr von Berg st.` reading given `von Berg st.` under these packs as the default reads `Dumas, Freiherr von Berg fils` (rules/S11); the default reading of the same `st.` is stranger, family `st. Novák`. Pinned in the 3f table. And with one word before a family comma, `Novák, st.` reads title `st.` by its period shape (rules/H2) under all four packs, reporting suffix-or-name with the generation as the alternative though the reading taken is a title, as the default reads `Dumas, fils.`; the ungated `Novák, ml.` reads suffix `ml.`. `Novák st., Jan` keeps family `Novák st.`, as the default keeps `Dumas fils, Alexandre`: the gated word before a family comma is a name word. Both pinned in the 3f table. - **Open:** `pan`, kept because the work order names it: the corpora show its cost (81 Chinese names across ctgov, ORCID, PSC and TSE read with the title) and no gain, the shape that excluded `bc`, and as a title on its own it also takes a lone given name after a family comma (`Smith, Pan` reads title `Pan` with no given name, a bare `Pan` title `Pan`), so whether it stays in the Czech pack is a question for the reviewer. Whether the uncontested titles (`mudr`, `judr`, `phdr`, `rndr` and the rest, no name reading and no clash found) belong in the default rather than a pack is a default change, measured on ctgov, outside phase 3's rule that nothing moves the default. -- **2026-10-30 #753, phase 3f amended — `locales.CS` AND `locales.SK` READ TWO FAMILY NAMES: cs.toml AND sk.toml TURN ON `two_family_names` (rules/O6) IN A `[rules]` TABLE, WITH NO GIVEN-NAME LIST; `SL` AND `HR` STAY CHOICES ALONE; THE DEFAULT DOES NOT MOVE.** Decided in chat on 2026-10-30, on the measurement below. Amends two claims of the phase 3f entry for these two packs: "a pack is then nothing but its tag", and "Each module ships no `DEVIATES`". +- **2026-10-30 #753, phase 3f amended — `locales.CS` AND `locales.SK` READ TWO FAMILY NAMES: cs.toml AND sk.toml TURN ON `two_family_names` (rules/O6) IN A `[rules]` TABLE, WITH NO GIVEN-NAME LIST; `SL` AND `HR` STAY CHOICES ALONE; THE DEFAULT DOES NOT MOVE.** (`SL` and `HR` staying choices alone superseded by decisions/O6's 2026-11-21 #1190 entry, which turns the switch on for both.) Decided in chat on 2026-10-30, on the measurement below. Amends two claims of the phase 3f entry for these two packs: "a pack is then nothing but its tag", and "Each module ships no `DEVIATES`". - **What changes.** cs.toml and sk.toml each gain `[rules]` `two_family_names = true`, compiled into the pack's policy patch (`PACK_RULES` in tools/vocab/build.py gains `cs` and `sk`). Each pack becomes a choice with a patch beside it, as `locales.ES` is, and declares `DEVIATES` for the patch's part only. That declaration is rules/O6's, `_locale.deviates_by_two_family_names`, now one predicate for the es, cs and sk packs (decisions/deviates-registry's entry of this date). The married double surname written without a hyphen stays whole: `Alena Pešová Řehořová` gives family `Pešová Řehořová`, where the default gives middle `Pešová`. - **Measured** 2026-10-30 on `bfb91163` plus this change, Python 3.11.17, records agreeing in every field, from these runs, each against a checkout of `bfb91163` (`--base`): `local_agreement.py cz-candidates --base` (the default, matching the base), `cz-candidates --locale cs --base` and `cz-candidates --locale sk --base` (each pack now, its moves against the pack at `bfb91163`), `orcid-researchers --base`, `orcid-researchers --locale cs --base` and `orcid-researchers --locale sk --base` (each report's CZ and SK rows). Three figures no report prints are read with `local_agreement.read` and `FIELDED` over the records under two parsers: the ORCID per-country moves, the cz-candidates moves against the default, and that the cs and sk packs read the ORCID CZ and SK records alike. - cz-candidates (fetched 2026-10-30; data kv2022 2026-03-28, ps2025 2025-10-05; 170,181 records): default 165,002 (96.96%); `locales.CS` before this change 165,027 (96.97%); now 165,880 (97.47%), 1,295 records now agreeing and 442 now disagreeing against the pack before, 1,318 and 440 against the default (+878); `locales.SK` now 165,878. diff --git a/docs/languages.rst b/docs/languages.rst index a7bcf9bd8..fde7874c6 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -40,8 +40,8 @@ Czech, Slovak, Slovenian and Croatian names Turn on ``cs``, ``sk``, ``sl`` or ``hr`` when your data is names in that language. Each of the four languages is a pack of its own, which -chooses that one language; the Czech and Slovak packs also read two -family names (`Double surnames`_). +chooses that one language, and reads two family names (`Double +surnames`_). These four languages tell a father from a son of the same name with a word written after the name: ``ml.`` for the younger and ``st.`` for @@ -87,7 +87,7 @@ So they wait for a pack: - ``ml.``, ``st.``; ``Mgr.`` read as the degree; two family names (``two_family_names``) * - ``locales.SL``, ``locales.HR`` - - ``ml.``, ``st.`` + - ``ml.``, ``st.``; two family names (``two_family_names``) .. doctest:: @@ -189,30 +189,36 @@ at the head of a name or of the part after a comma (see Double surnames ~~~~~~~~~~~~~~~ -A Czech or Slovak woman who keeps her own surname beside her -husband's writes the two without a hyphen, ``Alena Pešová Řehořová``, -which the default reads as a middle name and a family name. The two -packs read two family names (``two_family_names``, see +A Czech, Slovak, Slovenian or Croatian woman who keeps her own surname +beside her husband's writes the two without a hyphen, ``Alena Pešová +Řehořová``, which the default reads as a middle name and a family name. +The four packs read two family names (``two_family_names``, see :ref:`two-family-names`), so the double surname stays whole, each name in its own view (``surname1`` ``Pešová``, ``surname2`` ``Řehořová``). -Two given names pay for it: with no Czech or Slovak given-name list to -keep a given name out of the family (none is published for the whole -population), ``Petr Pavel Novák`` reads family ``Pavel Novák``. A family -comma keeps both as the default reads them: +Two given names pay for it: with no given-name list in any of the four +languages to keep a given name out of the family (none is published +for the whole population), ``Petr Pavel Novák`` reads family ``Pavel +Novák``. A family comma keeps both as the default reads them, and an +initial written between the given name and the surname stays the +middle name: .. doctest:: >>> czech.parse("Alena Pešová Řehořová").family 'Pešová Řehořová' + >>> croatian = parser_for(locales.HR) + >>> croatian.parse("Ana Puž Kukuljan").family + 'Puž Kukuljan' >>> czech.parse("Petr Pavel Novák").family 'Pavel Novák' >>> czech.parse("Novák, Petr Pavel").middle 'Pavel' + >>> croatian.parse("Ana M. Kukuljan").middle + 'M.' -The switch gains more names than it costs (`Measured effect: Czech and -Slovak`_). To keep the packs' vocabulary and turn the switch off, +The switch gains more names than it costs (`Measured effect`_). To keep the packs' vocabulary and turn the switch off, rebuild the policy: .. doctest:: @@ -286,8 +292,8 @@ Monsignor reading of ``en`` and ``fr``, which the default names: >>> czech.parse("Mgr. Jan Novák").tokens[0].reading.languages ('cs',) -Measured effect: Czech and Slovak -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Measured effect +~~~~~~~~~~~~~~~ Among ORCID's researchers, who split their own names into a given and a family box, reading two family names raises the names agreeing in @@ -297,7 +303,16 @@ elections, about 170,000 records, each a distinct set of the boxes the Czech registers file a name in, it raises them from 97.0% to 97.5%. The Spanish given-name list carried beside ``locales.CS`` moved fewer than two hundred of those register records, about seven in ten of them -to agreeing. The +to agreeing. + +For Croatian and Slovenian names it raises ORCID's agreeing names from +88.4% to 98.5% in Croatia and from 90.4% to 97.6% in Slovenia, and the +members of the Croatian Sabor and the Slovenian National Assembly whose +family name it reads right from 140 to 148 of 149 and from 84 to 89 of +90, the one loss in each a member with two given names. Among US +patents' inventors, whose boxes a professional filer fills, it lowers +them slightly, from 92.0% to 91.6% in Croatia and from 88.2% to 87.4% +in Slovenia. The dated figures are in ``docs/design/decisions/O6-two-family-names.md`` and ``docs/design/decisions/vocabulary-model.md``. diff --git a/docs/locales.rst b/docs/locales.rst index d1fc763e4..4fcc57872 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -242,8 +242,10 @@ says which parts each pack is made of. * - ``sl``, ``hr`` - Slovenian and Croatian - Each chooses its one language, which turns on the generations - ``ml.`` and ``st.`` See :ref:`west-south-slavic-packs`. - - ``Ivan Horvat ml.`` → suffix ``ml.`` + ``ml.`` and ``st.``, and reads two family names. See + :ref:`west-south-slavic-packs`. + - | ``Ivan Horvat ml.`` → suffix ``ml.`` + | ``Ana Puž Kukuljan`` → family ``Puž Kukuljan`` * - ``es`` - Spanish - Chooses ``es``, which turns on the titles the default leaves off diff --git a/docs/migrate.rst b/docs/migrate.rst index 37e77ab30..9b0651f60 100644 --- a/docs/migrate.rst +++ b/docs/migrate.rst @@ -2195,6 +2195,30 @@ loads, and reads as 3.1's pack did: a pickle holds the pack's values, not its name. Build the parser again from ``locales.PT_BR`` to read two family names. +Two family names under locales.HR and locales.SL +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``locales.HR`` and ``locales.SL`` read two family names +(``two_family_names``), as ``locales.CS`` and ``locales.SK`` do, where +3.0 and 3.1 read the first as a middle name; with no given-name list, +a second given name is read as a family name too. A family comma keeps +both as 3.1 read them: + +.. doctest:: + + >>> slovenian = parser_for(locales.SL) + >>> zavadlav = slovenian.parse("Elena Zavadlav Ušaj") + >>> zavadlav.middle, zavadlav.family + ('', 'Zavadlav Ušaj') + >>> slovenian.parse("Janez Jože Novak").family + 'Jože Novak' + >>> slovenian.parse("Novak, Janez Jože").middle + 'Jože' + +To keep the 3.1 reading, turn the switch off on top of the pack, as for +``locales.PT_BR`` above. A pack or parser pickled by 3.1 reads as 3.1's +pack did. + Malaysian a/l, a/p and anak ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/release_log.rst b/docs/release_log.rst index 2ea75040e..646f78b37 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -32,7 +32,7 @@ Release Log - **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` - **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` + - **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``, ``HR``, ``SL``, ``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` - **Change Parser.suggest() to read common surnames beyond the Chinese, Korean and Vietnamese ones, most of them Spanish.** ``Parser().suggest(["García Zorvan", "Quispe Qelliot"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST)``, where 3.1.0 found no evidence in either name and suggested nothing; a list of two to five Spanish names written family first now moves a given-first parser more often. :issue:`1364` - **Fix a job or degree written out after a name and a comma, which took the name over.** ``parse("Nadir Qassoumi, Bachelor")`` gives title ``Bachelor``, given ``Nadir``, family ``Qassoumi``, where 1.4.0 through 3.1.0 gave given ``Bachelor``, family ``Nadir Qassoumi``; ``Medical Doctor`` and ``Clinical Research Coordinator`` read as one title. A name the word opens reads it as the title too (``Student Mary Jones`` gives title ``Student``). A degree's possessive after the comma is the title as well (``Master's degree``, ``Bachelor's``), though one opening a name alone stays the given name. :issue:`1457`, :issue:`1487` - **Fix Malaysian a/l, a/p and anak, which read as middle names and cut the father's name.** ``parse("KUMAR A/L RAJAN NAIDU")`` gives family ``A/L RAJAN NAIDU`` and the same ``patronymic``, as ``bin`` reads, where 1.4.0 through 3.1.0 gave middle ``A/L RAJAN``, family ``NAIDU``; ``anak`` opening a name written without a comma (Balinese ``Anak Agung``) is left to position, the given name by default, and reported. :issue:`1468` @@ -41,6 +41,7 @@ Release Log - **Add locales.MY, a Burmese pack, which reads U and Daw as titles; chosen strictly, it reads a wholly Burmese list.** ``parser_for(locales.MY).parse("U Thein Sein")`` gives title ``U``, given ``Thein``, family ``Sein``, where the default, as 1.4.0 through 3.1.0, gives given ``U``, middle ``Thein``; ``parser_for(locales.MY, strict=True)`` also keeps syllables such as ``San`` and ``PE`` name words and the English ranks Burmese lists write titles, and costs a list of other names their particles and credentials and reads a rank that is also a given name as the rank (``Gen Goto`` gives title ``Gen``). An initial ``U.`` can become the title under the pack (``Smith, U.`` gives no given name): keep it to Burmese names. See :ref:`burmese-names`. :issue:`1231`, :issue:`1483` - **Fix MD inside a name written in capitals, which read as the degree and took the name behind it.** ``parse("SITI NORA MD YUSRI")`` gives middle ``NORA MD``, family ``YUSRI``, as 1.4.0 through 2.3.0 did, where 2.4.0 through 3.1.0 gave family ``NORA``, suffix ``MD YUSRI``; a name in lower case reads the same way, and both report ``suffix-or-name``, the degree being the other reading. The degree written before a family name in capitals reads so too (``JOHN SMITH MD JONES`` gives family ``JONES``, reported), where ``John Smith MD Jones`` and ``JOHN SMITH M.D. JONES`` keep it. :issue:`1394` - **Fix Emeritus, which read as a given name.** ``parse("Professor Emeritus John Smith")`` gives title ``Professor Emeritus``, given ``John``, where 1.4.0 through 3.1.0 gave title ``Professor``, given ``Emeritus``, middle ``John``; ``Emeritus Professor`` and ``Professor Emerita`` read the same way. ``Emerita`` alone stays the given name, reported, being a given name too. A title other than ``Professor`` or ``Prof`` before it still leaves it a name word (``Bishop Emeritus John Smith`` gives given ``Emeritus``). :issue:`1471` + - **Change locales.HR and locales.SL to read two family names, as locales.CS and locales.SK do.** ``parser_for(locales.HR).parse("Ana Puž Kukuljan")`` gives family ``Puž Kukuljan``, where 3.0.0 through 3.1.0 gave middle ``Puž``, family ``Kukuljan``; with no given-name list, a second given name is read as a family name too (``Janez Jože Novak`` gives family ``Jože Novak`` under ``locales.SL``), and a family comma keeps both as before. :issue:`1190` - **Change locales.PT_BR to read two family names, and add locales.PT_PT, which reads names from Portugal the same way.** ``parser_for(locales.PT_BR).parse("Ana Souza Lima")`` gives family ``Souza Lima``, where 3.0.0 through 3.1.0 gave middle ``Souza``, family ``Lima``; a second given name on the packs' Portuguese given-name list stays where it stands (``Ana Beatriz Costa`` keeps family ``Costa``), and ``locales.PT``, chosen for Portuguese names from any country, is unchanged. ``locales.PT_PT`` also reads four given names Portugal writes behind a particle and Brazil does not (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``do Carmo``, ``da Conceição`` and ``da Luz`` do). :issue:`1453`, :issue:`1189` - **Change the Spanish given-name lists, rewritten from their tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; nine words leave locales.ES_AR's list (``Gerhard``, ``Zuleyma`` among them) and nine join it (``Azhar``, ``Houari``, ``Grace``), each joining reading as a middle name where it read as the first family name, and locales.ES's gains ``Lahcen`` and drops ``Rim``. :issue:`1471`, :issue:`1476` diff --git a/nameparser/config/_rules.py b/nameparser/config/_rules.py index 27160bef4..5dfe6084a 100644 --- a/nameparser/config/_rules.py +++ b/nameparser/config/_rules.py @@ -13,11 +13,13 @@ RULES: tuple[tuple[str, tuple[tuple[str, object], ...]], ...] = ( ('cs', (('two_family_names', True),)), ('es', (('two_family_names', True),)), + ('hr', (('two_family_names', True),)), ('ne', (('initials_as_family', True),)), ('pt-BR', (('two_family_names', True),)), ('pt-PT', (('two_family_names', True),)), ('ru', (('patronymic_rules', ('east-slavic',)),)), ('sk', (('two_family_names', True),)), + ('sl', (('two_family_names', True),)), ('tr', (('patronymic_rules', ('turkic',)),)), ('vi', (('name_order', 'family-first-given-last'),)), ) diff --git a/nameparser/locales/hr.py b/nameparser/locales/hr.py index 154ba273d..faecd394d 100644 --- a/nameparser/locales/hr.py +++ b/nameparser/locales/hr.py @@ -1,5 +1,5 @@ -"""The Croatian locale pack: a choice of languages, ``hr``, and nothing -else -- no lexicon fragment and no policy patch (3.0, phase 3f, #753; +"""The Croatian locale pack: a choice of languages, ``hr``, and a policy +patch, no lexicon fragment (3.0, phase 3f, #753; the patch since #1190; mechanisms.md#LOCALE-PACKS-PURE-DATA). Choosing it turns on nameparser/vocab/hr.toml's readings written ``default = false``: the generations ``ml.`` (mlađi) and ``st.`` (stariji); on a word hr.toml @@ -10,19 +10,38 @@ word (decisions/vocabulary-model's 2026-10-30 phase 3f entry; ``père``, the one other word it named, is read by default since 2026-11-03). +It reads two family names (``Policy.two_family_names``, rules/O6), its +policy patch compiled from hr.toml's [rules] table by +tools/vocab/build.py, so the married double surname written without a +hyphen stays whole: ``Ana Puž Kukuljan`` gives family ``Puž Kukuljan``, +where the default gives the first of them as a middle name. Two given +names pay for it, with no given-name list to keep them out of the +family, as under CS and SK: ``Ivan Marko Horvat`` gives family ``Marko Horvat`` +(decisions/O6's 2026-11-21 #1190 entry, which records the cost). + Data sources: the readings' own entries in nameparser/vocab/hr.toml, each with its issue and the vetting on its note; nothing is listed here. -Deviations: derived, not declared. The words a choice of ``hr`` -can move are ``_reading_index.changed_words``, which the -non-interference gate in tests/v2/test_locales.py reads -(decisions/deviates-registry), so this module carries no DEVIATES. +Declared deviations (mechanisms.md#LOCALE-PACKS-PURE-DATA): the choice's +are derived, not declared -- the words whose compiled readings it +changes (``_reading_index.changed_words``), which the non-interference +gate in tests/v2/test_locales.py ors in -- so DEVIATES below declares +only what the patch changes. """ from __future__ import annotations from nameparser._lexicon import Lexicon -from nameparser._locale import Locale +from nameparser._locale import Locale, deviates_by_two_family_names, rules_patch + +HR = Locale( + code="hr", + lexicon=Lexicon.empty(), + # nameparser/vocab/hr.toml's [rules], compiled by tools/vocab/build.py + policy=rules_patch("hr"), + languages=frozenset({"hr"}), +) + -HR = Locale(code="hr", lexicon=Lexicon.empty(), - languages=frozenset({"hr"})) +# rules/O6's declaration, which every pack turning O6 on shares +DEVIATES = deviates_by_two_family_names diff --git a/nameparser/locales/sl.py b/nameparser/locales/sl.py index d38a39333..2ca1678dd 100644 --- a/nameparser/locales/sl.py +++ b/nameparser/locales/sl.py @@ -1,5 +1,5 @@ -"""The Slovenian locale pack: a choice of languages, ``sl``, and nothing -else -- no lexicon fragment and no policy patch (3.0, phase 3f, #753; +"""The Slovenian locale pack: a choice of languages, ``sl``, and a policy +patch, no lexicon fragment (3.0, phase 3f, #753; the patch since #1190; mechanisms.md#LOCALE-PACKS-PURE-DATA). Choosing it turns on nameparser/vocab/sl.toml's readings written ``default = false``: the generations ``ml.`` (mlajši) and ``st.`` (starejši); on a word sl.toml @@ -10,19 +10,38 @@ word (decisions/vocabulary-model's 2026-10-30 phase 3f entry; ``père``, the one other word it named, is read by default since 2026-11-03). +It reads two family names (``Policy.two_family_names``, rules/O6), its +policy patch compiled from sl.toml's [rules] table by +tools/vocab/build.py, so the married double surname written without a +hyphen stays whole: ``Elena Zavadlav Ušaj`` gives family ``Zavadlav Ušaj``, +where the default gives the first of them as a middle name. Two given +names pay for it, with no given-name list to keep them out of the +family, as under CS and SK: ``Janez Jože Novak`` gives family ``Jože Novak`` +(decisions/O6's 2026-11-21 #1190 entry, which records the cost). + Data sources: the readings' own entries in nameparser/vocab/sl.toml, each with its issue and the vetting on its note; nothing is listed here. -Deviations: derived, not declared. The words a choice of ``sl`` -can move are ``_reading_index.changed_words``, which the -non-interference gate in tests/v2/test_locales.py reads -(decisions/deviates-registry), so this module carries no DEVIATES. +Declared deviations (mechanisms.md#LOCALE-PACKS-PURE-DATA): the choice's +are derived, not declared -- the words whose compiled readings it +changes (``_reading_index.changed_words``), which the non-interference +gate in tests/v2/test_locales.py ors in -- so DEVIATES below declares +only what the patch changes. """ from __future__ import annotations from nameparser._lexicon import Lexicon -from nameparser._locale import Locale +from nameparser._locale import Locale, deviates_by_two_family_names, rules_patch + +SL = Locale( + code="sl", + lexicon=Lexicon.empty(), + # nameparser/vocab/sl.toml's [rules], compiled by tools/vocab/build.py + policy=rules_patch("sl"), + languages=frozenset({"sl"}), +) + -SL = Locale(code="sl", lexicon=Lexicon.empty(), - languages=frozenset({"sl"})) +# rules/O6's declaration, which every pack turning O6 on shares +DEVIATES = deviates_by_two_family_names diff --git a/nameparser/vocab/hr.toml b/nameparser/vocab/hr.toml index 38d193482..f6232bb87 100644 --- a/nameparser/vocab/hr.toml +++ b/nameparser/vocab/hr.toml @@ -1,5 +1,10 @@ schema = 1 +# locales.HR reads its names with two family names (rules/O6), the +# married double surname written without a hyphen (decisions/O6, 2026-11-21, #1190) +[rules] +two_family_names = true + [[word]] text = "gospodin" salutation = { issue = 606, gender = "m", after_given = true } diff --git a/nameparser/vocab/sl.toml b/nameparser/vocab/sl.toml index a9a209fd3..a5020c398 100644 --- a/nameparser/vocab/sl.toml +++ b/nameparser/vocab/sl.toml @@ -1,5 +1,10 @@ schema = 1 +# locales.SL reads its names with two family names (rules/O6), the +# married double surname written without a hyphen (decisions/O6, 2026-11-21, #1190) +[rules] +two_family_names = true + [[word]] text = "ml" generation = { default = false, expands = "mlajši, the Younger", issue = [661, 679, 684, 753], note = "real and standard, but ML is a pair of initials in other languages written in Latin script, and nothing in its writing tells the two apart, so no default reads it; a Slovenian pack turns it on" } diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 4d488128a..6610c347c 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -1389,22 +1389,24 @@ def test_mn_fills_no_patronymic() -> None: def test_cs_and_sk_pack_contents() -> None: # 3f, amended 2026-10-30: cs and sk are their choice plus rules/O6's - # patch; sl and hr stay nothing but their choice. cs's fragment, - # since #970, removes the given reading that gates its Ing, and - # keeps the family reading that gates mul.toml's credential + # patch, and hr and sl since #1190 (decisions/O6, 2026-11-21). cs's + # fragment, since #970, removes the given reading that gates its Ing, + # and keeps the family reading that gates mul.toml's credential from nameparser._locale import deviates_by_two_family_names - from nameparser.locales import cs as _cs, es as _es, sk as _sk + from nameparser.locales import ( + cs as _cs, es as _es, hr as _hr, sk as _sk, sl as _sl) fragments = {"cs": Lexicon.empty().remove("ing", kind="given"), - "sk": Lexicon.empty()} - for code, pack in (("cs", locales.CS), ("sk", locales.SK)): + "sk": Lexicon.empty(), "hr": Lexicon.empty(), + "sl": Lexicon.empty()} + for code, pack in (("cs", locales.CS), ("sk", locales.SK), + ("hr", locales.HR), ("sl", locales.SL)): assert pack == Locale(code=code, lexicon=fragments[code], policy=PolicyPatch(two_family_names=True), languages=frozenset({code})), code - for code in ("sl", "hr"): - assert _is_vocabulary_pack(locales.get(code)), code - # the patch's declaration is rules/O6's, one predicate for the three + assert not _is_vocabulary_pack(pack), code + # the patch's declaration is rules/O6's, one predicate for the # packs that turn O6 on, so their declarations cannot drift apart - for module in (_cs, _sk, _es): + for module in (_cs, _sk, _es, _hr, _sl): for name in ("Alena Pešová Řehořová", "Novák, Petr Pavel", "Mária-\u200bJana Kováčová", "Jan Novák", "Novák"): assert module.DEVIATES(name) == deviates_by_two_family_names(name) @@ -2541,13 +2543,21 @@ def _default_corpus() -> list[str]: "김민준 1", # rules/O6 over a segmented name and a word of no letter "Jan\u200bPavel -", # rules/O6 over a zero-width split and a lone mark ] +# sl and hr turn rules/O6 on since #1190, so their ml rotator is a +# name the patch alone leaves as the default reads it, as cs's is _ROTATORS["sl"] = [ - "Janez Novak ml.", # ml + "Novak ml.", # ml "Janez Novak st.", # st + "Elena Zavadlav Ušaj", # rules/O6, the patch + "김민준 1", # rules/O6 over a segmented name and a word of no letter + "Jan\u200bPavel -", # rules/O6 over a zero-width split and a lone mark ] _ROTATORS["hr"] = [ - "Ivan Horvat ml.", # ml + "Horvat ml.", # ml "Ivan Horvat st.", # st + "Ana Puž Kukuljan", # rules/O6, the patch + "김민준 1", # rules/O6 over a segmented name and a word of no letter + "Jan\u200bPavel -", # rules/O6 over a zero-width split and a lone mark ] # ar and he (#1257): ben mid-name, in each case and after a family comma; # ar also the credential ABD its choice drops for abd's bound given name @@ -3483,6 +3493,40 @@ def test_no_exclusion_is_pack_shaped_any_more() -> None: ("cs", None, "Novák, Petr Pavel", ("", "Petr", "Pavel", "Novák", "", "", ()), ("", "Petr", "Pavel", "Novák", "", "", ())), + # hr and sl turn the patch on since #1190, as cs and sk do, with the + # same cost and no given-name list (decisions/O6, 2026-11-21): an + # initial before the surname stays the middle name, a hyphenated + # pair is one word already, a family comma stands O6 down + ("hr", None, "Ana Puž Kukuljan", + ("", "Ana", "Puž", "Kukuljan", "", "", ()), + ("", "Ana", "", "Puž Kukuljan", "", "", ())), + ("sl", None, "Elena Zavadlav Ušaj", + ("", "Elena", "Zavadlav", "Ušaj", "", "", ()), + ("", "Elena", "", "Zavadlav Ušaj", "", "", ())), + ("hr", None, "dr. Ana Puž Kukuljan ml.", + ("dr.", "Ana", "Puž Kukuljan", "ml.", "", "", ()), + ("dr.", "Ana", "", "Puž Kukuljan", "ml.", "", ())), + ("sl", "FAMILY_FIRST", "Zavadlav Ušaj Elena", + ("", "Ušaj", "Elena", "Zavadlav", "", "", ()), + ("", "Elena", "", "Zavadlav Ušaj", "", "", ())), + ("hr", None, "Ana M. Kukuljan", + ("", "Ana", "M.", "Kukuljan", "", "", ()), + ("", "Ana", "M.", "Kukuljan", "", "", ())), + ("hr", None, "Ana Puž-Kukuljan", + ("", "Ana", "", "Puž-Kukuljan", "", "", ()), + ("", "Ana", "", "Puž-Kukuljan", "", "", ())), + ("hr", None, "Ivan Marko Horvat", + ("", "Ivan", "Marko", "Horvat", "", "", ()), + ("", "Ivan", "", "Marko Horvat", "", "", ())), + ("sl", None, "Janez Jože Novak", + ("", "Janez", "Jože", "Novak", "", "", ()), + ("", "Janez", "", "Jože Novak", "", "", ())), + ("sl", None, "Novak, Janez Jože", + ("", "Janez", "Jože", "Novak", "", "", ()), + ("", "Janez", "Jože", "Novak", "", "", ())), + ("hr", None, "Puž Kukuljan, Ana", + ("", "Ana", "", "Puž Kukuljan", "", "", ()), + ("", "Ana", "", "Puž Kukuljan", "", "", ())), # Bc and Ing, the pack's titles since #970: Bc a reading off by # default, Ing the same with the fragment removing the given reading # that would make it a title only in a phrase (rules/H9), so both diff --git a/tests/v2/test_vocab.py b/tests/v2/test_vocab.py index ff7ef9dcb..fa805d798 100644 --- a/tests/v2/test_vocab.py +++ b/tests/v2/test_vocab.py @@ -158,7 +158,7 @@ def test_a_reading_off_by_default_compiles_to_nothing() -> None: both = build.compile_files({ "en.toml": _w('[[word]]\ntext = "zzq"\ngeneration = {}'), "de.toml": _w('[[word]]\ntext = "zzq"\ncredential = { default = false }'), - "hr.toml": _w('[[word]]\ntext = "zzr"\nexcluded = { generation = "x" }'), + "sr.toml": _w('[[word]]\ntext = "zzr"\nexcluded = { generation = "x" }'), "pl.toml": _w('[[word]]\ntext = "zzr"\ngeneration = { default = false }'), }) assert "zzq" in both["SUFFIX_WORDS"] and "zzq" not in both["SUFFIX_ACRONYMS"] @@ -1725,7 +1725,7 @@ def test_the_pack_roster_names_shipped_packs_their_files_compile_into() -> None: assert set(build.PACK_RULES.values()) <= set(locales._REGISTRY) for tag, attr in build.PACK_RULES.items(): assert getattr(locales, attr).policy == rules_patch(tag), attr - with pytest.raises(KeyError, match="no vocabulary file 'en' holds a \\[rules\\] table; the files that do: cs, es, ne, pt-BR, pt-PT, ru, sk, tr, vi"): + with pytest.raises(KeyError, match="no vocabulary file 'en' holds a \\[rules\\] table; the files that do: cs, es, hr, ne, pt-BR, pt-PT, ru, sk, sl, tr, vi"): rules_patch("en") diff --git a/tools/differential/cldr_agreement_locales.json b/tools/differential/cldr_agreement_locales.json index 853574a90..e7450b65c 100644 --- a/tools/differential/cldr_agreement_locales.json +++ b/tools/differential/cldr_agreement_locales.json @@ -958,7 +958,57 @@ "got": "" } }, + "hr/foreignFull/givenFirst": { + "family": { + "expected": "von Brühl", + "got": "Martín von Brühl" + }, + "family_base": { + "expected": "Brühl", + "got": "Martín Brühl" + }, + "given_names": { + "expected": "Ada Cornelia César Martín", + "got": "Ada Cornelia César" + }, + "surname1_base": { + "expected": "Brühl", + "got": "Martín" + }, + "surname1_particles": { + "expected": "von", + "got": "" + }, + "surname2": { + "expected": "", + "got": "von Brühl" + }, + "text": "prof. dr. Ada Cornelia César Martín von Brühl Jr, univ. bacc" + }, + "hr/foreignGGS/givenFirst": { + "family": { + "expected": "Stöber", + "got": "Hamish Stöber" + }, + "given_names": { + "expected": "Zäzilia Hamish", + "got": "Zäzilia" + }, + "text": "Zäzilia Hamish Stöber" + }, "hr/nativeFull/givenFirst": { + "family": { + "expected": "Marić", + "got": "Hrvoje Marić" + }, + "family_base": { + "expected": "Marić", + "got": "Hrvoje Marić" + }, + "given_names": { + "expected": "Branko Hrvoje", + "got": "Branko" + }, "suffix": { "expected": "mlađi prof.", "got": "mlađi" @@ -980,6 +1030,17 @@ "got": "dr. sc. prof." } }, + "hr/nativeGGS/givenFirst": { + "family": { + "expected": "Babić", + "got": "Tomislav Babić" + }, + "given_names": { + "expected": "Marijana Tomislav", + "got": "Marijana" + }, + "text": "Marijana Tomislav Babić" + }, "ja/foreignFull/givenFirst": { "family": { "expected": "フォン スミス", @@ -1979,10 +2040,34 @@ "text": "Slovák Ján Matej" }, "sl/foreignFull/givenFirst": { + "family": { + "expected": "von Brühl", + "got": "Martín von Brühl" + }, + "family_base": { + "expected": "Brühl", + "got": "Martín Brühl" + }, + "given_names": { + "expected": "Ada Cornelia César Martín", + "got": "Ada Cornelia César" + }, "suffix": { "expected": "ml. dr. med., dr. dent. med.", "got": "ml., dent. med." }, + "surname1_base": { + "expected": "Brühl", + "got": "Martín" + }, + "surname1_particles": { + "expected": "von", + "got": "" + }, + "surname2": { + "expected": "", + "got": "von Brühl" + }, "text": "prof. dr. Ada Cornelia César Martín von Brühl ml., dr. med., dr. dent. med.", "title": { "expected": "prof. dr.", @@ -1990,20 +2075,66 @@ } }, "sl/foreignFull/surnameFirst": { + "family": { + "expected": "von Brühl", + "got": "von Brühl Ada" + }, + "family_base": { + "expected": "Brühl", + "got": "Brühl Ada" + }, + "given_names": { + "expected": "Ada Cornelia César Martín", + "got": "Cornelia César Martín" + }, "suffix": { "expected": "dr. med., dr. dent. med.", "got": "dent. med." }, + "surname2": { + "expected": "", + "got": "Ada" + }, "text": "prof. dr. von Brühl Ada Cornelia César Martín, dr. med., dr. dent. med.", "title": { "expected": "prof. dr.", "got": "prof. dr. dr. med. dr." } }, + "sl/foreignGGS/givenFirst": { + "family": { + "expected": "Stöber", + "got": "Hamish Stöber" + }, + "given_names": { + "expected": "Zäzilia Hamish", + "got": "Zäzilia" + }, + "text": "Zäzilia Hamish Stöber" + }, + "sl/foreignGGS/surnameFirst": { + "family": { + "expected": "Stöber", + "got": "Stöber Zäzilia" + }, + "given_names": { + "expected": "Zäzilia Hamish", + "got": "Hamish" + }, + "text": "Stöber Zäzilia Hamish" + }, "sl/nativeFull/givenFirst": { + "family": { + "expected": "Novak", + "got": "Peter Novak" + }, + "family_base": { + "expected": "Novak", + "got": "Peter Novak" + }, "given_names": { "expected": "Janez Peter", - "got": "g. Janez Peter" + "got": "g. Janez" }, "suffix": { "expected": "ml. univ. dipl. inž.", @@ -2018,15 +2149,11 @@ "sl/nativeFull/surnameFirst": { "family": { "expected": "Novak", - "got": "g." + "got": "g. Novak" }, "family_base": { "expected": "Novak", - "got": "g." - }, - "given_names": { - "expected": "Janez Peter", - "got": "Novak Janez Peter" + "got": "g. Novak" }, "suffix": { "expected": "univ. dipl. inž.", @@ -2038,6 +2165,28 @@ "got": "univ. dipl. inž." } }, + "sl/nativeGGS/givenFirst": { + "family": { + "expected": "Kovač", + "got": "Vera Kovač" + }, + "given_names": { + "expected": "Ana Marija Vera", + "got": "Ana Marija" + }, + "text": "Ana Marija Vera Kovač" + }, + "sl/nativeGGS/surnameFirst": { + "family": { + "expected": "Kovač", + "got": "Kovač Ana" + }, + "given_names": { + "expected": "Ana Marija Vera", + "got": "Marija Vera" + }, + "text": "Kovač Ana Marija Vera" + }, "tr/foreignFull/givenFirst": { "given_names": { "expected": "Ada Cornelia César Martín", diff --git a/tools/vocab/build.py b/tools/vocab/build.py index 1a7bd97d0..86373dab1 100644 --- a/tools/vocab/build.py +++ b/tools/vocab/build.py @@ -366,7 +366,7 @@ def _alnum(text: str) -> str: #: does not: locales.PT, chosen for Portuguese names from any country, #: leaves O6 off (decisions/O6, 2026-11-19). PACK_RULES: dict[str, str] = {"ru": "RU", "tr": "TR_AZ", "es": "ES", "cs": "CS", - "sk": "SK", "vi": "VI", "ne": "NE", + "sk": "SK", "hr": "HR", "sl": "SL", "vi": "VI", "ne": "NE", "pt-BR": "PT_BR", "pt-PT": "PT_PT"} #: The words check 13 lets hold a reading in another file beside their From d6f3fc4352f01d19bd56410bcd759c025e3fb3d1 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 22:20:13 -0800 Subject: [PATCH 2/5] Name hr.toml's and sl.toml's [rules] tables in AGENTS.md (#1190) Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index a95c4173a..e88006d8b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -263,7 +263,7 @@ Latin-script input is never touched by any of this: "Kim Min-jun" is genuinely o ### Vocabulary (`nameparser/vocab/`) and the configuration layer (`nameparser/config/`) -**The default vocabulary is written per word, in TOML, and compiled.** `nameparser/vocab/.toml` holds one file per BCP 47 language tag, each `[[word]]` entry a `text` and its readings keyed by kind. What a file means, how an entry is built, the kinds and properties with the set each compiles into, exclusions, bearer counts and the steps for adding a word are in `nameparser/vocab/README.md`, the reference for anyone editing the TOML; `tests/v2/test_vocab.py` holds its kind, property, derived-marker and reserved-name tables to the names `build.py` accepts and the sets it compiles, so read it rather than restating it here. The parser never reads the TOML: `tools/vocab/build.py` runs the build checks that replaced the modules' import-time asserts (its docstring numbers them), turns every reading into an index row with its file's tag, and writes the rows, and every file's tag (`FILES`, a file holding only exclusions included, for a strict choice to name), as the committed reading index `nameparser/config/_index.py` (#753, phase 3a) and, compiled, as the committed `nameparser/config/_compiled.py`, frozenset literals one entry per line; the build never reads `_index.py` back. A file a shipped pack reads may also hold a `[rules]` table, each key a `Policy` field (`patronymic_rules`, `name_order`, `two_family_names`, `two_given_names`, `initials_as_family`), which the build checks against its `RULE_KEYS` and `PACK_RULES` and writes as `nameparser/config/_rules.py`; `_locale.rules_patch(tag)` turns a file's table into the `PolicyPatch` a pack carries, RU's and TR_AZ's from `ru.toml` and `tr.toml`, and the `two_family_names` of ES, CS and SK from `es.toml`, `cs.toml` and `sk.toml`, and ES_AR's from `es.toml`, a country pack reading its language's table (#754, 4f; decisions/vocabulary-model's 2026-10-29 4f entry), and VI's `name_order` from `vi.toml` (#1108), and NE's `initials_as_family` from `ne.toml` (#1254), and the `two_family_names` of PT_BR and PT_PT from `pt-BR.toml` and `pt-PT.toml`, country files writing a table `pt.toml` does not, `pt-PT.toml` also holding Portugal's own `default = false` readings (decisions/O6, 2026-11-19, #1453; decisions/P10, 2026-11-19, #1189). The compiler is `nameparser/_reading_index.py`'s `compile_readings`, with the kind and property tables it reads (`CATEGORY`, `BEHAVIORAL`, `GATED_WORDS`), so the build and a choice of languages compile alike: `Locale.languages` (3.0, phase 3b) is a choice of BCP 47 tags, which `parser_for` unions across its packs and base's recorded choice and records on the `Lexicon` (`Lexicon.languages`, 3.0's 4i-c), the lexicon compiling its base's readings through `choose` and its own edits after them, `choose` selecting the readings (a chosen file's `default = false` ones on; on a word a chosen file holds a vocabulary reading of, other files' vocabulary readings off, save `mul.toml`'s and `und.toml`'s; a chosen conjunction's `may_be_initial` dropped; under `parser_for(..., strict=True)`, 3j, only the chosen files, `mul.toml` (#1005) and native-script words' readings as a plain choice of the same languages keeps them, name readings included, compiled, through `strict_pool`), `changed_words` deriving a choice's deviation surface which tests/v2/test_locales.py's gate reads, and `strict_ungated` the words a strict choice ungates against the plain one, which tests/v2/test_reading_index.py holds to a reviewed table (decisions/vocabulary-model, 2026-10-29 3b; 2026-10-31 #753, phase 3j); the build keeps the checks and loads that module by path, as it loads `_lexicon.py`, and `tests/v2/test_reading_index.py` holds that the index compiled with no choice is `_compiled.py` exactly. `readings_of(text)` there is the run-time reader of the index, every reading of a word with its file's tag, loaded on first call; `languages_of(text, categories)` is the reader a default parse calls for `Reading.languages` (3.0), through the lexicon's private `_files` (`_lexicon._ReadingFiles`, one per base, log and choice, hashed by identity so assemble's memo keyed by it costs no frame), which under a choice or a caller's log names the files whose reading is on in that lexicon instead (3.0's 4i-d), so the first parse that reads a word from its `Lexicon`'s vocabulary loads the index. Through 2.x each `config/` module re-exported its constants from `_compiled.py` (`TITLES = _compiled.TITLES`) under an autodoc docstring; 3.0 removed those modules (#1007, 2.8.1 warning of them), so the compiled sets are private, `Lexicon` reads them, and a caller lists a kind's words with `Lexicon.words(kind=...)`, docs/migrate.rst giving the call for each 2.x constant (a test runs every one). `tests/v2/test_vocab.py` fails when `_compiled.py` is stale, and `tests/v2/test_reading_index.py` when the index is, each naming the refresh command, and `test_vocab.py` gives every build check a mutation. The model, the phasing and what was declined: decisions/vocabulary-model. +**The default vocabulary is written per word, in TOML, and compiled.** `nameparser/vocab/.toml` holds one file per BCP 47 language tag, each `[[word]]` entry a `text` and its readings keyed by kind. What a file means, how an entry is built, the kinds and properties with the set each compiles into, exclusions, bearer counts and the steps for adding a word are in `nameparser/vocab/README.md`, the reference for anyone editing the TOML; `tests/v2/test_vocab.py` holds its kind, property, derived-marker and reserved-name tables to the names `build.py` accepts and the sets it compiles, so read it rather than restating it here. The parser never reads the TOML: `tools/vocab/build.py` runs the build checks that replaced the modules' import-time asserts (its docstring numbers them), turns every reading into an index row with its file's tag, and writes the rows, and every file's tag (`FILES`, a file holding only exclusions included, for a strict choice to name), as the committed reading index `nameparser/config/_index.py` (#753, phase 3a) and, compiled, as the committed `nameparser/config/_compiled.py`, frozenset literals one entry per line; the build never reads `_index.py` back. A file a shipped pack reads may also hold a `[rules]` table, each key a `Policy` field (`patronymic_rules`, `name_order`, `two_family_names`, `two_given_names`, `initials_as_family`), which the build checks against its `RULE_KEYS` and `PACK_RULES` and writes as `nameparser/config/_rules.py`; `_locale.rules_patch(tag)` turns a file's table into the `PolicyPatch` a pack carries, RU's and TR_AZ's from `ru.toml` and `tr.toml`, and the `two_family_names` of ES, CS and SK from `es.toml`, `cs.toml` and `sk.toml`, and HR's and SL's from `hr.toml` and `sl.toml` (decisions/O6, 2026-11-21, #1190), and ES_AR's from `es.toml`, a country pack reading its language's table (#754, 4f; decisions/vocabulary-model's 2026-10-29 4f entry), and VI's `name_order` from `vi.toml` (#1108), and NE's `initials_as_family` from `ne.toml` (#1254), and the `two_family_names` of PT_BR and PT_PT from `pt-BR.toml` and `pt-PT.toml`, country files writing a table `pt.toml` does not, `pt-PT.toml` also holding Portugal's own `default = false` readings (decisions/O6, 2026-11-19, #1453; decisions/P10, 2026-11-19, #1189). The compiler is `nameparser/_reading_index.py`'s `compile_readings`, with the kind and property tables it reads (`CATEGORY`, `BEHAVIORAL`, `GATED_WORDS`), so the build and a choice of languages compile alike: `Locale.languages` (3.0, phase 3b) is a choice of BCP 47 tags, which `parser_for` unions across its packs and base's recorded choice and records on the `Lexicon` (`Lexicon.languages`, 3.0's 4i-c), the lexicon compiling its base's readings through `choose` and its own edits after them, `choose` selecting the readings (a chosen file's `default = false` ones on; on a word a chosen file holds a vocabulary reading of, other files' vocabulary readings off, save `mul.toml`'s and `und.toml`'s; a chosen conjunction's `may_be_initial` dropped; under `parser_for(..., strict=True)`, 3j, only the chosen files, `mul.toml` (#1005) and native-script words' readings as a plain choice of the same languages keeps them, name readings included, compiled, through `strict_pool`), `changed_words` deriving a choice's deviation surface which tests/v2/test_locales.py's gate reads, and `strict_ungated` the words a strict choice ungates against the plain one, which tests/v2/test_reading_index.py holds to a reviewed table (decisions/vocabulary-model, 2026-10-29 3b; 2026-10-31 #753, phase 3j); the build keeps the checks and loads that module by path, as it loads `_lexicon.py`, and `tests/v2/test_reading_index.py` holds that the index compiled with no choice is `_compiled.py` exactly. `readings_of(text)` there is the run-time reader of the index, every reading of a word with its file's tag, loaded on first call; `languages_of(text, categories)` is the reader a default parse calls for `Reading.languages` (3.0), through the lexicon's private `_files` (`_lexicon._ReadingFiles`, one per base, log and choice, hashed by identity so assemble's memo keyed by it costs no frame), which under a choice or a caller's log names the files whose reading is on in that lexicon instead (3.0's 4i-d), so the first parse that reads a word from its `Lexicon`'s vocabulary loads the index. Through 2.x each `config/` module re-exported its constants from `_compiled.py` (`TITLES = _compiled.TITLES`) under an autodoc docstring; 3.0 removed those modules (#1007, 2.8.1 warning of them), so the compiled sets are private, `Lexicon` reads them, and a caller lists a kind's words with `Lexicon.words(kind=...)`, docs/migrate.rst giving the call for each 2.x constant (a test runs every one). `tests/v2/test_vocab.py` fails when `_compiled.py` is stale, and `tests/v2/test_reading_index.py` when the index is, each naming the refresh command, and `test_vocab.py` gives every build check a mutation. The model, the phasing and what was declined: decisions/vocabulary-model. The compiled SETS are frozen since 2.2 (#293): there is no `.add()`/`.remove()` on any of them, so a default word list is changed at runtime by configuring a `Lexicon`, never by editing a constant, and the shipped default is changed by editing the TOML and rebuilding. **The five dicts are not frozen.** `_compiled.CAPITALIZATION_EXCEPTIONS` is vocabulary-shaped, private since 3.0, and read once by the cached `Lexicon.default()`, so an edit after the first parse misses it — configure the object (`dataclasses.replace(lexicon, capitalization_exceptions=...)`). `_compiled.SAME_AS` (the name match's listed spellings, a dict of dicts, below), `_compiled.SAME_AS_NAMED` beside it, `_compiled.FAMILIAR` (the familiar forms) and `_compiled.ALTERNATE_SPELLINGS` (the alternate spellings) are the same hazard: each `Lexicon` reads them once into its own `_same_as`, `_same_as_named`, `_familiar` and `_alternate` at construction, the default's cached, so an edit to the module misses every lexicon already built — configure the object (`lexicon.add(word, kind=..., same_as=...)`). `REGEXES`, the other mutable mapping through 2.x, went with `config/regexes.py` in 3.0 (#1008). `tests/v2/test_contracts.py::test_every_vocabulary_constant_is_frozen` sweeps every module in `nameparser/config/` (`_compiled` and `_ko_surnames` hold its constants) and names those five dicts as explicit exemptions rather than letting its `isinstance` filter drop them. From ec373d836058c4cc2e0e76a7bef40efffb6c5855 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 22:29:41 -0800 Subject: [PATCH 3/5] Add hr and sl to the lists of packs turning O6 on, and derive the test's list (#1190) Review found five places outside the first diff still naming only the earlier packs: the pack-parts table and DEVIATES scope in locales.rst, the surname views in usage.rst and migrate.rst, and the shared declaration's docstring. The parametrized twice-counting test now reads its packs off the registry. languages.rst names the PSC figures, and the given-name-list claim is scoped to what was looked for. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/O6-two-family-names.md | 4 ++-- docs/languages.rst | 7 +++++-- docs/locales.rst | 10 ++++----- docs/migrate.rst | 2 +- docs/usage.rst | 2 +- nameparser/_locale.py | 4 ++-- tests/v2/test_locales.py | 22 ++++++++++++++------ tools/vocab/build.py | 3 ++- 8 files changed, 34 insertions(+), 20 deletions(-) diff --git a/docs/design/decisions/O6-two-family-names.md b/docs/design/decisions/O6-two-family-names.md index 567553cc0..d5b699d0e 100644 --- a/docs/design/decisions/O6-two-family-names.md +++ b/docs/design/decisions/O6-two-family-names.md @@ -305,7 +305,7 @@ - **Measured** 2026-11-20 on the branch against a checkout of master `89ec747c`. `local_agreement.py orcid-researchers --base --locale es_ar`, every country (1,823,708 records scored under the pack): 407 records fixed, 96 broken, 22 changed. By the word moved: `grace` 256 fixed / 4 broken, `mahdi` 142 / 24, `cheikh` 7 / 15 (a word Maghrebi surnames open, `CHEIKH MOUSSA`), and the words leaving at the cutoff 2 / 53 (`rehan` 24, `shamim` 22, `zakarya` 5, `wenjie` 2); in the Spanish-speaking countries, 3 fixed and none broken. `--locale es`: 2 fixed, 14 broken, every break `rim` (`Young Rim Oh`), none in a Spanish-speaking country. `config_diff.py score` over every group of `--languages es` in ORCID, PatentsView and PSC, the master lists (loaded from the checkout through an `expr:` spec) against the new: locales.ES_AR 1 record fixed in ORCID Chile and 1 in Paraguay, 1 broken of PSC's 6,089 Spanish filers, every other group unchanged; locales.ES unchanged in every group to two decimals. ORCID holds no `emerita` record moved. - **Accepted:** the moves outside the Spanish-speaking countries, mostly Arabic, South Asian and Korean given names, the cost a caller who chose a Spanish pack accepts for names it was not chosen for (decided 2026-11-20); and locales.ES's `rim`, which the tool's own cutoff drops. - Recompute: `uv run --with openpyxl --with xlrd python tools/es_given_names.py --list es-AR` (and `--list es`) against the cached INE tables, then the two commands above with `--base `, the `expr:` spec building `parser_for(Locale(code=..., lexicon=Lexicon(given_names=), policy=locales.ES_AR.policy, languages=frozenset({'es-AR'})))`. -- 2026-11-21 #1190 — `locales.HR` AND `locales.SL` TURN THE SWITCH ON, WITH NO GIVEN-NAME LIST, AS `locales.CS` AND `locales.SK` DO. Decided 2026-11-21. A Croatian or Slovenian woman who keeps her surname beside her husband's writes the two without a hyphen, as a Czech or Slovak one does (`Ana Puž Kukuljan`), the shape the default reads as a middle name. hr.toml and sl.toml each gain `[rules]` `two_family_names = true`, compiled into the pack's policy patch (`PACK_RULES` in tools/vocab/build.py gains `hr` and `sl`), and each pack declares `DEVIATES` through `_locale.deviates_by_two_family_names` (decisions/deviates-registry's entry of this date). The default does not move. Supersedes the 2026-10-30 phase 3f amended entry's "`SL` and `HR` read one family name, no population of theirs measured", and answers #1190's two questions: the CS and SK cost is accepted here too, with no given-name list (none is published for either whole population), and the two parliaments and ORCID are enough, no further local corpus needed. +- 2026-11-21 #1190 — `locales.HR` AND `locales.SL` TURN THE SWITCH ON, WITH NO GIVEN-NAME LIST, AS `locales.CS` AND `locales.SK` DO. Decided 2026-11-21. A Croatian or Slovenian woman who keeps her surname beside her husband's writes the two without a hyphen, as a Czech or Slovak one does (`Ana Puž Kukuljan`), the shape the default reads as a middle name. hr.toml and sl.toml each gain `[rules]` `two_family_names = true`, compiled into the pack's policy patch (`PACK_RULES` in tools/vocab/build.py gains `hr` and `sl`), and each pack declares `DEVIATES` through `_locale.deviates_by_two_family_names` (decisions/deviates-registry's entry of this date). The default does not move. Supersedes the 2026-10-30 phase 3f amended entry's "`SL` and `HR` read one family name, no population of theirs measured", and answers #1190's two questions: the CS and SK cost is accepted here too, with no given-name list (none was looked for), and the two parliaments and ORCID are enough, no further local corpus needed. - **Measured** on master `6ff048fe`, each pack against itself with the switch off (`config_diff.py score plain:HR 'plain:HR@two_family_names=1' plain:SL 'plain:SL@two_family_names=1' plain:CS --group HR --group SI --group Croatian --group Slovenian --cap 20000`, run in that checkout; ORCID's extract of 2025-10-17, PatentsView's and PSC's fetches as cached on 2026-11-21). `HR`, `SL` and `CS` score alike on every row, so the switch is what moves them. All boxes agreeing: | Population | Records | Off → on | Fixed | Broken | @@ -319,5 +319,5 @@ ORCID's `name` is composed from its two boxes, given first, so a two-word family box always reaches the parser as two trailing words: the ORCID gain is the boxes' own split, not a check that people write their names that way. The parliaments are the independent check, display names written by each chamber: of the Croatian Sabor's 149 members (OpenSanctions `hr_sabor`, `opensanctions-parliaments` as cached on 2026-11-21) the family is right for 140 with the switch off and 148 with it on, 9 fixed and 1 broken; of the Slovenian National Assembly's 90 (`si_dz_rs`), 84 and 89, 6 fixed and 1 broken. Every three-word name in either chamber moves, and every break is a member with two given names. Read by hand: the two chambers hold no other name of three or more words, and every two-word or hyphenated name reads the same either way. - **Accepted:** a name with two given names reads the second as a family name (`Janez Jože Novak` gives family 'Jože Novak'), as under CS and SK, the cost the PatentsView dip holds; CLDR's fictional `hr` and `sl` renderings with two given names lose too (`cldr_agreement_locales.json` re-recorded: 4 `hr` and 8 `sl` renderings move, each one taking a second word into the family, a second given name given first or the first given name family first, and none of them agreeing after). Open: a Croatian or Slovenian given-name list, which would lift the cost as the Spanish and Portuguese lists do; none was looked for past #1190. - - **Swept** under all three `name_order`s, comparing each pack with `CS` on the same 25 shapes (no comma, a full name, one word and nothing before a comma, a hyphenated pair, a particle, a suffix, a title, three and four words, an initial in the middle): HR, SL and CS read all 75 alike, so the two packs differ from CS by vocabulary alone. `Ana M. Kukuljan` keeps middle 'M.' under every order but the family-first ones, where it reads as the default does; a family comma stands O6 down. A strict choice of either reads as the plain one (`two_family_names` on, the patch beside the choice). + - **Swept** under all three `name_order`s, comparing each pack with `CS` on the same 25 shapes (no comma, a full name, one word and nothing before a comma, a hyphenated pair, a particle, a suffix, a title, three and four words, an initial in the middle): HR, SL and CS read all 75 alike, so the two packs differ from CS by vocabulary alone. `Ana M. Kukuljan` keeps middle 'M.' given-first, and under either family-first order reads as the default does; a family comma stands O6 down. A strict choice of either reads as the plain one (`two_family_names` on, the patch beside the choice). - Recompute: the `score` command above in a checkout of the base, and `config_diff.py diff 'plain:HR@two_family_names=0' plain:HR --local opensanctions-parliaments --group hr_sabor --readings ` (and `SL` with `si_dz_rs`) in this tree, each moved name judged by hand. diff --git a/docs/languages.rst b/docs/languages.rst index fde7874c6..b79f50506 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -199,7 +199,8 @@ name in its own view (``surname1`` ``Pešová``, ``surname2`` Two given names pay for it: with no given-name list in any of the four languages to keep a given name out of the family (none is published -for the whole population), ``Petr Pavel Novák`` reads family ``Pavel +for the whole Czech or Slovak population, and none has been looked for +in Slovenian or Croatian), ``Petr Pavel Novák`` reads family ``Pavel Novák``. A family comma keeps both as the default reads them, and an initial written between the given name and the surname stays the middle name: @@ -312,7 +313,9 @@ family name it reads right from 140 to 148 of 149 and from 84 to 89 of 90, the one loss in each a member with two given names. Among US patents' inventors, whose boxes a professional filer fills, it lowers them slightly, from 92.0% to 91.6% in Croatia and from 88.2% to 87.4% -in Slovenia. The +in Slovenia, and among the people with significant control of UK +companies it moves Croatian nationals from 97.5% to 97.3% and +Slovenian ones from 95.3% to 95.7%, a handful of records each way. The dated figures are in ``docs/design/decisions/O6-two-family-names.md`` and ``docs/design/decisions/vocabulary-model.md``. diff --git a/docs/locales.rst b/docs/locales.rst index 4fcc57872..9cd431410 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -138,8 +138,8 @@ Read that precisely: a shape is a pattern, not a language, so a pack can act on a name from a tradition it was not written for. A broad shape covers much: -- ``es``, ``es_ar``, ``cs``, ``sk``, ``pt_br`` and ``pt_pt`` may read - any name of three words differently. +- ``es``, ``es_ar``, ``cs``, ``sk``, ``hr``, ``sl``, ``pt_br`` and + ``pt_pt`` may read any name of three words differently. - ``vi``, whose name order is its shape, may read any name differently: the order moves every name a family comma does not fix, and its titles and removed readings reach the comma names too. @@ -404,8 +404,8 @@ says what it can change: - Chooses a language - Policy fields - Word list - * - ``ar``, ``bn``, ``ga``, ``gd``, ``he``, ``hi``, ``hr``, ``ms``, - ``nl``, ``pt``, ``sl`` + * - ``ar``, ``bn``, ``ga``, ``gd``, ``he``, ``hi``, ``ms``, ``nl``, + ``pt`` - yes - none - none @@ -413,7 +413,7 @@ says what it can change: - yes - ``two_family_names`` - a removal: ``Ing``'s given-name reading - * - ``sk`` + * - ``sk``, ``hr``, ``sl`` - yes - ``two_family_names`` - none diff --git a/docs/migrate.rst b/docs/migrate.rst index 9b0651f60..a6455263a 100644 --- a/docs/migrate.rst +++ b/docs/migrate.rst @@ -2247,7 +2247,7 @@ The second surname under two family names ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Under ``two_family_names``, as the ``es``, ``es_ar``, ``cs``, ``sk``, -``pt_br`` and ``pt_pt`` packs turn it on, the ``surname1`` and ``surname2`` views divide a +``hr``, ``sl``, ``pt_br`` and ``pt_pt`` packs turn it on, the ``surname1`` and ``surname2`` views divide a family of two surnames however the family was read, where 3.0 and 3.1 left it whole: written before a family comma, opening with a particle, and behind a given name a particle completes. No field moves: diff --git a/docs/usage.rst b/docs/usage.rst index b657678f7..718075cdc 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -264,7 +264,7 @@ Two family names: ``surname1`` and ``surname2`` ``surname2`` is the family's second name, where the parse read the family as two: with ``two_family_names`` on (:ref:`two-family-names`), as the ``es``, ``es_ar``, ``cs``, ``sk``, -``pt_br`` and ``pt_pt`` packs turn it on (:doc:`locales`), or for a Chinese name opening with +``hr``, ``sl``, ``pt_br`` and ``pt_pt`` packs turn it on (:doc:`locales`), or for a Chinese name opening with two surnames under ``zh`` (:ref:`east-asian-names`), and ``family`` keeps both. The family is divided by its own words, so the name written with a family comma gives the same two, and so does a family opening diff --git a/nameparser/_locale.py b/nameparser/_locale.py index c0becca46..e6de1add1 100644 --- a/nameparser/_locale.py +++ b/nameparser/_locale.py @@ -187,8 +187,8 @@ def rules_patch(tag: str) -> PolicyPatch: def deviates_by_two_family_names(name: str) -> bool: """The DEVIATES declaration of a pack whose patch turns on - ``Policy.two_family_names`` (rules/O6), the es, es_ar, cs, sk, - pt_br and pt_pt packs, and of the given-name list the es, es_ar, + ``Policy.two_family_names`` (rules/O6), the es, es_ar, cs, sk, hr, + sl, pt_br and pt_pt packs, and of the given-name list the es, es_ar, pt_br and pt_pt packs carry beside it, which acts only where O6 does. O6 acts only on a name of three or more name words, so a name declares that holds three or more words, commas read as spaces, diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 6610c347c..ab87c9f56 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -1403,9 +1403,9 @@ def test_cs_and_sk_pack_contents() -> None: assert pack == Locale(code=code, lexicon=fragments[code], policy=PolicyPatch(two_family_names=True), languages=frozenset({code})), code - assert not _is_vocabulary_pack(pack), code - # the patch's declaration is rules/O6's, one predicate for the - # packs that turn O6 on, so their declarations cannot drift apart + # the patch's declaration is rules/O6's, one predicate for every + # pack that turns O6 on (es_ar, pt_br and pt_pt among them, held to + # it in their own tests), so their declarations cannot drift apart for module in (_cs, _sk, _es, _hr, _sl): for name in ("Alena Pešová Řehořová", "Novák, Petr Pavel", "Mária-\u200bJana Kováčová", "Jan Novák", "Novák"): @@ -1483,8 +1483,18 @@ def test_the_twice_counted_controls_each_move_a_row() -> None: if by_name and not declared] +# every pack turning rules/O6 on, read off the packs so a new one joins +# (#1190's review: hr and sl were missing from a hand list here) +_O6_PACKS = sorted(code for code in _PACKS + if locales.get(code).policy.two_family_names is True) + + +def test_the_o6_packs_are_the_ones_shipped() -> None: + assert _O6_PACKS == ["cs", "es", "es_ar", "hr", "pt_br", "pt_pt", "sk", "sl"] + + @pytest.mark.parametrize("name", _NARROWED) -@pytest.mark.parametrize("code", ["es", "es_ar", "cs", "sk", "pt_br", "pt_pt"]) +@pytest.mark.parametrize("code", _O6_PACKS) def test_a_name_the_declaration_stopped_counting_twice_reads_as_the_default( code: str, name: str) -> None: assert _require_packed(code).parse(name).as_dict() == _default_parse(name) @@ -2515,8 +2525,8 @@ def _default_corpus() -> list[str]: # The choice packs (3f): one name per word of the derived surface, each # in a shape the default reads differently, so the gate's positive side # reaches every word the choice changes (held by -# test_choice_rotators_cover_every_changed_word below). cs and sk carry -# rules/O6's patch too, so each word's rotator is a name the patch alone +# test_choice_rotators_cover_every_changed_word below). cs, sk, hr and +# sl carry rules/O6's patch too, so each word's rotator is a name the patch alone # leaves as the default reads it -- two name words, or a marker run in # brackets -- (held by test_a_choice_word_rotator_is_moved_by_the_choice_alone), # and the patch has rotators of its own. diff --git a/tools/vocab/build.py b/tools/vocab/build.py index 86373dab1..79df06107 100644 --- a/tools/vocab/build.py +++ b/tools/vocab/build.py @@ -366,7 +366,8 @@ def _alnum(text: str) -> str: #: does not: locales.PT, chosen for Portuguese names from any country, #: leaves O6 off (decisions/O6, 2026-11-19). PACK_RULES: dict[str, str] = {"ru": "RU", "tr": "TR_AZ", "es": "ES", "cs": "CS", - "sk": "SK", "hr": "HR", "sl": "SL", "vi": "VI", "ne": "NE", + "sk": "SK", "hr": "HR", "sl": "SL", "vi": "VI", + "ne": "NE", "pt-BR": "PT_BR", "pt-PT": "PT_PT"} #: The words check 13 lets hold a reading in another file beside their From 2b7c44019f9fc3ba56ec735618d30b5af67360fe Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 22:32:58 -0800 Subject: [PATCH 4/5] Pin O6's other orders and comma shapes for hr and sl; correct the decisions entry's cost and CLDR claims (#1190) The test review asked for FAMILY_FIRST_GIVEN_LAST, a suffix comma, a credential after one and an empty head. The design-docs review found the PatentsView dip is mostly double surnames the filer split, not two given names; one CLDR move is a partial gain; a strict choice changes other readings; the phase 3f head entry needed a forward pointer; and the recipe needs --json for the counts the text output leaves out. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/O6-two-family-names.md | 6 +++--- docs/design/decisions/vocabulary-model.md | 2 +- tests/v2/test_locales.py | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/design/decisions/O6-two-family-names.md b/docs/design/decisions/O6-two-family-names.md index d5b699d0e..bfe2b1b39 100644 --- a/docs/design/decisions/O6-two-family-names.md +++ b/docs/design/decisions/O6-two-family-names.md @@ -318,6 +318,6 @@ | PSC, Slovenian | 277 | 95.31% → 95.67% | 10 | 9 | ORCID's `name` is composed from its two boxes, given first, so a two-word family box always reaches the parser as two trailing words: the ORCID gain is the boxes' own split, not a check that people write their names that way. The parliaments are the independent check, display names written by each chamber: of the Croatian Sabor's 149 members (OpenSanctions `hr_sabor`, `opensanctions-parliaments` as cached on 2026-11-21) the family is right for 140 with the switch off and 148 with it on, 9 fixed and 1 broken; of the Slovenian National Assembly's 90 (`si_dz_rs`), 84 and 89, 6 fixed and 1 broken. Every three-word name in either chamber moves, and every break is a member with two given names. Read by hand: the two chambers hold no other name of three or more words, and every two-word or hyphenated name reads the same either way. - - **Accepted:** a name with two given names reads the second as a family name (`Janez Jože Novak` gives family 'Jože Novak'), as under CS and SK, the cost the PatentsView dip holds; CLDR's fictional `hr` and `sl` renderings with two given names lose too (`cldr_agreement_locales.json` re-recorded: 4 `hr` and 8 `sl` renderings move, each one taking a second word into the family, a second given name given first or the first given name family first, and none of them agreeing after). Open: a Croatian or Slovenian given-name list, which would lift the cost as the Spanish and Portuguese lists do; none was looked for past #1190. - - **Swept** under all three `name_order`s, comparing each pack with `CS` on the same 25 shapes (no comma, a full name, one word and nothing before a comma, a hyphenated pair, a particle, a suffix, a title, three and four words, an initial in the middle): HR, SL and CS read all 75 alike, so the two packs differ from CS by vocabulary alone. `Ana M. Kukuljan` keeps middle 'M.' given-first, and under either family-first order reads as the default does; a family comma stands O6 down. A strict choice of either reads as the plain one (`two_family_names` on, the patch beside the choice). - - Recompute: the `score` command above in a checkout of the base, and `config_diff.py diff 'plain:HR@two_family_names=0' plain:HR --local opensanctions-parliaments --group hr_sabor --readings ` (and `SL` with `si_dz_rs`) in this tree, each moved name judged by hand. + - **Accepted:** a name with two given names reads the second as a family name (`Janez Jože Novak` gives family 'Jože Novak'), as under CS and SK; and a Russian name written given name, patronymic, surname takes the patronymic into the family. The PatentsView dip holds few of the first: read by hand, about 17 of HR's 24 broken records and 11 of SI's 37 are double surnames the filer split, the first surname in the given-names box, which the switch reads as intended; about 7 of HR's are two given names or a patronymic, and about 10 of SI's are Russian patronymics; and several people break under one filing and are fixed under another. So a Croatian or Slovenian given-name list would recover little of that dip. CLDR's fictional `hr` and `sl` renderings lose (`cldr_agreement_locales.json` re-recorded: 4 `hr` and 8 `sl` renderings move, and none agrees after). Eleven take a second word into the family, a second given name given first or the first given name family first. One is a partial gain: `sl/nativeFull/surnameFirst`, whose family held only `g.`, takes `Novak` beside it, so its `given_names` now agrees. Open: a Croatian or Slovenian given-name list, which would lift the cost as the Spanish and Portuguese lists do; none was looked for past #1190. + - **Swept** under all three `name_order`s, comparing each pack with `CS` on the same 25 shapes (no comma, a full name, one word and nothing before a comma, a hyphenated pair, a particle, a suffix, a title, three and four words, an initial in the middle): HR, SL and CS read all 75 alike, so the two packs differ from CS by vocabulary alone. `Ana M. Kukuljan` keeps middle 'M.' given-first, and under either family-first order reads as the default does; a family comma stands O6 down. Under a strict choice of either the patch is on too, beside the choice; strict changes other readings as it does for any pack (it drops `de`'s and `la`'s particle readings, so `Juan de la Vega` reads family 'la Vega'), and O6 then counts the words those readings leave. + - Recompute: the `score` command above in a checkout of the base, with `--json ` (its text prints fixed and broken only for the best column, so the PatentsView and PSC counts are read from the file), and `config_diff.py diff 'plain:HR@two_family_names=0' plain:HR --local opensanctions-parliaments --group hr_sabor --readings ` (and `SL` with `si_dz_rs`) in this tree, each moved name judged by hand. diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index 1a6bb43c8..43a64bd6f 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -380,7 +380,7 @@ Open: [#1145](https://github.com/derek73/python-nameparser/issues/1145), the dis - **Open: a period-joined token whose only title chunk the choice makes possibly given reads as a name word, in both directions.** `_vocab.period_joined_vocab` makes a token a title where ANY chunk is in `titles`, and under `ne` `श्री` has moved to `titles_ambiguous`. That costs `सु.श्री.` (सुश्री, Ms., written with its periods), title under the default and given under `ne`, 2 nepal-candidates names; and it fixes a given name glued behind the word, `श्री.राम थापा`, title `श्री.राम` under the default and given `श्री.राम` under `ne`. Whether a possibly-given chunk counts there is open; a fix would move the default for every word of `TITLES_AMBIGUOUS`, and its grid holds both `सु.श्री.` and `श्री.X`. - **Recompute:** the three commands above from a checkout of this change; the CLDR record with `cldr_agreement.py`; the word counts with `tools/name_usage.py guru गुरु श्री`. - **2026-10-30 #754, sub-phase 4g — THE COMPOUND GIVEN NAME IS A RULE KIND: `Policy.two_given_names`, rules/O7, OFF BY DEFAULT AND A `[rules]` KEY; NO DEFAULT PARSE MOVES.** Carries out item 7 of the 2026-10-28 #754 output-model entry and the 4g row of its item 9. The rule kind is built as the 4f entry's item 1 says a new one is: a `Policy` field with `ADDED_IN` (`3.0.0`, so a 2.8 `Policy` pickle loads with it off, tests/v2/data/policy_v28.pickle), a `flag` row in `tools/vocab/build.py`'s `RULE_KEYS` with its default `false` refused, a row in `_locale._RULE_VALUES`, and a mechanisms.md entry, DECLARED-SPAN, which it shares with rules/O6's switch, whose mirror it is. No file turns it on: whether `es` and `pt` do is 3g's. What the rule reads, its precedence against O6 and O3, and the measurements are decisions/O7's 2026-10-30 entry; the `Maria do Carmo Silva` shape the RFC's table names stays unread, the particle chain running to the end of the name, and is Open there. Item 6 of the 4f entry, deriving `DEVIATES` from the rules, stays open: this rule has no surface in the name for a pack to declare. -- **2026-10-30 #753, phase 3f (its `bc` and `ing` left out superseded by the 2026-11-21 #970 entry, which reads both as titles under `locales.CS`; its doctorates' `default = false` superseded by the 2026-11-06 #1115, the pack titles entry, which reads them by default, so the default reads `Jan Novák, MUDr` as the pack does; the post-nominals `DrSc` and `ArtD` read by default since decisions/suffix-acronym-collisions' 2026-11-20 #969 entry) — THE CZECH, SLOVAK, SLOVENIAN AND CROATIAN PACKS: `locales.CS`, `SK`, `SL` AND `HR`, ONE `Locale` PER LANGUAGE, EACH, LIKE `locales.NE`, A CHOICE OF ITS ONE TAG; `pan` AND `roz` BECOME READINGS OFF BY DEFAULT; THE DEFAULT DOES NOT MOVE.** Carries out 3f of item 11 of the 2026-10-27 #753 entry. +- **2026-10-30 #753, phase 3f (its `bc` and `ing` left out superseded by the 2026-11-21 #970 entry, which reads both as titles under `locales.CS`; its doctorates' `default = false` superseded by the 2026-11-06 #1115, the pack titles entry, which reads them by default, so the default reads `Jan Novák, MUDr` as the pack does; the post-nominals `DrSc` and `ArtD` read by default since decisions/suffix-acronym-collisions' 2026-11-20 #969 entry; `SL` and `HR` as choices alone with no `DEVIATES` superseded by decisions/O6's 2026-11-21 #1190 entry, which gives each rules/O6's patch, as the amended entry below gave CS and SK) — THE CZECH, SLOVAK, SLOVENIAN AND CROATIAN PACKS: `locales.CS`, `SK`, `SL` AND `HR`, ONE `Locale` PER LANGUAGE, EACH, LIKE `locales.NE`, A CHOICE OF ITS ONE TAG; `pan` AND `roz` BECOME READINGS OFF BY DEFAULT; THE DEFAULT DOES NOT MOVE.** Carries out 3f of item 11 of the 2026-10-27 #753 entry. - **One pack per language,** as the RFC's API section already had it ("each language is a pack of its own"), and for three reasons measured here: the files hold different words (sl and hr only the generations, sk `ArtD.`, cs `pan` and `roz`), so a shared pack would turn on Czech `pan` and `roz` for a Slovenian caller; the choice is a set, so a caller with data in two of them passes both (`parser_for(locales.CS, locales.SK)`); and a pack is then nothing but its tag, `Locale(code="cs", lexicon=Lexicon.empty(), languages=frozenset({"cs"}))`, auditable as its file. Each module ships no `DEVIATES`, as phase 3d's contract has it for a pack that is nothing but a choice: its deviations are `changed_words` of its choice, and the contract test now also refuses a choice pack whose choice changes no word (decisions/deviates-registry's 2026-10-30 phase 3f entry). - **The readings, all written `default = false`, so `_compiled.py` is unchanged.** 3c's generations `ml` and `st` in all four. In cs and sk, the academic titles written before the name as `academic` readings with their case masks (`mudr`, `mddr`, `mvdr`, `judr`, `phdr`, `rndr`, `paeddr`, `pharmdr`, `thdr`, `mgr`; cs also `mga` and `bca`) and the degrees written after it as `credential` readings (`drsc`; sk also `artd`): #848's open question 1, whether `Mgr.`, `MUDr.` and `PhDr.` follow `Ing.` to the suffix after a comma, is answered for the pack by Czech usage, title, since they stand before the name. `mgr` changes no compiled set, en and fr reading it as Monsignor already; under the choice its kind is `academic`. cs's and pl's `pan` exclusions become `salutation` readings, and cs's `roz` exclusion a `birth_marker` reading, each keeping its collision in its note. So `Jan Novák, MUDr` reads title `MUDr`, given `Jan` under `locales.CS` where the default reverses it (given `MUDr`, family `Jan Novák`), `Jan Novák MUDr.` reads the title at the end (rules/H5), `Jan Novák, DrSc` suffix `DrSc`, `Jana Nováková roz. Svobodová` maiden `Svobodová`, `Janez Novak st.` under `locales.SL` suffix `st.`, reported suffix-or-name, and `capitalized()` writes `MUDr.` for `mudr.`. Every reading was swept over the four comma shapes, the three orders, dotted, bare and one-case spellings and a family comma behind a `Freiherr` head; tests/v2/test_locales.py's `test_the_west_and_south_slavic_packs_read_what_the_default_refuses` pins a row of each, default and pack side by side. - **Left out, with the reason:** `bc` (bakalář) is an exclusion, measured: under a Czech choice it moved 23 of ctgov-officials' 536,981 officials, one a Czech `Bc` and the rest the US nursing credential Board Certified or initials (`Lora L. Beebe, PhD, PMHNP, BC` read title `BC`; `ACNP-BC` recased `ACNP-Bc`), and `Bc.` with its period is a title at the head by its shape anyway. `ing` stays mul.toml's ambiguous credential: an `academic` reading beside its `given` reading would be a title only inside a title phrase (rules/H9), moving nothing but `Ing` in a phrase, and its dotted spelling is a title by shape. `doc` (docent) is an English nickname (US SSA 1,391 given-name births, nam_dict band 4), recorded as no reading of any file; an `academic` reading would need that `given` reading beside it, which makes it a title only inside a title phrase (rules/H9), so it would move nothing a pack wants, and the dotted `doc.` is a title by shape already. Slovak `rod.` and `rodená`, the masculine `rozený`, the Slovene and Croatian academic abbreviations (`dr. sc.`, `mag.`, `univ. dipl. inž.`) and Slovak `pán` and `pani` are unvetted, not refused. diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index ab87c9f56..fc10f47b1 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -3537,6 +3537,26 @@ def test_no_exclusion_is_pack_shaped_any_more() -> None: ("hr", None, "Puž Kukuljan, Ana", ("", "Ana", "", "Puž Kukuljan", "", "", ()), ("", "Ana", "", "Puž Kukuljan", "", "", ())), + # each order, a suffix comma, a credential after one, and an empty + # head, where O6 stands down (the #1190 review's grid) + ("hr", "FAMILY_FIRST", "Puž Kukuljan Ana", + ("", "Kukuljan", "Ana", "Puž", "", "", ()), + ("", "Ana", "", "Puž Kukuljan", "", "", ())), + ("hr", "FAMILY_FIRST_GIVEN_LAST", "Puž Kukuljan Ana", + ("", "Ana", "Kukuljan", "Puž", "", "", ()), + ("", "Ana", "", "Puž Kukuljan", "", "", ())), + ("sl", "FAMILY_FIRST_GIVEN_LAST", "Zavadlav Ušaj Elena Marija", + ("", "Marija", "Ušaj Elena", "Zavadlav", "", "", ()), + ("", "Marija", "Elena", "Zavadlav Ušaj", "", "", ())), + ("hr", None, "Ana Puž Kukuljan, ml.", + ("ml.", "Ana", "Puž", "Kukuljan", "", "", ()), + ("", "Ana", "", "Puž Kukuljan", "ml.", "", ())), + ("sl", None, "Elena Zavadlav Ušaj, dr. med.", + ("dr. med.", "Elena", "Zavadlav", "Ušaj", "", "", ()), + ("dr. med.", "Elena", "", "Zavadlav Ušaj", "", "", ())), + ("hr", None, ", Ana Puž Kukuljan", + ("", "Ana", "Puž Kukuljan", "", "", "", ()), + ("", "Ana", "Puž Kukuljan", "", "", "", ())), # Bc and Ing, the pack's titles since #970: Bc a reading off by # default, Ing the same with the fragment removing the given reading # that would make it a title only in a phrase (rules/H9), so both From d6045ecea40e3a9b6cbb4aa4622888ca669dd5d1 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 22:36:14 -0800 Subject: [PATCH 5/5] Hold all eight O6 packs to the shared declaration; scope the PatentsView conclusion to Croatia (#1190) Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/O6-two-family-names.md | 2 +- docs/design/decisions/deviates-registry.md | 2 +- tests/v2/test_locales.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/design/decisions/O6-two-family-names.md b/docs/design/decisions/O6-two-family-names.md index bfe2b1b39..b70b536fb 100644 --- a/docs/design/decisions/O6-two-family-names.md +++ b/docs/design/decisions/O6-two-family-names.md @@ -318,6 +318,6 @@ | PSC, Slovenian | 277 | 95.31% → 95.67% | 10 | 9 | ORCID's `name` is composed from its two boxes, given first, so a two-word family box always reaches the parser as two trailing words: the ORCID gain is the boxes' own split, not a check that people write their names that way. The parliaments are the independent check, display names written by each chamber: of the Croatian Sabor's 149 members (OpenSanctions `hr_sabor`, `opensanctions-parliaments` as cached on 2026-11-21) the family is right for 140 with the switch off and 148 with it on, 9 fixed and 1 broken; of the Slovenian National Assembly's 90 (`si_dz_rs`), 84 and 89, 6 fixed and 1 broken. Every three-word name in either chamber moves, and every break is a member with two given names. Read by hand: the two chambers hold no other name of three or more words, and every two-word or hyphenated name reads the same either way. - - **Accepted:** a name with two given names reads the second as a family name (`Janez Jože Novak` gives family 'Jože Novak'), as under CS and SK; and a Russian name written given name, patronymic, surname takes the patronymic into the family. The PatentsView dip holds few of the first: read by hand, about 17 of HR's 24 broken records and 11 of SI's 37 are double surnames the filer split, the first surname in the given-names box, which the switch reads as intended; about 7 of HR's are two given names or a patronymic, and about 10 of SI's are Russian patronymics; and several people break under one filing and are fixed under another. So a Croatian or Slovenian given-name list would recover little of that dip. CLDR's fictional `hr` and `sl` renderings lose (`cldr_agreement_locales.json` re-recorded: 4 `hr` and 8 `sl` renderings move, and none agrees after). Eleven take a second word into the family, a second given name given first or the first given name family first. One is a partial gain: `sl/nativeFull/surnameFirst`, whose family held only `g.`, takes `Novak` beside it, so its `given_names` now agrees. Open: a Croatian or Slovenian given-name list, which would lift the cost as the Spanish and Portuguese lists do; none was looked for past #1190. + - **Accepted:** a name with two given names reads the second as a family name (`Janez Jože Novak` gives family 'Jože Novak'), as under CS and SK; and a Russian name written given name, patronymic, surname takes the patronymic into the family. The PatentsView dip holds few of the first: read by hand, about 17 of HR's 24 broken records and 11 of SI's 37 are double surnames the filer split, the first surname in the given-names box, which the switch reads as intended; about 7 of HR's are two given names or a patronymic, and about 10 of SI's are Russian patronymics; and several people break under one filing and are fixed under another. So a Croatian given-name list would recover little of Croatia's dip; SI's other 16 breaks were not classed, so what a Slovenian list would recover is not known. CLDR's fictional `hr` and `sl` renderings lose (`cldr_agreement_locales.json` re-recorded: 4 `hr` and 8 `sl` renderings move, and none agrees after). Eleven take a second word into the family, a second given name given first or the first given name family first. One is a partial gain: `sl/nativeFull/surnameFirst`, whose family held only `g.`, takes `Novak` beside it, so its `given_names` now agrees. Open: a Croatian or Slovenian given-name list, which would lift the cost as the Spanish and Portuguese lists do; none was looked for past #1190. - **Swept** under all three `name_order`s, comparing each pack with `CS` on the same 25 shapes (no comma, a full name, one word and nothing before a comma, a hyphenated pair, a particle, a suffix, a title, three and four words, an initial in the middle): HR, SL and CS read all 75 alike, so the two packs differ from CS by vocabulary alone. `Ana M. Kukuljan` keeps middle 'M.' given-first, and under either family-first order reads as the default does; a family comma stands O6 down. Under a strict choice of either the patch is on too, beside the choice; strict changes other readings as it does for any pack (it drops `de`'s and `la`'s particle readings, so `Juan de la Vega` reads family 'la Vega'), and O6 then counts the words those readings leave. - Recompute: the `score` command above in a checkout of the base, with `--json ` (its text prints fixed and broken only for the best column, so the PatentsView and PSC counts are read from the file), and `config_diff.py diff 'plain:HR@two_family_names=0' plain:HR --local opensanctions-parliaments --group hr_sabor --readings ` (and `SL` with `si_dz_rs`) in this tree, each moved name judged by hand. diff --git a/docs/design/decisions/deviates-registry.md b/docs/design/decisions/deviates-registry.md index 590cd513d..f63832c04 100644 --- a/docs/design/decisions/deviates-registry.md +++ b/docs/design/decisions/deviates-registry.md @@ -17,4 +17,4 @@ Open: none in this file. - 2026-11-05 #1087 — THE TWO-FAMILY-NAMES DECLARATION COUNTS BY THE SCRIPT TABLE. `_locale._letter_runs` counted a run twice when its first character's Unicode name began `CJK`, `HANGUL`, `HIRAGANA` or `KATAKANA`, a second definition of East Asian text beside `_policy._SCRIPT_RANGES`, which every script-conditional rule reads. It now asks `_script_matcher` over the table, so a run W1 can divide is one the declaration counts twice. Moved first, before the table held the conjoining jamo, the declaration would have dropped decomposed `김. 민준` (#1083's refused candidate, which measured 4 of 6,731 names moving); with HANGUL widened (decisions/nfd-shapes, same date), 3 of the 6,738 distinct corpus texts moved (measured 2026-11-05, every distinct name `tools/differential/snapshot.py` reads, the comparator the character-name test run beside the table in one script), each gaining a declaration, the safe direction: `ヤマダ タロウ`, `タナカ. John` and `タロウ·ヤマダ`, halfwidth katakana the name test did not count. None lost one. Over all of Unicode (version 14, Python 3.11), the letters the name test counted and the table does not are the compatibility jamo, the katakana phonetic extensions, and the supplementary plane's Minnan tone kana and archaic and small kana, which no rule classifies and W1 never divides, so a run of them counts once correctly; the table adds 々, 〆 and the halfwidth katakana. `test_the_two_family_names_declaration_counts_by_the_script_table` in tests/v2/test_locales.py holds the rows with both former definitions' answers as recorded controls. - 2026-11-12 #1237 — A CHOICE THAT CHANGES NO WORD, BESIDE A PATCH, IS RECORDED AS INERT. `locales.MN` chooses `mn`, whose readings are all on by default, beside a Cyrillic script order its patch carries in code (decisions/W4's 2026-11-12 #1237 entry), so its derived surface is empty. The phase 3f refusal is unchanged, since it reads only a pack that is nothing but its choice, and MN declares `DEVIATES` for its patch, which the gate reads; `test_choice_rotators_cover_every_changed_word` and `test_a_choice_word_rotator_is_moved_by_the_choice_alone` skip a pack listed in tests/v2/test_locales.py's `_INERT_CHOICES`, and `test_an_inert_choice_changes_no_word` fails the day such a choice changes a word, so the pack leaves the set and its rotators name the word. decisions/vocabulary-model's 2026-11-12 #1237 entry. - 2026-11-16 #1254 — `locales.NE` IS NO LONGER NOTHING BUT A CHOICE. The 2026-10-29 #753 phase 3b line named it the first pack the contract test refuses a `DEVIATES` on; decisions/O8's 2026-11-11 #1254 entry gave it rules/O8's `initials_as_family` from `ne.toml`'s `[rules]`, so it now declares a hand `DEVIATES` for the patch, as `CS` and `SK` do for theirs. NE has left the packs that are nothing but a choice. Found by the 3.1 release sweep. -- 2026-11-21 #1190 — `locales.HR` AND `locales.SL` ARE NO LONGER NOTHING BUT A CHOICE. Each gains rules/O6's patch from its file's `[rules]` table (decisions/O6's entry of this date), so each leaves the choice packs and declares `DEVIATES` for the patch's part as `locales.CS` and `locales.SK` do since the 2026-10-30 phase 3f amended entry: the shared `_locale.deviates_by_two_family_names`, which `test_cs_and_sk_pack_contents` now holds all five packs' declarations to. Their `ml` rotators became `Horvat ml.` and `Novak ml.`, since the three-word `Ivan Horvat ml.` and `Janez Novak ml.` are moved by the patch alone, which `test_a_choice_word_rotator_is_moved_by_the_choice_alone` refuses; each pack gains the patch's rotators, CS's and SK's shapes. +- 2026-11-21 #1190 — `locales.HR` AND `locales.SL` ARE NO LONGER NOTHING BUT A CHOICE. Each gains rules/O6's patch from its file's `[rules]` table (decisions/O6's entry of this date), so each leaves the choice packs and declares `DEVIATES` for the patch's part as `locales.CS` and `locales.SK` do since the 2026-10-30 phase 3f amended entry: the shared `_locale.deviates_by_two_family_names`, which `test_cs_and_sk_pack_contents` now holds the declarations of all eight packs turning O6 on to. Their `ml` rotators became `Horvat ml.` and `Novak ml.`, since the three-word `Ivan Horvat ml.` and `Janez Novak ml.` are moved by the patch alone, which `test_a_choice_word_rotator_is_moved_by_the_choice_alone` refuses; each pack gains the patch's rotators, CS's and SK's shapes. diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index fc10f47b1..33ffc4dbc 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -1394,7 +1394,8 @@ def test_cs_and_sk_pack_contents() -> None: # and keeps the family reading that gates mul.toml's credential from nameparser._locale import deviates_by_two_family_names from nameparser.locales import ( - cs as _cs, es as _es, hr as _hr, sk as _sk, sl as _sl) + cs as _cs, es as _es, es_ar as _es_ar, hr as _hr, pt_br as _pt_br, + pt_pt as _pt_pt, sk as _sk, sl as _sl) fragments = {"cs": Lexicon.empty().remove("ing", kind="given"), "sk": Lexicon.empty(), "hr": Lexicon.empty(), "sl": Lexicon.empty()} @@ -1404,9 +1405,8 @@ def test_cs_and_sk_pack_contents() -> None: policy=PolicyPatch(two_family_names=True), languages=frozenset({code})), code # the patch's declaration is rules/O6's, one predicate for every - # pack that turns O6 on (es_ar, pt_br and pt_pt among them, held to - # it in their own tests), so their declarations cannot drift apart - for module in (_cs, _sk, _es, _hr, _sl): + # pack that turns O6 on, so their declarations cannot drift apart + for module in (_cs, _sk, _es, _es_ar, _hr, _pt_br, _pt_pt, _sl): for name in ("Alena Pešová Řehořová", "Novák, Petr Pavel", "Mária-\u200bJana Kováčová", "Jan Novák", "Novák"): assert module.DEVIATES(name) == deviates_by_two_family_names(name)