Skip to content

Commit 297750c

Browse files
derek73claude
andauthored
Read where an East Slavic patronymic stands as a vote on the order (#1447) (#1488)
A new public Signal member, PATRONYMIC_POSITION, cast beside every East Slavic PATRONYMIC vote and read where rules/O1 reads the patronymic: the ending on the middle word votes given-first, otherwise the patronymic stands last and votes family-first. A list of Russian names written family first now gets FAMILY_FIRST with the rule, reading its names of two words too, where it got the rule with a given-first order; a FAMILY_FIRST_GIVEN_LAST base gets FAMILY_FIRST through #1364's rule. suggest_measure.py gains PatentsView's Israeli inventors and PSC's Israeli, Serbian, Croatian and Belarusian filers for the -ovich check. Measured at sizes 2 to 2,000, on the parliament lists under three bases, and over the base x position x switch sweep (decisions/group-suggestion, 2026-11-19 #1447). No parse moves. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 12b568f commit 297750c

8 files changed

Lines changed: 487 additions & 132 deletions

File tree

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

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

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

‎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 where a Russian-style patronymic stands as a vote on the order, and add Signal.PATRONYMIC_POSITION, the signal that casts it.** ``Parser().suggest(["Sidorov Ivan Petrovich", "Volkov Pavel Sergeevich", "Orlova Anna Ivanovna", "Zaitsev Oleg Nikolaevich", "Belova Vera Andreevna"]).patch`` gives ``PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=...)``, where 3.1.0 gave the rule with the given-first order, which misread any name of two words in such a list (``Sidorov Ivan`` gave family ``Ivan``); a patronymic in the middle votes given-first. :issue:`1447`
78
- **Fix the surname1 and surname2 views, which left a family of two surnames whole before a family comma, opening with a particle, or behind a given name a particle completes.** Under ``two_family_names``, as ``locales.ES``, ``ES_AR``, ``CS``, ``SK``, ``PT_BR`` and ``PT_PT`` turn it on, ``parser_for(locales.ES).parse("García Márquez, Gabriel")`` gives surname1 ``García``, surname2 ``Márquez``, as ``Gabriel García Márquez`` does, where 3.0.0 through 3.1.0 gave surname1 ``García Márquez``, surname2 ``''``. No field moves; a family joined by ``y`` or written as one hyphenated word stays whole, and so, where 3.0.0 through 3.1.0 divided them, do a lone particle and the word after it under a family-first order (``Van Gogh``) and a Turkic father's name with its marker; with ``capitals_as_family`` on too, the family the capitals name is divided. :issue:`1456`, :issue:`1479`
89
- **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`
910
- **Fix a job or degree written out after a name and a comma, which took the name over.** ``parse("Nadir Qassoumi, Bachelor")`` gives title ``Bachelor``, given ``Nadir``, family ``Qassoumi``, where 1.4.0 through 3.1.0 gave given ``Bachelor``, family ``Nadir Qassoumi``; ``Medical Doctor`` and ``Clinical Research Coordinator`` read as one title. A name the word opens reads it as the title too (``Student Mary Jones`` gives title ``Student``), and the possessive ``Master's degree`` still takes the name over. :issue:`1457`

‎docs/suggest.rst‎

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ Each name votes on its order from the evidence it carries:
317317
surname vote.
318318
- **A common given name that is rarely a surname** (``Emily``, not
319319
``Taylor``) as the first or last word.
320+
- **Where a Russian-style patronymic stands** in a name of three words
321+
(:ref:`suggest-patronymics`): last (``Sidorov Ivan Petrovich``), the
322+
family name is written first; in the middle (``Ivan Petrovich
323+
Sidorov``), it is written last.
320324

321325
Each is read past the titles and post-nominals your parser's vocabulary
322326
lists (``Dr.``, ``PhD``, ``Jr.``). A name with a comma states its own
@@ -348,8 +352,9 @@ carry one rule's patronymic and they are more than four in five of the
348352
names that cast any vote, on the order or on a patronymic.
349353

350354
Under the default parser a list written family name first reads its
351-
patronymic as the family name; with the rule, each name is put back in
352-
order and its patronymic set apart:
355+
patronymic as the family name. Where the patronymics stand says how
356+
the list is written, so the suggestion reads it family first, with the
357+
rule setting each patronymic apart:
353358

354359
.. doctest::
355360

@@ -360,7 +365,7 @@ order and its patronymic set apart:
360365
'Petrovich'
361366
>>> slavic = Parser().suggest(registry)
362367
>>> slavic.patch
363-
PolicyPatch(patronymic_rules=frozenset({<PatronymicRule.EAST_SLAVIC: 'east-slavic'>}))
368+
PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=frozenset({<PatronymicRule.EAST_SLAVIC: 'east-slavic'>}))
364369
>>> sidorov = slavic.parser.parse("Sidorov Ivan Petrovich")
365370
>>> sidorov.given, sidorov.family, sidorov.patronymic
366371
('Ivan', 'Sidorov', 'Petrovich')
@@ -369,11 +374,11 @@ The order that comes with the rule
369374
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370375

371376
A Turkic rule is suggested alone: it reads a name written either way
372-
round, so the order is left to the names' own votes. The East Slavic
373-
rule reorders a name only under a given-first order, so what is
374-
suggested with it depends on the base parser's order and on where the
375-
list writes the patronymic, last (``Sidorov Ivan Petrovich``) or in
376-
the middle (``Ivan Petrovich Sidorov``):
377+
round, so the order is left to the names' own votes. Where an East
378+
Slavic patronymic stands is itself a vote on the order, last
379+
(``Sidorov Ivan Petrovich``) for family first and in the middle
380+
(``Ivan Petrovich Sidorov``) for given first, so a list that writes its
381+
patronymics one way gets that order with the rule:
377382

378383
.. list-table::
379384
:header-rows: 1
@@ -383,18 +388,30 @@ the middle (``Ivan Petrovich Sidorov``):
383388
- The list writes the patronymic
384389
- Order suggested with the rule
385390
* - ``GIVEN_FIRST``
386-
- last or in the middle
391+
- last
392+
- ``FAMILY_FIRST``
393+
* - ``GIVEN_FIRST``
394+
- in the middle
387395
- none: the base's stays
388396
* - ``FAMILY_FIRST``
389-
- last in more names than in the middle
397+
- last
390398
- none: the base's stays
391399
* - ``FAMILY_FIRST``
392-
- in the middle in as many names, or more
400+
- in the middle
393401
- ``GIVEN_FIRST``
394402
* - ``FAMILY_FIRST_GIVEN_LAST``
395-
- last or in the middle
403+
- last
404+
- ``FAMILY_FIRST``, since its own order would read the
405+
patronymic as the given name
406+
* - ``FAMILY_FIRST_GIVEN_LAST``
407+
- in the middle
396408
- ``GIVEN_FIRST``
397409

410+
The rule reorders a name only under a given-first order, and reads a
411+
name written family first under a family-first one, where it reorders
412+
none and fills the ``patronymic`` view. A name of two words in the same
413+
list (``Sidorov Ivan``) is read in the order suggested.
414+
398415
.. doctest::
399416

400417
>>> family_first = Parser(policy=Policy(name_order=FAMILY_FIRST))
@@ -406,21 +423,13 @@ the middle (``Ivan Petrovich Sidorov``):
406423
>>> family_first.suggest(spoken).patch
407424
PolicyPatch(name_order=GIVEN_FIRST, patronymic_rules=frozenset({<PatronymicRule.EAST_SLAVIC: 'east-slavic'>}))
408425

409-
The names' own order votes come before the table in two cases:
410-
411-
- **They decide a family-first order.** The rule never overrides it:
412-
the list gets the rule with that order, under which the rule
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``).
416-
- **They decide given-first under a** ``FAMILY_FIRST`` **base.** The
417-
second row does not apply, and the list gets ``GIVEN_FIRST`` with
418-
the rule.
419-
420-
Where a ``FAMILY_FIRST`` base keeps its order, the rule reorders no
421-
name there and fills the ``patronymic`` view. The names written the
422-
other way, patronymic in the middle, get no given-first order, and the
423-
note under ``patronymic_rules`` counts them.
426+
Where the names' votes decide no order (a list writing as many
427+
patronymics one way as the other, or too few one way, or other
428+
evidence contradicting them), the rule brings the given-first order it reorders each name
429+
under, save under a ``FAMILY_FIRST`` base whose list writes the
430+
patronymic last in more names than in the middle, which keeps its
431+
order; the note under ``patronymic_rules`` counts the names written the
432+
other way.
424433

425434
What counts for and against
426435
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -445,13 +454,14 @@ What the report shows
445454
~~~~~~~~~~~~~~~~~~~~~
446455

447456
The ``patronymic_rules`` line has a row for each rule the names voted
448-
for, and the ``name_order`` line a note where the rule decided the
449-
order:
457+
for, the ``name_order`` line a ``patronymic-position`` row for where
458+
the patronymics stand, and a note on how the order and the rule were
459+
decided together:
450460

451461
.. doctest::
452462

453463
>>> [e.note for e in slavic.evidence if e.setting == "name_order"]
454-
['the East Slavic rule reorders each name; it needs a given-first order']
464+
["the East Slavic rule is decided too, but the names' order votes decide a family-first order, under which the rule reorders no name"]
455465

456466
.. _suggest-initials:
457467

@@ -664,9 +674,9 @@ and how it varies, and will differ for every dataset.
664674
of groups from 2 to 2,000 names, and 97% for nearly every kind, save
665675
the three kinds of list below.
666676
- **A list written the other way round** takes more names to move the
667-
base, from 5 for Chinese, Taiwanese, Korean, Czech, Polish and
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
677+
base, from 5 for Chinese, Taiwanese, Korean, Czech, Polish, Italian
678+
and Russian names to 50 for Indian ones and 200 for Bangladeshi
679+
ones. A group whose votes fall short of the thresholds
670680
keeps the base rather than guess (:ref:`suggest-deciding`).
671681

672682
Three kinds of list keep their order less often:

‎nameparser/_parser.py‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,11 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
320320
name of fewer than two words once those are read past casts
321321
none, and so does a name with a comma, unless only
322322
post-nominals follow the comma. A patronymic votes only where
323-
the patronymic rule reads one, and a trailing initial
324-
(``Smith J.``) only where at least three names, and 60% of the
323+
the patronymic rule reads one, and an East Slavic one votes on
324+
the order too, by where it stands: last for family-first
325+
(``Sidorov Ivan Petrovich``), in the middle for given-first
326+
(``Ivan Petrovich Sidorov``). A trailing initial
327+
(``Smith J.``) votes only where at least three names, and 60% of the
325328
group's names holding a name word, end in initials no other
326329
signal in the same name contradicts. A capitals word of two
327330
or three letters ending a name in mixed case (``Armitage JO``),
@@ -347,11 +350,12 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
347350
note says how many.
348351
A group decided East Slavic gets the rule and reads
349352
given-first, the order the rule reorders each name under,
350-
unless its names' own votes decide family-first, which the rule
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
353+
unless its names' own votes decide family-first, as a list of
354+
patronymics written last does, which the rule never overrides: there a
355+
``FAMILY_FIRST_GIVEN_LAST`` parser gets ``FAMILY_FIRST``, under
356+
which the patronymic is not read as the given name (``Popov Ivan
357+
Ivanovich``). One case keeps a declared order instead: under a
358+
``FAMILY_FIRST`` parser whose names' votes do not decide
355359
given-first, where more of the names carrying the patronymic
356360
write it last (``Sidorov Ivan Petrovich``) than in the middle
357361
(``Ivan Petrovich Sidorov``), the group keeps that order and
@@ -394,8 +398,8 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
394398
2026-11-14, 2026-11-15, 2026-11-16 and 2026-11-19, with
395399
tools/differential/suggest_measure.py on groups drawn from real
396400
names written in a known order, 300 groups a size
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
401+
(decisions/group-suggestion's 2026-11-19 #1364 and #1447
402+
entries hold the sizes): a group written in this parser's own order kept it
399403
in at least 97% of groups at every size from 2 to 2,000 names,
400404
under either base order, save three lists. ORCID holders who
401405
typed their given name in capitals (``ANNA Smith``), which the
@@ -414,12 +418,13 @@ def suggest(self, names: Iterable[str]) -> Suggestion:
414418
Moving the base takes more names, and
415419
how many depends on what the names carry: groups of Chinese,
416420
Taiwanese, Korean, Czech, Polish or Italian names (the romanized
417-
surnames and the common given names) were read right in 95% of
418-
groups from 5 names; German, Dutch, Spanish, British, French,
421+
surnames and the common given names) and of Russian ones (where
422+
their patronymics stand) were read right in 95% of groups from 5
423+
names; German, Dutch, Spanish, British, French,
419424
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
425+
Nigerian and Brazilian from 20; Indian from 50; and PSC's
426+
Bangladeshi filers from 200 (PatentsView's Philippine inventors
427+
from 20, through the Russian names among them). A group whose votes fall short of
423428
the thresholds keeps the base rather than guess, so a smaller
424429
group moves it in fewer of the draws. ``capitals_as_family``, measured 2026-11-12
425430
(decisions/group-suggestion's CAPITALS entry): ORCID holders who

‎nameparser/_suggest.py‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@
2727
(Hangul, Han) simply matches nothing. A patronymic
2828
votes, Latin or Cyrillic, only where the pipeline's rule reads one
2929
(rules/O1's three name words, rules/O2's four), through the pipeline's
30-
own predicates, never a copy of them. No signal raises on any string.
30+
own predicates, never a copy of them, and an East Slavic one casts a
31+
second vote, on the order, by where it stands as rules/O1 reads it
32+
(``Signal.PATRONYMIC_POSITION``: last family-first, in the middle
33+
given-first). No signal raises on any string.
3134
3235
``suggest`` tallies the group's votes and decides two settings
3336
together, ``patronymic_rules`` first and ``name_order`` second: a
3437
decided East Slavic rule reorders each name itself, and reorders none
3538
under a family-first order, so it decides the order as given-first,
36-
unless the names' own votes decide family-first, which it never
37-
overrides (a ``FAMILY_FIRST_GIVEN_LAST`` base then gets ``FAMILY_FIRST``),
39+
unless the names' own votes decide family-first, as a list of
40+
patronymics written last does, which it never overrides (a ``FAMILY_FIRST_GIVEN_LAST`` base
41+
then gets ``FAMILY_FIRST``),
3842
or the base reads ``FAMILY_FIRST`` and the patronymics are
3943
mostly written last, whose order it keeps (decisions/group-suggestion).
4044
Before either it decides
@@ -140,6 +144,13 @@ class Signal(StrEnum):
140144
#: A patronymic one rule reads (Russian ``Petrovich``, Azerbaijani
141145
#: ``Huseyn oglu``), the evidence on ``patronymic_rules``.
142146
PATRONYMIC = "patronymic"
147+
#: Where an East Slavic patronymic of three name words stands, read
148+
#: where rules/O1 reads it, the evidence on ``name_order``: in the
149+
#: middle (``Ivan Petrovich Sidorov``) the family is written last,
150+
#: the middle word winning where the last ends as a patronymic too;
151+
#: last (``Sidorov Ivan Petrovich``) it is written first. Cast only
152+
#: beside an East Slavic ``PATRONYMIC`` vote.
153+
PATRONYMIC_POSITION = "patronymic-position"
143154

144155

145156
_INITIAL_JOINS = re.compile(r"[.-]+")
@@ -361,6 +372,18 @@ def _patronymic(words: list[str]) -> PatronymicRule | None:
361372
return None
362373

363374

375+
def _patronymic_end(words: list[str]) -> tuple[Role, Role, Role]:
376+
"""The end a name casting the East Slavic vote writes its family at,
377+
read where rules/O1 reads it: the ending on the middle word is the
378+
given-first shape (given, patronymic, family), whatever the last
379+
word ends in, and otherwise the patronymic stands last, the
380+
family-first shape the rule restores (family, given, patronymic).
381+
Asked only of a name `_patronymic` votes East Slavic for, three
382+
words long."""
383+
middle = words[1].rstrip(".") or words[1]
384+
return GIVEN_FIRST if has_patronymic_ending(middle) else FAMILY_FIRST
385+
386+
364387
def _letter_run(text: str, readers: tuple[Parser, Parser]) -> str | None:
365388
"""The letters ending `text` that are evidence of the convention
366389
rules/O8 reads, folded and run together (`Lakshmi R. S.` gives
@@ -443,6 +466,8 @@ def _read(text: str, lexicon: Lexicon
443466
patronymic = _patronymic(words)
444467
if patronymic is not None:
445468
votes[Signal.PATRONYMIC] = patronymic
469+
if patronymic is PatronymicRule.EAST_SLAVIC:
470+
votes[Signal.PATRONYMIC_POSITION] = _patronymic_end(words)
446471
return votes, False, words
447472

448473

@@ -1191,14 +1216,18 @@ def _keeps_family_first(
11911216
with the ending on both its middle and its last word counts as
11921217
middle, as rules/O1 reads it. ``FAMILY_FIRST_GIVEN_LAST`` is never
11931218
kept: that order takes the patronymic of such a list for the given
1194-
name, and the given-first order with the rule reads it."""
1219+
name; the names' position votes give it ``FAMILY_FIRST``
1220+
(`_decide_order`), and where they decide no order the given-first
1221+
order with the rule reads it. Since the position votes (#1447) the
1222+
question is asked only where the votes decide no order or decide
1223+
the base's own."""
11951224
if policy.name_order != FAMILY_FIRST or order_end == GIVEN_FIRST:
11961225
return None
11971226
last = middle = 0
11981227
for _, votes, _, words in with_words:
11991228
if votes.get(Signal.PATRONYMIC) is PatronymicRule.EAST_SLAVIC:
12001229
# _patronymic votes East Slavic on three words alone
1201-
if has_patronymic_ending(words[1].rstrip(".") or words[1]):
1230+
if _patronymic_end(words) == GIVEN_FIRST:
12021231
middle += 1
12031232
else:
12041233
last += 1

0 commit comments

Comments
 (0)