Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions AGENTS.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ Why the maintainer makes the changes

Most changes here also move documented rules, the design records and a
snapshot of thousands of parsed names. The maintainer checks every change
against about 30 million records of real names from thirteen sources
(election candidates, donors, researchers, patent inventors, company filings).
against about 9 million records of real names from sixteen sources
(election candidates, donors, researchers, patent inventors, company filings;
counted 2026-11-16).
The tools that fetch them are in this repository, but the names are not: the
cache is about 12 GB, and one source alone takes about twelve hours to
download. A change that passes the committed tests can still move thousands
Expand Down
33 changes: 31 additions & 2 deletions docs/migrate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,11 @@ that wrote it:
- loads
- loads
- Nothing
* - ``Policy``, ``PolicyPatch``, and anything holding a ``Lexicon``
- 3.1
- ``ValueError``
- loads
- Keep a 3.0 copy while 3.0 must read it (below)
* - ``ParsedName``
- 2.x
- loads, rendering as 2.x did
Expand All @@ -729,8 +734,9 @@ that wrote it:
* - any of the rows above but the first
- 3.0
- loads
- loads
- Nothing
- loads, keeping 3.0's vocabulary, save a caller's word written with a
tatweel (below)
- Build a new ``Parser()`` for 3.1's readings

A ``HumanName`` or a ``Constants``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -761,6 +767,29 @@ loads it depends on the release that wrote it:
A re-pickled object keeps the vocabulary it was first pickled with, not
this release's; build a new ``Parser()`` for that.

Between 3.0 and 3.1
~~~~~~~~~~~~~~~~~~~

A pickle keeps the vocabulary of the release that wrote it. A
``Parser`` or locale pack pickled by 3.0 loads under 3.1 and reads and
matches as 3.0 did: it reads ``Md. Rahim Uddin`` with the title
``Md.``, does not split the Thai title off ``นายสมชาย``, finds no
familiar form between ``Bill`` and ``William``, and a pickled
``locales.NE`` lacks the ``initials_as_family`` 3.1 gives it. Build the
object again under 3.1 to read the 3.1 way.

A 3.0 ``Lexicon`` or ``Parser`` holding a word a caller added with an
Arabic tatweel (``ـ``) raises ``ValueError`` under 3.1, which deletes
the tatweel when it normalizes a word (:issue:`1151`): build it again
with the same ``add()`` calls.

The other way, 3.0.x refuses with ``ValueError`` anything holding a
``Lexicon``, ``Policy`` or ``PolicyPatch`` pickled by 3.1, a bare
``Policy()`` and a locale pack included: 3.1's vocabulary has readings
3.0 does not take, its ``Policy`` has two new fields, and
``Script.CYRILLIC`` is new. A ``ParsedName`` or ``Ambiguity`` loads
both ways.

Pickles between 2.x releases
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion docs/release_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Release Log

- **Change README's License section to credit the sources nameparser's word lists were measured on.** The ``License-Expression`` stays ``LGPL-2.1-or-later``, as in every release through 3.0.1: no list copied whole from a third party ships, the familiar forms being pairs the project found in ORCID and US public records and reviewed. No release shipped data from nam_dict (GNU FDL) or Old Dominion University's nicknames list (Apache 2.0), which the 3.1 cycle's familiar forms, and for nam_dict the suggester's table, held until they were rebuilt. The section names Spain's INE and Taiwan's surname ranking, whose counts two locale lists were measured on. :issue:`1370`, :issue:`1382`
- **Change locales.ZH's simplified surnames to the ones Wikidata's family-name items write, no longer Unihan's.** ``parser_for(locales.ZH).parse("谌龙")`` gives family ``谌龙``, undivided, where 2.5.0 through 3.0.1 gave family ``谌``, given ``龙``; seven simplified forms no Wikidata item attests (买, 厐, 盖, 篮, 芈, 诸, 谌) left the list, and their traditional forms (``諶龍``) still divide. 2.5.0 through 3.0.1 shipped those forms from Unihan, whose Unicode License v3 their metadata did not name; 3.1 ships no Unihan-derived data. :issue:`1370`
- **Remove loading a Lexicon, Parser or locale pack pickled by 2.x, which 3.0 deprecated.** ``pickle.loads`` of a ``Parser`` pickled by 2.8.0 raises ``ValueError`` saying to re-pickle it under 3.0, where 3.0.x loaded it with a ``DeprecationWarning``; the error for a 2.x ``Lexicon`` spelling now names :doc:`migrate`'s table rather than each word's calls. A ``Lexicon``, ``Parser`` or locale pack pickled by 3.1 does not load under 3.0.x, which refuses the readings 3.1 adds (a ``same_as`` on a title reading, or naming several words) and its new ``Policy`` fields. :issue:`1003`
- **Remove loading a Lexicon, Parser or locale pack pickled by 2.x, which 3.0 deprecated.** ``pickle.loads`` of a ``Parser`` pickled by 2.8.0 raises ``ValueError`` saying to re-pickle it under 3.0, where 3.0.x loaded it with a ``DeprecationWarning``; the error for a 2.x ``Lexicon`` spelling now names :doc:`migrate`'s table rather than each word's calls. A ``Lexicon``, ``Parser``, locale pack or ``Policy`` pickled by 3.1 does not load under 3.0.x; :ref:`migrate-pickles` lists what loads where. :issue:`1003`
- **Change PolicyPatch.script_orders to merge by script.** ``Policy().patched(PolicyPatch(script_orders={Script.HAN: GIVEN_FIRST}))`` keeps the Hangul and hiragana entries beside its Han one, where 2.1.0 through 3.0.1 replaced the whole table with the patch's; an empty patch no longer clears the table, which ``Policy(script_orders=())`` on the base parser does. A pack can now add one script's order without erasing a caller's own, and ``parser_for`` warns where two packs set one script differently. :issue:`1237`
- **Add locales.MN, a Mongolian pack.** ``parser_for(locales.MN).parse("Батын Сүхээ")`` gives family ``Батын``, the father's name, given ``Сүхээ``, where the default, as 1.4.0 through 3.0.1, gives given ``Батын``, family ``Сүхээ``. It reads a name written wholly in Cyrillic family first with the given name last, Russian and Kazakh names included, so keep it for Mongolian data; a romanized name keeps the caller's order, since Mongolians mostly write their names given-first in Latin letters. See :ref:`mongolian-names`. :issue:`1237`
- **Fix a Kyrgyz name with no surname reading the patronymic marker alone as the family under locales.TR_AZ.** ``parser_for(locales.TR_AZ).parse("Bekmyrza Cholponbai uulu")`` gives given ``Bekmyrza``, family ``Cholponbai uulu``, where 1.4.0 (with Turkic handling) through 3.0.1 gave middle ``Cholponbai``, family ``uulu``; a name of three name words ending in a standalone marker (``kyzy``, ``oğlu``, ``qizi``) reads the same way, and two still read the marker alone (``Cavad oğlu``). :issue:`1187`
Expand Down
2 changes: 1 addition & 1 deletion nameparser/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Read a generated grid's moves by SHAPE, not by corpus membership: #614's first d

