Skip to content

Read two family names under locales.PT_BR and a new locales.PT_PT - #1481

Merged
derek73 merged 12 commits into
masterfrom
claude/issue-1453-pt-two-family-names-aaf6c0
Nov 19, 2026
Merged

derek73 merged 12 commits into
masterfrom
claude/issue-1453-pt-two-family-names-aaf6c0

Conversation

@derek73

@derek73 derek73 commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Closes #1453

What changes

  • locales.PT_BR reads two family names (Policy.two_family_names, rules/O6), from a [rules] table in nameparser/vocab/pt-BR.toml, and carries a Portuguese given-name list that keeps a second given name out of the family. parser_for(locales.PT_BR).parse("Ana Souza Lima") gives family Souza Lima, where 3.0 and 3.1 gave middle Souza, family Lima; Ana Beatriz Costa keeps family Costa.
  • New locales.PT_PT for names from Portugal: it chooses pt-PT, reads pt.toml's words as locales.PT does, and turns on the same switch with the same list. Its table is in a new nameparser/vocab/pt-PT.toml, which holds the [rules] table and no word. The name follows the existing country-pack convention: ES_AR and PT_BR use the BCP 47 tag with an underscore, upper-cased for the attribute (pt_pt / PT_PT). --locale pt-PT on the command line now names it, where before it was refused and told the user to use pt.
  • locales.PT is unchanged. pt.toml holds no table, rules_patch("pt") raises, and a test holds both. Spanish is the reverse: there the language pack carries the switch. The docs say why: pt is chosen for Portuguese names from any country, and Angolan and Mozambican names lose under the switch.
  • The list: nameparser/locales/_pt_given_names.py, 721 entries. It is generated by the new tools/pt_given_names.py from ORCID's given and family boxes (CC0), pooling Portugal and Brazil.
    • It uses only records past the first 3,000 of each country. Those first 3,000 are exactly the records config_diff.py score --cap 3000 reads, so the list is never scored on the records it was built from.
    • A word is listed if it has at least 5 uses and at least 70% of them are in the given box.
    • Each word written with ç is listed again with c (goncalo, constanca), as the Spanish lists do for ñ (Should "Maria Begona Lopez" under locales.ES keep Begona out of the family, as "María Begoña López" does? #1081).
    • Every word was read by hand, and none was removed; REMOVED is empty. The vocabulary filter took out dr.
    • CC0 asks for no credit, so the list is credited in its module's docstring only, as the group suggester's ORCID table is. It is not in README.rst's License section or _CREDITED; that section lists only the sources whose licences ask for credit.

Per-country figures

Measured with config_diff.py score, ORCID's boxes, every box agreeing, at most 3,000 records a country, none of them used to build the list.

  • Default and PT read these records alike, but for one Angolan and one Brazilian record.
  • PT_BR and PT_PT read them alike.
  • Fixed/broken are counted against the default.
Group Records Default / PT PT_BR / PT_PT Fixed / broken
ORCID Portugal 2,923 72.1% 89.7% 629 / 116
ORCID Brazil 2,850 50.3% 79.8% 1,017 / 176
ORCID Cape Verde 563 61.5% 80.5% 147 / 40
ORCID São Tomé 121 50.4% 71.1% 32 / 7
ORCID Guinea-Bissau 220 66.8% 72.3% 46 / 34
ORCID Timor-Leste 495 64.0% 67.1% 88 / 73
ORCID Angola 2,861 76.4% 65.3% 386 / 706
ORCID Mozambique 2,853 85.6% 67.2% 166 / 689
PatentsView Portugal, cap 3,000 3,000 57.5% 65.7% 731 / 483
PatentsView Brazil, cap 3,000 3,000 75.2% 61.4% 393 / 807
PatentsView Portugal, whole 3,576 57.6% 66.1% 869 / 564
PatentsView Brazil, whole 15,029 75.7% 60.2% 1,978 / 4,317
PSC Portuguese 2,996 59.2% 62.8% 732 / 626
PSC Brazilian 1,920 53.7% 62.9% 588 / 412

Brazilian and Portuguese inventors on US patents. The switch costs Brazilian inventors 15.6 points over the whole corpus (75.7% → 60.2%) and gains Portuguese inventors about 8.5 points (57.6% → 66.1%).

  • Every one of the 4,317 Brazilian records it breaks holds a single surname in the family box; 122 of them also have an agnomen or Jr. there.
  • In the other 4,195, the word the switch takes from the first-name box is:
    • mostly a family word in the list's build (a second surname, Eder Ferreira / Rangel): 2,696;
    • a word no build record holds, mostly Japanese or Italian given names (Jurandir Itizo / Yanagihara): 1,274;
    • a given name under the cut: 217.
  • So the shape is a filer putting one surname in the family box, as guessed; the word taken is mostly a middle surname, not a second given name.
  • The docs say this in the guidance on choosing a pack: choose pt_br or pt_pt for names whose family part is written whole, and keep pt for data filed with a single surname as the family name.

The cut

Lists were scored the same way (decisions/O6's entry has the full table).

  • One pooled list beats lists built per country: Portugal's own list reads fewer Portuguese records, and Brazil's own list gains 0.07 points in Brazil but loses 1.1 in Portugal.
  • 5 uses and a 0.7 share (721 entries) is within half a point of the best cut everywhere but PatentsView Brazil. There 3 × 0.5 gains 0.66 points, at 481 more words to read by hand.

What is left wrong, by shape (under PT_BR, cap 3,000)

Shape ORCID PT ORCID BR PV PT PV BR
family of 3+ surnames read as two 117 (4.0%) 268 (9.4%) 378 (12.6%) 78
a surname filed among the given names, taken 91 174 516 654
a word the build never saw, taken 28 36 78 266
a given name under the cut, taken (mateus, bernardo, tadeu) 15 26 26 53
a listed given name that is the first surname, kept out 15 29 11 18

Families of three or more surnames are not part of this change; they are #1482. They are the largest gap in ORCID Portugal and ORCID Brazil, and the switch broke none of them.

Moves on names as written

  • tse-donors, 848,351 Brazilian names. PT_BR against 3.1's pack moves 500,485 names, all into the family:
    • 418,432 take a word the list's build holds mostly as a family word (alves, pereira, silva);
    • 66,222 take a word it never saw;
    • 15,249 take a given name under the cut (cezar, tadeu, bernardo);
    • 491 take an initial or e.
  • Committed corpora. PT_BR moves 1,543 of 7,644 names, nearly all non-Portuguese names of three or more words: the switch's declared cost.
  • CLDR's pt file.
    • Its native given-first renderings are unchanged.
    • Two foreign renderings newly disagree.
    • Three renderings that already disagreed now also disagree in the family: a title after a family-first family is taken as a second surname, and a given name is taken in the given-first foreign one.
    • cldr_agreement_locales.json is re-recorded.
  • The default parse and locales.PT move nothing. snapshot.jsonl gains one rule example text, rules/S11's JOSE CARLOS F, and changes no reading.
  • Pickles. A locales.PT_BR or parser pickled by 3.1 still loads, and reads as 3.1 did (checked against the 3.1.0 wheel). docs/migrate.rst says so.

Also changed

  • Layering. tests/v2/test_layering.py's data-module rule now lets a language pack's country packs import its data module too (_pt_given_names.py → pt_br, pt_pt). This widens the check, so es_ar may now import _es_given_names as well. The narrower rule's refusals keep their rows: pt → _es_given_names and es → _es_ar_given_names, plus a new pt_br → _es_given_names.
  • config_diff.py.
    • LANGUAGES_OF["PT"] is ("pt-PT",), like Brazil's pt-BR, so --languages pt no longer reaches Portugal's records.
    • gap_specs reads a plain choice of a rules-only file's tag as its pack, not the default.
    • cldr_agreement.py lists PT_PT in NO_CLDR, since CLDR 48 has no pt_PT names file.
  • rules/S11. Under PT_BR, JOSE CARLOS SILVA F now reads family SILVA F. The example is kept with that reading, and JOSE CARLOS F is added for the letter alone; decisions/S11 carries a dated entry.
  • Docs.
    • docs/languages.rst has a rewritten section on Portuguese two family names, with doctests, a per-country table and the PatentsView guidance.
    • docs/locales.rst updates the pack table and the Portuguese section.
    • docs/migrate.rst adds "Changed in 3.2" for PT_BR.
    • The release log has a bullet.
    • policy.rst, usage.rst and customize.rst mention the new pack.
  • Design records. decisions/O6 has a dated 2026-11-19 entry, Standing lines, and head notes on the 3g and Add locales.ES_AR, Spanish with a given-name list cut for Argentina #1061 entries. mechanisms.md (LOCALE-PACKS-PURE-DATA), the AGENTS.md files and nameparser/vocab/README.md are updated.

Checks

  • uv run pytest passes (50,929 after merging master, which added locales.MY, Add locales.MY, a Burmese pack: U and Daw as titles, nine syllables kept name words #1480).
  • uv run pytest -n0 -m serial passes.
  • The full suite passes on Python 3.15.
  • uv run mypy and uv run ruff check pass.
  • sphinx-build -b doctest docs and python -m doctest README.rst pass.
  • The suite was run without the ja extra, which this environment lacks.
  • New cases.py rows were run against master. The five feat(#1453) rows fail there: four PT_BR rows read otherwise, and the PT_PT row has no pack on master. The three rows pinning unchanged readings under PT and PT_BR (the language pack, the list's veto, a particle family) read the same on master; the c-spelling row is PT_PT's.

Reviews

  • pr-review-toolkit: code-reviewer, pr-test-analyzer and comment-analyzer.
  • design-docs-reviewer. Axes 1, 2, 3, 4, 5, 6, 7, 10 and 12 were run. Axes 8, 9 and 11 were skipped as inapplicable.
  • Fix commits. Each was reviewed in turn, the last included:
    • 0eaca97 (code-reviewer);
    • 467f96a (design-docs-reviewer);
    • 25ea585, 91aa50f and 7ede310 (code-reviewer);
    • d44a035 and c2ee905 (comment-analyzer); the next commit applies that review's two corrections in its own verified wording.
    • The merge of master (code-reviewer): every conflicted hunk keeps both packs, and the generated files equal what their generators write.
  • type-design-analyzer and silent-failure-hunter were not run: the PR adds no types, and no error handling beyond the tool's refusal of an empty corpus.

Decisions (all three decided 2026-11-19)

  1. PT_BR ships with the switch on, as built. The PatentsView Brazil loss is accepted, and the pack knowingly misses the 2026-11-04 country-pack measure there. The loss is a filing convention (one surname in the family box) that no list can tell apart, while the populations whose names were split by the person or their own filer (ORCID, PSC) gain. decisions/O6's 2026-11-19 entry records this; the docs keep the guidance to use pt for data filed with a single surname.
  2. The cut stays at 5 uses and a 0.7 share.
  3. Families of three or more surnames are Should a Portuguese family of three or more surnames be read whole? (Ana Souza Lima Rocha gives middle Souza, family Lima Rocha under locales.PT_BR) #1482. The decisions entry and the three-surname case row point there.

🤖 Generated with Claude Code

derek73 and others added 10 commits November 19, 2026 12:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, missing test rows (#1453)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n to keep pt (#1453)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ale pt-PT example (#1453)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73 derek73 added this to the 3.2 milestone Nov 19, 2026
@derek73 derek73 added vocabulary Fixed by a word-list entry: per-word vocabulary and language packs locale-packs Locale packs and language choices (nameparser.locales) name-order Name order, family-first and two family names (rules/O) labels Nov 19, 2026
@derek73 derek73 self-assigned this Nov 19, 2026
derek73 and others added 2 commits November 19, 2026 13:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73
derek73 merged commit d12af9d into master Nov 19, 2026
14 checks passed
@derek73
derek73 deleted the claude/issue-1453-pt-two-family-names-aaf6c0 branch November 19, 2026 21:30
derek73 added a commit that referenced this pull request Nov 19, 2026
…1456, #1479) (#1485)

* Divide a family of two surnames by its own words, behind a comma too (#1456, #1479)

Under two_family_names the surname1/surname2 views now divide a family
of two surnames however it was read: before a family comma, where a
particle chain made it, behind a given name a particle completes
(rules/P10), and the family O9's capitals named. One function,
_post_rules._divide_family, decides for every path, O6's take
included: P1's fold units over the family in written order, a bound
given-name word counted with the word it completes, exactly two
marked, a first unit of particles alone, a connective, a shared name
and a Turkic father's name with its marker left whole. No field moves;
nothing moves with the switch off.

rules/O6, R10, R11, P10, O7 and O9 amended, with dated decisions
entries; the connective and the one-word hyphen question stays open in
decisions/R10. Case rows gain an optional views mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Measure the division under the Portuguese packs #1481 turned on; list them (#1456, #1479)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Record the four questions the PR raised as decided (#1456, #1479)

The capitals family is divided, the moves the issues did not ask for
are accepted, a lone particle ending a family stays the second unit,
and the connective and the one-word hyphen stay open; decided
2026-11-19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* State the decided trailing particle in rules/O6 and its Standing line (#1456, #1479)

The review of the decision commit found the lone particle ending a
family decided only in a Log item, the rule's wording predicting a
division for Smith van der, Juan, which the code leaves whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

locale-packs Locale packs and language choices (nameparser.locales) name-order Name order, family-first and two family names (rules/O) vocabulary Fixed by a word-list entry: per-word vocabulary and language packs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should locales.PT turn on two_family_names? Maria Santos Silva reads family Silva under the pack, where Portugal's own boxes say Santos Silva

1 participant