From 347e60c53b54d94047060411ccf61bd906b08f61 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 16:00:05 -0800 Subject: [PATCH 1/6] Read Portugal's own given names behind a particle under locales.PT_PT (#1189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pt-PT.toml gains rosário (with rosario), jesus and carmo as `default = false` given readings written `after_particle` (rules/P10), so `Maria do Rosário Pinto` gives middle 'do Rosário', family 'Pinto' under locales.PT_PT, and locales.PT, locales.PT_BR and the default read it as before. Each clears P10's bar on Portugal's ORCID records (15/1, 16/1, 9/2) and none on Brazil's; conceição (10/4) is left out. decisions/P10 records the measurement and the country tier; the tests that held pt-PT.toml as a file of a [rules] table alone now plant one. Co-Authored-By: Claude Opus 5.5 --- .../P10-given-name-a-particle-completes.md | 16 +++++++++++ docs/design/decisions/vocabulary-model.md | 2 +- .../P10-given-name-a-particle-completes.md | 7 ++++- docs/locales.rst | 13 +++++++++ docs/release_log.rst | 2 +- nameparser/config/_index.py | 5 +++- nameparser/locales/pt.py | 4 ++- nameparser/locales/pt_pt.py | 13 +++++---- nameparser/vocab/pt-PT.toml | 22 +++++++++++++-- tests/v2/cases.py | 28 +++++++++++++++++++ tests/v2/test_config_diff.py | 11 +++----- tests/v2/test_locales.py | 19 ++++++++++--- tests/v2/test_reading_index.py | 25 +++++++++-------- tools/differential/config_diff.py | 4 +-- tools/differential/corpus_rules.jsonl | 3 ++ tools/differential/snapshot.jsonl | 3 ++ 16 files changed, 139 insertions(+), 38 deletions(-) diff --git a/docs/design/decisions/P10-given-name-a-particle-completes.md b/docs/design/decisions/P10-given-name-a-particle-completes.md index f4b1804c6..f5e02a70a 100644 --- a/docs/design/decisions/P10-given-name-a-particle-completes.md +++ b/docs/design/decisions/P10-given-name-a-particle-completes.md @@ -10,6 +10,7 @@ - An unaccented spelling is measured on its own and marked where its counts pass, so it may part from its accented twin: `fatima` is on by default, as `fátima` is, and `kassia` (11 fixed to 4 broken, 73%) is not marked where `kássia` is on by default. One with too few fixed and broken names to decide alone takes its twin's reading (`ceu`, `graca`, `gracas`) — 2026-11-06 #1118, #1122. - A word `es.toml` marks that passes on Portugal's, Brazil's and Portuguese-speaking Africa's names, scored under the strict Portuguese choice itself (whose particles hold no `del` or `los`), is marked in `pt.toml` too, so that choice, which compiles no `es.toml`, reads it (`fátima`, `fatima`, `socorro`, `lourdes`, `maria`); one failing or reaching too few names there is read only where `es.toml` is compiled (`rocio` 64%, `rosario` 43%, `jesús` 67%; `carmen`, `pilar`, `angeles`, written `del Carmen`, `del Pilar`, `de los Angeles`, reach one or two names under it) — 2026-11-06 #1122, decided in chat. - `valle` stays on by default though it breaks more Portuguese names than it fixes (7 fixed to 32 broken, mostly `do Valle` surnames), since it passes pooled (379 to 95, 80%): the pooled reading was chosen over requiring every language's countries to pass, which would also have taken `jesús`, `rosario` and `rocio` from the default: among Spanish-speaking countries' names the four fix 4,236 and break 113, among Portuguese-speaking countries' 47 and 52, so the stricter bar would have given up about 4,100 Spanish names for a net 5 Portuguese ones — 2026-11-06 #1122, decided in chat. +- A word passing in one country's names alone, scored under that country's pack, is marked `default = false` in the country's file, read under that country's choice and not under its language's or another country's: `rosário` (with `rosario`), `jesus` and `carmo` in `pt-PT.toml`, under `locales.PT_PT`. Nothing is marked for Brazil — 2026-11-19 #1189. Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `ca.toml` because the property moved nothing with the switch off; under this rule a `dels` particle beside `àngels` written `after_particle` reads middle 'dels Àngels', family 'Puig' by default, today's reading, so the reason no longer holds and the words want their own measurement — #1059. @@ -50,3 +51,18 @@ Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `c - **Measured** (2026-11-06, the tree against `origin/master` `b1d3d210` read with `--base`, py3.11). ORCID's capped corpus by default: 24 fixed, 6 broken, 12 changed agreeing in neither; under `--locale pt_br`: 0 fixed, 1 broken (`Karina | de Kassia Abreu`, `kassia` unmarked). PSC: 6 fixed (`Francisco | Da Graca | Geraldes`), 1 broken (`Angelita | Da Graca Brenzink`), 1 changed. `snapshot.py --local tse-donors --base` moves 1,187 of 854,531 names, in family and middle alone (`ADRIANA DAS GRACAS LIMA`, `AMANDA DE CASSIA LOPES`). The committed snapshot moves the rule's two default examples, and the `da Piedade` examples join it. - Recompute: for each word, the ORCID extract's records (`local_orcid.extract_path()`) from BR PT AO MZ CV GW ST TL, and from ES MX AR CO CL PE VE EC UY BO PY CR GT CU DO HN SV NI PA PR AD, with both boxes filled, whose `given family`, NFC lower case with edge periods and commas stripped, holds the word behind a word of `Lexicon.default()._sets.particles`; each parsed with `Lexicon.default()` and with `.remove(word, kind="given")` (for the pack words, `parser_for(locales.PT).lexicon` and its removal; for the strict readings, the Portuguese-speaking countries alone, `parser_for(locales.PT, strict=True)`, its lexicon's particles, and its lexicon with `.remove(word, kind="given")`, or `.add(word, kind="given", after_particle=True)` for a word it does not mark, each beside its policy), a parse agreeing where its given and middle joined equal the given box and its family the family box, case-folded; fixed where only the reading's parse agrees, broken where only the other's. The rows with the commands above, `--base` a `git archive` export of `b1d3d210`. - 2026-11-19 #1479 — THE FAMILY A PHRASE LEAVES IS DIVIDED AS ANY FAMILY IS. #1479 asked whether the second surname missing behind a P10 phrase (`María del Carmen García López` under `two_family_names`, surname2 '') was a defect or a decision. Neither this file nor decisions/O6 or decisions/R10 recorded a decision: the Accepted clause it rested on described how the parse got there, P2's chain `del Carmen García López` leaving O6 a family of two words that O6 took nothing into and so marked nothing in, and gave no reason to want it. A defect, then, fixed with #1456 by dividing every family by its own words (decisions/O6's 2026-11-19 #1456, #1479 entry): the family gives surname1 `García`, surname2 `López`. Measured on Spanish-speaking ORCID holders under `locales.ES`, the shape held 3,204 records whose family the parser read as the holder's family box, all but 7 (three name words behind the phrase) divided now. The clause is replaced by an example under the rule's O6 Precedence. +- 2026-11-19 #1189 — PORTUGAL'S OWN GIVEN NAMES A PARTICLE COMPLETES. #1118 and #1122 pooled the bar over every Portuguese-speaking country, so a word written as a given name in Portugal and as a surname in Brazil failed it (`conceição` 302 to 344 pooled). #1453 added `pt-PT.toml` and `locales.PT_PT`, a choice Brazil's pack does not make (`pt-BR` selects `pt-BR` and `pt`, never `pt-PT`), so a reading can be on for Portugal alone. Each word was scored as this file's 2026-11-06 #1122 bar scores one, a word at a time, under the country's pack with and without the reading. + - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 15 fixed to 1 broken (94%), `jesus` 16 to 1 (94%), `carmo` 9 to 2 (82%), each over ten names and past 75%. `rosario`, the spelling without the accent, is scored with its twin and marked with it; `es.toml` reads it already in every choice but a strict one, so its reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before). + - **Left out:** `conceição` 10 to 4 (71%), a near miss, and the bar is not bent for a word. Too few names to judge: `nazaré` 3 to 0, `assunção` 2 to 0, `luz` 2 to 0, `anjos` 1 to 0, `dores` 1 to 0; `mercês`, `belém` and `penha` move none. `ó` (Nossa Senhora do Ó) is not part of this, being an Irish particle in `ga.toml`. + - **Nothing for Brazil:** under `locales.PT_BR` on Brazil's records `jesus` scores 9 to 21, `conceição` 2 to 10, `carmo` 6 to 2 (eight names), `rosário` none. `locales.PT_BR`, `locales.PT` and the default read no name differently (`tests/v2/test_locales.py` holds that pt-PT's choice alone changes the three words). + - **`jesus` behind a particle only.** The reading is P10's, so `Jesus Costa` keeps given 'Jesus', and `Maria de Jesus` with no name word after the phrase keeps family 'de Jesus' (rules/P10's "A name word must be left for the family"); after a family comma `Costa, Maria de Jesus` read middle 'de Jesus' already. + - **Measured** (2026-11-19, master `12b568f8`, py3.11), `config_diff.py score`, at most 20,000 records a group, every box filled, fixed and broken against `locales.PT_PT`: + + | Population | `rosário` | `jesus` | `carmo` | `conceição` | the three | + |---|---:|---:|---:|---:|---:| + | ORCID Portugal (19,460) | 15 / 1 | 16 / 1 | 9 / 2 | 10 / 4 | 40 / 4 | + | PSC, Portuguese (5,333) | 0 / 0 | 7 / 2 | 4 / 0 | 6 / 1 | 11 / 2 | + | PatentsView Portugal (3,576) | 2 / 1 | 3 / 1 | 0 / 0 | 2 / 2 | 5 / 2 | + + Portugal's parliament (`config_diff.py diff --local opensanctions-parliaments --group pt_parliament`, 2,256 spellings): 3 move, each to the reading its deputy's parliamentary name keeps, the phrase in the given part. + - Recompute: `config_diff.py score plain:PT_PT --group PT --group Portuguese --cap 20000 --min 50`, `` being `expr:parser_for(Locale(code='x', lexicon=locales.PT_PT.lexicon.add(w, kind='given', after_particle=True), policy=locales.PT_PT.policy, languages=frozenset({'pt-PT'})))` for each word (both spellings for `rosário` and `conceição`), on a checkout of `12b568f8`; Brazil's the same under `locales.PT_BR`, `--group BR`. diff --git a/docs/design/decisions/vocabulary-model.md b/docs/design/decisions/vocabulary-model.md index a55b27ea1..ceeb8aac0 100644 --- a/docs/design/decisions/vocabulary-model.md +++ b/docs/design/decisions/vocabulary-model.md @@ -18,7 +18,7 @@ The vocabulary was a set of base sets plus marker subsets (`particles` and `part - Of the romanized titles a pack's phase lists, one whose native spelling is a default title turns on unless, counted in persons and pooled across every population measured, names open with it more often than it opens one as the title; a spelling outside the phase's list (`Shreemati`, `Srimati`) stays open until a phase writes it as a reading: `hi` turns on `smt`, `shrimati` and `shriyut`, `bn` `smt`, `shrimati` and `adhyapak` (`shriyut` with no bearer anywhere, `adhyapak` with family-name bearers only, every one where the title claim, acting at the head, does not reach), while `shri`, opening given names in every population measured, stays excluded, and `sushri`, an Odia given name, is a `default = false` salutation in hi.toml with the Odia name declared in or.toml, so the plain `hi` choice, made for data that holds those names, reads it as a title only inside a title phrase and a strict one as the title (decisions/indic-honorifics, 2026-11-03 #345/#870) — 2026-10-30 #753, phase 3e. - A language pack is a choice of languages on `Locale.languages` selecting which readings compile, a tag choosing its own file and its ancestors', and a reading index, loaded on its first lookup, carries the languages to run time; strict is file-strict, the chosen files, `mul.toml` and native-script words' readings only, `und.toml` not among them, so it needs no 3i; third-party language files are deferred — 2026-10-27 #753 (Derek); 2026-10-29 #753, phase 3a (Derek); 2026-10-29 #753, phase 3b; 2026-10-30 #753, file-strict; 2026-11-02 #1005 (Derek); 2026-11-07 #1148. - A strict choice is `parser_for(..., strict=True)` over the whole choice, filtering the base's readings as a plain choice does, the caller's own edits applying after it, and a chained call keeping its base's strictness unless it passes `strict`, an explicit `False` on a strict base raising and an explicit `True` making a plain base's choice strict; a strict call whose packs choose no language raises; a strict choice accepts a tag whose file holds no reading, which a plain one refuses as changing nothing; a bare choice has no constructor, no `locales.choose`; and the words strict ungates are derived against the plain choice of the same tags and held to a reviewed set by a test — 2026-10-31 #753, phase 3j; 2026-11-02 #754, sub-phase 4i-c. -- A choice is matched without regard to case, a tag whose file does not exist selects its ancestors' (`pt-AO` selects `pt`; `pt-PT`, whose file holds a `[rules]` table and no reading, selects `pt` the same way, decisions/O6 2026-11-19), `mul` and `und` are no language to choose, and a vocabulary reading turned on also prefers (a name reading never does, decision 15), so `de`'s generation `i` drops `ca`'s and `pl`'s conjunction under a `de` choice; the `Lexicon` records its choice, so that a choice chained through `base=` unions with the base's, and a caller's own edits apply after the choice, plain or strict, in the order written, a pack's fragment joining before the caller's lexicon — 2026-10-29 #753, phase 3b; 2026-11-02 #754, the `Lexicon` surface (Derek); 2026-11-02 #754, sub-phase 4i-c. +- A choice is matched without regard to case, a tag whose file does not exist selects its ancestors' (`pt-AO` selects `pt`; a region's file holding a `[rules]` table and no reading selects its language's the same way, as `pt-PT.toml` did from decisions/O6's 2026-11-19 entry until #1189 gave it readings), `mul` and `und` are no language to choose, and a vocabulary reading turned on also prefers (a name reading never does, decision 15), so `de`'s generation `i` drops `ca`'s and `pl`'s conjunction under a `de` choice; the `Lexicon` records its choice, so that a choice chained through `base=` unions with the base's, and a caller's own edits apply after the choice, plain or strict, in the order written, a pack's fragment joining before the caller's lexicon — 2026-10-29 #753, phase 3b; 2026-11-02 #754, the `Lexicon` surface (Derek); 2026-11-02 #754, sub-phase 4i-c. - A reading right in its own language and wrong only as a default, because another language written in the same script collides with it, is written `default = false` in its file, never excluded, so that after the packs an exclusion means wrong everywhere: cs `st` since phase 2h, and cs `ml`, hr, sk and sl `ml` and `st` since 3c (fr `père`, converted with them, is read by default since 2026-11-03, a collision inside French), the rest in their packs' PRs — 2026-10-27 #753 (Derek); 2026-10-29 #753, phase 3c. - A name reading written `default = false` derives no marker in the default and counts for no check guarding the default's compile; a particle whose word's only `given` readings are off is refused until a pack needs one — 2026-10-29 #753, phase 3a. - A caller configures vocabulary by reading, `Lexicon` deriving the sets and gates the build derives, and the compiled sets become internal in 3.0 — 2026-10-28 #754, the `Lexicon` surface (Derek). diff --git a/docs/design/rules/P10-given-name-a-particle-completes.md b/docs/design/rules/P10-given-name-a-particle-completes.md index 323bb4c2a..ec64303b7 100644 --- a/docs/design/rules/P10-given-name-a-particle-completes.md +++ b/docs/design/rules/P10-given-name-a-particle-completes.md @@ -19,12 +19,17 @@ "Maria do Carmo Silva" → family="do Carmo Silva" · boundary "João da Silva Santos" → family="da Silva Santos" · boundary ``` -- **A word whose evidence falls short of the default's is marked for its language alone**, read where the caller chooses that language and left to the surname otherwise: Portuguese da Piedade. +- **A word whose evidence falls short of the default's is marked for its language alone**, read where the caller chooses that language and left to the surname otherwise: Portuguese da Piedade. One that passes in a single country's names is marked for that country alone: Portugal's do Rosário, de Jesus and do Carmo, which Brazil's names do not support (de Jesus there is mostly a surname). ``` "Maria da Piedade Costa" [pt] → middle="da Piedade" "MARIA DA PIEDADE COSTA" [pt_br] → family="COSTA" "Maria da Piedade Costa" → family="da Piedade Costa" · boundary "Maria da Piedade Costa" [es] → family="da Piedade Costa" · boundary + "Maria do Rosário Pinto" [pt_pt] → middle="do Rosário" + "Teresa de Jesus Sousa Pinto" [pt_pt] → family="Sousa Pinto" + "Maria do Carmo Silva" [pt_pt] → middle="do Carmo" + "Maria de Jesus Pinto" [pt_br] → family="de Jesus Pinto" · boundary + "Maria do Rosário Pinto" [pt] → family="do Rosário Pinto" · boundary ``` - **A title, a suffix and a nickname are no name words**, so they stand outside the reading. ``` diff --git a/docs/locales.rst b/docs/locales.rst index 2001ae4f1..3dce0e61c 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -675,6 +675,19 @@ does by default (see :ref:`two-given-names`): >>> piedade.middle, piedade.family ('da Piedade', 'Costa') +``pt_pt`` also reads three such phrases that Portugal's names support +and Brazil's do not, ``do Rosário``, ``de Jesus`` and ``do Carmo``: +in Brazil ``de Jesus`` behind a first name is mostly a surname, so +``pt`` and ``pt_br`` read each as the start of the family: + +.. doctest:: + + >>> parser_for(locales.PT_BR).parse("Maria do Rosário Pinto").family + 'do Rosário Pinto' + >>> rosario = parser_for(locales.PT_PT).parse("Maria do Rosário Pinto") + >>> rosario.middle, rosario.family + ('do Rosário', 'Pinto') + ``pt_br`` also turns on ``SB``. Brazilian filings abbreviate the agnomen *Sobrinho* (nephew) to ``SB``, which is also the S.B. degree, so the default does not read it. Under the pack it is a suffix only diff --git a/docs/release_log.rst b/docs/release_log.rst index 3fec6bcaf..a238e31b8 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -15,7 +15,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.PT_BR to read two family names, and add locales.PT_PT, which reads names from Portugal the same way.** ``parser_for(locales.PT_BR).parse("Ana Souza Lima")`` gives family ``Souza Lima``, where 3.0.0 through 3.1.0 gave middle ``Souza``, family ``Lima``; a second given name on the packs' Portuguese given-name list stays where it stands (``Ana Beatriz Costa`` keeps family ``Costa``), and ``locales.PT``, chosen for Portuguese names from any country, is unchanged. :issue:`1453` + - **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 three given names Portugal writes behind a particle and Brazil does not (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``de Jesus`` and ``do Carmo`` do). :issue:`1453`, :issue:`1189` - **Change locales.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` * 3.1.0 - November 16, 2026 diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 9d227bffc..cca660271 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -419,6 +419,7 @@ ('caridad', (('es', 'given', (('after_particle', True),)),)), ('carly', (('en', 'familiar', (('short_for', ('carolyn',)),)),)), ('carmen', (('es', 'given', (('after_particle', True),)),)), + ('carmo', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), ('caro', (('en', 'credential', ()), ('en', 'given', ()), ('en', 'family', ()), ('mul', 'familiar', (('short_for', ('caroline',)),)))), ('carol', (('en', 'familiar', (('short_for', ('caroline',)),)), ('pt-BR', 'familiar', (('short_for', ('caroline',)),)))), ('carrie', (('en', 'familiar', (('short_for', ('caroline', 'carolyn')),)),)), @@ -1394,6 +1395,7 @@ ('jess', (('en', 'familiar', (('short_for', ('jessica',)),)),)), ('jessi', (('en', 'familiar', (('short_for', ('jessica',)),)),)), ('jessie', (('en', 'familiar', (('short_for', ('jessica',)),)),)), + ('jesus', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), ('jesús', (('es', 'given', (('after_particle', True),)),)), ('jez', (('en', 'familiar', (('short_for', ('jeremy',)),)),)), ('jill', (('en', 'familiar', (('short_for', ('jillian',)),)),)), @@ -2396,9 +2398,10 @@ ('roddy', (('en', 'familiar', (('short_for', ('roderick',)),)),)), ('ron', (('en', 'familiar', (('short_for', ('ronald',)),)),)), ('ros', (('en', 'familiar', (('short_for', ('rosalind', 'roslyn')),)),)), - ('rosario', (('es', 'given', (('after_particle', True),)),)), + ('rosario', (('es', 'given', (('after_particle', True),)), ('pt-PT', 'given', (('after_particle', True), ('default', False))))), ('rose', (('en', 'familiar', (('short_for', ('rosemary',)),)), ('mul', 'familiar', (('short_for', ('rosie',)),)), ('pt-BR', 'familiar', (('short_for', ('rosemary',)),)))), ('rosie', (('en', 'familiar', (('short_for', ('rosalie', 'rosalind', 'rosanna', 'rosemary')),)),)), + ('rosário', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), ('rouva', (('fi', 'salutation', (('after_given', True),)),)), ('royal', (('en', 'modifier', (('addresses', 'given'),)), ('en', 'given', ()), ('en', 'family', ()))), ('roz', (('cs', 'birth_marker', (('default', False),)), ('en', 'familiar', (('short_for', ('rosalind',)),)))), diff --git a/nameparser/locales/pt.py b/nameparser/locales/pt.py index ef7ac334d..00ce89d64 100644 --- a/nameparser/locales/pt.py +++ b/nameparser/locales/pt.py @@ -11,7 +11,9 @@ ``Professora``) are read by default since #1115. locales.PT_BR and locales.PT_PT choose ``pt-BR`` and ``pt-PT``, which select ``pt`` too, so they read all of these the same way; each also reads two -family names, which this pack does not (decisions/O6, 2026-11-19). +family names, which this pack does not (decisions/O6, 2026-11-19), and +locales.PT_PT reads Portugal's own given names behind a particle +(pt-PT.toml, ``do Rosário``, #1189), which this pack does not. Data sources: the counts are on the readings in pt.toml (tools/name_usage.py and the local corpora). The pack carries no diff --git a/nameparser/locales/pt_pt.py b/nameparser/locales/pt_pt.py index 6bae6f7ba..c3c3587ae 100644 --- a/nameparser/locales/pt_pt.py +++ b/nameparser/locales/pt_pt.py @@ -1,10 +1,13 @@ """The European Portuguese locale pack: locales.PT for names from Portugal, with two family names. It chooses ``pt-PT``, which selects -its ancestor pt.toml (nameparser/vocab/pt-PT.toml holds only the -[rules] table ``rules_patch`` reads, and no reading for a choice to -select), so it reads every word locales.PT reads -(``do`` a particle, ``da Piedade`` the second half of a compound given -name); it reads two family names (``Policy.two_family_names``, +nameparser/vocab/pt-PT.toml and its ancestor pt.toml, so it reads every +word locales.PT reads (``do`` a particle, ``da Piedade`` the second half +of a compound given name) and Portugal's own: pt-PT.toml's +``default = false`` readings, the second halves of compound given names +written behind a particle that Portugal's names support and Brazil's do +not (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``de +Jesus`` and ``do Carmo`` do; rules/P10, decisions/P10 2026-11-19, +#1189); it reads two family names (``Policy.two_family_names``, rules/O6), its policy patch compiled from pt-PT.toml's [rules] table by tools/vocab/build.py: ``Rui Sousa Pinto`` gives family ``Sousa Pinto``, where locales.PT gives middle ``Sousa``; and it carries diff --git a/nameparser/vocab/pt-PT.toml b/nameparser/vocab/pt-PT.toml index a89f0b648..8269f09e9 100644 --- a/nameparser/vocab/pt-PT.toml +++ b/nameparser/vocab/pt-PT.toml @@ -2,8 +2,24 @@ schema = 1 # European Portuguese: locales.PT_PT reads its names with two family names # (rules/O6), its given-name list keeping a given name out of the family. -# The file holds no word: a reading Portugal writes and Brazil does not -# has not been needed, and pt.toml holds the language's (decisions/O6, the -# 2026-11-19 entry) +# The words are the readings Portugal writes and Brazil does not, each +# `default = false`, so only a choice of pt-PT turns it on; pt.toml holds +# the language's (decisions/O6 and decisions/P10, the 2026-11-19 entries) [rules] two_family_names = true + +[[word]] +text = "carmo" +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria do Carmo), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 11 names of Portugal's ORCID holders, 9 to the boxes they filled and 2 away from them, 82%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 6 to the boxes and 2 away, too few to judge (decisions/P10) (2026-11-19, #1189)" } + +[[word]] +text = "jesus" +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria de Jesus), on for Portugal alone, behind a first name a given name there and mostly a surname in Brazil: marked as P10's words are, under locales.PT_PT it moves 17 names of Portugal's ORCID holders, 16 to the boxes they filled and 1 away from them, 94%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 9 to the boxes and 21 away (decisions/P10) (2026-11-19, #1189)" } + +[[word]] +text = "rosario" +given = { default = false, after_particle = true, note = "the spelling of rosário without its accent, scored with it (Maria do Rosario): es.toml reads it so already in every choice but a strict one, so this reading keeps it under a strict Portuguese choice of Portugal, which compiles no es.toml (decisions/P10) (2026-11-19, #1189)" } + +[[word]] +text = "rosário" +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria do Rosário), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 16 names of Portugal's ORCID holders, 15 to the boxes they filled and 1 away from them, 94%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves none (decisions/P10) (2026-11-19, #1189)" } diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 2a285d873..e36b1fc2c 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -18071,6 +18071,34 @@ def _check_cjk_shape_purity(self) -> None: "first as a middle name, a gap #1453 leaves for #1482; " "read middle 'Mirandela Gomes', family 'Paz' 3.0.0 " "through 3.1"), + Case("portuguese_rosario_given_name_under_pt_pt", "Maria do Rosário Pinto", + {"given": "Maria", "middle": "do Rosário", "family": "Pinto"}, + locale="pt_pt", classification="feat(#1189)", + notes="P10: pt-PT.toml's rosário, on for Portugal's choice alone; " + "locales.PT_PT is new in 3.2"), + Case("portuguese_jesus_given_name_under_pt_pt", "Teresa de Jesus Sousa Pinto", + {"given": "Teresa", "middle": "de Jesus", "family": "Sousa Pinto"}, + locale="pt_pt", classification="feat(#1189)", + notes="P10: pt-PT.toml's jesus, then O6 reads the two family names " + "after it"), + Case("portuguese_carmo_given_name_under_pt_pt", "MARIA DO CARMO PINTO", + {"given": "MARIA", "middle": "DO CARMO", "family": "PINTO"}, + locale="pt_pt", classification="feat(#1189)", + notes="P10: pt-PT.toml's carmo, written in capitals"), + Case("portuguese_jesus_with_no_name_after_under_pt_pt", "Maria de Jesus", + {"given": "Maria", "family": "de Jesus"}, + locale="pt_pt", classification="parity", + notes="P10 completes a given name only with a name word after it, " + "so 'de Jesus' ending the name is the family (#1189)"), + Case("portuguese_jesus_family_under_pt_br", "Maria de Jesus Pinto", + {"given": "Maria", "family": "de Jesus Pinto"}, + locale="pt_br", classification="parity", + notes="pt-PT.toml's reading is off for Brazil's choice, where " + "'de Jesus' behind a first name is mostly a surname (#1189)"), + Case("portuguese_rosario_family_under_pt", "Maria do Rosário Pinto", + {"given": "Maria", "family": "do Rosário Pinto"}, + locale="pt", classification="parity", + notes="pt-PT.toml's reading is off for the language's pack (#1189)"), Case("given_name_title_marquis_at_the_head", "Marquis Johnson", {"given": "Marquis", "family": "Johnson"}, classification="fix(#913)", diff --git a/tests/v2/test_config_diff.py b/tests/v2/test_config_diff.py index 0f9c6df59..b73e3e235 100644 --- a/tests/v2/test_config_diff.py +++ b/tests/v2/test_config_diff.py @@ -319,15 +319,14 @@ def test_every_shipped_pack_rides_on_some_tag() -> None: from nameparser._reading_index import selected reached = {item.lower() for tag in cd.choosable() for spec in cd.gap_specs(tag) for item in spec.partition(":")[2].split("+") if item.isupper()} - # a pack choosing a region tag no file holds (es_ar's es-AR), or one - # whose file holds no reading (pt_pt's pt-PT, a [rules] table alone), - # selects its language's files and nothing more, so the strict gap - # the report measures for the pack choosing those files is its own + # a pack choosing a region tag no file holds (es_ar's es-AR) selects + # its language's files and nothing more, so the strict gap the report + # measures for the pack choosing those files is its own files = {code: selected(locales.get(code).languages) for code in locales.available() if locales.get(code).languages} same_files = {code for code, f in files.items() if any(f == files.get(other) for other in reached - {code})} - assert same_files == {"es_ar", "pt", "pt_pt"} + assert same_files == {"es_ar"} assert set(locales.available()) <= reached | same_files @@ -335,8 +334,6 @@ def test_a_pack_choosing_no_language_is_stacked_with_its_tag() -> None: assert cd.gap_specs("zh") == ("plain:ZH+zh", "strict:ZH+zh") assert cd.gap_specs("tr") == ("plain:TR_AZ+tr", "strict:TR_AZ+tr") assert cd.gap_specs("pt-BR") == ("plain:PT_BR", "strict:PT_BR") - # pt-PT.toml holds a [rules] table and no reading: a plain choice of - # the tag selects pt.toml, so its plain side is the pack, not the default assert cd.gap_specs("pt-PT") == ("plain:PT_PT", "strict:PT_PT") assert cd.gap_specs("vi") == ("plain:VI", "strict:VI") # hu.toml holds no reading a parse reads, only exclusions, so the diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 9c61c6ab8..f1b076822 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -2503,7 +2503,15 @@ def test_a_choice_word_rotator_is_moved_by_the_choice_alone(code: str) -> None: "ANA SILVA E SOUZA", # e, pt's connective *_PT_TWO_FAMILY_NAMES, ] -_ROTATORS["pt_pt"] = [*_ROTATORS["pt"], *_PT_TWO_FAMILY_NAMES] +_ROTATORS["pt_pt"] = [ + *_ROTATORS["pt"], + # Portugal's own given names P10 completes, which pt_br's and pt's + # choices leave to the family (#1189) + "Maria do Carmo Costa", # carmo + "Maria de Jesus Costa", # jesus + "Maria do Rosário Costa", # rosário + *_PT_TWO_FAMILY_NAMES, +] # #1115 turned these titles on by default, so no choice moves them: the @@ -3719,10 +3727,13 @@ def test_the_portuguese_country_packs_read_two_family_names_and_pt_does_not() -> languages=frozenset({tag}))) assert not bare.policy.two_family_names, tag assert not parser_for(locales.PT).policy.two_family_names - # pt-PT.toml holds no word, so pt_pt's choice selects pt's file alone - assert selected(locales.PT_PT.languages) == {"pt"} + # pt-PT.toml holds Portugal's own readings (#1189), which pt_pt's + # choice turns on beside pt's and pt_br's does not + assert selected(locales.PT_PT.languages) == {"pt-PT", "pt"} assert (changed_words(selected(locales.PT_PT.languages)) - == changed_words(selected(locales.PT.languages))) + - changed_words(selected(locales.PT.languages)) + == {"carmo", "jesus", "rosário"}) + assert "pt-PT" not in selected(locales.PT_BR.languages) pt, br, pp = (_require_packed(c) for c in ("pt", "pt_br", "pt_pt")) assert pt.parse("Rui Sousa Pinto").family == "Pinto" assert pt.parse("Pedro Sousa Alves Filho").family == "Alves" diff --git a/tests/v2/test_reading_index.py b/tests/v2/test_reading_index.py index 8a78c0653..54b347d94 100644 --- a/tests/v2/test_reading_index.py +++ b/tests/v2/test_reading_index.py @@ -187,8 +187,9 @@ def test_a_tag_selects_its_own_file_and_its_ancestors_never_its_descendants() -> assert ri.selected(["pt-br"]) == {"pt-BR", "pt"} # a region no file holds selects what its language's file holds assert ri.selected(["pt-AO"]) == {"pt"} - # nor does one whose file holds a [rules] table and no reading - assert ri.selected(["pt-PT"]) == {"pt"} + # a region whose file holds readings selects it beside its language's + # (pt-PT.toml, Portugal's own readings since #1189) + assert ri.selected(["pt-PT"]) == {"pt-PT", "pt"} # no macrolanguage table: Malay does not select Indonesian assert ri.selected(["ms"]) == {"ms"} assert ri.selected([]) == frozenset() @@ -330,19 +331,19 @@ def test_a_strict_pool_holds_the_chosen_files_mul_and_native_script_only() -> No assert native and all(r in pool for r in native) -def test_a_file_holding_no_reading_is_chosen_only_strictly() -> None: +def test_a_file_holding_no_reading_is_chosen_only_strictly( + monkeypatch: pytest.MonkeyPatch) -> None: empty = ri.files() - ri.tags() assert empty and ri.tags() <= ri.files() - # a region's file holding only a [rules] table (pt-PT.toml, #1453) - # is chosen plainly through its language's file, which holds readings, - # and strictly with it + # no shipped region's file holds a [rules] table and no reading since + # pt-PT.toml took Portugal's own readings (#1189), so one is planted regions = {tag for tag in empty if tag.split("-")[0] in ri.tags()} - assert regions == {"pt-PT"} - for tag in sorted(regions): - language = tag.split("-")[0] - assert ri.selected([tag]) == ri.selected([language]) - assert ri.selected([tag], strict=True) == {tag} | ri.selected([language], strict=True) - assert not any(r.tag == tag for r in ri.index()) + assert regions == set() + monkeypatch.setattr(ri, "files", lambda: frozenset(ri.tags() | empty | {"pt-AO"})) + # such a file is chosen plainly through its language's file, which + # holds readings, and strictly with it + assert ri.selected(["pt-AO"]) == ri.selected(["pt"]) + assert ri.selected(["pt-AO"], strict=True) == {"pt-AO"} | ri.selected(["pt"], strict=True) for tag in sorted(empty - regions): with pytest.raises(ValueError, match=f"{tag}.toml holds no reading a parse reads"): diff --git a/tools/differential/config_diff.py b/tools/differential/config_diff.py index 94f91b82c..b68e99cc9 100644 --- a/tools/differential/config_diff.py +++ b/tools/differential/config_diff.py @@ -744,8 +744,8 @@ def gap_specs(tag: str) -> tuple[str, str]: it stacked with the bare tag (a strict call needs a language), or else the bare tag. A file holding no reading is refused as a plain choice (it would change nothing), so its plain side is the default, - unless its language's file holds readings (pt-PT.toml, a [rules] - table alone), which a plain choice of the tag selects.""" + unless its language's file holds readings (a region's file holding a + [rules] table alone), which a plain choice of the tag selects.""" from nameparser import _reading_index, locales packs = [locales.get(c) for c in sorted(locales.available())] items = [p.code.upper() for p in packs if tag in p.languages] diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index a0558b9fe..10c65ffbc 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -1274,9 +1274,11 @@ "Maria da Silva Santos" "Maria das Graças Silva" "Maria de Fatima Costa" +"Maria de Jesus Pinto" "Maria de Lurdes Costa" "Maria do Carmo Silva" "Maria do Carmo da Silva" +"Maria do Rosário Pinto" "Maria do Socorro Silva" "Mariam binti MD Salleh" "Mariam binti Md Salleh" @@ -1743,6 +1745,7 @@ "TER PETROSYAN, LEVON" "THE ROCK Mary" "Tariq Abdul Aziz" +"Teresa de Jesus Sousa Pinto" "The Hon. Justice Mary Smith" "The Hon. Wing Lau" "The Mahdi Muhammad Ahmad" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 1dec71db5..f10c9b8e9 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -3084,9 +3084,11 @@ {"name": "Maria da Silva Santos", "given": "Maria", "family": "da Silva Santos", "initials": "M. S. S."} {"name": "Maria das Graças Silva", "given": "Maria", "middle": "das Graças", "family": "Silva", "initials": "M. G. S."} {"name": "Maria de Fatima Costa", "given": "Maria", "middle": "de Fatima", "family": "Costa", "initials": "M. F. C."} +{"name": "Maria de Jesus Pinto", "given": "Maria", "family": "de Jesus Pinto", "initials": "M. J. P."} {"name": "Maria de Lurdes Costa", "given": "Maria", "middle": "de Lurdes", "family": "Costa", "initials": "M. L. C."} {"name": "Maria do Carmo Silva", "given": "Maria", "family": "do Carmo Silva", "initials": "M. C. S."} {"name": "Maria do Carmo da Silva", "given": "Maria", "middle": "do Carmo", "family": "da Silva", "initials": "M. C. S."} +{"name": "Maria do Rosário Pinto", "given": "Maria", "family": "do Rosário Pinto", "initials": "M. R. P."} {"name": "Maria do Socorro Silva", "given": "Maria", "middle": "do Socorro", "family": "Silva", "initials": "M. S. S."} {"name": "Mariam Geedi Hamish Hussein", "given": "Mariam", "middle": "Geedi Hamish", "family": "Hussein", "initials": "M. G. H. H."} {"name": "Mariam binti MD Salleh", "given": "Mariam", "family": "binti", "suffix": "MD Salleh", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as family (position)"], "initials": "M. b.", "capitalized_force": "Mariam Binti MD Salleh"} @@ -4332,6 +4334,7 @@ {"name": "Teitur Þórðarson", "given": "Teitur", "family": "Þórðarson", "initials": "T. Þ."} {"name": "Teodoro de Faria", "given": "Teodoro", "family": "de Faria", "initials": "T. F."} {"name": "Teresa Mañé i Miravet", "given": "Teresa", "family": "Mañé i Miravet", "initials": "T. M. M."} +{"name": "Teresa de Jesus Sousa Pinto", "given": "Teresa", "family": "de Jesus Sousa Pinto", "initials": "T. J. S. P."} {"name": "Tewolde Berhan Gebre Egziabher", "given": "Tewolde", "middle": "Berhan Gebre", "family": "Egziabher", "initials": "T. B. G. E."} {"name": "Teógenes Díaz-Corralejo Fernández", "given": "Teógenes", "middle": "Díaz-Corralejo", "family": "Fernández", "initials": "T. D. F."} {"name": "Tham Jun", "given": "Tham", "family": "Jun", "initials": "T. J."} From 4ea0669c7baacfcf9524084751647c384b753c0e Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 16:07:07 -0800 Subject: [PATCH 2/6] Correct the #1189 prose the reviews found stale or wrong, and test the strict choice es.toml's rosario is read under a strict choice of es too, so the note says where it is not; prose that still said pt-PT.toml holds no word (AGENTS.md, the vocab README, decisions/O6's Standing line) and the user docs listing which phrases are marked (policy.rst, locales.rst) name the new readings; decisions/P10 names the capped population the words were scored on. A test holds the strict choices of PT_PT, PT_BR and PT, and two rows hold one word after de Jesus and a suffix comma. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- docs/design/decisions/O6-two-family-names.md | 2 +- .../P10-given-name-a-particle-completes.md | 6 +++--- .../P10-given-name-a-particle-completes.md | 2 +- docs/locales.rst | 18 +++++++++++------- docs/policy.rst | 5 ++++- nameparser/locales/pt.py | 4 +++- nameparser/locales/pt_pt.py | 5 +++-- nameparser/vocab/README.md | 4 ++-- nameparser/vocab/pt-PT.toml | 10 ++++++---- tests/v2/cases.py | 14 ++++++++++++-- tests/v2/test_locales.py | 9 +++++++++ tests/v2/test_reading_index.py | 4 ++-- tools/differential/config_diff.py | 4 +++- 14 files changed, 61 insertions(+), 28 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 232994bbb..22cb0b70f 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` holding nothing else (decisions/O6, 2026-11-19, #1453). 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 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. diff --git a/docs/design/decisions/O6-two-family-names.md b/docs/design/decisions/O6-two-family-names.md index fab39bae8..3b7dc5316 100644 --- a/docs/design/decisions/O6-two-family-names.md +++ b/docs/design/decisions/O6-two-family-names.md @@ -4,7 +4,7 @@ - Two family names are an opt-in `Policy` switch, `two_family_names`, off by default: the convention is Spain's and most of Latin America's but not Argentina's, and given-first it is the same string shape as a name with a middle name, so no default can read it — 2026-10-24 #754. - `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 nothing but its table) writing the `[rules]` table `pt.toml` does not, and both carry one Portuguese given-name list — 2026-11-19 #1453. +- `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. - 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. diff --git a/docs/design/decisions/P10-given-name-a-particle-completes.md b/docs/design/decisions/P10-given-name-a-particle-completes.md index f5e02a70a..1c8da71b7 100644 --- a/docs/design/decisions/P10-given-name-a-particle-completes.md +++ b/docs/design/decisions/P10-given-name-a-particle-completes.md @@ -10,7 +10,7 @@ - An unaccented spelling is measured on its own and marked where its counts pass, so it may part from its accented twin: `fatima` is on by default, as `fátima` is, and `kassia` (11 fixed to 4 broken, 73%) is not marked where `kássia` is on by default. One with too few fixed and broken names to decide alone takes its twin's reading (`ceu`, `graca`, `gracas`) — 2026-11-06 #1118, #1122. - A word `es.toml` marks that passes on Portugal's, Brazil's and Portuguese-speaking Africa's names, scored under the strict Portuguese choice itself (whose particles hold no `del` or `los`), is marked in `pt.toml` too, so that choice, which compiles no `es.toml`, reads it (`fátima`, `fatima`, `socorro`, `lourdes`, `maria`); one failing or reaching too few names there is read only where `es.toml` is compiled (`rocio` 64%, `rosario` 43%, `jesús` 67%; `carmen`, `pilar`, `angeles`, written `del Carmen`, `del Pilar`, `de los Angeles`, reach one or two names under it) — 2026-11-06 #1122, decided in chat. - `valle` stays on by default though it breaks more Portuguese names than it fixes (7 fixed to 32 broken, mostly `do Valle` surnames), since it passes pooled (379 to 95, 80%): the pooled reading was chosen over requiring every language's countries to pass, which would also have taken `jesús`, `rosario` and `rocio` from the default: among Spanish-speaking countries' names the four fix 4,236 and break 113, among Portuguese-speaking countries' 47 and 52, so the stricter bar would have given up about 4,100 Spanish names for a net 5 Portuguese ones — 2026-11-06 #1122, decided in chat. -- A word passing in one country's names alone, scored under that country's pack, is marked `default = false` in the country's file, read under that country's choice and not under its language's or another country's: `rosário` (with `rosario`), `jesus` and `carmo` in `pt-PT.toml`, under `locales.PT_PT`. Nothing is marked for Brazil — 2026-11-19 #1189. +- A word passing in one country's names alone, scored under that country's pack over ORCID's capped corpus, is marked `default = false` in the country's file, read under that country's choice and not under its language's or another country's: `rosário` (with `rosario`), `jesus` and `carmo` in `pt-PT.toml`, under `locales.PT_PT`. Nothing is marked for Brazil — 2026-11-19 #1189. Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `ca.toml` because the property moved nothing with the switch off; under this rule a `dels` particle beside `àngels` written `after_particle` reads middle 'dels Àngels', family 'Puig' by default, today's reading, so the reason no longer holds and the words want their own measurement — #1059. @@ -51,8 +51,8 @@ Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `c - **Measured** (2026-11-06, the tree against `origin/master` `b1d3d210` read with `--base`, py3.11). ORCID's capped corpus by default: 24 fixed, 6 broken, 12 changed agreeing in neither; under `--locale pt_br`: 0 fixed, 1 broken (`Karina | de Kassia Abreu`, `kassia` unmarked). PSC: 6 fixed (`Francisco | Da Graca | Geraldes`), 1 broken (`Angelita | Da Graca Brenzink`), 1 changed. `snapshot.py --local tse-donors --base` moves 1,187 of 854,531 names, in family and middle alone (`ADRIANA DAS GRACAS LIMA`, `AMANDA DE CASSIA LOPES`). The committed snapshot moves the rule's two default examples, and the `da Piedade` examples join it. - Recompute: for each word, the ORCID extract's records (`local_orcid.extract_path()`) from BR PT AO MZ CV GW ST TL, and from ES MX AR CO CL PE VE EC UY BO PY CR GT CU DO HN SV NI PA PR AD, with both boxes filled, whose `given family`, NFC lower case with edge periods and commas stripped, holds the word behind a word of `Lexicon.default()._sets.particles`; each parsed with `Lexicon.default()` and with `.remove(word, kind="given")` (for the pack words, `parser_for(locales.PT).lexicon` and its removal; for the strict readings, the Portuguese-speaking countries alone, `parser_for(locales.PT, strict=True)`, its lexicon's particles, and its lexicon with `.remove(word, kind="given")`, or `.add(word, kind="given", after_particle=True)` for a word it does not mark, each beside its policy), a parse agreeing where its given and middle joined equal the given box and its family the family box, case-folded; fixed where only the reading's parse agrees, broken where only the other's. The rows with the commands above, `--base` a `git archive` export of `b1d3d210`. - 2026-11-19 #1479 — THE FAMILY A PHRASE LEAVES IS DIVIDED AS ANY FAMILY IS. #1479 asked whether the second surname missing behind a P10 phrase (`María del Carmen García López` under `two_family_names`, surname2 '') was a defect or a decision. Neither this file nor decisions/O6 or decisions/R10 recorded a decision: the Accepted clause it rested on described how the parse got there, P2's chain `del Carmen García López` leaving O6 a family of two words that O6 took nothing into and so marked nothing in, and gave no reason to want it. A defect, then, fixed with #1456 by dividing every family by its own words (decisions/O6's 2026-11-19 #1456, #1479 entry): the family gives surname1 `García`, surname2 `López`. Measured on Spanish-speaking ORCID holders under `locales.ES`, the shape held 3,204 records whose family the parser read as the holder's family box, all but 7 (three name words behind the phrase) divided now. The clause is replaced by an example under the rule's O6 Precedence. -- 2026-11-19 #1189 — PORTUGAL'S OWN GIVEN NAMES A PARTICLE COMPLETES. #1118 and #1122 pooled the bar over every Portuguese-speaking country, so a word written as a given name in Portugal and as a surname in Brazil failed it (`conceição` 302 to 344 pooled). #1453 added `pt-PT.toml` and `locales.PT_PT`, a choice Brazil's pack does not make (`pt-BR` selects `pt-BR` and `pt`, never `pt-PT`), so a reading can be on for Portugal alone. Each word was scored as this file's 2026-11-06 #1122 bar scores one, a word at a time, under the country's pack with and without the reading. - - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 15 fixed to 1 broken (94%), `jesus` 16 to 1 (94%), `carmo` 9 to 2 (82%), each over ten names and past 75%. `rosario`, the spelling without the accent, is scored with its twin and marked with it; `es.toml` reads it already in every choice but a strict one, so its reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before). +- 2026-11-19 #1189 — PORTUGAL'S OWN GIVEN NAMES A PARTICLE COMPLETES. #1118 and #1122 pooled the bar over every Portuguese-speaking country, so a word written as a given name in Portugal and as a surname in Brazil failed it (`conceição` 302 to 344 pooled). #1453 added `pt-PT.toml` and `locales.PT_PT`, a choice Brazil's pack does not make (`pt-BR` selects `pt-BR` and `pt`, never `pt-PT`), so a reading can be on for Portugal alone. Each word was scored by #1122's bar (75% of the names it moves fixed, ten names or more), a word at a time, under the country's pack with and without the reading, over ORCID's capped corpus (`raw.jsonl`, at most 20,000 records a country), not the whole extract the Standing bar names: a country tier is scored on that country's records, and Portugal's capped records are all of its 19,460 scored ones (19,465 in the issue's count, five set aside by `local_agreement.read`). + - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 15 fixed to 1 broken (94%), `jesus` 16 to 1 (94%), `carmo` 9 to 2 (82%), each over ten names and past 75%. `rosario`, the spelling without the accent, is scored with its twin and marked with it; `es.toml`'s reading is on by default and in every plain choice, and under a strict one only where `es` is chosen, so its reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before). A strict choice of `pt` or `pt-BR` still reads it as the family, as it did. - **Left out:** `conceição` 10 to 4 (71%), a near miss, and the bar is not bent for a word. Too few names to judge: `nazaré` 3 to 0, `assunção` 2 to 0, `luz` 2 to 0, `anjos` 1 to 0, `dores` 1 to 0; `mercês`, `belém` and `penha` move none. `ó` (Nossa Senhora do Ó) is not part of this, being an Irish particle in `ga.toml`. - **Nothing for Brazil:** under `locales.PT_BR` on Brazil's records `jesus` scores 9 to 21, `conceição` 2 to 10, `carmo` 6 to 2 (eight names), `rosário` none. `locales.PT_BR`, `locales.PT` and the default read no name differently (`tests/v2/test_locales.py` holds that pt-PT's choice alone changes the three words). - **`jesus` behind a particle only.** The reading is P10's, so `Jesus Costa` keeps given 'Jesus', and `Maria de Jesus` with no name word after the phrase keeps family 'de Jesus' (rules/P10's "A name word must be left for the family"); after a family comma `Costa, Maria de Jesus` read middle 'de Jesus' already. diff --git a/docs/design/rules/P10-given-name-a-particle-completes.md b/docs/design/rules/P10-given-name-a-particle-completes.md index ec64303b7..374250a24 100644 --- a/docs/design/rules/P10-given-name-a-particle-completes.md +++ b/docs/design/rules/P10-given-name-a-particle-completes.md @@ -19,7 +19,7 @@ "Maria do Carmo Silva" → family="do Carmo Silva" · boundary "João da Silva Santos" → family="da Silva Santos" · boundary ``` -- **A word whose evidence falls short of the default's is marked for its language alone**, read where the caller chooses that language and left to the surname otherwise: Portuguese da Piedade. One that passes in a single country's names is marked for that country alone: Portugal's do Rosário, de Jesus and do Carmo, which Brazil's names do not support (de Jesus there is mostly a surname). +- **A word whose evidence falls short of the default's is marked for its language alone**, read where the caller chooses that language and left to the surname otherwise: Portuguese da Piedade. One that passes in a single country's names is marked for that country alone: Portugal's do Rosário, de Jesus and do Carmo, which Brazil's names do not support or are too few to judge (de Jesus there is mostly a surname). ``` "Maria da Piedade Costa" [pt] → middle="da Piedade" "MARIA DA PIEDADE COSTA" [pt_br] → family="COSTA" diff --git a/docs/locales.rst b/docs/locales.rst index 3dce0e61c..bb5de04dd 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -333,8 +333,9 @@ says which parts each pack is made of. | ``Tiago Barros Queiroz`` → family ``Barros Queiroz`` * - ``pt_pt`` - Portuguese from Portugal - - ``pt`` with two family names and ``pt_br``'s given-name list. See - :ref:`portuguese-two-family-names`. + - ``pt`` with two family names and ``pt_br``'s given-name list, and + ``do Rosário``, ``de Jesus`` and ``do Carmo`` as given names. See + :ref:`portuguese-two-family-names` and :ref:`portuguese-packs`. - ``Rui Sousa Pinto`` → family ``Sousa Pinto``, where ``pt`` gives ``Pinto`` * - ``ru`` @@ -617,8 +618,9 @@ costs the other languages' readings of those words. Most of these packs are described in :doc:`languages`, where the table above links each. Two groups are described here: the Irish and Scottish Gaelic packs (:ref:`gaelic-clan-particles`), and the Portuguese ones, -which turn on ``da Piedade``, in ``pt_br`` ``SB``, and in ``pt_br`` -and ``pt_pt`` two family names (:ref:`portuguese-packs`). +which turn on ``da Piedade``, in ``pt_br`` ``SB``, in ``pt_pt`` +``do Rosário``, ``de Jesus`` and ``do Carmo``, and in ``pt_br`` and +``pt_pt`` two family names (:ref:`portuguese-packs`). .. _gaelic-clan-particles: @@ -676,9 +678,11 @@ does by default (see :ref:`two-given-names`): ('da Piedade', 'Costa') ``pt_pt`` also reads three such phrases that Portugal's names support -and Brazil's do not, ``do Rosário``, ``de Jesus`` and ``do Carmo``: -in Brazil ``de Jesus`` behind a first name is mostly a surname, so -``pt`` and ``pt_br`` read each as the start of the family: +and Brazil's do not (in Brazil ``de Jesus`` behind a first name is +mostly a surname): ``do Rosário``, ``de Jesus`` and ``do Carmo``. +``pt`` and ``pt_br`` read them as the start of the family; ``do +Rosario``, without the accent, every pack reads as a middle name, as +Spanish ``del Rosario`` is read: .. doctest:: diff --git a/docs/policy.rst b/docs/policy.rst index fe14ec84e..0a5091120 100644 --- a/docs/policy.rst +++ b/docs/policy.rst @@ -803,8 +803,11 @@ Which words are marked: - **Under** ``locales.PT``, ``locales.PT_BR`` **and** ``locales.PT_PT`` **only**, a Portuguese word too rare to measure (``da Piedade``; see :ref:`language-packs`). +- **Under** ``locales.PT_PT`` **only**, words Portugal's names support + and Brazil's do not (``do Rosário``, ``de Jesus``, ``do Carmo``; see + :ref:`portuguese-packs`). - **Not marked**: a phrase too often a surname, as Portuguese - ``do Carmo`` is, stays the family, the same shape as ``"João da Silva + ``do Carmo`` is outside ``locales.PT_PT``, stays the family, the same shape as ``"João da Silva Santos"``, and so does one opening with a saint (``"Domingo Santa María González"``). diff --git a/nameparser/locales/pt.py b/nameparser/locales/pt.py index 00ce89d64..7954431e9 100644 --- a/nameparser/locales/pt.py +++ b/nameparser/locales/pt.py @@ -13,7 +13,9 @@ too, so they read all of these the same way; each also reads two family names, which this pack does not (decisions/O6, 2026-11-19), and locales.PT_PT reads Portugal's own given names behind a particle -(pt-PT.toml, ``do Rosário``, #1189), which this pack does not. +(pt-PT.toml, ``do Rosário``, #1189), which this pack does not; the +spelling without the accent, ``do Rosario``, every plain choice reads +through es.toml's reading. Data sources: the counts are on the readings in pt.toml (tools/name_usage.py and the local corpora). The pack carries no diff --git a/nameparser/locales/pt_pt.py b/nameparser/locales/pt_pt.py index c3c3587ae..75df017b8 100644 --- a/nameparser/locales/pt_pt.py +++ b/nameparser/locales/pt_pt.py @@ -5,7 +5,7 @@ of a compound given name) and Portugal's own: pt-PT.toml's ``default = false`` readings, the second halves of compound given names written behind a particle that Portugal's names support and Brazil's do -not (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``de +not, or are too few to judge (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``de Jesus`` and ``do Carmo`` do; rules/P10, decisions/P10 2026-11-19, #1189); it reads two family names (``Policy.two_family_names``, rules/O6), its policy patch compiled from pt-PT.toml's [rules] table @@ -18,7 +18,8 @@ Mozambican names worse (decisions/O6, the 2026-11-19 entry, which measures it). -Data sources: the counts are on the readings in pt.toml; the given +Data sources: the counts are on the readings in pt.toml and +pt-PT.toml; the given names are measured on ORCID's public data file (CC0), whose credit the list's module carries. diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index b53c275d5..4b8937afb 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -190,7 +190,7 @@ A property is **behavioral** when it compiles into a set and so changes how name | `title_case_is_name` | behavioral | `suffix` | false | `TITLE_CASE_NAME_WORDS`, on a `generation` or a `credential` written as a word (`acronym = false`) only: says the word's Title case is its writing as a name, so where a name reading gates the word ([rules/S11](../../docs/design/rules/S11-suffix-word-that-is-also-a-name.md), a suffix word that is also a name), its writing leans: Title case is the name, lower case in a name of mixed case the suffix, capitals nothing ([rules/S6](../../docs/design/rules/S6-case-signal-at-the-suffix-slot.md), the case signal at the suffix slot), as in `Marie Fils` and `Alexandre Dumas fils`. Unwritten, a gated word's writing says nothing and the count decides, as for `Junior`, whose Title case is how the generation is written too; an agnomen's writing never speaks (#1039) | | `attached` | behavioral | `suffix`, `title` | absent | on a suffix word reading, `GLUED_HONORIFICS`: `{ side = "after" }` splits the word off the end of a name token, as in `田中さん` ([rules/W2](../../docs/design/rules/W2-glued-honorific-peel.md), the glued-honorific peel); on a one-word title reading, `GLUED_TITLES`: `{ side = "before" }` splits the title off the start of the name's first word, as in `นายสมชาย` ([rules/W6](../../docs/design/rules/W6-glued-title-peel.md), the glued-title peel) | | `shared` | behavioral | `name` | false | `SHARED_NAMES`: a name a community gives every member, written after the personal name and before a family name where there is one (Sikh `kaur` and `singh`), no personal or family name of the bearer's own: two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) and two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) neither take it nor complete one with it, so `Harpreet Kaur Dhillon` keeps middle `Kaur` under either, and a given name a particle completes ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md)) is never one, so `Kaur del Carmen García` keeps family `del Carmen García` by default (#704) | -| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share (decisions/P10, #704, #1118, #1122) | +| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `jesus`, `carmo`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share (decisions/P10, #704, #1118, #1122) | | `completed_by` | behavioral | `bound_given` | none | `BOUND_PHRASES`: the words that complete the bound given name into one name unit past the first name word, a list (`completed_by = ["الله", "الرحمن"]` on `عبد`), each one word written folded: `سعيد عبد الله` reads family `عبد الله` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md), a bound given name and the word that completes it), while a word left off the list after it is a name of its own, as in `نوال عبد هاشم` (#694) | | `dotted` | behavioral | `title` | false | `DOTTED_TITLES`: the title abbreviates several words and is written with a full stop after each letter (`us`, `uk`, German `pd`), so a run of single letters joined by full stops that spells it is that title at the head of a name where a title the name keeps follows it, as in `U.S. District Judge Marc Treadwell`, and the initials it is written as otherwise (`U.S. Grant`) ([rules/H10](../../docs/design/rules/H10-title-written-as-a-run-of-letters.md), a title written as a run of letters). A title abbreviating one word (`dr`, `mr`, `lt`) is left unmarked, since two initials spell it (`D.R. Judge Smith` reads given 'D.', middle 'R. Judge', its given names 'D.R. Judge', no title) | | `capital_opening` | behavioral | `particle` | false | `CAPITAL_OPENING_PARTICLES`: the particle is written with a capital where the word before it in the family name is no particle, nor, where it opens the family name, the word written right before it in any role (`Van der Walt` keeps its lowercase `der`), as the Armenian priestly prefix is (`ter` and `der`: `LEVON TER PETROSYAN` repairs to `Levon Ter Petrosyan`), and keeps its lowercase after one (`Jan van der Berg`) ([rules/R12](../../docs/design/rules/R12-particle-opening-the-family-name-with-a-capital.md), a particle opening the family name with a capital); it moves no parse. A Dutch surname opened by `ter` takes the capital too (`Gerard Ter Borch`), a cost accepted in decisions/R12 | @@ -295,7 +295,7 @@ patronymic_rules = ["east-slavic"] | `two_given_names` | `true` | `two_given_names` (rules/O7) | | `initials_as_family` | `true` | `initials_as_family` (rules/O8) | -A rule is written only to turn it on: `name_order = "given-first"`, `two_family_names = false`, `two_given_names = false` and `initials_as_family = false` are the defaults, and a pack's value overrides the caller's own, so the build refuses all four rather than let a pack switch a caller's rule off. The files that hold a table are exactly the ones `PACK_RULES` in `tools/vocab/build.py` lists, each beside the pack that reads it (`tr.toml` is `locales.TR_AZ`'s, one file for Turkish and Azerbaijani, since there is no `az.toml`; `es.toml`'s is `locales.ES_AR`'s too, a country pack reading its language's table; and `pt-BR.toml`'s and `pt-PT.toml`'s are `locales.PT_BR`'s and `locales.PT_PT`'s, countries turning on a rule `pt.toml` leaves off, `pt-PT.toml` holding the table and no word); a table in any other file is a build error, since nothing would read it, and so is a file listed there without one. Writing a `[rules]` table does not choose the file's vocabulary: that is the pack's `languages`, a separate field. +A rule is written only to turn it on: `name_order = "given-first"`, `two_family_names = false`, `two_given_names = false` and `initials_as_family = false` are the defaults, and a pack's value overrides the caller's own, so the build refuses all four rather than let a pack switch a caller's rule off. The files that hold a table are exactly the ones `PACK_RULES` in `tools/vocab/build.py` lists, each beside the pack that reads it (`tr.toml` is `locales.TR_AZ`'s, one file for Turkish and Azerbaijani, since there is no `az.toml`; `es.toml`'s is `locales.ES_AR`'s too, a country pack reading its language's table; and `pt-BR.toml`'s and `pt-PT.toml`'s are `locales.PT_BR`'s and `locales.PT_PT`'s, countries turning on a rule `pt.toml` leaves off, `pt-PT.toml` holding the table and Portugal's own `default = false` readings, #1189); a table in any other file is a build error, since nothing would read it, and so is a file listed there without one. Writing a `[rules]` table does not choose the file's vocabulary: that is the pack's `languages`, a separate field. A rule KIND the table does not list (a married-name ending) is a change to the parser, not to a file: a new `Policy` field (with `ADDED_IN`), a row in `build.py`'s `RULE_KEYS` and in `_locale.py`'s `_RULE_VALUES`, and a mechanisms.md entry of its own for the rule kind, or an amendment to the entry whose shape it shares (`initials_as_family` joined DECLARED-SPAN's switches) (mechanisms.md#LOCALE-PACKS-PURE-DATA). `tests/v2/test_vocab.py` holds the two tables to each other and to `Policy`. diff --git a/nameparser/vocab/pt-PT.toml b/nameparser/vocab/pt-PT.toml index 8269f09e9..f6545fd8d 100644 --- a/nameparser/vocab/pt-PT.toml +++ b/nameparser/vocab/pt-PT.toml @@ -2,9 +2,11 @@ schema = 1 # European Portuguese: locales.PT_PT reads its names with two family names # (rules/O6), its given-name list keeping a given name out of the family. -# The words are the readings Portugal writes and Brazil does not, each -# `default = false`, so only a choice of pt-PT turns it on; pt.toml holds -# the language's (decisions/O6 and decisions/P10, the 2026-11-19 entries) +# The words are readings Portugal's names support and Brazil's do not, +# each `default = false`, so only a choice of pt-PT turns them on +# (`rosario`, which es.toml reads by default, is here for a strict +# choice); pt.toml holds the language's (decisions/O6 and decisions/P10, +# the 2026-11-19 entries) [rules] two_family_names = true @@ -18,7 +20,7 @@ given = { default = false, after_particle = true, note = "the second of a compou [[word]] text = "rosario" -given = { default = false, after_particle = true, note = "the spelling of rosário without its accent, scored with it (Maria do Rosario): es.toml reads it so already in every choice but a strict one, so this reading keeps it under a strict Portuguese choice of Portugal, which compiles no es.toml (decisions/P10) (2026-11-19, #1189)" } +given = { default = false, after_particle = true, note = "the spelling of rosário without its accent, scored with it (Maria do Rosario): es.toml's reading is on by default and in every plain choice, and under a strict one only where es is chosen, so this reading keeps it under a strict choice of Portugal, which compiles no es.toml (decisions/P10) (2026-11-19, #1189)" } [[word]] text = "rosário" diff --git a/tests/v2/cases.py b/tests/v2/cases.py index e36b1fc2c..22332349b 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -18074,8 +18074,8 @@ def _check_cjk_shape_purity(self) -> None: Case("portuguese_rosario_given_name_under_pt_pt", "Maria do Rosário Pinto", {"given": "Maria", "middle": "do Rosário", "family": "Pinto"}, locale="pt_pt", classification="feat(#1189)", - notes="P10: pt-PT.toml's rosário, on for Portugal's choice alone; " - "locales.PT_PT is new in 3.2"), + notes="P10: pt-PT.toml's rosário, on for Portugal's choice alone " + "(#1189); locales.PT_PT was added by #1453"), Case("portuguese_jesus_given_name_under_pt_pt", "Teresa de Jesus Sousa Pinto", {"given": "Teresa", "middle": "de Jesus", "family": "Sousa Pinto"}, locale="pt_pt", classification="feat(#1189)", @@ -18085,6 +18085,16 @@ def _check_cjk_shape_purity(self) -> None: {"given": "MARIA", "middle": "DO CARMO", "family": "PINTO"}, locale="pt_pt", classification="feat(#1189)", notes="P10: pt-PT.toml's carmo, written in capitals"), + Case("portuguese_jesus_one_word_after_under_pt_pt", "Rita de Jesus Quaresma", + {"given": "Rita", "middle": "de Jesus", "family": "Quaresma"}, + locale="pt_pt", classification="feat(#1189)", + notes="P10 reads first, so O6 takes nothing into a family of one " + "word behind the phrase"), + Case("portuguese_carmo_before_a_suffix_comma_under_pt_pt", + "Rita do Carmo Quaresma, Jr.", + {"given": "Rita", "middle": "do Carmo", "family": "Quaresma", "suffix": "Jr."}, + locale="pt_pt", classification="feat(#1189)", + notes="P10 behind a suffix comma, as without it"), Case("portuguese_jesus_with_no_name_after_under_pt_pt", "Maria de Jesus", {"given": "Maria", "family": "de Jesus"}, locale="pt_pt", classification="parity", diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index f1b076822..5d547797f 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -3734,6 +3734,15 @@ def test_the_portuguese_country_packs_read_two_family_names_and_pt_does_not() -> - changed_words(selected(locales.PT.languages)) == {"carmo", "jesus", "rosário"}) assert "pt-PT" not in selected(locales.PT_BR.languages) + # a strict choice of Portugal reads them too, and the spelling without + # the accent, which only es.toml's reading gave a plain choice; a + # strict choice of Brazil or of the language reads none of them + for strict_pack, middle in ((locales.PT_PT, True), (locales.PT_BR, False), + (locales.PT, False)): + strict = parser_for(strict_pack, strict=True) + for phrase in ("do Rosario", "do Rosário", "de Jesus", "do Carmo"): + parsed = strict.parse(f"Rita {phrase} Quaresma") + assert parsed.middle == (phrase if middle else ""), (strict_pack.code, phrase) pt, br, pp = (_require_packed(c) for c in ("pt", "pt_br", "pt_pt")) assert pt.parse("Rui Sousa Pinto").family == "Pinto" assert pt.parse("Pedro Sousa Alves Filho").family == "Alves" diff --git a/tests/v2/test_reading_index.py b/tests/v2/test_reading_index.py index 54b347d94..9b1b02ce9 100644 --- a/tests/v2/test_reading_index.py +++ b/tests/v2/test_reading_index.py @@ -335,8 +335,8 @@ def test_a_file_holding_no_reading_is_chosen_only_strictly( monkeypatch: pytest.MonkeyPatch) -> None: empty = ri.files() - ri.tags() assert empty and ri.tags() <= ri.files() - # no shipped region's file holds a [rules] table and no reading since - # pt-PT.toml took Portugal's own readings (#1189), so one is planted + # no shipped region's file holds no reading since pt-PT.toml took + # Portugal's own (#1189), so one is planted regions = {tag for tag in empty if tag.split("-")[0] in ri.tags()} assert regions == set() monkeypatch.setattr(ri, "files", lambda: frozenset(ri.tags() | empty | {"pt-AO"})) diff --git a/tools/differential/config_diff.py b/tools/differential/config_diff.py index b68e99cc9..9046ac93b 100644 --- a/tools/differential/config_diff.py +++ b/tools/differential/config_diff.py @@ -745,7 +745,9 @@ def gap_specs(tag: str) -> tuple[str, str]: else the bare tag. A file holding no reading is refused as a plain choice (it would change nothing), so its plain side is the default, unless its language's file holds readings (a region's file holding a - [rules] table alone), which a plain choice of the tag selects.""" + [rules] table alone; none ships since #1189, and + tests/v2/test_reading_index.py plants one), which a plain choice of + the tag selects.""" from nameparser import _reading_index, locales packs = [locales.get(c) for c in sorted(locales.available())] items = [p.code.upper() for p in packs if tag in p.languages] From d52de7d08e2ccd2dabb5cd56c7a8a13981d82e61 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 16:53:35 -0800 Subject: [PATCH 3/6] Say Brazil's names refute the words or are too few to judge (#1189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only jesus is refuted by Brazil's counts; rosário moves none of Brazil's names and carmo too few. docs/locales.rst says the unaccented `do Rosario` is a middle name in every pack's plain choice, a strict choice of pt or pt_br reading it as the family. Co-Authored-By: Claude Opus 5.5 --- docs/locales.rst | 13 ++++++++----- docs/policy.rst | 4 ++-- nameparser/vocab/pt-PT.toml | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/locales.rst b/docs/locales.rst index bb5de04dd..11584ccbc 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -678,11 +678,10 @@ does by default (see :ref:`two-given-names`): ('da Piedade', 'Costa') ``pt_pt`` also reads three such phrases that Portugal's names support -and Brazil's do not (in Brazil ``de Jesus`` behind a first name is -mostly a surname): ``do Rosário``, ``de Jesus`` and ``do Carmo``. -``pt`` and ``pt_br`` read them as the start of the family; ``do -Rosario``, without the accent, every pack reads as a middle name, as -Spanish ``del Rosario`` is read: +and Brazil's refute or are too few to judge (in Brazil ``de Jesus`` +behind a first name is mostly a surname): ``do Rosário``, ``de Jesus`` +and ``do Carmo``. ``pt`` and ``pt_br`` read them as the start of the +family: .. doctest:: @@ -692,6 +691,10 @@ Spanish ``del Rosario`` is read: >>> rosario.middle, rosario.family ('do Rosário', 'Pinto') +``do Rosario``, without the accent, every pack's plain choice reads as a +middle name, as Spanish ``del Rosario`` is read; a strict choice of +``pt`` or ``pt_br``, which leaves Spanish out, reads it as the family. + ``pt_br`` also turns on ``SB``. Brazilian filings abbreviate the agnomen *Sobrinho* (nephew) to ``SB``, which is also the S.B. degree, so the default does not read it. Under the pack it is a suffix only diff --git a/docs/policy.rst b/docs/policy.rst index 0a5091120..4bc0e0f1c 100644 --- a/docs/policy.rst +++ b/docs/policy.rst @@ -804,10 +804,10 @@ Which words are marked: Portuguese word too rare to measure (``da Piedade``; see :ref:`language-packs`). - **Under** ``locales.PT_PT`` **only**, words Portugal's names support - and Brazil's do not (``do Rosário``, ``de Jesus``, ``do Carmo``; see + and Brazil's refute or are too few to judge (``do Rosário``, ``de Jesus``, ``do Carmo``; see :ref:`portuguese-packs`). - **Not marked**: a phrase too often a surname, as Portuguese - ``do Carmo`` is outside ``locales.PT_PT``, stays the family, the same shape as ``"João da Silva + ``do Carmo`` is (outside ``locales.PT_PT``), stays the family, the same shape as ``"João da Silva Santos"``, and so does one opening with a saint (``"Domingo Santa María González"``). diff --git a/nameparser/vocab/pt-PT.toml b/nameparser/vocab/pt-PT.toml index f6545fd8d..271ffc31d 100644 --- a/nameparser/vocab/pt-PT.toml +++ b/nameparser/vocab/pt-PT.toml @@ -2,7 +2,8 @@ schema = 1 # European Portuguese: locales.PT_PT reads its names with two family names # (rules/O6), its given-name list keeping a given name out of the family. -# The words are readings Portugal's names support and Brazil's do not, +# The words are readings Portugal's names support and Brazil's refute +# or are too few to judge, # each `default = false`, so only a choice of pt-PT turns them on # (`rosario`, which es.toml reads by default, is here for a strict # choice); pt.toml holds the language's (decisions/O6 and decisions/P10, From cba9d0f65fbbb54fb102ffa6d7ea6081f6dcb08c Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 17:41:20 -0800 Subject: [PATCH 4/6] =?UTF-8?q?Score=20#1189's=20words=20on=20the=20whole?= =?UTF-8?q?=20ORCID=20extract:=20concei=C3=A7=C3=A3o=20and=20luz=20in,=20j?= =?UTF-8?q?esus=20out?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P10's Standing bar names the whole extract, and there `jesus` scores 40 fixed to 17 broken (70%) on Portugal's names while `conceição` (53/11) and `luz` (12/2) pass; the capped corpus had read them the other way. pt-PT.toml now marks rosário, carmo, conceição and luz (with their unaccented spellings), and decisions/P10's entry gives both tables, the whole extract deciding. Brazil's whole-extract figures, re-run, fail every word. Co-Authored-By: Claude Opus 5.5 --- .../P10-given-name-a-particle-completes.md | 30 ++++++++++--------- .../P10-given-name-a-particle-completes.md | 6 ++-- docs/locales.rst | 12 ++++---- docs/policy.rst | 3 +- docs/release_log.rst | 2 +- nameparser/config/_index.py | 4 ++- nameparser/locales/pt_pt.py | 8 ++--- nameparser/vocab/README.md | 2 +- nameparser/vocab/pt-PT.toml | 19 ++++++++---- tests/v2/cases.py | 28 ++++++++++------- tests/v2/test_locales.py | 9 ++++-- tools/differential/corpus_rules.jsonl | 4 +-- tools/differential/snapshot.jsonl | 4 +-- 13 files changed, 75 insertions(+), 56 deletions(-) diff --git a/docs/design/decisions/P10-given-name-a-particle-completes.md b/docs/design/decisions/P10-given-name-a-particle-completes.md index 1c8da71b7..879c8b6ed 100644 --- a/docs/design/decisions/P10-given-name-a-particle-completes.md +++ b/docs/design/decisions/P10-given-name-a-particle-completes.md @@ -10,7 +10,7 @@ - An unaccented spelling is measured on its own and marked where its counts pass, so it may part from its accented twin: `fatima` is on by default, as `fátima` is, and `kassia` (11 fixed to 4 broken, 73%) is not marked where `kássia` is on by default. One with too few fixed and broken names to decide alone takes its twin's reading (`ceu`, `graca`, `gracas`) — 2026-11-06 #1118, #1122. - A word `es.toml` marks that passes on Portugal's, Brazil's and Portuguese-speaking Africa's names, scored under the strict Portuguese choice itself (whose particles hold no `del` or `los`), is marked in `pt.toml` too, so that choice, which compiles no `es.toml`, reads it (`fátima`, `fatima`, `socorro`, `lourdes`, `maria`); one failing or reaching too few names there is read only where `es.toml` is compiled (`rocio` 64%, `rosario` 43%, `jesús` 67%; `carmen`, `pilar`, `angeles`, written `del Carmen`, `del Pilar`, `de los Angeles`, reach one or two names under it) — 2026-11-06 #1122, decided in chat. - `valle` stays on by default though it breaks more Portuguese names than it fixes (7 fixed to 32 broken, mostly `do Valle` surnames), since it passes pooled (379 to 95, 80%): the pooled reading was chosen over requiring every language's countries to pass, which would also have taken `jesús`, `rosario` and `rocio` from the default: among Spanish-speaking countries' names the four fix 4,236 and break 113, among Portuguese-speaking countries' 47 and 52, so the stricter bar would have given up about 4,100 Spanish names for a net 5 Portuguese ones — 2026-11-06 #1122, decided in chat. -- A word passing in one country's names alone, scored under that country's pack over ORCID's capped corpus, is marked `default = false` in the country's file, read under that country's choice and not under its language's or another country's: `rosário` (with `rosario`), `jesus` and `carmo` in `pt-PT.toml`, under `locales.PT_PT`. Nothing is marked for Brazil — 2026-11-19 #1189. +- A word passing in one country's names alone, scored by the bar above over that country's records in the whole ORCID extract, under the country's pack, is marked `default = false` in the country's file, read under that country's choice and not under its language's or another country's: `rosário` (with `rosario`), `carmo`, `conceição` (with `conceicao`) and `luz` in `pt-PT.toml`, under `locales.PT_PT`. Nothing is marked for Brazil — 2026-11-19 #1189. Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `ca.toml` because the property moved nothing with the switch off; under this rule a `dels` particle beside `àngels` written `after_particle` reads middle 'dels Àngels', family 'Puig' by default, today's reading, so the reason no longer holds and the words want their own measurement — #1059. @@ -51,18 +51,20 @@ Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `c - **Measured** (2026-11-06, the tree against `origin/master` `b1d3d210` read with `--base`, py3.11). ORCID's capped corpus by default: 24 fixed, 6 broken, 12 changed agreeing in neither; under `--locale pt_br`: 0 fixed, 1 broken (`Karina | de Kassia Abreu`, `kassia` unmarked). PSC: 6 fixed (`Francisco | Da Graca | Geraldes`), 1 broken (`Angelita | Da Graca Brenzink`), 1 changed. `snapshot.py --local tse-donors --base` moves 1,187 of 854,531 names, in family and middle alone (`ADRIANA DAS GRACAS LIMA`, `AMANDA DE CASSIA LOPES`). The committed snapshot moves the rule's two default examples, and the `da Piedade` examples join it. - Recompute: for each word, the ORCID extract's records (`local_orcid.extract_path()`) from BR PT AO MZ CV GW ST TL, and from ES MX AR CO CL PE VE EC UY BO PY CR GT CU DO HN SV NI PA PR AD, with both boxes filled, whose `given family`, NFC lower case with edge periods and commas stripped, holds the word behind a word of `Lexicon.default()._sets.particles`; each parsed with `Lexicon.default()` and with `.remove(word, kind="given")` (for the pack words, `parser_for(locales.PT).lexicon` and its removal; for the strict readings, the Portuguese-speaking countries alone, `parser_for(locales.PT, strict=True)`, its lexicon's particles, and its lexicon with `.remove(word, kind="given")`, or `.add(word, kind="given", after_particle=True)` for a word it does not mark, each beside its policy), a parse agreeing where its given and middle joined equal the given box and its family the family box, case-folded; fixed where only the reading's parse agrees, broken where only the other's. The rows with the commands above, `--base` a `git archive` export of `b1d3d210`. - 2026-11-19 #1479 — THE FAMILY A PHRASE LEAVES IS DIVIDED AS ANY FAMILY IS. #1479 asked whether the second surname missing behind a P10 phrase (`María del Carmen García López` under `two_family_names`, surname2 '') was a defect or a decision. Neither this file nor decisions/O6 or decisions/R10 recorded a decision: the Accepted clause it rested on described how the parse got there, P2's chain `del Carmen García López` leaving O6 a family of two words that O6 took nothing into and so marked nothing in, and gave no reason to want it. A defect, then, fixed with #1456 by dividing every family by its own words (decisions/O6's 2026-11-19 #1456, #1479 entry): the family gives surname1 `García`, surname2 `López`. Measured on Spanish-speaking ORCID holders under `locales.ES`, the shape held 3,204 records whose family the parser read as the holder's family box, all but 7 (three name words behind the phrase) divided now. The clause is replaced by an example under the rule's O6 Precedence. -- 2026-11-19 #1189 — PORTUGAL'S OWN GIVEN NAMES A PARTICLE COMPLETES. #1118 and #1122 pooled the bar over every Portuguese-speaking country, so a word written as a given name in Portugal and as a surname in Brazil failed it (`conceição` 302 to 344 pooled). #1453 added `pt-PT.toml` and `locales.PT_PT`, a choice Brazil's pack does not make (`pt-BR` selects `pt-BR` and `pt`, never `pt-PT`), so a reading can be on for Portugal alone. Each word was scored by #1122's bar (75% of the names it moves fixed, ten names or more), a word at a time, under the country's pack with and without the reading, over ORCID's capped corpus (`raw.jsonl`, at most 20,000 records a country), not the whole extract the Standing bar names: a country tier is scored on that country's records, and Portugal's capped records are all of its 19,460 scored ones (19,465 in the issue's count, five set aside by `local_agreement.read`). - - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 15 fixed to 1 broken (94%), `jesus` 16 to 1 (94%), `carmo` 9 to 2 (82%), each over ten names and past 75%. `rosario`, the spelling without the accent, is scored with its twin and marked with it; `es.toml`'s reading is on by default and in every plain choice, and under a strict one only where `es` is chosen, so its reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before). A strict choice of `pt` or `pt-BR` still reads it as the family, as it did. - - **Left out:** `conceição` 10 to 4 (71%), a near miss, and the bar is not bent for a word. Too few names to judge: `nazaré` 3 to 0, `assunção` 2 to 0, `luz` 2 to 0, `anjos` 1 to 0, `dores` 1 to 0; `mercês`, `belém` and `penha` move none. `ó` (Nossa Senhora do Ó) is not part of this, being an Irish particle in `ga.toml`. - - **Nothing for Brazil:** under `locales.PT_BR` on Brazil's records `jesus` scores 9 to 21, `conceição` 2 to 10, `carmo` 6 to 2 (eight names), `rosário` none. `locales.PT_BR`, `locales.PT` and the default read no name differently (`tests/v2/test_locales.py` holds that pt-PT's choice alone changes the three words). - - **`jesus` behind a particle only.** The reading is P10's, so `Jesus Costa` keeps given 'Jesus', and `Maria de Jesus` with no name word after the phrase keeps family 'de Jesus' (rules/P10's "A name word must be left for the family"); after a family comma `Costa, Maria de Jesus` read middle 'de Jesus' already. - - **Measured** (2026-11-19, master `12b568f8`, py3.11), `config_diff.py score`, at most 20,000 records a group, every box filled, fixed and broken against `locales.PT_PT`: +- 2026-11-19 #1189 — PORTUGAL'S OWN GIVEN NAMES A PARTICLE COMPLETES. #1118 and #1122 pooled the bar over every Portuguese-speaking country, so a word written as a given name in Portugal and as a surname in Brazil was scored by both countries' names at once. #1453 added `pt-PT.toml` and `locales.PT_PT`, a choice Brazil's pack does not make (`pt-BR` selects `pt-BR` and `pt`, never `pt-PT`), so a reading can be on for Portugal alone. Each word is scored by #1122's bar (75% of the names it moves fixed, ten names or more), a word at a time, under the country's pack with and without the reading, over the country's records in the whole ORCID extract, since the Standing bar names the whole extract. + - **First taken on the capped corpus, and superseded.** The words were first chosen on ORCID's capped corpus (`raw.jsonl`, at most 20,000 records a country: Portugal's 19,460 scored), where `rosário` 15 to 1, `jesus` 16 to 1 and `carmo` 9 to 2 passed and `conceição` 10 to 4 (71%) missed. The whole extract holds about five times Portugal's records, and there `jesus` fails and `conceição` and `luz` pass; the whole extract decides, being the population the bar names. Both tables are below. + - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 41 fixed to 2 broken (95%), `carmo` 48 to 7 (87%), `conceição` 53 to 11 (83%), `luz` 12 to 2 (86%). `rosario` and `conceicao`, the spellings without accents, are scored with their twins and marked with them. `es.toml`'s `rosario` reading is on by default and in every plain choice, and under a strict one only where `es` is chosen, so the reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before); a strict choice of `pt` or `pt-BR` still reads it as the family. + - **Left out:** `jesus`, 40 to 17 (70%), which the capped corpus had passed. Too few names to judge: `nazaré` 5 to 0, `assunção` 4 to 1, `anjos` 3 to 1, `dores`, `mercês` and `belém` 1 to 0 each, `penha` 0 to 1. `ó` (Nossa Senhora do Ó) is not part of this, being an Irish particle in `ga.toml`. + - **Nothing for Brazil.** Under `locales.PT_BR` over Brazil's records in the whole extract every word fails: `rosário` 15 to 29, `jesus` 248 to 784, `carmo` 173 to 201, `conceição` 132 to 226, `luz` 20 to 83, `nazaré` 35 to 14 (71%, the nearest), `anjos` 29 to 180, `penha` 22 to 17, `dores` 19 to 12. `locales.PT_BR`, `locales.PT` and the default read no name differently (`tests/v2/test_locales.py` holds that pt-PT's choice alone changes the words, and a strict choice of each). + - **Behind a particle only.** The reading is P10's, so a name ending with the phrase keeps it as the family (`Maria da Luz`, rules/P10's "A name word must be left for the family"), and a family comma reads it as before (`Costa, Maria da Conceição`). + - **Measured** (2026-11-19, master `1ca93b25`, py3.11), fixed and broken against `locales.PT_PT`, every box filled: - | Population | `rosário` | `jesus` | `carmo` | `conceição` | the three | - |---|---:|---:|---:|---:|---:| - | ORCID Portugal (19,460) | 15 / 1 | 16 / 1 | 9 / 2 | 10 / 4 | 40 / 4 | - | PSC, Portuguese (5,333) | 0 / 0 | 7 / 2 | 4 / 0 | 6 / 1 | 11 / 2 | - | PatentsView Portugal (3,576) | 2 / 1 | 3 / 1 | 0 / 0 | 2 / 2 | 5 / 2 | + | Population | `rosário` | `carmo` | `conceição` | `luz` | `jesus` (left out) | the four | + |---|---:|---:|---:|---:|---:|---:| + | ORCID Portugal, whole extract (553 records holding a phrase) | 41 / 2 | 48 / 7 | 53 / 11 | 12 / 2 | 40 / 17 | | + | ORCID Portugal, capped (19,460) | 15 / 1 | 9 / 2 | 10 / 4 | 2 / 0 | 16 / 1 | 36 / 7 | + | PSC, Portuguese (5,333) | 0 / 0 | 4 / 0 | 6 / 1 | 0 / 0 | 7 / 2 | 10 / 1 | + | PatentsView Portugal (3,576) | 2 / 1 | 0 / 0 | 2 / 2 | 0 / 0 | 3 / 1 | 4 / 3 | - Portugal's parliament (`config_diff.py diff --local opensanctions-parliaments --group pt_parliament`, 2,256 spellings): 3 move, each to the reading its deputy's parliamentary name keeps, the phrase in the given part. - - Recompute: `config_diff.py score plain:PT_PT --group PT --group Portuguese --cap 20000 --min 50`, `` being `expr:parser_for(Locale(code='x', lexicon=locales.PT_PT.lexicon.add(w, kind='given', after_particle=True), policy=locales.PT_PT.policy, languages=frozenset({'pt-PT'})))` for each word (both spellings for `rosário` and `conceição`), on a checkout of `12b568f8`; Brazil's the same under `locales.PT_BR`, `--group BR`. + Portugal's parliament (`config_diff.py diff --local opensanctions-parliaments --group pt_parliament`, 2,256 spellings): 13 move, each putting the phrase in the given part, where the issue found Portugal's deputies keep it (the 2026-11-08 count on #1189). + - Recompute: the whole-extract rows, for a country, over the records of `local_orcid.extract_path()` with that `country` and both boxes filled whose `given family` holds the word behind `da`, `de`, `do`, `das`, `des` or `dos`, each kept and scored as `config_diff.score` keeps and scores one (`config_diff.kept`, `score_rows` with `local_agreement.FIELDED` for ORCID), under `plain:PT_PT` (Portugal) or `plain:PT_BR` (Brazil) and the same pack with `.add(w, kind='given', after_particle=True)` on its lexicon for each spelling of the word; the other rows with `config_diff.py score plain:PT_PT --group PT --group Portuguese --cap 20000 --min 50 --json ` (the fixed and broken of every configuration are in the JSON; the printed table names only the best), `` being `expr:parser_for(Locale(code='x', lexicon=locales.PT_PT.lexicon.add(w, kind='given', after_particle=True), policy=locales.PT_PT.policy, languages=frozenset({'pt-PT'})))` with one `.add` per spelling, the four together for the last column; each on a checkout of `1ca93b25`. diff --git a/docs/design/rules/P10-given-name-a-particle-completes.md b/docs/design/rules/P10-given-name-a-particle-completes.md index 374250a24..31d9fc595 100644 --- a/docs/design/rules/P10-given-name-a-particle-completes.md +++ b/docs/design/rules/P10-given-name-a-particle-completes.md @@ -19,16 +19,16 @@ "Maria do Carmo Silva" → family="do Carmo Silva" · boundary "João da Silva Santos" → family="da Silva Santos" · boundary ``` -- **A word whose evidence falls short of the default's is marked for its language alone**, read where the caller chooses that language and left to the surname otherwise: Portuguese da Piedade. One that passes in a single country's names is marked for that country alone: Portugal's do Rosário, de Jesus and do Carmo, which Brazil's names do not support or are too few to judge (de Jesus there is mostly a surname). +- **A word whose evidence falls short of the default's is marked for its language alone**, read where the caller chooses that language and left to the surname otherwise: Portuguese da Piedade. One that passes in a single country's names is marked for that country alone: Portugal's do Rosário, do Carmo, da Conceição and da Luz, which Brazil's names refute. ``` "Maria da Piedade Costa" [pt] → middle="da Piedade" "MARIA DA PIEDADE COSTA" [pt_br] → family="COSTA" "Maria da Piedade Costa" → family="da Piedade Costa" · boundary "Maria da Piedade Costa" [es] → family="da Piedade Costa" · boundary "Maria do Rosário Pinto" [pt_pt] → middle="do Rosário" - "Teresa de Jesus Sousa Pinto" [pt_pt] → family="Sousa Pinto" + "Teresa da Conceição Sousa Pinto" [pt_pt] → family="Sousa Pinto" "Maria do Carmo Silva" [pt_pt] → middle="do Carmo" - "Maria de Jesus Pinto" [pt_br] → family="de Jesus Pinto" · boundary + "Maria da Conceição Pinto" [pt_br] → family="da Conceição Pinto" · boundary "Maria do Rosário Pinto" [pt] → family="do Rosário Pinto" · boundary ``` - **A title, a suffix and a nickname are no name words**, so they stand outside the reading. diff --git a/docs/locales.rst b/docs/locales.rst index 11584ccbc..605ba0b9f 100644 --- a/docs/locales.rst +++ b/docs/locales.rst @@ -334,7 +334,7 @@ says which parts each pack is made of. * - ``pt_pt`` - Portuguese from Portugal - ``pt`` with two family names and ``pt_br``'s given-name list, and - ``do Rosário``, ``de Jesus`` and ``do Carmo`` as given names. See + ``do Rosário``, ``do Carmo``, ``da Conceição`` and ``da Luz`` as given names. See :ref:`portuguese-two-family-names` and :ref:`portuguese-packs`. - ``Rui Sousa Pinto`` → family ``Sousa Pinto``, where ``pt`` gives ``Pinto`` @@ -619,7 +619,7 @@ Most of these packs are described in :doc:`languages`, where the table above links each. Two groups are described here: the Irish and Scottish Gaelic packs (:ref:`gaelic-clan-particles`), and the Portuguese ones, which turn on ``da Piedade``, in ``pt_br`` ``SB``, in ``pt_pt`` -``do Rosário``, ``de Jesus`` and ``do Carmo``, and in ``pt_br`` and +``do Rosário``, ``do Carmo``, ``da Conceição`` and ``da Luz``, and in ``pt_br`` and ``pt_pt`` two family names (:ref:`portuguese-packs`). .. _gaelic-clan-particles: @@ -677,11 +677,9 @@ does by default (see :ref:`two-given-names`): >>> piedade.middle, piedade.family ('da Piedade', 'Costa') -``pt_pt`` also reads three such phrases that Portugal's names support -and Brazil's refute or are too few to judge (in Brazil ``de Jesus`` -behind a first name is mostly a surname): ``do Rosário``, ``de Jesus`` -and ``do Carmo``. ``pt`` and ``pt_br`` read them as the start of the -family: +``pt_pt`` also reads four such phrases that Portugal's names support +and Brazil's refute: ``do Rosário``, ``do Carmo``, ``da Conceição`` and ``da Luz``. ``pt`` and ``pt_br`` read them as the +start of the family: .. doctest:: diff --git a/docs/policy.rst b/docs/policy.rst index 4bc0e0f1c..258994f4e 100644 --- a/docs/policy.rst +++ b/docs/policy.rst @@ -804,7 +804,8 @@ Which words are marked: Portuguese word too rare to measure (``da Piedade``; see :ref:`language-packs`). - **Under** ``locales.PT_PT`` **only**, words Portugal's names support - and Brazil's refute or are too few to judge (``do Rosário``, ``de Jesus``, ``do Carmo``; see + and Brazil's refute (``do Rosário``, ``do Carmo``, ``da Conceição``, + ``da Luz``; see :ref:`portuguese-packs`). - **Not marked**: a phrase too often a surname, as Portuguese ``do Carmo`` is (outside ``locales.PT_PT``), stays the family, the same shape as ``"João da Silva diff --git a/docs/release_log.rst b/docs/release_log.rst index a238e31b8..4019acaad 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -15,7 +15,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.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 three given names Portugal writes behind a particle and Brazil does not (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``de Jesus`` and ``do Carmo`` do). :issue:`1453`, :issue:`1189` + - **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 locales.ES_AR's given-name list, rewritten from its tool.** ``parser_for(locales.ES_AR).parse("Juan Gerhard Lopez")`` gives family ``Gerhard Lopez``, where 3.0.0 through 3.1.0 gave middle ``Gerhard``; six words leave the list (``Gerhard``, ``Emerita``, ``Zuleyma`` among them) and six join it (``Azhar``, ``Houari``), each joining reading as a middle name where it read as the first family name. :issue:`1471` * 3.1.0 - November 16, 2026 diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index cca660271..4c82dfc76 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -639,6 +639,8 @@ ('comptroller', (('en', 'office', (('attaches', ('gen',)),)),)), ('computer', (('en', 'modifier', ()),)), ('comtesse', (('fr', 'nobility', ()),)), + ('conceicao', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), + ('conceição', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), ('concepción', (('es', 'given', (('after_particle', True),)),)), ('conductor', (('en', 'occupation', ()),)), ('connie', (('en', 'familiar', (('short_for', ('constance',)),)),)), @@ -1395,7 +1397,6 @@ ('jess', (('en', 'familiar', (('short_for', ('jessica',)),)),)), ('jessi', (('en', 'familiar', (('short_for', ('jessica',)),)),)), ('jessie', (('en', 'familiar', (('short_for', ('jessica',)),)),)), - ('jesus', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), ('jesús', (('es', 'given', (('after_particle', True),)),)), ('jez', (('en', 'familiar', (('short_for', ('jeremy',)),)),)), ('jill', (('en', 'familiar', (('short_for', ('jillian',)),)),)), @@ -1649,6 +1650,7 @@ ('luiz', (('pt-BR', 'spelling', (('spelling_of', ('luis',)),)),)), ('lupita', (('en', 'familiar', (('short_for', ('guadalupe',)),)), ('es', 'familiar', (('short_for', ('guadalupe',)),)))), ('lurdes', (('pt', 'given', (('after_particle', True),)),)), + ('luz', (('pt-PT', 'given', (('after_particle', True), ('default', False))),)), ('lvn', (('en', 'credential', ()),)), ('lvo', (('en', 'credential', ()),)), ('lvt', (('en', 'credential', ()),)), diff --git a/nameparser/locales/pt_pt.py b/nameparser/locales/pt_pt.py index 75df017b8..0afd2c086 100644 --- a/nameparser/locales/pt_pt.py +++ b/nameparser/locales/pt_pt.py @@ -4,10 +4,10 @@ word locales.PT reads (``do`` a particle, ``da Piedade`` the second half of a compound given name) and Portugal's own: pt-PT.toml's ``default = false`` readings, the second halves of compound given names -written behind a particle that Portugal's names support and Brazil's do -not, or are too few to judge (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``de -Jesus`` and ``do Carmo`` do; rules/P10, decisions/P10 2026-11-19, -#1189); it reads two family names (``Policy.two_family_names``, +written behind a particle that Portugal's names support and Brazil's +refute (``Maria do Rosário Pinto`` gives middle ``do Rosário``, as ``do +Carmo``, ``da Conceição`` and ``da Luz`` do; rules/P10, decisions/P10 +2026-11-19, #1189); it reads two family names (``Policy.two_family_names``, rules/O6), its policy patch compiled from pt-PT.toml's [rules] table by tools/vocab/build.py: ``Rui Sousa Pinto`` gives family ``Sousa Pinto``, where locales.PT gives middle ``Sousa``; and it carries diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index 4b8937afb..257b4eed8 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -190,7 +190,7 @@ A property is **behavioral** when it compiles into a set and so changes how name | `title_case_is_name` | behavioral | `suffix` | false | `TITLE_CASE_NAME_WORDS`, on a `generation` or a `credential` written as a word (`acronym = false`) only: says the word's Title case is its writing as a name, so where a name reading gates the word ([rules/S11](../../docs/design/rules/S11-suffix-word-that-is-also-a-name.md), a suffix word that is also a name), its writing leans: Title case is the name, lower case in a name of mixed case the suffix, capitals nothing ([rules/S6](../../docs/design/rules/S6-case-signal-at-the-suffix-slot.md), the case signal at the suffix slot), as in `Marie Fils` and `Alexandre Dumas fils`. Unwritten, a gated word's writing says nothing and the count decides, as for `Junior`, whose Title case is how the generation is written too; an agnomen's writing never speaks (#1039) | | `attached` | behavioral | `suffix`, `title` | absent | on a suffix word reading, `GLUED_HONORIFICS`: `{ side = "after" }` splits the word off the end of a name token, as in `田中さん` ([rules/W2](../../docs/design/rules/W2-glued-honorific-peel.md), the glued-honorific peel); on a one-word title reading, `GLUED_TITLES`: `{ side = "before" }` splits the title off the start of the name's first word, as in `นายสมชาย` ([rules/W6](../../docs/design/rules/W6-glued-title-peel.md), the glued-title peel) | | `shared` | behavioral | `name` | false | `SHARED_NAMES`: a name a community gives every member, written after the personal name and before a family name where there is one (Sikh `kaur` and `singh`), no personal or family name of the bearer's own: two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) and two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) neither take it nor complete one with it, so `Harpreet Kaur Dhillon` keeps middle `Kaur` under either, and a given name a particle completes ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md)) is never one, so `Kaur del Carmen García` keeps family `del Carmen García` by default (#704) | -| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `jesus`, `carmo`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share (decisions/P10, #704, #1118, #1122) | +| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `carmo`, `conceição`, `luz`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share (decisions/P10, #704, #1118, #1122) | | `completed_by` | behavioral | `bound_given` | none | `BOUND_PHRASES`: the words that complete the bound given name into one name unit past the first name word, a list (`completed_by = ["الله", "الرحمن"]` on `عبد`), each one word written folded: `سعيد عبد الله` reads family `عبد الله` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md), a bound given name and the word that completes it), while a word left off the list after it is a name of its own, as in `نوال عبد هاشم` (#694) | | `dotted` | behavioral | `title` | false | `DOTTED_TITLES`: the title abbreviates several words and is written with a full stop after each letter (`us`, `uk`, German `pd`), so a run of single letters joined by full stops that spells it is that title at the head of a name where a title the name keeps follows it, as in `U.S. District Judge Marc Treadwell`, and the initials it is written as otherwise (`U.S. Grant`) ([rules/H10](../../docs/design/rules/H10-title-written-as-a-run-of-letters.md), a title written as a run of letters). A title abbreviating one word (`dr`, `mr`, `lt`) is left unmarked, since two initials spell it (`D.R. Judge Smith` reads given 'D.', middle 'R. Judge', its given names 'D.R. Judge', no title) | | `capital_opening` | behavioral | `particle` | false | `CAPITAL_OPENING_PARTICLES`: the particle is written with a capital where the word before it in the family name is no particle, nor, where it opens the family name, the word written right before it in any role (`Van der Walt` keeps its lowercase `der`), as the Armenian priestly prefix is (`ter` and `der`: `LEVON TER PETROSYAN` repairs to `Levon Ter Petrosyan`), and keeps its lowercase after one (`Jan van der Berg`) ([rules/R12](../../docs/design/rules/R12-particle-opening-the-family-name-with-a-capital.md), a particle opening the family name with a capital); it moves no parse. A Dutch surname opened by `ter` takes the capital too (`Gerard Ter Borch`), a cost accepted in decisions/R12 | diff --git a/nameparser/vocab/pt-PT.toml b/nameparser/vocab/pt-PT.toml index 271ffc31d..4c0cde160 100644 --- a/nameparser/vocab/pt-PT.toml +++ b/nameparser/vocab/pt-PT.toml @@ -2,8 +2,7 @@ schema = 1 # European Portuguese: locales.PT_PT reads its names with two family names # (rules/O6), its given-name list keeping a given name out of the family. -# The words are readings Portugal's names support and Brazil's refute -# or are too few to judge, +# The words are readings Portugal's names support and Brazil's refute, # each `default = false`, so only a choice of pt-PT turns them on # (`rosario`, which es.toml reads by default, is here for a strict # choice); pt.toml holds the language's (decisions/O6 and decisions/P10, @@ -13,11 +12,19 @@ two_family_names = true [[word]] text = "carmo" -given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria do Carmo), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 11 names of Portugal's ORCID holders, 9 to the boxes they filled and 2 away from them, 82%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 6 to the boxes and 2 away, too few to judge (decisions/P10) (2026-11-19, #1189)" } +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria do Carmo), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 55 names of ORCID holders in Portugal over the whole extract, 48 to the boxes they filled and 7 away from them, 87%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 173 to the boxes and 201 away (decisions/P10) (2026-11-19, #1189)" } [[word]] -text = "jesus" -given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria de Jesus), on for Portugal alone, behind a first name a given name there and mostly a surname in Brazil: marked as P10's words are, under locales.PT_PT it moves 17 names of Portugal's ORCID holders, 16 to the boxes they filled and 1 away from them, 94%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 9 to the boxes and 21 away (decisions/P10) (2026-11-19, #1189)" } +text = "conceicao" +given = { default = false, after_particle = true, note = "the spelling of conceição without its accents, scored with it (Maria da Conceicao) (decisions/P10) (2026-11-19, #1189)" } + +[[word]] +text = "conceição" +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria da Conceição), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 64 names of ORCID holders in Portugal over the whole extract, 53 to the boxes they filled and 11 away from them, 83%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 132 to the boxes and 226 away (decisions/P10) (2026-11-19, #1189)" } + +[[word]] +text = "luz" +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria da Luz), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 14 names of ORCID holders in Portugal over the whole extract, 12 to the boxes they filled and 2 away from them, 86%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 20 to the boxes and 83 away (decisions/P10) (2026-11-19, #1189)" } [[word]] text = "rosario" @@ -25,4 +32,4 @@ given = { default = false, after_particle = true, note = "the spelling of rosár [[word]] text = "rosário" -given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria do Rosário), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 16 names of Portugal's ORCID holders, 15 to the boxes they filled and 1 away from them, 94%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves none (decisions/P10) (2026-11-19, #1189)" } +given = { default = false, after_particle = true, note = "the second of a compound given name written behind a particle (Maria do Rosário), on for Portugal alone: marked as P10's words are, under locales.PT_PT it moves 43 names of ORCID holders in Portugal over the whole extract, 41 to the boxes they filled and 2 away from them, 95%, past the 75% a reading needs; under locales.PT_BR on Brazil's it moves 15 to the boxes and 29 away (decisions/P10) (2026-11-19, #1189)" } diff --git a/tests/v2/cases.py b/tests/v2/cases.py index 22332349b..f9295047d 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -18076,17 +18076,17 @@ def _check_cjk_shape_purity(self) -> None: locale="pt_pt", classification="feat(#1189)", notes="P10: pt-PT.toml's rosário, on for Portugal's choice alone " "(#1189); locales.PT_PT was added by #1453"), - Case("portuguese_jesus_given_name_under_pt_pt", "Teresa de Jesus Sousa Pinto", - {"given": "Teresa", "middle": "de Jesus", "family": "Sousa Pinto"}, + Case("portuguese_conceicao_given_name_under_pt_pt", "Teresa da Conceição Sousa Pinto", + {"given": "Teresa", "middle": "da Conceição", "family": "Sousa Pinto"}, locale="pt_pt", classification="feat(#1189)", - notes="P10: pt-PT.toml's jesus, then O6 reads the two family names " - "after it"), + notes="P10: pt-PT.toml's conceição, then O6 reads the two family " + "names after it"), Case("portuguese_carmo_given_name_under_pt_pt", "MARIA DO CARMO PINTO", {"given": "MARIA", "middle": "DO CARMO", "family": "PINTO"}, locale="pt_pt", classification="feat(#1189)", notes="P10: pt-PT.toml's carmo, written in capitals"), - Case("portuguese_jesus_one_word_after_under_pt_pt", "Rita de Jesus Quaresma", - {"given": "Rita", "middle": "de Jesus", "family": "Quaresma"}, + Case("portuguese_luz_one_word_after_under_pt_pt", "Rita da Luz Quaresma", + {"given": "Rita", "middle": "da Luz", "family": "Quaresma"}, locale="pt_pt", classification="feat(#1189)", notes="P10 reads first, so O6 takes nothing into a family of one " "word behind the phrase"), @@ -18095,16 +18095,22 @@ def _check_cjk_shape_purity(self) -> None: {"given": "Rita", "middle": "do Carmo", "family": "Quaresma", "suffix": "Jr."}, locale="pt_pt", classification="feat(#1189)", notes="P10 behind a suffix comma, as without it"), - Case("portuguese_jesus_with_no_name_after_under_pt_pt", "Maria de Jesus", - {"given": "Maria", "family": "de Jesus"}, + Case("portuguese_luz_with_no_name_after_under_pt_pt", "Maria da Luz", + {"given": "Maria", "family": "da Luz"}, locale="pt_pt", classification="parity", notes="P10 completes a given name only with a name word after it, " - "so 'de Jesus' ending the name is the family (#1189)"), + "so 'da Luz' ending the name is the family (#1189)"), + Case("portuguese_jesus_family_under_pt_pt", "Maria de Jesus Pinto", + {"given": "Maria", "family": "de Jesus Pinto"}, + locale="pt_pt", classification="parity", + notes="'jesus' is left out of pt-PT.toml: 40 of Portugal's ORCID " + "names fixed to 17 broken, 70%, under P10's 75% (#1189)"), Case("portuguese_jesus_family_under_pt_br", "Maria de Jesus Pinto", {"given": "Maria", "family": "de Jesus Pinto"}, locale="pt_br", classification="parity", - notes="pt-PT.toml's reading is off for Brazil's choice, where " - "'de Jesus' behind a first name is mostly a surname (#1189)"), + notes="no reading marks 'jesus' for Brazil's choice, where " + "'de Jesus' behind a first name is mostly a surname, and " + "is left out for Portugal too (#1189)"), Case("portuguese_rosario_family_under_pt", "Maria do Rosário Pinto", {"given": "Maria", "family": "do Rosário Pinto"}, locale="pt", classification="parity", diff --git a/tests/v2/test_locales.py b/tests/v2/test_locales.py index 5d547797f..79151d312 100644 --- a/tests/v2/test_locales.py +++ b/tests/v2/test_locales.py @@ -2508,7 +2508,9 @@ def test_a_choice_word_rotator_is_moved_by_the_choice_alone(code: str) -> None: # Portugal's own given names P10 completes, which pt_br's and pt's # choices leave to the family (#1189) "Maria do Carmo Costa", # carmo - "Maria de Jesus Costa", # jesus + "Maria da Conceição Costa", # conceição + "Maria da Conceicao Costa", # conceicao + "Maria da Luz Costa", # luz "Maria do Rosário Costa", # rosário *_PT_TWO_FAMILY_NAMES, ] @@ -3732,7 +3734,7 @@ def test_the_portuguese_country_packs_read_two_family_names_and_pt_does_not() -> assert selected(locales.PT_PT.languages) == {"pt-PT", "pt"} assert (changed_words(selected(locales.PT_PT.languages)) - changed_words(selected(locales.PT.languages)) - == {"carmo", "jesus", "rosário"}) + == {"carmo", "conceicao", "conceição", "luz", "rosário"}) assert "pt-PT" not in selected(locales.PT_BR.languages) # a strict choice of Portugal reads them too, and the spelling without # the accent, which only es.toml's reading gave a plain choice; a @@ -3740,7 +3742,8 @@ def test_the_portuguese_country_packs_read_two_family_names_and_pt_does_not() -> for strict_pack, middle in ((locales.PT_PT, True), (locales.PT_BR, False), (locales.PT, False)): strict = parser_for(strict_pack, strict=True) - for phrase in ("do Rosario", "do Rosário", "de Jesus", "do Carmo"): + for phrase in ("do Rosario", "do Rosário", "do Carmo", "da Conceição", + "da Conceicao", "da Luz"): parsed = strict.parse(f"Rita {phrase} Quaresma") assert parsed.middle == (phrase if middle else ""), (strict_pack.code, phrase) pt, br, pp = (_require_packed(c) for c in ("pt", "pt_br", "pt_pt")) diff --git a/tools/differential/corpus_rules.jsonl b/tools/differential/corpus_rules.jsonl index 10c65ffbc..653a872cc 100644 --- a/tools/differential/corpus_rules.jsonl +++ b/tools/differential/corpus_rules.jsonl @@ -1270,11 +1270,11 @@ "Maria R d S" "Maria R y S" "Maria Rossi Dott.ssa" +"Maria da Conceição Pinto" "Maria da Piedade Costa" "Maria da Silva Santos" "Maria das Graças Silva" "Maria de Fatima Costa" -"Maria de Jesus Pinto" "Maria de Lurdes Costa" "Maria do Carmo Silva" "Maria do Carmo da Silva" @@ -1745,7 +1745,7 @@ "TER PETROSYAN, LEVON" "THE ROCK Mary" "Tariq Abdul Aziz" -"Teresa de Jesus Sousa Pinto" +"Teresa da Conceição Sousa Pinto" "The Hon. Justice Mary Smith" "The Hon. Wing Lau" "The Mahdi Muhammad Ahmad" diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index f10c9b8e9..96406fb07 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -3080,11 +3080,11 @@ {"name": "Maria Rossi Dott.ssa", "title": "Dott.ssa", "given": "Maria", "family": "Rossi", "initials": "M. R."} {"name": "Maria Silva", "given": "Maria", "family": "Silva", "initials": "M. S."} {"name": "Maria Wijaya", "given": "Maria", "family": "Wijaya", "initials": "M. W."} +{"name": "Maria da Conceição Pinto", "given": "Maria", "family": "da Conceição Pinto", "initials": "M. C. P."} {"name": "Maria da Piedade Costa", "given": "Maria", "family": "da Piedade Costa", "initials": "M. P. C."} {"name": "Maria da Silva Santos", "given": "Maria", "family": "da Silva Santos", "initials": "M. S. S."} {"name": "Maria das Graças Silva", "given": "Maria", "middle": "das Graças", "family": "Silva", "initials": "M. G. S."} {"name": "Maria de Fatima Costa", "given": "Maria", "middle": "de Fatima", "family": "Costa", "initials": "M. F. C."} -{"name": "Maria de Jesus Pinto", "given": "Maria", "family": "de Jesus Pinto", "initials": "M. J. P."} {"name": "Maria de Lurdes Costa", "given": "Maria", "middle": "de Lurdes", "family": "Costa", "initials": "M. L. C."} {"name": "Maria do Carmo Silva", "given": "Maria", "family": "do Carmo Silva", "initials": "M. C. S."} {"name": "Maria do Carmo da Silva", "given": "Maria", "middle": "do Carmo", "family": "da Silva", "initials": "M. C. S."} @@ -4334,7 +4334,7 @@ {"name": "Teitur Þórðarson", "given": "Teitur", "family": "Þórðarson", "initials": "T. Þ."} {"name": "Teodoro de Faria", "given": "Teodoro", "family": "de Faria", "initials": "T. F."} {"name": "Teresa Mañé i Miravet", "given": "Teresa", "family": "Mañé i Miravet", "initials": "T. M. M."} -{"name": "Teresa de Jesus Sousa Pinto", "given": "Teresa", "family": "de Jesus Sousa Pinto", "initials": "T. J. S. P."} +{"name": "Teresa da Conceição Sousa Pinto", "given": "Teresa", "family": "da Conceição Sousa Pinto", "initials": "T. C. S. P."} {"name": "Tewolde Berhan Gebre Egziabher", "given": "Tewolde", "middle": "Berhan Gebre", "family": "Egziabher", "initials": "T. B. G. E."} {"name": "Teógenes Díaz-Corralejo Fernández", "given": "Teógenes", "middle": "Díaz-Corralejo", "family": "Fernández", "initials": "T. D. F."} {"name": "Tham Jun", "given": "Tham", "family": "Jun", "initials": "T. J."} From 4c1d74e60051e783f1b5cef3af40378600870fd7 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 17:47:40 -0800 Subject: [PATCH 5/6] Say rosario is marked but not scored, and give luz one tier (#1189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every plain choice reads es.toml's rosario already, so the plain scores count rosário alone; the vocab README no longer lists luz as left out beside its new Portugal reading; docs/languages.rst says pt_pt reads the held-out records within 0.1 point of pt_br. Co-Authored-By: Claude Opus 5.5 --- .../decisions/P10-given-name-a-particle-completes.md | 2 +- docs/languages.rst | 7 +++++-- nameparser/vocab/README.md | 2 +- nameparser/vocab/pt-PT.toml | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/design/decisions/P10-given-name-a-particle-completes.md b/docs/design/decisions/P10-given-name-a-particle-completes.md index 879c8b6ed..b911b968d 100644 --- a/docs/design/decisions/P10-given-name-a-particle-completes.md +++ b/docs/design/decisions/P10-given-name-a-particle-completes.md @@ -53,7 +53,7 @@ Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `c - 2026-11-19 #1479 — THE FAMILY A PHRASE LEAVES IS DIVIDED AS ANY FAMILY IS. #1479 asked whether the second surname missing behind a P10 phrase (`María del Carmen García López` under `two_family_names`, surname2 '') was a defect or a decision. Neither this file nor decisions/O6 or decisions/R10 recorded a decision: the Accepted clause it rested on described how the parse got there, P2's chain `del Carmen García López` leaving O6 a family of two words that O6 took nothing into and so marked nothing in, and gave no reason to want it. A defect, then, fixed with #1456 by dividing every family by its own words (decisions/O6's 2026-11-19 #1456, #1479 entry): the family gives surname1 `García`, surname2 `López`. Measured on Spanish-speaking ORCID holders under `locales.ES`, the shape held 3,204 records whose family the parser read as the holder's family box, all but 7 (three name words behind the phrase) divided now. The clause is replaced by an example under the rule's O6 Precedence. - 2026-11-19 #1189 — PORTUGAL'S OWN GIVEN NAMES A PARTICLE COMPLETES. #1118 and #1122 pooled the bar over every Portuguese-speaking country, so a word written as a given name in Portugal and as a surname in Brazil was scored by both countries' names at once. #1453 added `pt-PT.toml` and `locales.PT_PT`, a choice Brazil's pack does not make (`pt-BR` selects `pt-BR` and `pt`, never `pt-PT`), so a reading can be on for Portugal alone. Each word is scored by #1122's bar (75% of the names it moves fixed, ten names or more), a word at a time, under the country's pack with and without the reading, over the country's records in the whole ORCID extract, since the Standing bar names the whole extract. - **First taken on the capped corpus, and superseded.** The words were first chosen on ORCID's capped corpus (`raw.jsonl`, at most 20,000 records a country: Portugal's 19,460 scored), where `rosário` 15 to 1, `jesus` 16 to 1 and `carmo` 9 to 2 passed and `conceição` 10 to 4 (71%) missed. The whole extract holds about five times Portugal's records, and there `jesus` fails and `conceição` and `luz` pass; the whole extract decides, being the population the bar names. Both tables are below. - - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 41 fixed to 2 broken (95%), `carmo` 48 to 7 (87%), `conceição` 53 to 11 (83%), `luz` 12 to 2 (86%). `rosario` and `conceicao`, the spellings without accents, are scored with their twins and marked with them. `es.toml`'s `rosario` reading is on by default and in every plain choice, and under a strict one only where `es` is chosen, so the reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before); a strict choice of `pt` or `pt-BR` still reads it as the family. + - **Marked**, in `pt-PT.toml`, `default = false`: `rosário` 41 fixed to 2 broken (95%), `carmo` 48 to 7 (87%), `conceição` 53 to 11 (83%), `luz` 12 to 2 (86%). `conceicao`, the spelling without accents, is scored with its twin and marked with it. `rosario` is marked with `rosário` but not scored: `es.toml`'s `rosario` reading is on by default and in every plain choice, so the plain scores above count the accented spelling alone, and a strict one reads it only where `es` is chosen, so the reading here keeps it under a strict choice of Portugal (`parser_for(locales.PT_PT, strict=True)` read `Maria do Rosario Carneiro` family 'do Rosario Carneiro' before); a strict choice of `pt` or `pt-BR` still reads it as the family. - **Left out:** `jesus`, 40 to 17 (70%), which the capped corpus had passed. Too few names to judge: `nazaré` 5 to 0, `assunção` 4 to 1, `anjos` 3 to 1, `dores`, `mercês` and `belém` 1 to 0 each, `penha` 0 to 1. `ó` (Nossa Senhora do Ó) is not part of this, being an Irish particle in `ga.toml`. - **Nothing for Brazil.** Under `locales.PT_BR` over Brazil's records in the whole extract every word fails: `rosário` 15 to 29, `jesus` 248 to 784, `carmo` 173 to 201, `conceição` 132 to 226, `luz` 20 to 83, `nazaré` 35 to 14 (71%, the nearest), `anjos` 29 to 180, `penha` 22 to 17, `dores` 19 to 12. `locales.PT_BR`, `locales.PT` and the default read no name differently (`tests/v2/test_locales.py` holds that pt-PT's choice alone changes the words, and a strict choice of each). - **Behind a particle only.** The reading is P10's, so a name ending with the phrase keeps it as the family (`Maria da Luz`, rules/P10's "A name word must be left for the family"), and a family comma reads it as before (`Costa, Maria da Conceição`). diff --git a/docs/languages.rst b/docs/languages.rst index 617c9346f..62047706f 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -535,8 +535,11 @@ with the filer, on records the list was not built from: - 67.2% - 2,853 -So Cape Verdean and São Toméan lists read better under ``pt_pt`` than -under ``pt``, and Angolan and Mozambican lists worse. +``pt_pt`` reads these records within 0.1 point of ``pt_br`` (Portugal +89.6%, Brazil 79.7%), its own given names behind a particle (``da +Conceição``) moving a few. So Cape Verdean and São Toméan lists read +better under ``pt_pt`` than under ``pt``, and Angolan and Mozambican +lists worse. Whether the switch helps also depends on who split the names. It gains most on names their bearers split themselves, as ORCID's are. diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index 257b4eed8..eaacb1af0 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -190,7 +190,7 @@ A property is **behavioral** when it compiles into a set and so changes how name | `title_case_is_name` | behavioral | `suffix` | false | `TITLE_CASE_NAME_WORDS`, on a `generation` or a `credential` written as a word (`acronym = false`) only: says the word's Title case is its writing as a name, so where a name reading gates the word ([rules/S11](../../docs/design/rules/S11-suffix-word-that-is-also-a-name.md), a suffix word that is also a name), its writing leans: Title case is the name, lower case in a name of mixed case the suffix, capitals nothing ([rules/S6](../../docs/design/rules/S6-case-signal-at-the-suffix-slot.md), the case signal at the suffix slot), as in `Marie Fils` and `Alexandre Dumas fils`. Unwritten, a gated word's writing says nothing and the count decides, as for `Junior`, whose Title case is how the generation is written too; an agnomen's writing never speaks (#1039) | | `attached` | behavioral | `suffix`, `title` | absent | on a suffix word reading, `GLUED_HONORIFICS`: `{ side = "after" }` splits the word off the end of a name token, as in `田中さん` ([rules/W2](../../docs/design/rules/W2-glued-honorific-peel.md), the glued-honorific peel); on a one-word title reading, `GLUED_TITLES`: `{ side = "before" }` splits the title off the start of the name's first word, as in `นายสมชาย` ([rules/W6](../../docs/design/rules/W6-glued-title-peel.md), the glued-title peel) | | `shared` | behavioral | `name` | false | `SHARED_NAMES`: a name a community gives every member, written after the personal name and before a family name where there is one (Sikh `kaur` and `singh`), no personal or family name of the bearer's own: two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) and two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) neither take it nor complete one with it, so `Harpreet Kaur Dhillon` keeps middle `Kaur` under either, and a given name a particle completes ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md)) is never one, so `Kaur del Carmen García` keeps family `del Carmen García` by default (#704) | -| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `carmo`, `conceição`, `luz`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share (decisions/P10, #704, #1118, #1122) | +| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `carmo`, `conceição`, `luz`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz`, left out by #704's given-box share, is marked for Portugal since #1189 (decisions/P10, #704, #1118, #1122) | | `completed_by` | behavioral | `bound_given` | none | `BOUND_PHRASES`: the words that complete the bound given name into one name unit past the first name word, a list (`completed_by = ["الله", "الرحمن"]` on `عبد`), each one word written folded: `سعيد عبد الله` reads family `عبد الله` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md), a bound given name and the word that completes it), while a word left off the list after it is a name of its own, as in `نوال عبد هاشم` (#694) | | `dotted` | behavioral | `title` | false | `DOTTED_TITLES`: the title abbreviates several words and is written with a full stop after each letter (`us`, `uk`, German `pd`), so a run of single letters joined by full stops that spells it is that title at the head of a name where a title the name keeps follows it, as in `U.S. District Judge Marc Treadwell`, and the initials it is written as otherwise (`U.S. Grant`) ([rules/H10](../../docs/design/rules/H10-title-written-as-a-run-of-letters.md), a title written as a run of letters). A title abbreviating one word (`dr`, `mr`, `lt`) is left unmarked, since two initials spell it (`D.R. Judge Smith` reads given 'D.', middle 'R. Judge', its given names 'D.R. Judge', no title) | | `capital_opening` | behavioral | `particle` | false | `CAPITAL_OPENING_PARTICLES`: the particle is written with a capital where the word before it in the family name is no particle, nor, where it opens the family name, the word written right before it in any role (`Van der Walt` keeps its lowercase `der`), as the Armenian priestly prefix is (`ter` and `der`: `LEVON TER PETROSYAN` repairs to `Levon Ter Petrosyan`), and keeps its lowercase after one (`Jan van der Berg`) ([rules/R12](../../docs/design/rules/R12-particle-opening-the-family-name-with-a-capital.md), a particle opening the family name with a capital); it moves no parse. A Dutch surname opened by `ter` takes the capital too (`Gerard Ter Borch`), a cost accepted in decisions/R12 | diff --git a/nameparser/vocab/pt-PT.toml b/nameparser/vocab/pt-PT.toml index 4c0cde160..fb44877b2 100644 --- a/nameparser/vocab/pt-PT.toml +++ b/nameparser/vocab/pt-PT.toml @@ -28,7 +28,7 @@ given = { default = false, after_particle = true, note = "the second of a compou [[word]] text = "rosario" -given = { default = false, after_particle = true, note = "the spelling of rosário without its accent, scored with it (Maria do Rosario): es.toml's reading is on by default and in every plain choice, and under a strict one only where es is chosen, so this reading keeps it under a strict choice of Portugal, which compiles no es.toml (decisions/P10) (2026-11-19, #1189)" } +given = { default = false, after_particle = true, note = "the spelling of rosário without its accent (Maria do Rosario), marked with it but not scored, since every plain choice reads it already: es.toml's reading is on by default and in every plain choice, and under a strict one only where es is chosen, so this reading keeps it under a strict choice of Portugal, which compiles no es.toml (decisions/P10) (2026-11-19, #1189)" } [[word]] text = "rosário" From a313eec6db75a31aa6d8e422076291fed8c8e9c9 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 17:48:56 -0800 Subject: [PATCH 6/6] Order the languages.rst sentences so 'So' follows the table, and say which way pt_pt differs (#1189) Co-Authored-By: Claude Opus 5.5 --- docs/languages.rst | 11 ++++++----- nameparser/vocab/README.md | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/languages.rst b/docs/languages.rst index 62047706f..c399c3fe1 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -535,11 +535,12 @@ with the filer, on records the list was not built from: - 67.2% - 2,853 -``pt_pt`` reads these records within 0.1 point of ``pt_br`` (Portugal -89.6%, Brazil 79.7%), its own given names behind a particle (``da -Conceição``) moving a few. So Cape Verdean and São Toméan lists read -better under ``pt_pt`` than under ``pt``, and Angolan and Mozambican -lists worse. +So Cape Verdean and São Toméan lists read better under ``pt_pt`` than +under ``pt``, and Angolan and Mozambican lists worse. ``pt_pt`` reads +Portugal's and Brazil's records 0.1 point below ``pt_br`` (89.6% and +79.7%): its own given names behind a particle (``da Conceição``), which +gain on Portugal's names as a whole, cost a few more of these records +than they fix. Whether the switch helps also depends on who split the names. It gains most on names their bearers split themselves, as ORCID's are. diff --git a/nameparser/vocab/README.md b/nameparser/vocab/README.md index eaacb1af0..9fe60c84e 100644 --- a/nameparser/vocab/README.md +++ b/nameparser/vocab/README.md @@ -190,7 +190,7 @@ A property is **behavioral** when it compiles into a set and so changes how name | `title_case_is_name` | behavioral | `suffix` | false | `TITLE_CASE_NAME_WORDS`, on a `generation` or a `credential` written as a word (`acronym = false`) only: says the word's Title case is its writing as a name, so where a name reading gates the word ([rules/S11](../../docs/design/rules/S11-suffix-word-that-is-also-a-name.md), a suffix word that is also a name), its writing leans: Title case is the name, lower case in a name of mixed case the suffix, capitals nothing ([rules/S6](../../docs/design/rules/S6-case-signal-at-the-suffix-slot.md), the case signal at the suffix slot), as in `Marie Fils` and `Alexandre Dumas fils`. Unwritten, a gated word's writing says nothing and the count decides, as for `Junior`, whose Title case is how the generation is written too; an agnomen's writing never speaks (#1039) | | `attached` | behavioral | `suffix`, `title` | absent | on a suffix word reading, `GLUED_HONORIFICS`: `{ side = "after" }` splits the word off the end of a name token, as in `田中さん` ([rules/W2](../../docs/design/rules/W2-glued-honorific-peel.md), the glued-honorific peel); on a one-word title reading, `GLUED_TITLES`: `{ side = "before" }` splits the title off the start of the name's first word, as in `นายสมชาย` ([rules/W6](../../docs/design/rules/W6-glued-title-peel.md), the glued-title peel) | | `shared` | behavioral | `name` | false | `SHARED_NAMES`: a name a community gives every member, written after the personal name and before a family name where there is one (Sikh `kaur` and `singh`), no personal or family name of the bearer's own: two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) and two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) neither take it nor complete one with it, so `Harpreet Kaur Dhillon` keeps middle `Kaur` under either, and a given name a particle completes ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md)) is never one, so `Kaur del Carmen García` keeps family `del Carmen García` by default (#704) | -| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `carmo`, `conceição`, `luz`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz`, left out by #704's given-box share, is marked for Portugal since #1189 (decisions/P10, #704, #1118, #1122) | +| `after_particle` | behavioral | `name` | false | `PARTICLE_GIVEN_NAMES`, on a `given` reading only: a given name written behind a particle as the second of a compound given name (`carmen` in `María del Carmen`): behind a one-word given name the particle run and the word are a middle name, though the chain would run on into the family, as in `María del Carmen García` ([rules/P10](../../docs/design/rules/P10-given-name-a-particle-completes.md), a given name a particle completes, which states the conditions), which two-given-name handling ([rules/O7](../../docs/design/rules/O7-two-given-names.md)) then takes into the given name and two-family-name handling ([rules/O6](../../docs/design/rules/O6-two-family-names.md)) leaves where it stands. A word is marked where, of the names its reading moves to the boxes their filers filled or away from them, at least 75% move to them, with ten such names or more: on by default where that holds over every language's countries pooled, written `default = false` in its language's file where it holds in that language's countries alone, for a choice of the language to turn on, or in a country's file where it holds in that country's names alone (`pt-PT.toml`'s `rosário`, `carmo`, `conceição`, `luz`, #1189), and left out where it fails (`kassia`); a word with fewer than ten such names keeps the tier an earlier measure gave it (`ribamar`, `piedade`), and `luz` was left out by #704's given-box share before #1189 (decisions/P10, #704, #1118, #1122) | | `completed_by` | behavioral | `bound_given` | none | `BOUND_PHRASES`: the words that complete the bound given name into one name unit past the first name word, a list (`completed_by = ["الله", "الرحمن"]` on `عبد`), each one word written folded: `سعيد عبد الله` reads family `عبد الله` ([rules/P12](../../docs/design/rules/P12-bound-given-name-and-the-word-that-completes-it.md), a bound given name and the word that completes it), while a word left off the list after it is a name of its own, as in `نوال عبد هاشم` (#694) | | `dotted` | behavioral | `title` | false | `DOTTED_TITLES`: the title abbreviates several words and is written with a full stop after each letter (`us`, `uk`, German `pd`), so a run of single letters joined by full stops that spells it is that title at the head of a name where a title the name keeps follows it, as in `U.S. District Judge Marc Treadwell`, and the initials it is written as otherwise (`U.S. Grant`) ([rules/H10](../../docs/design/rules/H10-title-written-as-a-run-of-letters.md), a title written as a run of letters). A title abbreviating one word (`dr`, `mr`, `lt`) is left unmarked, since two initials spell it (`D.R. Judge Smith` reads given 'D.', middle 'R. Judge', its given names 'D.R. Judge', no title) | | `capital_opening` | behavioral | `particle` | false | `CAPITAL_OPENING_PARTICLES`: the particle is written with a capital where the word before it in the family name is no particle, nor, where it opens the family name, the word written right before it in any role (`Van der Walt` keeps its lowercase `der`), as the Armenian priestly prefix is (`ter` and `der`: `LEVON TER PETROSYAN` repairs to `Levon Ter Petrosyan`), and keeps its lowercase after one (`Jan van der Berg`) ([rules/R12](../../docs/design/rules/R12-particle-opening-the-family-name-with-a-capital.md), a particle opening the family name with a capital); it moves no parse. A Dutch surname opened by `ter` takes the capital too (`Gerard Ter Borch`), a cost accepted in decisions/R12 |