### Heads and title runs

#614's second review found two gaps. The first was a shape: no grid put TWO words that are both a title and a particle at the head (`Freiherr St van Berg MA`, where an index into the pieces was applied to a merged view of them -- `TITLES ∩ particles_ambiguous` is `{freiherr, st}` with the ranks `graf`, `gräfin`, `fürst` and `prinz` since #709, so put `Freiherr` and `St` (and one rank) in every head list, each in its bare and its period-marked spelling -- #637's grid had `St` and `Freiherr` alone and missed that `St.` and `Freiherr.` are declined by the bound join and then attached by P6). #701's review added one: put a title/suffix dual (`Ms`, `Sr.`, `Cpl`) SECOND in a title run, behind an ordinary title. A stop that asks only "is this word suffix vocabulary" passes every row that opens with the dual and fails `Rev. Sr. Smith, Mary`; it was found by comparing `T Smith, John` against `T John Smith` over every title word, and a comma-versus-comma-less comparison is the cheap check for any rule that moves a word between the two slots.
#614's second review found two gaps. The first was a shape: no grid put TWO words that are both a title and a particle at the head (`Freiherr St van Berg MA`, where an index into the pieces was applied to a merged view of them -- `TITLES ∩ particles_ambiguous` is `{freiherr, st}` with the ranks `graf`, `gräfin`, `fürst` and `prinz` since #709 and the Armenian `տեր` since #1320 (2026-11-16, `sorted(L.titles & L.particles_ambiguous)` with `L = Parser().lexicon._sets`), so put `Freiherr` and `St` (and one rank) in every head list, each in its bare and its period-marked spelling -- #637's grid had `St` and `Freiherr` alone and missed that `St.` and `Freiherr.` are declined by the bound join and then attached by P6). #701's review added one: put a title/suffix dual (`Ms`, `Sr.`, `Cpl`) SECOND in a title run, behind an ordinary title. A stop that asks only "is this word suffix vocabulary" passes every row that opens with the dual and fails `Rev. Sr. Smith, Mary`; it was found by comparing `T Smith, John` against `T John Smith` over every title word, and a comma-versus-comma-less comparison is the cheap check for any rule that moves a word between the two slots.

### A report's field

Expand Down
2 changes: 1 addition & 1 deletion nameparser/_pipeline/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The decision site also has the token index and the detail text in hand, which th

**If a fork's two branches are taken in DIFFERENT stages, every one of them needs the emitter** -- `PARTICLE_OR_GIVEN` is decided in `_assign` when the ambiguous particle stays a lone leading piece, in `_group` when something shifts it off the name's leading piece and the prefix chain claims it, and wherever P6's attachment takes a trailing particle into the family -- in `_assign` after a family comma (since #613, and behind an empty part before the comma since #892), in `post_rules` at the end of a name read family-first (#467) -- so every one of them reports; for two years only the first did.

