Skip to content

Commit c5e58aa

Browse files
derek73claude
andauthored
Add an ORCID surname table to the group suggester (#1364) (#1484)
* Add an ORCID surname table to the group suggester (#1364) COMMON_SURNAMES: every word ORCID's holders typed in the family-name box 100 times or more and in the given-name box in at most 5% of their uses, less the other tables' words, the titles and suffixes the given names refuse, the lexicon's particles, conjunctions, bound given names, maiden markers and Hangul surnames, and the Turkic patronymic markers: 559 words, mostly Spanish. It votes with the romanized table as SURNAMES, under the surname signal's rules. Where a decided East Slavic rule meets a family-first order the votes decide, a FAMILY_FIRST_GIVEN_LAST base gets FAMILY_FIRST, whose reading leaves the patronymic where it is written. suggest_measure.py gains Spanish-, Portuguese- and Filipino-language populations and two of given names that are surnames (pv-surname-given, pv-listed-given). Measured at 5% and 12%; 5% ships, 12% is open (decisions/group-suggestion, 2026-11-19 #1364). No parse moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Skip the suggest_measure tests reading the checkout's tables outside a checkout (#1364) _script_tables loads nameparser/config/_order_names.py by its checkout path, which the installed-package layout does not hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d12af9d commit c5e58aa

15 files changed

Lines changed: 792 additions & 106 deletions

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎docs/design/decisions/group-suggestion.md‎

Lines changed: 30 additions & 10 deletions
Large diffs are not rendered by default.

‎docs/getting-started.rst‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ it, and ``suggestion.base`` is the parser you started from:
114114
>>> print(suggestion)
115115
Suggested for 5 names (base: Parser(Lexicon(default), Policy())):
116116
name_order FAMILY_FIRST 4 for, 0 against, 1 no evidence
117-
surname FAMILY_FIRST 3
117+
surname FAMILY_FIRST 4
118118
given-name FAMILY_FIRST 2
119119
patronymic_rules unchanged (none) no evidence
120120
initials_as_family unchanged (False) no evidence
@@ -125,10 +125,10 @@ parser has: all five names are in mixed case with no word in capitals,
125125
so they are evidence for leaving ``capitals_as_family`` off.
126126

127127
Four names vote for family first: ``Kim``, ``Wang`` and ``Nguyen`` by
128-
the romanized surname in front, ``Garcia Emily`` by the common given
129-
name at the end (``Garcia`` is not one of the surnames ``suggest``
130-
reads). ``Wang Xiaoming`` carries both kinds, so the surname and
131-
given-name rows count it once each.
128+
the common surname in front, ``Garcia Emily`` by the surname in front
129+
and the common given name at the end. ``Wang Xiaoming`` and ``Garcia
130+
Emily`` carry both kinds, so the surname and given-name rows count each
131+
of them once.
132132

133133
``Taylor Morgan`` gives no evidence, so the suggested parser reads it
134134
family first only because the rest of the list is written that way;
@@ -140,9 +140,10 @@ disagrees <suggest-disagreeing>`).
140140
What ``suggest`` decides
141141
~~~~~~~~~~~~~~~~~~~~~~~~
142142

143-
The evidence is in the names themselves: a common romanized Chinese,
144-
Korean or Vietnamese surname, or a common given name that is rarely
145-
a surname (``Mary``, not ``James``), at one end; a
143+
The evidence is in the names themselves: a common surname (a
144+
romanized Chinese, Korean or Vietnamese one, or one rarely written as
145+
a given name, ``Garcia``), or a common given name that is rarely a
146+
surname (``Mary``, not ``James``), at one end; a
146147
family name written in capitals; a lowercase particle; initials after
147148
the name, as a bibliography writes them (:ref:`suggest-evidence`).
148149

‎docs/release_log.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Release Log
44

55
nameparser 3.2 is under development.
66

7+
- **Change Parser.suggest() to read common surnames beyond the Chinese, Korean and Vietnamese ones, most of them Spanish.** ``Parser().suggest(["García Zorvan", "Quispe Qelliot"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST)``, where 3.1.0 found no evidence in either name and suggested nothing; a list of two to five Spanish names written family first now moves a given-first parser more often. :issue:`1364`
78
- **Fix Malaysian a/l, a/p and anak, which read as middle names and cut the father's name.** ``parse("KUMAR A/L RAJAN NAIDU")`` gives family ``A/L RAJAN NAIDU`` and the same ``patronymic``, as ``bin`` reads, where 1.4.0 through 3.1.0 gave middle ``A/L RAJAN``, family ``NAIDU``; ``anak`` opening a name written without a comma (Balinese ``Anak Agung``) is left to position, the given name by default, and reported. :issue:`1468`
89
- **Fix Dutch Oude, which read as a middle name.** ``parse("Piet Oude Luttikhuis")`` gives family ``Oude Luttikhuis``, where 1.4.0 through 3.1.0 gave middle ``Oude``, family ``Luttikhuis``; ``Oude`` opening a name stays the given name, reported, being a rare Dutch given name too. :issue:`1455`
910
- **Add locales.NL, which reads ten as a family-name particle.** ``parser_for(locales.NL).parse("Jan ten Brink")`` gives family ``ten Brink``, where the default, as 1.4.0 through 3.1.0, gives middle ``ten``; a ``Ten`` opening a name stays the given name, reported, save under ``strict=True``. It also takes a Chinese given-name syllable inside a name into the family (``Kheng Ten Choo`` gives family ``Ten Choo``), and choosing Dutch reads ``VD`` as ``van der`` rather than the credential (``John Smith, VD`` gives family ``John Smith VD``). See :ref:`dutch-particles`. :issue:`1455`

‎docs/suggest.rst‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ the settings its names agree on, and a parser that reads with them.
2828
'Morgan'
2929

3030
Four names vote for family first: ``Kim``, ``Wang`` and ``Nguyen`` by
31-
the romanized surname in front, ``Garcia Emily`` by the common given
32-
name at the end; ``Wang Xiaoming`` carries both, so each signal's row
33-
counts it. ``Taylor Morgan`` gives no evidence: it is read family
31+
the common surname in front, ``Garcia Emily`` by the surname in front
32+
and the common given name at the end; ``Wang Xiaoming`` and ``Garcia
33+
Emily`` carry both, so each signal's row counts them. ``Taylor Morgan`` gives no evidence: it is read family
3434
first because the list is, and nothing in the name can confirm that.
3535

3636
Each name votes on its order from the evidence it carries
@@ -113,7 +113,7 @@ the names that disagree with it:
113113
>>> print(suggestion)
114114
Suggested for 5 names (base: Parser(Lexicon(default), Policy())):
115115
name_order FAMILY_FIRST 4 for, 0 against, 1 no evidence
116-
surname FAMILY_FIRST 3
116+
surname FAMILY_FIRST 4
117117
given-name FAMILY_FIRST 2
118118
patronymic_rules unchanged (none) no evidence
119119
initials_as_family unchanged (False) no evidence
@@ -179,7 +179,7 @@ The report counts it as ``against`` and names it on its last line:
179179
>>> print(mixed)
180180
Suggested for 6 names (base: Parser(Lexicon(default), Policy())):
181181
name_order FAMILY_FIRST 4 for, 1 against, 1 no evidence
182-
surname FAMILY_FIRST 3
182+
surname FAMILY_FIRST 4
183183
given-name FAMILY_FIRST 2
184184
given-name GIVEN_FIRST 1
185185
patronymic_rules unchanged (none) no evidence
@@ -249,7 +249,7 @@ A setting whose votes fall short of its threshold above keeps the
249249
base parser's value rather than a guess, whatever the other settings
250250
decide. Where every setting falls short, or no name in the list
251251
carries evidence, the patch is empty. None of these
252-
names holds a romanized surname, a given name that is rarely a
252+
names holds a listed surname, a given name that is rarely a
253253
surname, or any other evidence on the order:
254254

255255
.. doctest::
@@ -310,8 +310,11 @@ Each name votes on its order from the evidence it carries:
310310
of bylines may get no order suggestion: where you know a list is
311311
bylines, set ``name_order=FAMILY_FIRST`` yourself.
312312
- **A lowercase particle** first or before the last word.
313-
- **A common romanized Chinese, Korean or Vietnamese surname** as the
314-
first or last word.
313+
- **A common surname** as the first or last word: a romanized
314+
Chinese, Korean or Vietnamese one, or one that researchers rarely
315+
write as a given name (``García``, ``Quispe``, ``Popov``), most of
316+
them Spanish. A name with a listed surname at both ends casts no
317+
surname vote.
315318
- **A common given name that is rarely a surname** (``Emily``, not
316319
``Taylor``) as the first or last word.
317320

@@ -407,7 +410,9 @@ The names' own order votes come before the table in two cases:
407410

408411
- **They decide a family-first order.** The rule never overrides it:
409412
the list gets the rule with that order, under which the rule
410-
reorders no name.
413+
reorders no name. A ``FAMILY_FIRST_GIVEN_LAST`` base gets
414+
``FAMILY_FIRST`` there, since its own order would read the
415+
patronymic as the given name (``Popov Ivan Ivanovich``).
411416
- **They decide given-first under a** ``FAMILY_FIRST`` **base.** The
412417
second row does not apply, and the list gets ``GIVEN_FIRST`` with
413418
the rule.
@@ -657,14 +662,14 @@ and how it varies, and will differ for every dataset.
657662

658663
- **A list written in the base's own order** keeps it in at least 95%
659664
of groups from 2 to 2,000 names, and 97% for nearly every kind, save
660-
the two kinds of list below.
665+
the three kinds of list below.
661666
- **A list written the other way round** takes more names to move the
662667
base, from 5 for Chinese, Taiwanese, Korean, Czech, Polish and
663-
Italian names to 50 for Russian and Indian ones. A group whose votes
664-
fall short of the thresholds keeps the base rather than guess
665-
(:ref:`suggest-deciding`).
668+
Italian names to 50 for Russian and Indian ones and 200 for
669+
Bangladeshi ones. A group whose votes fall short of the thresholds
670+
keeps the base rather than guess (:ref:`suggest-deciding`).
666671

667-
Two kinds of list keep their order less often:
672+
Three kinds of list keep their order less often:
668673

669674
- **Given names in capitals** (``ANNA Smith``) have their capitals read
670675
as a family name, and such a list is suggested ``capitals_as_family``
@@ -677,6 +682,10 @@ Two kinds of list keep their order less often:
677682
but two or three joined initials (``AM Hoy``) kept it in just under
678683
95% of groups of 50 and 93% of groups of 100. Where you know how such
679684
a list is written, set ``name_order`` yourself.
685+
- **Given names that are common surnames elsewhere** (``Cooper``,
686+
``Burke``, ``Moreno``) are read as surnames. A list of nothing but
687+
such given names is read the wrong way round; mixed into a longer
688+
list, they are outvoted.
680689

681690
``capitals_as_family`` was suggested in at least 95% of groups from 4
682691
names for researchers who typed their family name in capitals, and

‎nameparser/_parser.py‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,19 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
348348
A group decided East Slavic gets the rule and reads
349349
given-first, the order the rule reorders each name under,
350350
unless its names' own votes decide family-first, which the rule
351-
never overrides. One case keeps a declared order instead: under
352-
a ``FAMILY_FIRST`` parser whose names' votes do not decide
351+
never overrides: there a ``FAMILY_FIRST_GIVEN_LAST`` parser gets
352+
``FAMILY_FIRST``, under which the patronymic is not read as the
353+
given name (``Popov Ivan Ivanovich``). One case keeps a
354+
declared order instead: under a ``FAMILY_FIRST`` parser whose names' votes do not decide
353355
given-first, where more of the names carrying the patronymic
354356
write it last (``Sidorov Ivan Petrovich``) than in the middle
355357
(``Ivan Petrovich Sidorov``), the group keeps that order and
356358
gets the rule alone, which reorders no name there and fills the
357359
``patronymic`` view; the names written the other way get no
358360
given-first order, and the patronymic evidence's note counts
359-
them. A tie, and a ``FAMILY_FIRST_GIVEN_LAST`` parser,
360-
get the given-first order with the rule. A Turkic group
361+
them. A tie, and a ``FAMILY_FIRST_GIVEN_LAST`` parser whose
362+
names' votes do not decide family-first, get the given-first
363+
order with the rule. A Turkic group
361364
gets the rule alone, its order decided by its names' own votes.
362365
``initials_as_family`` (rules/O8) is turned on where one run of
363366
letters ends at least two names and at least half of the names
@@ -388,11 +391,11 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
388391
bare str, bytes, a mapping or a non-str item raises TypeError.
389392
390393
Measured 2026-11-10, re-taken 2026-11-11, 2026-11-12,
391-
2026-11-14, 2026-11-15 and 2026-11-16, with
394+
2026-11-14, 2026-11-15, 2026-11-16 and 2026-11-19, with
392395
tools/differential/suggest_measure.py on groups drawn from real
393396
names written in a known order, 300 groups a size
394-
(decisions/group-suggestion's 2026-11-16 ORDER FLOOR entry holds
395-
the table): a group written in this parser's own order kept it
397+
(decisions/group-suggestion's 2026-11-19 #1364 entry holds
398+
the sizes): a group written in this parser's own order kept it
396399
in at least 97% of groups at every size from 2 to 2,000 names,
397400
under either base order, save three lists. ORCID holders who
398401
typed their given name in capitals (``ANNA Smith``), which the
@@ -403,19 +406,22 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
403406
(``AM Hoy``) kept it in at least 97% of groups at every size
404407
measured, to 500 names (it holds 644), but 50 and 100 names,
405408
where it kept it in 94.7% and 93.3%, the name tables voting on
406-
a few of its names; ORCID's bylines of
407-
every writing kept it in 95.3% and 96.7% at 100 and 200 names
408-
and at least 97% at every other size.
409+
a few of its names. And a list of nothing but given names that
410+
ORCID's holders type as surnames (``Cooper``, ``Burke``) fell
411+
below 95% at every size and was read wrong in every group from
412+
5 names, the surname table voting on each of them (that file's
413+
2026-11-19 #1364 entry).
409414
Moving the base takes more names, and
410415
how many depends on what the names carry: groups of Chinese,
411416
Taiwanese, Korean, Czech, Polish or Italian names (the romanized
412417
surnames and the common given names) were read right in 95% of
413418
groups from 5 names; German, Dutch, Spanish, British, French,
414-
Romanian and Vietnamese from 10; US, Japanese, Turkish,
415-
Nigerian and Brazilian from 20; and Russian and Indian from
416-
50. A group whose votes fall short of the thresholds keeps
417-
the base rather than guess, so a smaller group moves it in fewer
418-
of the draws. ``capitals_as_family``, measured 2026-11-12
419+
Romanian, Vietnamese and Japanese from 10; US, Turkish,
420+
Nigerian and Brazilian from 20; Russian and Indian from 50;
421+
PatentsView's Philippine inventors from 100; and PSC's
422+
Bangladeshi filers from 200. A group whose votes fall short of
423+
the thresholds keeps the base rather than guess, so a smaller
424+
group moves it in fewer of the draws. ``capitals_as_family``, measured 2026-11-12
419425
(decisions/group-suggestion's CAPITALS entry): ORCID holders who
420426
typed their family name in capitals were suggested it in at least
421427
95% of groups from 4 names, and from 10 where many of the

‎nameparser/_suggest.py‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
decided East Slavic rule reorders each name itself, and reorders none
3535
under a family-first order, so it decides the order as given-first,
3636
unless the names' own votes decide family-first, which it never
37-
overrides, or the base reads ``FAMILY_FIRST`` and the patronymics are
37+
overrides (a ``FAMILY_FIRST_GIVEN_LAST`` base then gets ``FAMILY_FIRST``),
38+
or the base reads ``FAMILY_FIRST`` and the patronymics are
3839
mostly written last, whose order it keeps (decisions/group-suggestion).
3940
Before either it decides
4041
``initials_as_family`` (rules/O8) from the runs of letters ending the
@@ -81,10 +82,11 @@
8182
apply_patch, initials_as_family_may_move,
8283
)
8384
from ._types import (
84-
ADDED_IN, FAMILY_FIRST, GIVEN_FIRST, ReadingSource, Role,
85+
ADDED_IN, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST, GIVEN_FIRST,
86+
ReadingSource, Role,
8587
_guarded_getstate, _guarded_setstate,
8688
)
87-
from .config._order_names import COMMON_GIVEN_NAMES, ROMANIZED_SURNAMES
89+
from .config._order_names import COMMON_GIVEN_NAMES, SURNAMES
8890

8991
if TYPE_CHECKING:
9092
from ._parser import Parser
@@ -128,8 +130,9 @@ class Signal(StrEnum):
128130
TRAILING_INITIAL = "trailing-initial"
129131
#: A lowercase particle first or before the last word.
130132
PARTICLE = "particle"
131-
#: A common romanized Chinese, Korean or Vietnamese surname as the
132-
#: first or last word.
133+
#: A common surname as the first or last word: a romanized Chinese,
134+
#: Korean or Vietnamese one, or one ORCID's holders rarely type as a
135+
#: given name (``García``, #1364).
133136
SURNAME = "surname"
134137
#: A common given name that is rarely a surname (``Emily``, not
135138
#: ``Taylor``) as the first or last word.
@@ -238,13 +241,13 @@ def _listed(word: str, table: frozenset[str]) -> bool:
238241
def _a_listed_name(word: str) -> bool:
239242
"""A word the name tables list: name evidence, which is never read
240243
past as a title or a post-nominal (`Law`, a Cantonese surname and a
241-
listed title). The given-name table holds no listed suffix since
242-
#1357, and the surname table's (`ma`, `meng`) are acronyms that may
243-
be a name, which are not read past bare with or without this test,
244-
so the post-nominal half acts on no shipped word; it holds for a
245-
table built otherwise."""
246-
return (_listed(word, ROMANIZED_SURNAMES)
247-
or _listed(word, COMMON_GIVEN_NAMES))
244+
listed title). The given-name and ORCID surname tables hold no
245+
listed suffix or title (their builder refuses them), and the
246+
romanized surname table's suffixes (`ma`, `meng`) are acronyms that
247+
may be a name, which are not read past bare with or without this
248+
test, so the post-nominal half acts on no shipped word; it holds for
249+
a table built otherwise."""
250+
return _listed(word, SURNAMES) or _listed(word, COMMON_GIVEN_NAMES)
248251

249252

250253
def _is_leading_title(word: str, lexicon: Lexicon) -> bool:
@@ -426,9 +429,9 @@ def _read(text: str, lexicon: Lexicon
426429
# (#1397)
427430
silent = _opens_in_short_capitals(words) or (
428431
_ends_in_short_capitals(words)
429-
and _listed(words[-1], ROMANIZED_SURNAMES))
432+
and _listed(words[-1], SURNAMES))
430433
tables = () if silent else (
431-
(Signal.SURNAME, ROMANIZED_SURNAMES, FAMILY_FIRST, GIVEN_FIRST),)
434+
(Signal.SURNAME, SURNAMES, FAMILY_FIRST, GIVEN_FIRST),)
432435
for signal, table, first_order, last_order in (
433436
*tables,
434437
(Signal.GIVEN_NAME, COMMON_GIVEN_NAMES, GIVEN_FIRST, FAMILY_FIRST)):
@@ -1239,7 +1242,11 @@ def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role],
12391242
decided East Slavic rule decides the order as given-first, since
12401243
the rule reorders each name and reorders none under a family-first
12411244
order, unless the names' own votes decide family-first: a decided
1242-
order is never overridden, and the rule then reorders no name. A
1245+
order is never overridden, and the rule then reorders no name. There
1246+
a ``FAMILY_FIRST_GIVEN_LAST`` base gets ``FAMILY_FIRST``, whose
1247+
reading the rule leaves as written (`Popov Ivan Ivanovich`, given
1248+
`Ivan`); its own spelling would read the patronymic as the given name
1249+
(decisions/group-suggestion, 2026-11-19 #1364). A
12431250
rule that keeps a ``FAMILY_FIRST`` base's order
12441251
(`_keeps_family_first`) is not passed here: the order is then the
12451252
votes' or the base's."""
@@ -1262,6 +1269,8 @@ def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role],
12621269
# the order tally holds orders alone
12631270
order = base_order if _end(base_order) == end else cast(
12641271
"tuple[Role, Role, Role]", end)
1272+
if rule_needs_given_first and order == FAMILY_FIRST_GIVEN_LAST:
1273+
order = FAMILY_FIRST
12651274
fields: dict[str, object] = (
12661275
{} if order == base_order else {_NAME_ORDER: order})
12671276
return (tally.evidence(_NAME_ORDER, order, True,

0 commit comments

Comments
 (0)