What can still do the shifting is narrow, and #367 is why: a plain title no longer can (`Dr. Van Johnson` reads as `Van Johnson` does and reports from `_assign`), so the `_group` emitter needs a word that is BOTH a title and a particle — measured, `TITLES ∩ particles_ambiguous` is `{freiherr, st}` in the default vocabulary, and the ranks `graf`, `gräfin`, `fürst` and `prinz` since #709 (2026-11-04) (`do` left TITLES in #296's audit; the particle-line block in decisions/vocabulary-exclusions records the before and after), plus any overlap a caller's config creates — standing ahead of the chained particle as the LEADING NAME word. Titles may precede it, so `Dr. St van Johnson` reaches the emitter and `St van Johnson` does too; a given name may not, so `Jan Freiherr von Richthofen` does not reach it while `Freiherr von Richthofen` and `Dr. Freiherr von Richthofen` do. Two shapes that look like they should reach it and do NOT, both measured by stepping `STAGES` and watching where `ambiguities` grows: `Dr. Do van Johnson` and `Do St Johnson` report from `assign`, not `group`, because `do` is no longer a title and so stays the leading name piece assign reports on — a both-vocabulary word CHAINED (`Jan St Johnson`) reports nothing at all. When checking whether that emitter is dead, a both-vocabulary word in the leading name position is the thing to look for, and the answer is that it is not dead.
What can still do the shifting is narrow, and #367 is why: a plain title no longer can (`Dr. Van Johnson` reads as `Van Johnson` does and reports from `_assign`), so the `_group` emitter needs a word that is BOTH a title and a particle — measured, `TITLES ∩ particles_ambiguous` is `{freiherr, st}` in the default vocabulary, the ranks `graf`, `gräfin`, `fürst` and `prinz` since #709, and the Armenian `տեր` since #1320 (2026-11-16, `sorted(L.titles & L.particles_ambiguous)` with `L = Parser().lexicon._sets`) (`do` left TITLES in #296's audit; the particle-line block in decisions/vocabulary-exclusions records the before and after), plus any overlap a caller's config creates — standing ahead of the chained particle as the LEADING NAME word. Titles may precede it, so `Dr. St van Johnson` reaches the emitter and `St van Johnson` does too; a given name may not, so `Jan Freiherr von Richthofen` does not reach it while `Freiherr von Richthofen` and `Dr. Freiherr von Richthofen` do. Two shapes that look like they should reach it and do NOT, both measured by stepping `STAGES` and watching where `ambiguities` grows: `Dr. Do van Johnson` and `Do St Johnson` report from `assign`, not `group`, because `do` is no longer a title and so stays the leading name piece assign reports on — a both-vocabulary word CHAINED (`Jan St Johnson`) reports nothing at all. When checking whether that emitter is dead, a both-vocabulary word in the leading name position is the thing to look for, and the answer is that it is not dead.

The stage-ownership map in `tests/v2/pipeline/test_state.py` must list `ambiguities` for each such stage, and it passes vacuously until a case row exercises the path, so add the row too. Report BOTH directions of a two-way fork — "John Smith V" (read as a suffix) and "John V" (read as the family name) are equally guesses.

Expand Down
2 changes: 1 addition & 1 deletion nameparser/vocab/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Loaded when a session reads a vocabulary TOML file. The steps for adding a word

## Step 1: its other readings

First check the word's OTHER readings: `uv run python tools/vocab/query.py --word <word>` lists every reading and exclusion of it in every file, which is where the overlaps between categories now show. Real overlaps exist: `st`/`freiherr` and the ranks `graf`, `gräfin`, `fürst`, `prinz` (#709) ∈ `PARTICLES` ∩ `TITLES`, and `do`/`mc`/`vd` ∈ `PARTICLES` ∩ `SUFFIX_ACRONYMS`; `abd` = "ABD" ∈ `SUFFIX_ACRONYMS`; `abu` ∈ `PARTICLES` ∩ `BOUND_GIVEN_NAMES` (position-dependent: leading token → given-name join, mid-name → family-name join). Usually position-dependent and harmless, but can force a guard or an exclusion (the `last_base` all-particles guard; `abd`, kept out of `BOUND_GIVEN_NAMES` until decisions/P5 found the credential collision cost nothing at either end).
First check the word's OTHER readings: `uv run python tools/vocab/query.py --word <word>` lists every reading and exclusion of it in every file, which is where the overlaps between categories now show. Real overlaps exist: `st`/`freiherr`, the ranks `graf`, `gräfin`, `fürst`, `prinz` (#709) and the Armenian `տեր` (#1320) ∈ `PARTICLES` ∩ `TITLES` (2026-11-16, `sorted(L.titles & L.particles)` with `L = Parser().lexicon._sets`), and `do`/`mc`/`vd` ∈ `PARTICLES` ∩ `SUFFIX_ACRONYMS`; `abd` = "ABD" ∈ `SUFFIX_ACRONYMS`; `abu` ∈ `PARTICLES` ∩ `BOUND_GIVEN_NAMES` (position-dependent: leading token → given-name join, mid-name → family-name join). Usually position-dependent and harmless, but can force a guard or an exclusion (the `last_base` all-particles guard; `abd`, kept out of `BOUND_GIVEN_NAMES` until decisions/P5 found the credential collision cost nothing at either end).

## Step 2: real names, not memory

Expand Down
Loading
Loading