From b49c2e34250500195e8495684c707fb71ac200cb Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Thu, 19 Nov 2026 15:46:40 -0800 Subject: [PATCH] Read where an East Slavic patronymic stands as a vote on the order (#1447) 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 --- AGENTS.md | 2 +- docs/design/decisions/group-suggestion.md | 35 +- docs/release_log.rst | 1 + docs/suggest.rst | 76 ++-- nameparser/_parser.py | 33 +- nameparser/_suggest.py | 39 +- tests/v2/test_suggest.py | 425 ++++++++++++++++++---- tools/differential/suggest_measure.py | 8 +- 8 files changed, 487 insertions(+), 132 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 2915c7a60..232994bbb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -326,7 +326,7 @@ The 2.0 rewrite landed as underscore-private modules beside the v1 code, which 2 **Measuring a change to name matching: use `tools/differential/match_diff.py --base `.** A change to `nameparser/_match.py`, or to the vocabulary only the name match reads (`same_as`, `familiar`), moves no parse, so the snapshot and every corpus check below report nothing; `match_diff.py` lists every name pair whose `check` result or keys moved, under twenty-two settings, and every consistent pair sharing no key (#1278). A clean run vouches only for the shapes its draw holds: it draws its pairs from tests/v2/test_match.py and the corpora, so a change to a shape no drawn pair holds reports 0 moves (#1390 moved 0 of 687,500 rows until its own test rows existed). Add the change's rows to the test file first, then read the run. A setting naming an outcome the base does not know subtracts nothing there, so `-joined` against a base older than #1261 compares a caller who drops `joined` with the old default, which is the claim that caller keeps what they accepted. The base is the branch's merge base, re-pointed for each branch: a scratch base kept from the previous PR measures that PR's moves too, and #1261's first figures came from #1262's base, found by review. #1221, #1267 and #1260 each wrote a throwaway oracle for this first (tools/differential/README.md, "Measuring a change"). It parses under `Parser()` and `locales.ES` alone, so a change to how a caller's `Lexicon` edit is applied moves nothing in it by construction (#1404's `remove` of a familiar pair: 0 moves, which vouches only that the default did not move), and is tested through a matcher built on the edited lexicon. And an edit that names a word the match reads must compare it as the match does: the familiar index files each name under its folded forms (`_lexicon._forms`), so #1404's first build, cutting a pair by its stored spelling, left `Alex` / `Alejandro` consistent through the pair `mul.toml` stores on `álex`, found only because a test asked the matcher and not the lexicon's readings; give such an edit a row whose stored word differs from the written one by an accent and by a transcription (`ü` / `ue`). -**Measuring a change to the group suggester: use `tools/differential/suggest_measure.py`.** Run it after any change to `nameparser/_suggest.py`, to `nameparser/config/_order_names.py` (or `tools/vocab/order_names.py`, which writes it) or to a predicate a signal reads (the capitals, particle and patronymic tests, and the title, suffix and numeral tests a name is read past), or to rules/O9, whose reading the `capitals_as_family` vote asks of the parse itself: `suggest` moves no parse, so the snapshot and every corpus check report nothing. It draws groups of known order, 2, 3, 4, 5, 10, 20, 50 and 200 names by default (a change to a threshold adds `--sizes 2,3,4,5,10,20,50,100,200,500,1000,2000`: a share counted among the names that vote holds at 200 names and fails past it, which no default size shows, and #1442's two stray votes decided lists of 500 and more for that reason), from the local corpora and reports the share of groups read right by size, the same-order rows being the anti-goal (at least 95% at every size, save `pv-listed-given`'s two same-order rows, a list of nothing but given names that are surnames the ORCID surname table lists (`Cooper`, `Burke`, `Clarke`), which that table reads the wrong way round, a cost left open (decisions/group-suggestion, 2026-11-19 #1364), save `orcid-givcaps`' two same-order rows, a list writing its given names in capitals (`ANNA Smith`), which the capitals signal reads the wrong way round by design (decisions/group-suggestion, 2026-11-12 CAPITALS), and `orcid-byline-joined`'s given-first row at 50 and 100 names, and at 200 until #1357, a list of nothing but `AM Hoy` bylines that the few names the name tables vote on decide (decisions/group-suggestion, 2026-11-14 #1355, which took `orcid-byline`'s own row off this list, as #1397 took `orcid-famcaps-short`'s); groups of 2 to 4 are where #1308's final review found a patronymic rule forcing given-first on a family-first base); `--set NAME=VALUE` overrides a threshold, and `--set _MIN_VOTES=1000000 --set _MIN_PATRONYMIC_VOTES=1000000 --set _MIN_RUN_NAMES=1000000` decides nothing and is the harness proof (the order count alone leaves the patronymic rule free to decide its own given-first order, and the two vote counts leave the letters setting free to decide; `_MIN_VOTES` also holds `capitals_as_family`, whose table `--set _MIN_CAPITALS_LETTERS=1000000` empties alone). A table change also moves the `print(suggestion)` evidence docs/getting-started.rst and docs/suggest.rst show as doctests, which `uv run pytest` does not run: run `uv run sphinx-build -b doctest docs ` too (#1374's ORCID table made `Wang Xiaoming` a given-name vote and failed every build job). Its figures are quoted in `Parser.suggest`'s docstring, docs/suggest.rst and docs/design/decisions/group-suggestion.md; re-take all three when they move (decisions/group-suggestion's THRESHOLDS entry names the command, and its latest dated entry carrying re-taken sizes, 2026-11-19 #1364's, holds the figures the other two round; the 2026-11-12 CAPITALS entry holds the `capitals_as_family` table, which the docstring's and docs/suggest.rst's capitals sentences round). A signal that reads one of the pipeline's predicates must read it exactly where the pipeline's rule does, no wider and no narrower, and its tests need a row at each edge: #1310's patronymic signal first voted an `-ovich` ending on any word (wider: two-word `Abramovich Roman` decided East Slavic and forced given-first), then its fix refused one on the first word, which rules/O1 never asks about (narrower: `Abramovich Roman Arkadyevich`, which the rule reads right, cast nothing). Only the second review caught the narrowing. A signal that votes where exactly ONE end of a name is listed votes by the other end alone once one end is no longer read: #1355's first sketch stopped looking up a short capitals word opening a name, and `WU Zhi` then cast a given-first surname vote by `Zhi`, so the shipped rule silences the signal on the whole name; when a rule stops reading a word, put a name whose other word is listed too in its grid. And a rule keyed to a word's shape needs a population of nothing but that shape: the default populations mix short capitals surnames with long ones, so the ending word's twin of that defect (`Zhi LI`) went unseen from #1308 until #1355 cut `orcid-famcaps-short`, and #1397 fixed it (decisions/group-suggestion, 2026-11-14 #1355 and #1397). A setting has more than one effect, and a suggestion that leaves something out leaves it out on every base: #1356 was first decided on "the East Slavic rule stands down under a family-first order", true of its reordering and false of its `patronymic` view, and PR #1399 as first pushed then kept every family-first base's order. Five names written `Zzyvan Petrovich Qqsidorov` under `FAMILY_FIRST` were read family `Zzyvan` where master moved the base and read them right; and `SIDOROV Ivan Petrovich` five times under `FAMILY_FIRST_GIVEN_LAST` lost the rule, though `capitals_as_family`, suggested in the same patch, makes the rule name the patronymic there. Review found both; the tool's table was identical with and without them, its populations then holding neither shape and no `FAMILY_FIRST_GIVEN_LAST` base anywhere in it (it has read the parliament lists under one since, which catches the second kind on a real list; its draws still run under two bases). Before deciding what a suggestion leaves out, sweep every base order × every switch the same patch can turn on × both written positions of the word the rule reads, and compare whole names read right (given and family), not the family alone: `FAMILY_FIRST_GIVEN_LAST` reads the family of `Sidorov Ivan Petrovich` right and its given name wrong, which a family count scored as nothing to fix. One signal is wider on purpose, and says so where it is decided: the letters signal (#1254) counts a run joined with full stops (`B.K.`), which rules/O8 never moves, beside the spaced runs it does, since three quarters of Nepal's runs are written joined (decisions/group-suggestion, 2026-11-11 LETTER RUNS); a test holds every other run to the rule exactly. +**Measuring a change to the group suggester: use `tools/differential/suggest_measure.py`.** Run it after any change to `nameparser/_suggest.py`, to `nameparser/config/_order_names.py` (or `tools/vocab/order_names.py`, which writes it) or to a predicate a signal reads (the capitals, particle and patronymic tests, and the title, suffix and numeral tests a name is read past), or to rules/O9, whose reading the `capitals_as_family` vote asks of the parse itself: `suggest` moves no parse, so the snapshot and every corpus check report nothing. It draws groups of known order, 2, 3, 4, 5, 10, 20, 50 and 200 names by default (a change to a threshold adds `--sizes 2,3,4,5,10,20,50,100,200,500,1000,2000`: a share counted among the names that vote holds at 200 names and fails past it, which no default size shows, and #1442's two stray votes decided lists of 500 and more for that reason), from the local corpora and reports the share of groups read right by size, the same-order rows being the anti-goal (at least 95% at every size, save `pv-listed-given`'s two same-order rows, a list of nothing but given names that are surnames the ORCID surname table lists (`Cooper`, `Burke`, `Clarke`), which that table reads the wrong way round, a cost left open (decisions/group-suggestion, 2026-11-19 #1364), save `orcid-givcaps`' two same-order rows, a list writing its given names in capitals (`ANNA Smith`), which the capitals signal reads the wrong way round by design (decisions/group-suggestion, 2026-11-12 CAPITALS), and `orcid-byline-joined`'s given-first row at 50 and 100 names, and at 200 until #1357, a list of nothing but `AM Hoy` bylines that the few names the name tables vote on decide (decisions/group-suggestion, 2026-11-14 #1355, which took `orcid-byline`'s own row off this list, as #1397 took `orcid-famcaps-short`'s); groups of 2 to 4 are where #1308's final review found a patronymic rule forcing given-first on a family-first base); `--set NAME=VALUE` overrides a threshold, and `--set _MIN_VOTES=1000000 --set _MIN_PATRONYMIC_VOTES=1000000 --set _MIN_RUN_NAMES=1000000` decides nothing and is the harness proof (the order count alone leaves the patronymic rule free to decide its own given-first order, and the two vote counts leave the letters setting free to decide; `_MIN_VOTES` also holds `capitals_as_family`, whose table `--set _MIN_CAPITALS_LETTERS=1000000` empties alone). A table change also moves the `print(suggestion)` evidence docs/getting-started.rst and docs/suggest.rst show as doctests, which `uv run pytest` does not run: run `uv run sphinx-build -b doctest docs ` too (#1374's ORCID table made `Wang Xiaoming` a given-name vote and failed every build job). Its figures are quoted in `Parser.suggest`'s docstring, docs/suggest.rst and docs/design/decisions/group-suggestion.md; re-take all three when they move (decisions/group-suggestion's THRESHOLDS entry names the command, and its latest dated entries carrying re-taken sizes, 2026-11-19 #1364's and #1447's, hold the figures the other two round; the 2026-11-12 CAPITALS entry holds the `capitals_as_family` table, which the docstring's and docs/suggest.rst's capitals sentences round). A signal that reads one of the pipeline's predicates must read it exactly where the pipeline's rule does, no wider and no narrower, and its tests need a row at each edge: #1310's patronymic signal first voted an `-ovich` ending on any word (wider: two-word `Abramovich Roman` decided East Slavic and forced given-first), then its fix refused one on the first word, which rules/O1 never asks about (narrower: `Abramovich Roman Arkadyevich`, which the rule reads right, cast nothing). Only the second review caught the narrowing. A signal that votes where exactly ONE end of a name is listed votes by the other end alone once one end is no longer read: #1355's first sketch stopped looking up a short capitals word opening a name, and `WU Zhi` then cast a given-first surname vote by `Zhi`, so the shipped rule silences the signal on the whole name; when a rule stops reading a word, put a name whose other word is listed too in its grid. And a rule keyed to a word's shape needs a population of nothing but that shape: the default populations mix short capitals surnames with long ones, so the ending word's twin of that defect (`Zhi LI`) went unseen from #1308 until #1355 cut `orcid-famcaps-short`, and #1397 fixed it (decisions/group-suggestion, 2026-11-14 #1355 and #1397). A setting has more than one effect, and a suggestion that leaves something out leaves it out on every base: #1356 was first decided on "the East Slavic rule stands down under a family-first order", true of its reordering and false of its `patronymic` view, and PR #1399 as first pushed then kept every family-first base's order. Five names written `Zzyvan Petrovich Qqsidorov` under `FAMILY_FIRST` were read family `Zzyvan` where master moved the base and read them right; and `SIDOROV Ivan Petrovich` five times under `FAMILY_FIRST_GIVEN_LAST` lost the rule, though `capitals_as_family`, suggested in the same patch, makes the rule name the patronymic there. Review found both; the tool's table was identical with and without them, its populations then holding neither shape and no `FAMILY_FIRST_GIVEN_LAST` base anywhere in it (it has read the parliament lists under one since, which catches the second kind on a real list; its draws still run under two bases). Before deciding what a suggestion leaves out, sweep every base order × every switch the same patch can turn on × both written positions of the word the rule reads, and compare whole names read right (given and family), not the family alone: `FAMILY_FIRST_GIVEN_LAST` reads the family of `Sidorov Ivan Petrovich` right and its given name wrong, which a family count scored as nothing to fix. One signal is wider on purpose, and says so where it is decided: the letters signal (#1254) counts a run joined with full stops (`B.K.`), which rules/O8 never moves, beside the spaced runs it does, since three quarters of Nepal's runs are written joined (decisions/group-suggestion, 2026-11-11 LETTER RUNS); a test holds every other run to the rule exactly. **Validating a new parsing rule** — before implementing, simulate it in a throwaway script against `TEST_NAMES` (plus a few target-language examples) to catch regressions/false-positives early. E.g. this surfaced the `last_base` `do`/`st`/`mc` empties and the patronymic `"David Michael Abramovich"` false-reorder. After the change, `tests/v2/test_snapshot.py` lists every corpus name it moved, grouped by changed field -- read them, and re-record with `uv run python tools/differential/snapshot.py --record` once every move is intended, so the PR diff of `snapshot.jsonl` shows the reviewer the same list. `uv run python tools/differential/cldr_agreement.py` reports how the tree's agreement with CLDR's stated name fields moved; `tests/v2/test_cldr_agreement.py` fails on any move, and `tools/differential/cldr_agreement.json` doubles as a measured list of names the parser and CLDR read differently. The same command and test score the GND corpus's real names (`gnd_fields.jsonl`, record `gnd_agreement.json`) by the same rules, and `--record` rewrites every record, printing per source what it accepts. A locale-pack change reads the second view the same command prints, per pack (`cldr_agreement_locales.json`, #672, and `wikidata_native_agreement_locales.json` for real Han and kana names); its `JA` rows run only with the `ja` extra installed. A change to Han, Hangul or kana order or to Korean segmentation reads `wikidata_native_agreement.json` too: the only real names in those scripts the corpora hold. It holds no honorific, so a change to the honorific peel moves nothing there. A change to comma or credential handling also reads the local corpus of hand-typed names (`snapshot.py --local ctgov-officials --base `, which reads the base from a baseline kept for its package's files and never the shared snapshot beside the corpus (a base read once from the same fetch is copied rather than parsed again; `--sample N` reads a fixed sample while iterating; the shared snapshot beside the corpus is one file per source for every worktree, and #752's phase 2f found ctgov reporting a sibling branch's 1,334 joined-credential readings as its own moves against it); tools/differential/README.md's "Local corpora"): the one population of names nobody chose for a test or a catalog, so it shows how often each shape is typed, and the one no CI run sees. A change to title handling reads `ukec-individuals` the same way: UK donors' names in spoken order and mixed case, in 8,219 of whose 15,214 `parse()` read a title on 2026-10-22. A change to English titles, honorifics or post-nominals also reads `snapshot.py --local govuk-people` the same way: GOV.UK's display names of ministers, officials and officers, the title run and the post-nominals as an office writes them (`The Rt Hon`, `Sir`, `Baroness`, ranks; `KC`, `CBE`, `KCB`), in 2,093 of whose 6,021 `parse()` read one or both on 2026-10-30. A change to Spanish titles, to the `es` pack, or to how a title marks where a name starts after an office reads `snapshot.py --local dof-signatures` the same way: the names in the signature blocks of Mexico's Diario Oficial for 2025, cut from the clause that names the signatory's office, 65.4% of its 33,565 signatures opening with a title (`Lic.`, `Dr.`, `Mtro.`, `C.`, `Licenciada`, `C.P.`), whose first word `parse()` read as a title in 82.1% and `parser_for(locales.ES)` in 86.8% on 2026-10-31. A change to particles or generational words reads `snapshot.py --local tse-donors` the same way, Brazilian names in spoken order dense with both. A change to initials, to a title word outside English, or to how a script's combining marks are read reads `snapshot.py --local nepal-candidates` the same way: Nepal's local election candidates, each a romanized name (surnames written as initials, `B.K.`, `K.C.`; honorific titles such as `Guru` in front, `Shekh`, a title there until #752's phase 2j made it one only inside a title phrase, and `Md.`, a title by its period's shape until #1383 made it Muhammad written short, the given name) beside the same name in Devanagari, written with vowel signs and the virama, combining marks the letter-shape tests do not count as letters (decisions/nfd-shapes), and with the joiners ZWJ and ZWNJ. It is the only large population of South Asian names the corpora hold, and its corpus reads both scripts. A change to non-Latin scripts or to Arabic-script names reads `snapshot.py --local jrc-names` the same way, and `local_corpora.py groups jrc-names`: the spellings of one person across scripts and transliterations, harvested from news text, with 17,074 Arabic-script spellings where the committed corpora hold 315 distinct names with an Arabic letter, 96 of them CLDR's fictional renderings (2026-10-24), and under a licence that keeps even a reading of one of its names in the cache. A change to patronymics, to Turkic or East Slavic names, to Indic titles and initials, or to Slavic or Portuguese double surnames reads `snapshot.py --local opensanctions-parliaments --base ` the same way, and `local_corpora.py groups opensanctions-parliaments`: the members of twenty-eight national chambers as each parliament writes them (Azerbaijan, the Central Asian chambers, Turkey, Croatia, Slovenia, Slovakia, Portugal, India, Ukraine, Belarus, Russia, Indonesia, Ethiopia, South Korea, Israel, Mongolia, and since 2026-11-19 Malaysia, Pakistan's two chambers, Egypt and Somalia, #1465) and Indonesia's 2018 regional heads, read through OpenSanctions, 26,515 spellings of 20,856 members on 2026-11-19 (24,302 of 19,283 on 2026-11-12, before the five chambers and some other lists' newer exports; 24,084 of 19,216 on 2026-11-08, before the Khural and other lists' newer exports), some members' aliases in another script (Kazakh beside Russian Cyrillic, Uzbek Cyrillic beside Latin, Devanagari beside Latin, Hangul and Hanja or Hebrew beside Latin) or with a title (`Shri`, `Smt.`), the population issues #1186 to #1192 were read from, and the one that measures Indonesia's `H.` and `Imam` (#1205, #1206) Ethiopia's father's name (#1203), Korea's Hangul and Hanja (#1213, #1215, #1216) Israel's Hebrew (#1209 to #1211) and Mongolia's Cyrillic, the father's name first (#1237, `mn_parliament`, 126 members, added 2026-11-12), and Egypt's Arabic-script names, each written short and with the full chain of names (#1072, #1464); `config_diff.py --group ` keeps one parliament. A change to Malay, Indian-Malaysian or Chinese-Malaysian names (`bin`, `binti`, `B.`, `bt`, `a/l`, `a/p`, `anak`, the `@` alias, `MD`, honorifics such as `Ustaz` and `Cikgu` opening a name, a Chinese name written family first) or to names written wholly in capitals reads `snapshot.py --local my-candidates --base ` the same way: Malaysia's election candidates of 2008 to 2023 as their ballots name them, in capitals, 3,077 distinct names on 2026-11-19, grouped by the ethnicity each file states (`config_diff.py --group chinese`), the population issues #1467, #1468, #1164, #1183 and #1179 were read from. A change that cuts one written word across two fields, or joins two written words, first reads how `local_agreement.py` compares a box (`agrees`, tools/differential/README.md): 3.1's #1296 cut `B.A.S.D.` into given `B.`, middle `A.S.D.`, and 1,140 `orcid-researchers` records scored a miss though read right until #1470 (measured 2026-11-19). A change to which field a word lands in also reads `local_agreement.py psc-individuals --base ` the same way: real names with the four boxes their filers typed them into (UK companies' people with significant control), scored field by field and by nationality; and `local_agreement.py orcid-researchers --base `, ORCID holders' own two boxes (given names, family name) from every country, scored by the country they work or live in -- a population each person split for themselves, academic but worldwide, the one to read for a change a language pack makes. Its `name` is COMPOSED from those boxes, given first, so it cannot show which word a writer put first: a count of where a word falls in it is fixed by construction, and #1163's 538 records with the trailing letters in the family box against 0 with the word before them (`Lakshmi R S`, never `R S Lakshmi`) reproduced from that field. Order is measured on the free-text `credit` name (125,960 of the 2026-10-27 fetch's 1,831,533 records, which lean towards bibliographic bylines), against the boxes (decisions/O8); and `local_agreement.py patentsview-inventors --base `, US patents' inventors in the two boxes their filings give, split by a professional filer, with how many people filed under each name in each country, the one to read for how common a name's word is among a country's US-patent inventors. A change to titles or post-nominals, or to the `cs` pack, reads `local_agreement.py cz-candidates --base `, and with `--locale cs` too: Czech election candidates' four boxes (the title before the name, given names, surname, the title after it), scored by election, the only population whose titles are stated apart from the name, 36% of its 170,181 records titled (2026-10-30), nearly all academic degrees; its names are composed from the boxes (`Ing. Jan Novák, Ph.D.`), so it says nothing about how a writer spaces or punctuates them. A change to family-first order, to Vietnamese names or to their titles reads `local_agreement.py uit-vinames --base ` and `local_agreement.py vn-assembly --base `, and with `--locale vi`, `locales.VI` being that pack (#1108): 21,090 distinct names and 499 National Assembly deputies written family name first with their diacritics, whose parts no one filed but the convention derives (first word the family, last the given, the words between the middle name), so they score middle names, which ORCID's two boxes cannot, and `vn-assembly` the `GS.`/`PGS.`/`TS.`/`ThS.` titles composed from the education each deputy states. These are the only real fielded populations outside the committed fields files, and no CI run sees them either. diff --git a/docs/design/decisions/group-suggestion.md b/docs/design/decisions/group-suggestion.md index 0e600992c..63e63059c 100644 --- a/docs/design/decisions/group-suggestion.md +++ b/docs/design/decisions/group-suggestion.md @@ -11,10 +11,12 @@ - What `suggest` decides for a group is one release's answer, not a promise across releases: the tables and thresholds are tuned between them, so a caller keeps the settings applied (the patch, or the `Policy` it made) with the data; nothing promises that a later release suggests the same settings for the same names — 2026-11-15 ACROSS RELEASES. - The evidence declined (the vocabulary's name readings, `Reading.languages`, the familiar forms) — 2026-11-10 DECLINED. - A comma name states its own order and does not vote on order — 2026-11-10 SIGNALS. -- An East Slavic group gets the patronymic rule with a given-first order, since the rule reads either written order one name at a time and reorders none under a declared family-first order, unless the names' own order votes decide family-first, which the rule never overrides (a `FAMILY_FIRST_GIVEN_LAST` base then gets `FAMILY_FIRST`), or the next line keeps a `FAMILY_FIRST` base's order — 2026-11-10 SIGNALS, 2026-11-10 FIX WAVE, 2026-11-19 #1364. -- Where the East Slavic rule is decided under a `FAMILY_FIRST` base and the names' own votes do not decide given-first, the suggestion keeps the base's order and suggests the rule alone if more of the names carrying the patronymic write it last (family, given, patronymic) than in the middle (given, patronymic, family); a tie, a middle majority, a `FAMILY_FIRST_GIVEN_LAST` base and a given-first base get the given-first order with the rule, as before; a base already carrying the rule keeps its rule value on every branch — 2026-11-15 #1356. +- An East Slavic group gets the patronymic rule with a given-first order, since the rule reads either written order one name at a time and reorders none under a declared family-first order, unless the names' own order votes decide family-first, as a list of patronymics written last does by their position, which the rule never overrides (a `FAMILY_FIRST_GIVEN_LAST` base then gets `FAMILY_FIRST`), or the next line keeps a `FAMILY_FIRST` base's order — 2026-11-10 SIGNALS, 2026-11-10 FIX WAVE, 2026-11-19 #1364, 2026-11-19 #1447. +- Where the East Slavic rule is decided under a `FAMILY_FIRST` base and the names' own votes do not decide given-first, the suggestion keeps the base's order and suggests the rule alone if more of the names carrying the patronymic write it last (family, given, patronymic) than in the middle (given, patronymic, family); where the names' votes decide no order, a tie, a middle majority and a `FAMILY_FIRST_GIVEN_LAST` base get the given-first order with the rule; a base already carrying the rule keeps its rule value on every branch — 2026-11-15 #1356, 2026-11-19 #1447. - A list mixing East Slavic and Turkic patronymics is left as it is for 3.1: one patronymic decision is made for the list, by the thresholds, so the larger set's rule where it clears them and none where neither does — 2026-11-15 #1356. - A patronymic votes only where the pipeline's rule reads one (rules/O1's three name words, rules/O2's four, and since 2026-11-12 #1187 its three with the marker last), a name is read past its listed titles and post-nominals, and a comma followed by post-nominals alone reads the name before it — 2026-11-10 FIX WAVE. +- An East Slavic patronymic also votes on the order, by where it stands as rules/O1 reads it (the ending on the middle word for given-first, whatever the last word ends in; otherwise family-first), under every base order, as a signal of its own, `Signal.PATRONYMIC_POSITION`; a Turkic patronymic casts no such vote — 2026-11-19 #1447. +- One public `Signal` member per kind of vote: a signal votes on one setting, and a kind of evidence that votes on a second setting adds a member rather than a field on `NameEvidence` or a vote counted only in the tally — 2026-11-19 #1447. - An order is decided by at least two names, more than two thirds of the names casting an order vote and at least 1% of the group's names a comma does not leave out; a patronymic rule by at least five names carrying it and more than four in five of the names casting any vote; otherwise the base stands — 2026-11-10 THRESHOLDS, 2026-11-16 ORDER FLOOR. - Where any name casts a trailing-initial vote, the votes are cast only where at least three names, and at least 60% of the group's names holding a name word, end in initials no other signal in the same name contradicts; elsewhere every one is set aside, a contested one included (60% kept after a curve of lower shares and a minimum of 2 names, each declined), the order evidence's note says how many names end so, and the patronymic evidence's note how many names whose only vote was set aside still count in its share — 2026-11-11 TRAILING INITIAL. - `initials_as_family` (rules/O8) is turned on where one run of letters ends at least two of the group's names and at least half of the names ending in a run, a spaced run counted where the rule moves it and a run joined with full stops (`B.K.`) counted beside it; a group decided so casts no trailing-initial vote on its order; a group never turns the switch off, and a base reading names family first decides nothing — 2026-11-11 LETTER RUNS. @@ -26,13 +28,13 @@ - A name word in a script that writes no initials followed by a letter of it casts no trailing-initial vote, since no byline writes such a name before an initial, as rules/T5 and the order report read it: a group of Thai or Burmese names, each a word and a letter, suggests nothing — 2026-11-12 #1256. - A caller with a large list is told a sample of a few hundred names from each source is enough: nearly every kind of list measured is read right from 200 names, a longer list is rarely better (bylines written given first under a family-first base are the one kind measured that kept improving), and since the 1% floor no list measured in its base's own order is read worse at 2,000 names — 2026-11-16 #1442, 2026-11-16 ORDER FLOOR. -Open: the other three settings count their shares among the names with evidence on them, never the group, so a few stray names decide `patronymic_rules`, `initials_as_family` or `capitals_as_family` in a long silent list (2026-11-16 ORDER FLOOR, its bullet on the other settings); no measured population moves on any of them, and no issue is filed. A group gate for the short capitals words, under which one votes where another name of the list writes a longer capitals word at the same end, measured and not taken for 3.1 (2026-11-14 #1355, its Declined bullet), to weigh beside #1402. For a list mixing East Slavic and Turkic patronymics (uz_senate, kz_senate), suggesting both rules, and reading the Kazakh `-uly` and `-kyzy` endings as a Turkic signal, are not taken for 3.1 and not decided against (2026-11-15 #1356, its Not taken bullet). `_MIN_PATRONYMIC_VOTES`, five names, was set to keep small Russian groups written family first from moving a family-first base to given-first (2026-11-10 THRESHOLDS); since 2026-11-15 #1356 a `FAMILY_FIRST` base keeps its order on such a group, and that entry measured what relaxing the count does now: no same-order cell moves, and groups written given-first move a family-first base sooner. The threshold is unchanged and has no issue. #1308, the tracking issue, is closed; its other open item, the given names the given-name table's family-share filter drops, was #1357, settled for `John`, `David` and `Robert` by 2026-11-15 #1357, which leaves `James`, `Paul`, `George`, `Charles`, `Thomas` and `Martin` out. #1364's ORCID surname table at a given-box share of 12%, which helps Portuguese and Brazilian lists written given first and costs those written family first at 10 and 20 names, and the census table for English it held, are open (2026-11-19 #1364, its Declined and Open bullets; 2026-11-15 #1357 holds what a gate measured for the census table); so is the cost that table's `pv-listed-given` shows, English given names ORCID's holders rarely type as one (`Cooper`, `Burke`). Not measured, and without an issue: the table's 20-use floor (`MIN_USES`), and a family share between 10% and 15%. +Open: the other three settings count their shares among the names with evidence on them, never the group, so a few stray names decide `patronymic_rules`, `initials_as_family` or `capitals_as_family` in a long silent list (2026-11-16 ORDER FLOOR, its bullet on the other settings); no measured population moves on any of them, and no issue is filed. A group gate for the short capitals words, under which one votes where another name of the list writes a longer capitals word at the same end, measured and not taken for 3.1 (2026-11-14 #1355, its Declined bullet), to weigh beside #1402. For a list mixing East Slavic and Turkic patronymics (uz_senate, kz_senate), suggesting both rules, and reading the Kazakh `-uly` and `-kyzy` endings as a Turkic signal, are not taken for 3.1 and not decided against (2026-11-15 #1356, its Not taken bullet). `_MIN_PATRONYMIC_VOTES`, five names, was set to keep small Russian groups written family first from moving a family-first base to given-first (2026-11-10 THRESHOLDS); since 2026-11-15 #1356 a `FAMILY_FIRST` base keeps its order on such a group, and that entry measured what relaxing the count did then: no same-order cell moved, and groups written given-first moved a family-first base sooner; since 2026-11-19 #1447 two names written given first decide given-first by their position votes without the rule, so that measurement predates the vote and is not re-taken. The threshold is unchanged and has no issue. #1308, the tracking issue, is closed; its other open item, the given names the given-name table's family-share filter drops, was #1357, settled for `John`, `David` and `Robert` by 2026-11-15 #1357, which leaves `James`, `Paul`, `George`, `Charles`, `Thomas` and `Martin` out. #1364's ORCID surname table at a given-box share of 12%, which helps Portuguese and Brazilian lists written given first and costs those written family first at 10 and 20 names, and the census table for English it held, are open (2026-11-19 #1364, its Declined and Open bullets; 2026-11-15 #1357 holds what a gate measured for the census table); so is the cost that table's `pv-listed-given` shows, English given names ORCID's holders rarely type as one (`Cooper`, `Burke`). Not measured, and without an issue: the table's 20-use floor (`MIN_USES`), and a family share between 10% and 15%. ## Log - **2026-11-10 SCOPE — THE NEVER-DETECT-LANGUAGE RULE IS ABOUT THE PARSE, AND THE GROUP SUGGESTER IS OUTSIDE IT (DECIDED BY 2026-11-15 ACCEPTED).** AGENTS.md's design philosophy says the parser never detects language, because the language of a Latin-script name cannot be read off the name. `Parser.suggest` works on a group the caller declares to share one convention, reads statistics over the group and returns configuration with the evidence behind it, which the caller applies; it never mutates a base `Parser` or a default and changes no parse. Proposed wording: "the parser never detects language; the group suggester may, says what it saw, and its answer is configuration the caller applies". The given-name table does not ask what language a name is; it asks whether a word is almost always a given name, anywhere. This entry is the first commit of the branch so the wording can be settled before the code is read; the only items recorded as decided are the two under TABLES (the private tables, the nam_dict approval); the rest of this file was proposed for review when this entry was written (decided since, 2026-11-15 ACCEPTED). - **2026-11-10 TABLES — TWO PRIVATE COMPILED TABLES, READ BY THE SUGGESTER ONLY (THE PRIVATE TABLES AND THE NAM_DICT DERIVATION DECIDED THAT DAY; THE REST DECIDED BY 2026-11-15 ACCEPTED).** (The pinyin's source and its Unicode licence superseded by 2026-11-12 PINYIN FROM WIKIDATA: the surname readings Wikidata's family-name items state, CC0; the given-name table's source, nam_dict's country columns, by 2026-11-12 GIVEN NAMES FROM ORCID: ORCID's given-name boxes by stated country; its family share of 5%, "set once and not tuned", superseded by 2026-11-15 #1357: 10%, measured; its two tables made three by 2026-11-19 #1364, the ORCID surnames.) The romanized surnames (zh, ko, vi) and the common given names are written by tools under `tools/vocab/`, like `familiar.py`, into committed private modules under `nameparser/config/`, with a test that each is current. They are not `Lexicon` kinds for the first version, because a `family` reading on `Lee`, `Song` or `Long` would move the suffix gates derived from name readings and a `given` reading would move titles and particles; a table no parse reads moves no snapshot. Making them `Lexicon` kinds later, if a caller needs to tune them, stays open. The given-name table is derived from nam_dict's 55 country columns (top N per country by frequency band, unioned), keeping a name only if ORCID's researchers wrote it in the family box at most 5% of the times they wrote it (at least 20 uses), it is longer than one letter and it is not in the romanized surname sets. N (500) was chosen with the spikes (SIGNALS, top 100 against top 500); the family share and the use count were set once and not tuned, the THRESHOLDS measurement finding that the tables meet its constraint as built. Licences: nam_dict GNU FDL 1.2, ORCID's public data file CC0, Unihan the Unicode licence; the module header carries the sources once. The table derived from nam_dict is approved. -- **2026-11-10 SIGNALS (its "the rule stands down under a family-first base" superseded by 2026-11-15 #1356 as wider than true: the rule's reordering stands down, its patronymic view fills under `FAMILY_FIRST`) — WHAT EACH SIGNAL VOTES, AS MEASURED WITH THE THROWAWAY SPIKES (DECIDED BY 2026-11-15 ACCEPTED).** Measured with the throwaway spikes on 2026-11-10. The spikes counted votes per SIGNAL (a name read by two signals cast two votes, and its group decided on the signal votes), where `suggest` counts one order vote per NAME, so their group figures below are not comparable with suggest's; the per-name re-take, with its command, is 2026-11-10 THRESHOLDS. Populations are PatentsView inventors by country, UK company filers (PSC) by nationality, Czech candidates, Vietnamese names and national parliament lists (OpenSanctions); none of them built the given-name list. +- **2026-11-10 SIGNALS (its "the rule stands down under a family-first base" superseded by 2026-11-15 #1356 as wider than true: the rule's reordering stands down, its patronymic view fills under `FAMILY_FIRST`; its "the patronymic does not vote on order", and the position vote it declined, superseded by 2026-11-19 #1447, under which an East Slavic patronymic's position votes on the order through a signal of its own while the rule stays a decision apart) — WHAT EACH SIGNAL VOTES, AS MEASURED WITH THE THROWAWAY SPIKES (DECIDED BY 2026-11-15 ACCEPTED).** Measured with the throwaway spikes on 2026-11-10. The spikes counted votes per SIGNAL (a name read by two signals cast two votes, and its group decided on the signal votes), where `suggest` counts one order vote per NAME, so their group figures below are not comparable with suggest's; the per-name re-take, with its command, is 2026-11-10 THRESHOLDS. Populations are PatentsView inventors by country, UK company filers (PSC) by nationality, Czech candidates, Vietnamese names and national parliament lists (OpenSanctions); none of them built the given-name list. - Capitals word position: decisive where present (Turkey's parliament `Mehmet DEMİR` 592:0); a capitals run in the middle (Hong Kong `Jeffrey LAM Kin-fung`) does not vote. - Comma names do not vote on order: 373 comma names outvoted the comma-less majority of India's Lok Sabha list. - Trailing initial (`Smith J.`) votes family-first; a leading initial does not, having voted 76 wrong of 112 in given-first Indian groups (`S. Ramesh`). Since 2026-11-11 TRAILING INITIAL it votes only where initials end most of the group's names. @@ -43,7 +45,7 @@ Open: the other three settings count their shares among the names with evidence - Declined: the vocabulary's `given` and `family` readings as order evidence. Measured with the throwaway spikes, they vote wrong about as often as right and mostly wrong in family-first groups (Dutch 92 right, 496 wrong): they are collision words, chosen because they clash with a title or particle, not common names. - Declined: `Reading.languages` as evidence for suggesting a language pack. English and the Spanish given-name list top nearly every group, Cyrillic groups carry no tags and Portugal's parliament ranks the Spanish list over `pt`. A pack could later follow from settings evidence; it is out of the first version. - Declined, superseded: the familiar forms. They were useful (Western family-first groups 93-100% from 10 names once the romanized surnames were subtracted, `Kim`, `Lee` and `Chan` being listed familiar forms), but the common-given-names list alone does as well or better, and it keeps the parse's `familiar` vocabulary out of this. -- **2026-11-10 TURKIC (its two items "left open" superseded by 2026-11-15 #1356, which settles the given-first order a decided East Slavic rule forces, for a `FAMILY_FIRST` base whose list writes the patronymic last, and leaves the mixed list as it is; its comparator for a three-word name ending in a standalone marker in a family-last list, the marker alone, superseded by decisions/O2's 2026-11-12 #1187 entry, under which the `kg_jogorku_kenesh` row's `nothing`, `{E}` and `suggest` read 86/90 and its `{T}` and `{E,T}` stay 90/90) — THE RULE ALONE, NO ORDER OF ITS OWN (DECIDED BY 2026-11-15 ACCEPTED).** Measured on the OpenSanctions parliament lists, read from `~/.cache/nameparser-tools/local/opensanctions-parliaments/raw.jsonl` line by line, keeping the rows whose `form` is `"name"` and whose `script` is `Latin` or `Cyrillic` (the dataset keys named below). The `script` field also holds `mixed` on four rows (one in `uz_legislative_chamber`'s `Firdavs Qobiljonovich Qurbоnov`, one more there, one in `uz_senate`, one in `kz_senate`): a name written with a Cyrillic letter inside a Latin word, a lookalike typo, which no real reader sees as another script, so they are dropped and not scored. Lists: Latin `az_parliament` 124, `kz_senate` 48, `uz_senate` 59, `uz_legislative_chamber` 143, `tm_mejlis` 124, Cyrillic `kz_mazhilis` 96, `kg_jogorku_kenesh` 90. Scoring: a name is right when `parsed.family` is the true family. Where the list writes the family in capitals (`az_parliament`, `kz_mazhilis`) the one capitals word is the true family; elsewhere the family is the end the list writes it at, read by eye off the first twelve names of each list in file order (after the filter above), then applied to every name of two or more words (kz_senate and uz_senate first, uz_legislative_chamber, tm_mejlis and kg_jogorku_kenesh last). So only `az_parliament` and `kz_mazhilis` have an independent truth; every other row is scored against the list's own convention (the end that list writes the family at), not against a sampled reading of each name, and it shows what the settings do to a list written that way, not how often they read real families. The by-eye sample is twelve, not the thirty first planned. Re-taken 2026-11-10 by `uv run python tools/differential/suggest_measure.py` (its TURKIC table, the same selection and scoring, with a `suggest` column end to end), which reproduces every cell below; the label of kz_mazhilis was wrong as first written ("family first (capitals)"), the list writing its capitals family last (`Тилектес Серикбайулы АДАМБЕКОВ`), as the 96/96 under the default order shows. Family right out of the scored names under each fixed `Policy` (the second column holds the order the list uses): +- **2026-11-10 TURKIC (its two items "left open" superseded by 2026-11-15 #1356, which settles the given-first order a decided East Slavic rule forces, for a `FAMILY_FIRST` base whose list writes the patronymic last, and leaves the mixed list as it is; its known cost for `uz_senate` and `kz_senate` under the default base, 52/59 and 41/48, superseded by 2026-11-19 #1447, under which their patronymics written last decide family-first and they read 59/59 and 48/48; its comparator for a three-word name ending in a standalone marker in a family-last list, the marker alone, superseded by decisions/O2's 2026-11-12 #1187 entry, under which the `kg_jogorku_kenesh` row's `nothing`, `{E}` and `suggest` read 86/90 and its `{T}` and `{E,T}` stay 90/90) — THE RULE ALONE, NO ORDER OF ITS OWN (DECIDED BY 2026-11-15 ACCEPTED).** Measured on the OpenSanctions parliament lists, read from `~/.cache/nameparser-tools/local/opensanctions-parliaments/raw.jsonl` line by line, keeping the rows whose `form` is `"name"` and whose `script` is `Latin` or `Cyrillic` (the dataset keys named below). The `script` field also holds `mixed` on four rows (one in `uz_legislative_chamber`'s `Firdavs Qobiljonovich Qurbоnov`, one more there, one in `uz_senate`, one in `kz_senate`): a name written with a Cyrillic letter inside a Latin word, a lookalike typo, which no real reader sees as another script, so they are dropped and not scored. Lists: Latin `az_parliament` 124, `kz_senate` 48, `uz_senate` 59, `uz_legislative_chamber` 143, `tm_mejlis` 124, Cyrillic `kz_mazhilis` 96, `kg_jogorku_kenesh` 90. Scoring: a name is right when `parsed.family` is the true family. Where the list writes the family in capitals (`az_parliament`, `kz_mazhilis`) the one capitals word is the true family; elsewhere the family is the end the list writes it at, read by eye off the first twelve names of each list in file order (after the filter above), then applied to every name of two or more words (kz_senate and uz_senate first, uz_legislative_chamber, tm_mejlis and kg_jogorku_kenesh last). So only `az_parliament` and `kz_mazhilis` have an independent truth; every other row is scored against the list's own convention (the end that list writes the family at), not against a sampled reading of each name, and it shows what the settings do to a list written that way, not how often they read real families. The by-eye sample is twelve, not the thirty first planned. Re-taken 2026-11-10 by `uv run python tools/differential/suggest_measure.py` (its TURKIC table, the same selection and scoring, with a `suggest` column end to end), which reproduces every cell below; the label of kz_mazhilis was wrong as first written ("family first (capitals)"), the list writing its capitals family last (`Тилектес Серикбайулы АДАМБЕКОВ`), as the 96/96 under the default order shows. Family right out of the scored names under each fixed `Policy` (the second column holds the order the list uses): | list | order | nothing | {T} | {T}+FF | {T}+FFGL | {E} | {E,T} | FF alone | |---|---|---|---|---|---|---|---|---| @@ -57,7 +59,7 @@ Open: the other three settings count their shares among the names with evidence Only 121 of az's 124 names, 2 of uz_senate's, 7 of uz_legislative_chamber's, 2 of tm_mejlis's and 4 of kg_jogorku_kenesh's carry a Turkic marker word (`oglu`, `oğlu`, `qızı`, `o‘g‘li`); the other lists write Russified `-ovich` patronymics, which are East Slavic votes, and no Turkic setting touches them. The order columns are the list's own convention, so FF raises the family-first lists and breaks the family-last ones whether or not the rule is on: the order is not a property of the patronymic. What the rule adds is that `{TURKIC}` alone reads a marker name either way round under the default order (`Mamedov Ali Huseyn oglu` and `Ali Huseyn oglu Mamedov` both family Mamedov, given Ali, patronymic `Huseyn oglu`), where the default alone leaves family `oglu`; under `FAMILY_FIRST` the given-first `Ali Huseyn oglu Mamedov` reads family Ali. So the builder check the first design stated, that TURKIC under the default order leaves family `oglu`, no longer holds on the tree measured here (the rule reads both) and the Turkic answer is the East Slavic one minus the forced order: a decided Turkic rule gives `patronymic_rules={TURKIC}`, and the order is decided from the names' own votes, never forced to given-first, because forcing it would turn az's capitals-written family-first names (124/124 with the order decided, 121/124 with it forced) wrong. End to end through `Parser().suggest` on each whole list: az 124/124 (`name_order=FAMILY_FIRST` from the capitals votes, `{TURKIC}`), the Russified lists decided `{EAST_SLAVIC}`. Known cost: where a list holds both shapes the larger set wins the one patronymic decision, so uz_senate (2 marker names against `-ovich`) decides East Slavic and reads 52/59 (its `o‘g‘li` names, and its two-word names, which the forced given-first order of a decided East Slavic rule reads family-last); kz_senate's `-uly` patronymics (`Kydyrali Darkhan Kuandykuly`) are not a Turkic signal at all and read 41/48, still above "nothing" at 0/48. Both are about East Slavic deciding a mixed group, not the Turkic answer, and are left open. -- **2026-11-10 THRESHOLDS (its "TOP, MAX_FAMILY_SHARE and MIN_USES in tools/vocab/order_names.py are unchanged" superseded by 2026-11-15 #1357 for the family share, now 10%; its "no surname lookup" for a final capitals word of two or three letters superseded by 2026-11-14 #1397, which looks the word up, to veto only; its "Known cost", the forced given-first order, and its parliament bullet's "get the given-first order the rule needs" for ua_rada, kz_senate and uz_senate, superseded by 2026-11-15 #1356 for a `FAMILY_FIRST` base, whose order such a list now keeps, and standing under the other two bases; that entry also measured what `_MIN_PATRONYMIC_VOTES` still decides) — TWO NAMES, MORE THAN TWO THIRDS; A PATRONYMIC RULE FIVE NAMES AND MORE THAN FOUR IN FIVE (DECIDED BY 2026-11-15 ACCEPTED).** Measured with `uv run python tools/differential/suggest_measure.py` (defaults: groups of 2, 3, 4, 5, 10, 20, 50 and 200 names, 300 groups a size, seed 20261110; 20s wall clock on 2026-11-10 on one 12-CPU machine, a machine-bound figure a re-take times again; the candidates below were run before sizes 2 to 4 joined the defaults, over 5 to 200). Each population is a local corpus whose names are composed from their filers' boxes, so the order is known: PatentsView inventors of 13 countries, UK company filers (PSC) of 8 nationalities, Czech candidates and Vietnamese names, at most 20,000 names each drawn by a seeded reservoir, every group written given-first and family-first and read under a given-first and a family-first base. A group is right where the suggested `name_order` writes the family at the end it was written with. The constraint is the anti-goal: a group written in its base's own order must stay right in at least 95% of groups at every size. Harness proof first: `--set _MIN_VOTES=1000000 --set _MIN_PATRONYMIC_VOTES=1000000` decides nothing (the second holds the patronymic rule, which forces an order of its own; before the patronymic count, `_MIN_VOTES` held both), and every one of the 46 rows written against its base read 0% at all eight sizes, every one of the 46 written in its base's order 100%. The figures here were re-taken after a review found the first draft's group draws seeded like the reservoir's, which made a group a run of consecutive records of a sorted file; the two streams are seeded apart now, and nothing below comes from the coupled draw. +- **2026-11-10 THRESHOLDS (its "TOP, MAX_FAMILY_SHARE and MIN_USES in tools/vocab/order_names.py are unchanged" superseded by 2026-11-15 #1357 for the family share, now 10%; its "no surname lookup" for a final capitals word of two or three letters superseded by 2026-11-14 #1397, which looks the word up, to veto only; its "Known cost", the forced given-first order, and its parliament bullet's "get the given-first order the rule needs" for ua_rada, kz_senate and uz_senate, superseded by 2026-11-15 #1356 for a `FAMILY_FIRST` base, whose order such a list now keeps, and by 2026-11-19 #1447 under the other two, where the patronymics written last vote family-first and `ua_rada`, `kz_senate` and `uz_senate` get it; that entry also measured what `_MIN_PATRONYMIC_VOTES` still decides) — TWO NAMES, MORE THAN TWO THIRDS; A PATRONYMIC RULE FIVE NAMES AND MORE THAN FOUR IN FIVE (DECIDED BY 2026-11-15 ACCEPTED).** Measured with `uv run python tools/differential/suggest_measure.py` (defaults: groups of 2, 3, 4, 5, 10, 20, 50 and 200 names, 300 groups a size, seed 20261110; 20s wall clock on 2026-11-10 on one 12-CPU machine, a machine-bound figure a re-take times again; the candidates below were run before sizes 2 to 4 joined the defaults, over 5 to 200). Each population is a local corpus whose names are composed from their filers' boxes, so the order is known: PatentsView inventors of 13 countries, UK company filers (PSC) of 8 nationalities, Czech candidates and Vietnamese names, at most 20,000 names each drawn by a seeded reservoir, every group written given-first and family-first and read under a given-first and a family-first base. A group is right where the suggested `name_order` writes the family at the end it was written with. The constraint is the anti-goal: a group written in its base's own order must stay right in at least 95% of groups at every size. Harness proof first: `--set _MIN_VOTES=1000000 --set _MIN_PATRONYMIC_VOTES=1000000` decides nothing (the second holds the patronymic rule, which forces an order of its own; before the patronymic count, `_MIN_VOTES` held both), and every one of the 46 rows written against its base read 0% at all eight sizes, every one of the 46 written in its base's order 100%. The figures here were re-taken after a review found the first draft's group draws seeded like the reservoir's, which made a group a run of consecutive records of a sorted file; the two streams are seeded apart now, and nothing below comes from the coupled draw. - The rule before this entry (`_MIN_VOTES = 1`, a share of a half for the order and the patronymic rule; `--set _MIN_VOTES=1 --set _MIN_SHARE=0.5 --set _MIN_PATRONYMIC_SHARE=0.5`) failed it: its worst same-order row read 54%, 66%, 70%, 68% and 82% at the five sizes, PatentsView's Russian inventors written family-first under a family-first base. 43% of those names carry a patronymic (`Koryukalov Yury Igorevich`, the tool's signal counts), so many groups decided the East Slavic rule, and its forced given-first order reads the other names (`Popov Ivan`) given-first. - Candidates, each a run of the tool with `--set` (`_MIN_VOTES`, order share, patronymic share: the worst same-order row at 5 / 10 / 20 / 50 / 200, then the mean of the rows written against their base): 1, 0.6, 0.8: 91 / 92 / 97 / 98 / 100, mean 88 / 95 / 98 / 100 / 100; 1, 2/3, 0.8: 91 / 92 / 97 / 99 / 100, mean 87 / 94 / 97 / 99 / 100 (with one vote enough, Indian inventors' given-first groups fail at 5 and 10: one name voting family-first moves 9% of them); 2, 0.5, 0.8: 96 / 99 / 97 / 98 / 100, mean 72 / 88 / 96 / 100 / 100; 2, 0.6, 0.8: 96 / 99 / 98 / 98 / 100, the same mean; 2, 2/3, 0.5: 54 / 66 / 70 / 68 / 82 (the Russian groups again, whatever the order share); 2, 2/3, 0.8: 96 / 99 / 99 / 100 / 100, mean 71 / 87 / 95 / 99 / 100; 2, 2/3, 0.9: the same as 0.8; 3, 2/3, 0.8: 96 / 99 / 100 / 100 / 100, mean 53 / 79 / 92 / 99 / 100. - Chosen: `_MIN_VOTES = 2`, `_MIN_SHARE = 2/3` and a new `_MIN_PATRONYMIC_SHARE = 0.8`, the last read for the Turkic rule as for the East Slavic one. Two names is the least that meets the constraint at 5 and 10 names, re-checked on the uncoupled draw; two thirds holds the same-order rows at 99% from 10 names where 0.6 lets them fall to 98%, for one point of the mean, and a tie or two names against one decides nothing; the patronymic rule gets its own, higher share because a decided East Slavic rule overrides the order, and four in five is the lowest tried that keeps the Russian family-first groups at the bar from 5 names (96% at 5, 99% at 10, 100% from 20, before the patronymic count below). Nine in ten does no better, because the groups it still moves are those whose voting names are all patronymic ones, the rest casting no vote. The contested names stay in the patronymic share's denominator (the names casting any vote): `--checks` decides each group of a draw of its own (the same sizes and trials, 2 to 200, 110,400 groups) that holds at least `_MIN_PATRONYMIC_VOTES` names of one rule, the groups that could decide it (2,031 after the fix wave), under both denominators, with and without the names whose only evidence is a contested order, and none decides another rule (a planted positive control, five patronymic names and two contested ones, does); a name with conflicting order signals still carries evidence. TOP, MAX_FAMILY_SHARE and MIN_USES in tools/vocab/order_names.py are unchanged: the tables meet the constraint as built, and what they limit is how soon a group written against its base moves, which is the coverage question left open. @@ -318,7 +320,7 @@ Open: the other three settings count their shares among the names with evidence - The ending word looked up as any word, so it votes alone too (`silent = _opens_in_short_capitals(words)`). The largest gains written given-first under a family-first base (`orcid-famcaps-short` 43.0 / 69.3 / 82.0 / 93.7 / 99.7 / 100%, `orcid-famcaps-ea` 74.0 / 94.7 / 98.3 / 99.3 / 100%), but initials that spell a surname then vote given-first (`Marsh JO`): `orcid-byline-joined` written family-first casts 41 right and 71 wrong surname votes, and its same-order row falls to 98.7 / 97.0 / 94.3 / 93.7 / 80.3 / 66.7 / 72.3 / 76.7%; `orcid-byline`'s to 100 / 99.3 / 99.3 / 99.3 / 99.0 / 98.0 / 98.7 / 100%. - The first variant for a name of exactly two words, the rule before this entry for a longer one (`silent = _opens_in_short_capitals(words) or (_ends_in_short_capitals(words) and len(words) == 2)`, and in the loop below it `at_last = False` for the surname table where the name ends in a short capitals word). The byline costs of the first variant, cell for cell, and less of the fix: `orcid-famcaps-short` given-first under a given-first base 99.7 / 99.7 / 98.7 / 99.0 / 96.0 / 97.3 / 99.7 / 100%, 147 wrong surname votes left of 440. - How often each shape is written, a dated snapshot of 2026-11-14 on d516e89c (the tree before this change), counted with a script in the 3.1 cycle's session notes (`1397-gate/shapes1397.py`, not the repository; the definition here is all it does). Over the 1,831,533 records of ORCID's `raw.jsonl`, the 125,960 with a non-empty `credit` field: read `words = _suggest._name_words(credit, Lexicon.default())[0]`, the words the signals read past titles and post-nominals, and keep the name where no comma left it out, it has two words or more and `_suggest._ends_in_short_capitals(words)` holds. 1,025 names. A word matches the family box where the two are equal once casefolded with hyphens and spaces removed (the `family` field whole). The last word matches it in 156 (the family written last, in short capitals); of the rest the first word matches it in 573 (a byline, its initials joined); 296 match neither way. The surname vote (`name_votes(credit, lexicon)` at d516e89c) was cast on 40 of the 573, all family-first and so right, and on 19 of the 156, all family-first and so wrong, which is why silencing every such name was not taken. A recount that reads other words (the raw text split at spaces) or matches the family box another way gives other digits; these are this definition's. 5,013 holders have a family box of that shape and a given box with no capitals word (the tool's `orcid-famcaps-short`), which is how they filled a form, not how they write a name. -- **2026-11-15 #1356 (its table, and its `orcid-byline-joined` exception "at 50 and 200 names", superseded by 2026-11-15 #1357; its `QQSIDOROV Zzyvan Petrovich` case under a `FAMILY_FIRST_GIVEN_LAST` base, whose patch now carries `name_order=FAMILY_FIRST` too, by 2026-11-19 #1364) — PATRONYMICS WRITTEN LAST KEEP A FAMILY_FIRST BASE'S ORDER; EVERY OTHER EAST SLAVIC GROUP GETS THE GIVEN-FIRST ORDER AS BEFORE.** A decided East Slavic rule decided the order as given-first on any base (2026-11-10 SIGNALS, FIX WAVE), so a caller who had declared `FAMILY_FIRST` for a list written family first was moved to a setting that reads its names without a patronymic family-last (`Aliyev Farrukh`) and its Turkic marker names by the wrong word. Decided: where the base's order is `FAMILY_FIRST`, the East Slavic rule is decided and the names' own votes do not decide given-first, the suggestion keeps the base's order and suggests the rule only where MORE East Slavic voters end in the patronymic than have it in the middle; otherwise, a tie included, it behaves as before (given-first with the rule). A `FAMILY_FIRST_GIVEN_LAST` base and a given-first base are as before. The order is kept only on that one branch, and a base's own rule value is never dropped. A list mixing East Slavic and Turkic patronymics is left as it is, and `_MIN_PATRONYMIC_VOTES` is unchanged. The rest of this entry is implementation and record. +- **2026-11-15 #1356 (its table, and its `orcid-byline-joined` exception "at 50 and 200 names", superseded by 2026-11-15 #1357; its `QQSIDOROV Zzyvan Petrovich` case under a `FAMILY_FIRST_GIVEN_LAST` base, whose patch now carries `name_order=FAMILY_FIRST` too, by 2026-11-19 #1364; its "every other East Slavic group gets the given-first order" superseded by 2026-11-19 #1447: a group whose patronymics stand last gets the family-first order they vote for under a given-first and a `FAMILY_FIRST_GIVEN_LAST` base, one written in the middle the given-first order, and the given-first order the rule brings is left for a group whose votes decide no order; its Observed bullet, that a name written family, given, patronymic casts no order vote and two given-first names decide given-first beside any number of them, superseded the same way, each such name voting family-first by its position (eight beside Anna and Igor now decide family-first, 8 for and 2 against); its TURKIC `suggest` column's 41/48 and 52/59 read 48/48 and 59/59 under the default base since then) — PATRONYMICS WRITTEN LAST KEEP A FAMILY_FIRST BASE'S ORDER; EVERY OTHER EAST SLAVIC GROUP GETS THE GIVEN-FIRST ORDER AS BEFORE.** A decided East Slavic rule decided the order as given-first on any base (2026-11-10 SIGNALS, FIX WAVE), so a caller who had declared `FAMILY_FIRST` for a list written family first was moved to a setting that reads its names without a patronymic family-last (`Aliyev Farrukh`) and its Turkic marker names by the wrong word. Decided: where the base's order is `FAMILY_FIRST`, the East Slavic rule is decided and the names' own votes do not decide given-first, the suggestion keeps the base's order and suggests the rule only where MORE East Slavic voters end in the patronymic than have it in the middle; otherwise, a tie included, it behaves as before (given-first with the rule). A `FAMILY_FIRST_GIVEN_LAST` base and a given-first base are as before. The order is kept only on that one branch, and a base's own rule value is never dropped. A list mixing East Slavic and Turkic patronymics is left as it is, and `_MIN_PATRONYMIC_VOTES` is unchanged. The rest of this entry is implementation and record. - The facts it rests on, by parse on 8f4b77b9. Under a declared family-first order the rule's REORDERING stands down (rules/O1), and the `patronymic` view it fills (rules/R9) does not: `Policy(name_order=FAMILY_FIRST, patronymic_rules={EAST_SLAVIC})` reads `Sidorov Ivan Petrovich` as family `Sidorov`, given `Ivan`, middle `Petrovich`, patronymic `Petrovich`, the fields of `FAMILY_FIRST` alone and the view. `FAMILY_FIRST` reads a name written given, patronymic, family wrong with or without the rule (`Ivan Petrovich Sidorov`: family `Ivan`). `FAMILY_FIRST_GIVEN_LAST` reads the family of `Sidorov Ivan Petrovich` right and its given name wrong (given `Petrovich`, middle `Ivan`), and the rule alone moves no field and fills no view there. And with a given-first order the rule reads BOTH writings right, rotating the one written family first: a list where every name carries a patronymic is read whole under the forced order, whatever the mix; what that order costs is the names with no patronymic in a list written family first. - As implemented: of the names casting the East Slavic vote, each of three words by rules/O1, a name writes the patronymic in the middle where its middle word carries the ending (`has_patronymic_ending`, the first of the vote's own two tests), and last otherwise; a name with the ending on both words counts as middle, as rules/O1 reads it and rotates nothing. Names casting no East Slavic vote are not counted. Where the order is kept the patronymic evidence's note says how many of the voters write the patronymic last and, where some write it in the middle, how many get no given-first order from the suggestion; it says nothing of how those are read, since `capitals_as_family`, suggested in the same patch, reads them where their family is in capitals (five `QQSIDOROV Zzyvan Petrovich` and three `Jjmark Borisovich JJVOLKAR`: the order kept, the rule and the switch suggested, 8 of 8 whole names read right, 5 at the base); the order evidence is the votes' or the base's, with no rule note. Everywhere else the order evidence carries the earlier note ("it needs a given-first order"). Where the names' own votes decide family-first under a given-first or a `FAMILY_FIRST_GIVEN_LAST` base the rule comes with the votes' order as before, its order note now saying the rule "reorders no name" under it where it said "stands down". A base already carrying the rule: under `FAMILY_FIRST` with the patronymics mostly last, nothing changes and the evidence is decided as the base's; on every other branch the given-first order is suggested and the rule stays the base's. A base carrying the Turkic rule alone gets the East Slavic one beside it on every branch. The Turkic rule's own decision is untouched. - Measured with `uv run python tools/differential/suggest_measure.py --wrong-words 12 --base `, the master this sits on (2026-11-15; 300 groups a size, seed 20261110, sizes 2 / 3 / 4 / 5 / 10 / 20 / 50 / 200), the tool reading one population and one base added with this entry: `pv-RU-patronymic` (8,393 names: PatentsView's Russian inventors whose given box is a given name and a patronymic, so that written given-first they are given, patronymic, family and written family-first family, given, patronymic), and `FAMILY_FIRST_GIVEN_LAST` as a third base for the parliament lists. The parliament rows are from the `opensanctions-parliaments` cache as fetched 2026-11-12, not re-fetched. Five rows moved: @@ -449,7 +451,7 @@ Open: the other three settings count their shares among the names with evidence - The eight that never settle: `orcid-givcaps`' four rows and `orcid-byline-joined` written given first under a family-first base, the kinds docs/suggest.rst's "Where it stops" names; `orcid-byline` written given first under a family-first base, which reads 57% at 200 names and 99% only at 2,000, the one row a longer list kept helping; and `pv-RU-patronymic` written family first, both rows. The two that settle at 500 are the same-order rows `orcid-byline` (99% at 200) and `orcid-byline-joined` (94 / 92 / 96% at 50 / 100 / 200, its 100-name cell a size no earlier table printed, and its 500 a draw from a population of 644), each written given first under a given-first base. - `pv-RU-patronymic` written family first under a family-first base, a same-order row, reads 100 / 100 / 100 / 100 / 99 / 100 / 94 / 84 / 88% at those sizes: under 95% from 500 names, where every earlier table stopped at 200. About 3 of its names in 1,000 cast a wrong given-name vote (a surname that is also a given name, written first) and about 1 in 1,000 a right order vote, from the capitals and surname signals (the given-name signal casts no right vote there), and `_MIN_VOTES` and `_MIN_SHARE` count only the names that voted, so two stray votes decide a list of any length. #1442 holds the reproduction with made-up names and what a fix has to keep; one run of 200 groups a size, so 84% and 88% are not told apart. - Decided for the docs: the user page advises a sample of a few hundred names per source, which is true before and after any fix to #1442. Not decided: a floor on votes as a share of the whole list. -- **2026-11-16 ORDER FLOOR (its sizes from which a row written against its base is read right, and `orcid-byline`'s given-first row, superseded by 2026-11-19 #1364 for the populations its table moves: 500 names for `orcid-byline` written given first under a family-first base, 100 for `orcid-byline-joined` written family first under a given-first base, and `orcid-byline` written given first under a given-first base 99.0 / 98.7 / 100% at 50 / 100 / 200 names, no longer an exception) — AN ORDER NEEDS ITS VOTES TO BE AT LEAST 1% OF THE GROUP, NOT ONLY OF THE NAMES THAT VOTE.** Settles [#1442](https://github.com/derek73/python-nameparser/issues/1442). `_MIN_VOTES` and `_MIN_SHARE` counted only the names casting an order vote, so in a long list where almost no name votes, two stray votes decided the order for every name (2026-11-16 #1442 above: `pv-RU-patronymic` written family first under a family-first base, 87% at 1,000 and 2,000 names). +- **2026-11-16 ORDER FLOOR (its sizes from which a row written against its base is read right, and `orcid-byline`'s given-first row, superseded by 2026-11-19 #1364 for the populations its table moves: 500 names for `orcid-byline` written given first under a family-first base, 100 for `orcid-byline-joined` written family first under a given-first base, and `orcid-byline` written given first under a given-first base 99.0 / 98.7 / 100% at 50 / 100 / 200 names, no longer an exception; its "what the floor changes beside a decided East Slavic rule", ten `Zzyvova Qqsan Petrovich` under `FAMILY_FIRST_GIVEN_LAST` getting the rule's given-first order, superseded by 2026-11-19 #1447: the patronymics' positions vote family-first, the end the two strays vote too, and the twelve clear the floor, so the base gets `FAMILY_FIRST` (ten alone, 10 of 1,012, would be held back and the rule's given-first order stand); written in the middle, the ten positions vote given-first and are held back the same way, the rule giving that order; the floor's case against the rule is held by names whose position is contested, `QQSAN Petrovich Zzyvova`) — AN ORDER NEEDS ITS VOTES TO BE AT LEAST 1% OF THE GROUP, NOT ONLY OF THE NAMES THAT VOTE.** Settles [#1442](https://github.com/derek73/python-nameparser/issues/1442). `_MIN_VOTES` and `_MIN_SHARE` counted only the names casting an order vote, so in a long list where almost no name votes, two stray votes decided the order for every name (2026-11-16 #1442 above: `pv-RU-patronymic` written family first under a family-first base, 87% at 1,000 and 2,000 names). - Decided: `_suggest._MIN_ORDER_GROUP_SHARE = 0.01`. The names voting for the winning end must also be at least 1% of the group's names, voting or not, save the names a comma left out (`_Tally.winner`). The order evidence's note says how many names voted for which end and why that is too few where the floor alone leaves the order undecided, and where the votes it holds back are for family-first against the given-first order a decided East Slavic rule sets; where they are for the rule's own given-first order the note says nothing of them, since they decided nothing (found by the review of 66c827d9, whose note named the held-back votes beside an order the rule had decided). - The denominator leaves out the names a comma left out (`_comma_note`) because a comma name states its own order and the order decided reads none of them: 199 `Smith, John` with `Smith Mary` and `Kim Minjun` decide family-first on the two names the order reads, where a whole-list denominator (66c827d9) held them back as 2 of 201. Re-measured after the change with the same command: no cell of any table and no parliament suggestion moves, the one parliament list holding comma names, `in_sansad` (373 of its 8,295), deciding given-first on 1,068 votes, far over 1% either way. - What the floor changes beside a decided East Slavic rule, pinned by tests (`test_strays_against_the_rules_order_no_longer_decide_it`): ten names written given, patronymic, family (`Qqsan Petrovich Zzyvova`) with `Smith Mary` and `Kim Minjun` among 1,000 silent names decided family-first on master under a given-first base and under `FAMILY_FIRST` (the two strays outvoting nothing), under which the rule reorders no name, and now get the rule's given-first order; under `FAMILY_FIRST_GIVEN_LAST` the same with the patronymic written last (`Zzyvova Qqsan Petrovich`), where master kept that order and its reading of the patronymic as the given name. This is the one place the floor moves an outcome toward an order rather than toward the base, and it moves it to the order the patronymics carry. `_keeps_family_first` reads the same winner, so a held-back stray order under a `FAMILY_FIRST` base whose patronymics are written last falls to #1356's branch: the base keeps its order and gets the rule alone. @@ -501,7 +503,7 @@ Open: the other three settings count their shares among the names with evidence - `orcid-byline-joined` written given first under a given-first base, every cell of the 300-trial run (2 / 3 / 4 / 5 / 10 / 20 / 50 / 100 / 200 / 500 names; it holds 644): 100.0 / 100.0 / 100.0 / 99.7 / 99.7 / 98.3 / 94.7 / 93.3 / 97.3 / 100.0%, identical with and without the floor. Its 200-name cell is 0.3 points over 97%, and two other runs read it 96% (#1442's entry above, 200 trials, and the review's of 66c827d9, 100 trials), so "at least 97% at every size but 50 and 100" in `Parser.suggest`'s docstring rests on this run alone and is within a group or two of failing it. - The same-order cells under 97%, exactly, outside `orcid-givcaps` (whose rows fail at every size from 2, as 2026-11-12 CAPITALS records): `orcid-byline-joined` written given first under a given-first base, 94.7% and 93.3% at 50 and 100 names, the lowest same-order cells of a population other than `orcid-givcaps`, so docs/suggest.rst's "just under 95% of groups of 50" holds and gains the 100; `orcid-byline` written the same way, 95.3% and 96.7% at 100 and 200 (97.0% at 50), which `Parser.suggest`'s docstring and docs/suggest.rst had as "at least 97%" from tables that printed no 100 and rounded the 200. #1442's entry above read the first 92% at 100 names on 200 trials. - The docs: docs/suggest.rst's advice to give a sample of a few hundred names stands, for speed and because more rarely helps. It says the order's own votes are not read worse in a long list, scoped to the lists measured, and that a handful of names can still decide the other three settings in one (the bullet above on them); its deciding table and the order paragraph state the floor. -- **2026-11-19 #1364 — A SECOND SURNAME TABLE, ORCID'S FAMILY-BOX WORDS ITS HOLDERS RARELY TYPE AS A GIVEN NAME, VOTES WITH THE ROMANIZED ONE; ITS GIVEN-BOX SHARE IS 5%.** Decided in [#1364](https://github.com/derek73/python-nameparser/issues/1364) on 2026-11-19: option (B), the ORCID mirror of the given-name table, Spanish first because that is what the recipe gives, private to the suggester, its size whatever the recipe yields at the measured cutoff, and a looser share of about 12% measured for Portuguese surnames; a census-derived table for English (option A) is held until a real list written family first without commas is found, the example in the issue being constructed. Decided here, by the measurement below: the share is 5%, and a `FAMILY_FIRST_GIVEN_LAST` base gets `FAMILY_FIRST` where a decided East Slavic rule meets a family-first order the names' votes decide. +- **2026-11-19 #1364 (its sizes bullet's PatentsView Philippine inventors at 100 names and `pv-RU-patronymic` written family first under a given-first base read right at no size, superseded by 2026-11-19 #1447: 20 names and 2, through the patronymics' position votes) — A SECOND SURNAME TABLE, ORCID'S FAMILY-BOX WORDS ITS HOLDERS RARELY TYPE AS A GIVEN NAME, VOTES WITH THE ROMANIZED ONE; ITS GIVEN-BOX SHARE IS 5%.** Decided in [#1364](https://github.com/derek73/python-nameparser/issues/1364) on 2026-11-19: option (B), the ORCID mirror of the given-name table, Spanish first because that is what the recipe gives, private to the suggester, its size whatever the recipe yields at the measured cutoff, and a looser share of about 12% measured for Portuguese surnames; a census-derived table for English (option A) is held until a real list written family first without commas is found, the example in the issue being constructed. Decided here, by the measurement below: the share is 5%, and a `FAMILY_FIRST_GIVEN_LAST` base gets `FAMILY_FIRST` where a decided East Slavic rule meets a family-first order the names' votes decide. - The recipe, `tools/vocab/order_names.py`'s `common_surnames`: every word ORCID's holders typed in the family-name box 100 times or more (`MIN_SURNAME_USES`), anywhere in the box, and in the given-name box in at most 5% of the times they typed it in either (`MAX_GIVEN_SHARE`), with two or more letters and no full stop, counted under the spelling the suggester looks it up by (`spelling`, the given names' fold), with no ranking per country (a holder's stated country says where they work, not where a surname is from). `surname_refusals` then leaves out the romanized surnames and the given names the same run writes (so no word is in two tables, which `check_tables` refuses), the titles and suffixes the given names refuse, and `listed_name_pieces`: the default lexicon's particles, conjunctions, bound given names, maiden markers and its Hangul surnames, which the parse reads by their script (rules/W1, rules/W4) and which the suggester's tables hold none of; `load_common_surnames` leaves out a Turkic patronymic marker. A floor of 400 (`MIN_SURNAMES`) refuses a cut input. - What it gives (2026-11-19, over the `orcid-researchers` cache: ORCID's public data file dated 2025-10-17, fetched 2026-10-27, 1,831,533 records, sha256 `b95ffd683d03d44c80260dff55a0dc7e1224bdeaedfc6eee6e9015d41b2ca6d2` in its `meta.json`): 1,812 family words reach the floor, 1,783 of them with two or more letters and no full stop; 578 of them have a given-box share of 5% or less; 14 of those are romanized surnames and none a given name, leaving 564; the refusals remove five (`den`, `der`, particles; `김`, `이`, the Hangul surnames; `кызы`, a Turkic marker), and the table holds 559. The issue's figures, 1,776, 578 and 565, were taken on 2026-11-12 under an earlier spelling and given-name table; the two counts that differ were not traced word by word. The 25 commonest are Spanish (`rodriguez`, `gonzalez`, `garcia`, `lopez`, `perez`, …); beside them Serbian and Croatian (`jovanovic`, `horvat`), Azerbaijani and Bulgarian (`mammadov`, `georgieva`), Arabic (`alshammari`), Persian (`hosseini`), Japanese (`sato`, `suzuki`), Nepali (`paudel`, `shrestha`), Indian (`banerjee`, `mukherjee`), Danish and Swedish (`jensen`, `nilsson`), German (`schmidt`, `mvller`, Müller under the fold's `ü`) and English and Irish (`moore`, `white`, `hall`, `cooper`, `murphy`). The title and suffix refusals remove nothing at 5%; at 12% they remove `phd`, `caro`, `neto` and `filho`, and the particle refusal `von`, `ait` and `abou` too. Recompute: `uv run python tools/vocab/order_names.py` prints the block. - The vote: the table joins the romanized one as `SURNAMES`, read by the one surname signal under its rules: a listed word at one end of a name and not at the other votes that the family is written at that end, a name listed at both ends from either table votes nothing (`García Quispe`, `Wang García`), a one-letter word is never looked up, a name opening in two or three capitals casts no surname vote (2026-11-14 #1355: `AM García`) and a listed short capitals word ending one silences it (2026-11-14 #1397, now read from both tables: `Zorvan LYU`, `lyu` being the one table word of three letters or fewer). `_a_listed_name` reads both, so a listed surname is never read past as a title (`García. Zorvan`, which rules/H2's shape reads as a title at the head). No word of the table is a title or a suffix by the parse's own reading at either end of a name, which a test holds as it holds the given names. No new `Signal`: the evidence is the same kind, a surname at one end. @@ -521,3 +523,18 @@ Open: the other three settings count their shares among the names with evidence - Declined: 12% for 3.2. It gives Portuguese and Brazilian lists written given first a large gain at two to five names and Indian lists a smaller one, but costs Brazilian and Portuguese lists written family first at 10 and 20 names, moving the size from which two populations are read right in 95% of groups (PatentsView's Brazilian 20 to 50, PSC's Portuguese 10 to 20); whether those rows are a real cost or only the boxes' writing is open. Removing a word in both tables from both: no word can be, the recipe refusing every word of the other two. A per-country ranking, as the given names have: a family word's country is not the holder's. - Open: the 12% share, above; and the cost `pv-listed-given` shows, a given name in English that ORCID's holders rarely type as one (`Cooper`, `Burke`), which only a given-name source cleared for use could take out of the table (PatentsView and PSC are the tool's populations and may not build it, as the issue's measurement rules). A typographic apostrophe (`O’Brien`) is counted and looked up under its own spelling, apart from `o'brien`, as in the given names; nothing votes wrong for it. - For #1452, which will read this table for `two_family_names` (a listed surname second-to-last, another name word after it): the table is `COMMON_SURNAMES`, apart from the romanized surnames in `SURNAMES`, whose second-to-last word in a Chinese name is a given-name syllable. It counts a family word anywhere in the box, so a second surname is in it (`lopez` beside `garcia`); it holds surnames of other languages too, so a listed word is no evidence of a Spanish list alone; and the boxes the tool's populations compose from hold the first surname in the given box in a share of PatentsView's and PSC's Spanish-language records (above), which a measurement of that vote needs to know. +- **2026-11-19 #1447 — WHERE AN EAST SLAVIC PATRONYMIC STANDS IS A VOTE ON THE ORDER, CAST BY A SIGNAL OF ITS OWN, `PATRONYMIC_POSITION`.** Decided in [#1447](https://github.com/derek73/python-nameparser/issues/1447) on 2026-11-19: a patronymic's position is an order vote under all three base orders, last for family-first and in the middle for given-first, read where rules/O1 reads it; under a `FAMILY_FIRST_GIVEN_LAST` base a list whose patronymics stand last is suggested `FAMILY_FIRST`; the `-ovich` surname among silent names is checked on real lists before it counts against the change. A list of Russian names written family first said how it is written in every name and cast no order vote: `Sidorov Ivan Petrovich` × 20 got the rule with a given-first order, which the rule reorders each three-word name under, and read `Sidorov Ivan`, a name of two words in the same list, given `Sidorov`. + - The vote: `_read` casts `Signal.PATRONYMIC_POSITION` beside `Signal.PATRONYMIC` on every name `_patronymic` votes East Slavic for, `GIVEN_FIRST` where the middle word carries the ending (whatever the last word ends in, as rules/O1 reads it) and `FAMILY_FIRST` otherwise, the family-first shape the rule restores (`_patronymic_end`, the one predicate `_keeps_family_first` counts with too). It is an order signal like the others: a name whose other signals vote the other end is contested and casts no order vote (`David Michael Abramovich`, `Boris Zzyvan Petrovich`), and a name that disagrees on a decided order is listed as one. A Turkic patronymic casts none: the Turkic rule reads either written order and moves no name between them. + - The signal (decided 2026-11-19, replacing the issue's "no new member if the code allows"): a new public `Signal` member, not a field on `NameEvidence` and not a vote counted in the tally alone. A field and a member each add to the public API, so avoiding an addition does not choose between them; the member fits the structure there is, one vote a signal, so a caller reading a name's votes sees it with no special field; a vote counted only in the tally hides a vote the name cast, and saying what it saw is what `suggest` is for; and #1452 meets the same need, its surname signal voting on the order and on two family names, so one member per kind of vote is the rule that carries (Standing). The member is `PATRONYMIC_POSITION` (`"patronymic-position"`), after `PATRONYMIC`, the order `SettingEvidence.by_signal` sorts in. + - How it relates to 2026-11-19 #1364's rule, stated once (Standing): where a decided East Slavic rule meets a family-first order the names' votes decide, a `FAMILY_FIRST_GIVEN_LAST` base gets `FAMILY_FIRST`. #1364 made it reachable for lists whose surnames vote; this makes it reachable for every list whose patronymics stand last, so the issue's "a list whose patronymics stand last is suggested `FAMILY_FIRST`" needs no second rule. One gap it leaves, as master leaves it: two to four such names under that base vote family-first, which is the base's own end, and decide no rule (five names), so the base's order stays and reads each patronymic as the given name. + - What changes in 2026-11-15 #1356 (its head note): a group whose patronymics stand last gets the family-first order its names vote, under a given-first base and under `FAMILY_FIRST_GIVEN_LAST`, where it got the given-first order with the rule; one written in the middle gets the given-first order by its votes; the given-first order the rule brings, and `_keeps_family_first`, now act only where the names' votes decide no order (a list writing as many patronymics each way, or one whose other signals contest them). Under a `FAMILY_FIRST` base #1356's outcomes are unchanged. + - Measured with `tools/differential/suggest_measure.py` at seed 20261110, 300 groups a size, one `--json` run per arm and the files compared cell by cell: master as `--tree `, this branch as itself, then based on c5e58aa2 (it was rebased onto 12b568f8 after; #1485 and #1486 change neither `_suggest.py` nor the tables, but #1486 adds title words a name is read past and #1485 changes `_pipeline/_post_rules.py`, which `_suggest` imports a predicate from; the design-docs review re-took the parliament figures and the position votes' totals on the rebased branch against 12b568f8, the same, and the draw tables were not re-taken), at the default sizes with `--wrong-words 12` and at `--sizes 2,3,4,5,10,20,50,100,200,500,1000,2000` (2026-11-19). The tool gained populations for the `-ovich` check, which both arms draw alike: PatentsView's Israeli inventors (`pv-IL`, which `pv-surname-given` and `pv-listed-given` now draw from too) and PSC's Israeli, Serbian, Croatian and Belarusian filers. + - Same-order rows, the anti-goal: none falls below 95% outside the standing exceptions, which read as on master (`orcid-byline-joined` 93.3% at 100 names, `orcid-givcaps`, `pv-listed-given`); the one same-order cell lower than master is PatentsView's Russian inventors written given first under a given-first base, 100.0% → 99.7% at 2 names (one group in 300). + - Rows written against the base, the size from which 95% of groups are read right, master → branch, where it moves (2 to 2,000 names): PatentsView's Russian inventors written family first under a given-first base 50 → 4 (written given first under a family-first base 4 → 4); `pv-RU-patronymic` written family first under a given-first base read right at no size (28.3% at its best, 200 names) → 2, and written given first under a family-first base 4 → 2; PatentsView's Philippine inventors written family first under a given-first base 100 → 20, because 473 of the population's 3,814 records are Soviet-era inventors filed under `PH` (`Vladimir Nikolaevich Firsov`), whose patronymics the vote reads right. No row needs more names. Rows that move without changing that size, all within a point or two: PSC's Belarusian filers (written given first under a family-first base 99.0% → 98.7% at 5 names), Israeli inventors written family first under a given-first base up by under a point. + - The `-ovich` check, the decision's third item, on real lists: over PatentsView's whole pools, a name written given first whose position votes family-first and that no other signal contests (a surname ending as a patronymic does, after a given name no table lists) is 72 of 2,570,746 US inventors, 9 of 49,196 Israeli and 2 of 3,344 Argentine (`Scott Preston Simonovich`, `Yosef David Meirovich`; recompute: every record of the `patentsview-inventors` extract, `local_patentsview.extract_path()`, of the country, its name composed `f"{given} {family}"` as the tool composes it, read by `_suggest._read` with the default lexicon, counting the records, not distinct names, whose `PATRONYMIC_POSITION` vote is `FAMILY_FIRST` and whose other votes, the `PATRONYMIC` rule left out, are that end alone); Croatian and Serbian names cast no position vote, written `-ić` and `-ović`, which no East Slavic ending matches: of PatentsView's 880 Croatian and 637 Serbian records 1 and 2 cast one, each a Russian name voting given-first, right (`Grigorii Petrovich Grabovoi`), and none in PSC's 479 and 512; a listed given name at the head contests the rest (`David Michael Abramovich`). Every same-order cell of `pv-US`, `pv-IL` and PSC's Israeli, Serbian, Croatian and Belarusian filers reads 99.3% or more at every size, so no guard was proposed. In the draws the position signal's votes are 9,324 right and 41 wrong over every population at the default sizes, 28 of the wrong ones PatentsView's Russian inventors written given first (`Zukov Andrey Aleksandrovich`, records whose boxes, composed given first, hold the name family first). The made-up shape the issue named, five `Qqmilan Ppetar Jovanovich` among fifteen silent names of two words, now moves a given-first base to family-first, which reads the fifteen wrong: no real list measured has that shape. + - Whole names on the parliament lists (each list's own order, `LIST_ORDER`; family the first word and given name the second where it writes the family first, else the first and last words; #1356's probe over `parliament_lists()`, both trees), under each of the three bases: `ua_rada` 1,367 → 1,588 of 1,588 under a given-first and a `FAMILY_FIRST_GIVEN_LAST` base, `kz_senate` 41 → 48 of 48 and `uz_senate` 52 → 59 of 59 under the same two; every other list and base reads as on master, and none loses a name. + - The sweep (the same probe's made-up lists, the issue's base order × written position × each switch): eleven lists (written last, in the middle, in capitals at either end, mixed 4/4, 5/3 and 3/5, and either writing with two names of two words) under the three bases with six switches each (none, `initials_as_family`, `capitals_as_family`, the Turkic rule or the East Slavic rule on the base, `middle_as_family`): 36 of 198 cases move, every one a list written family first under a given-first or `FAMILY_FIRST_GIVEN_LAST` base getting `FAMILY_FIRST`; none reads fewer whole names, and the list written family first with two names of two words reads 8 of 8 where master read 6 (`middle_as_family` 0 → 2, that switch reading every middle word as a family name). No case under a `FAMILY_FIRST` base moves. + - The harness proof (`--set _MIN_VOTES=1000000 --set _MIN_PATRONYMIC_VOTES=1000000 --set _MIN_RUN_NAMES=1000000`, on the branch): each of the 96 rows written against its base reads 0%, each of the 96 written in it 100%, over 48 populations, and no parliament list's order or rule is decided. + - Recorded, found by the reviews of the branch, the first three pinned by tests: a name ending in a patronymic and an initial (`Zzyvan Petrovich Q.`) is now contested, its position voting given-first against the trailing initial, so it no longer counts as a name ending in initials: six such names read right under every base (the rule, given-first, the initial the family) where master read the given name as the family, but three bylines beside three such names fall under the trailing-initial signal's 60% and decide nothing, where master decided family-first; a list of four East Slavic names and three Turkic ones decides no rule (4 of 7), and the East Slavic names' positions decide the order alone, family-first where they stand last (which reads both kinds) and given-first where they stand in the middle beside Turkic names written family first under a `FAMILY_FIRST` base, which then reads each Turkic marker as the family (`Mamedov Ali Huseyn oglu`, family `oglu`; the mixed list is the open question of 2026-11-15 #1356); and a `NameEvidence` or `Suggestion` holding the new member does not unpickle under 3.1, an enum value it does not know (measured by the review, held by no test here, the older release being outside the tree), for the release's pickle-break bullet; a test holds that one round-trips under this release. + - Declined: a guard against the `-ovich` surname, since no real list measured has a same-order row under 95% for it (above). Keeping the given-first order with the rule for lists written family first under a given-first base, as #1356 did: it misreads every name of two words in such a list, and the parliament lists read better without it. + - For #1452: by the rule above, the surname signal's vote on `two_family_names` (a listed surname second-to-last) is a `Signal` member of its own, not a second value of `SURNAME`; `_order_ends` and `_disagrees` take any signal other than `PATRONYMIC` for an order signal, so a member voting on another setting needs its own branch there and in `_setting_of`, as `PATRONYMIC` has. diff --git a/docs/release_log.rst b/docs/release_log.rst index 56bee9be4..b6187842b 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,6 +4,7 @@ Release Log nameparser 3.2 is under development. + - **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` - **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` - **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` - **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` diff --git a/docs/suggest.rst b/docs/suggest.rst index 690cfbed0..64210f80e 100644 --- a/docs/suggest.rst +++ b/docs/suggest.rst @@ -317,6 +317,10 @@ Each name votes on its order from the evidence it carries: surname vote. - **A common given name that is rarely a surname** (``Emily``, not ``Taylor``) as the first or last word. +- **Where a Russian-style patronymic stands** in a name of three words + (:ref:`suggest-patronymics`): last (``Sidorov Ivan Petrovich``), the + family name is written first; in the middle (``Ivan Petrovich + Sidorov``), it is written last. Each is read past the titles and post-nominals your parser's vocabulary 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 names that cast any vote, on the order or on a patronymic. Under the default parser a list written family name first reads its -patronymic as the family name; with the rule, each name is put back in -order and its patronymic set apart: +patronymic as the family name. Where the patronymics stand says how +the list is written, so the suggestion reads it family first, with the +rule setting each patronymic apart: .. doctest:: @@ -360,7 +365,7 @@ order and its patronymic set apart: 'Petrovich' >>> slavic = Parser().suggest(registry) >>> slavic.patch - PolicyPatch(patronymic_rules=frozenset({})) + PolicyPatch(name_order=FAMILY_FIRST, patronymic_rules=frozenset({})) >>> sidorov = slavic.parser.parse("Sidorov Ivan Petrovich") >>> sidorov.given, sidorov.family, sidorov.patronymic ('Ivan', 'Sidorov', 'Petrovich') @@ -369,11 +374,11 @@ The order that comes with the rule ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A Turkic rule is suggested alone: it reads a name written either way -round, so the order is left to the names' own votes. The East Slavic -rule reorders a name only under a given-first order, so what is -suggested with it depends on the base parser's order and on where the -list writes the patronymic, last (``Sidorov Ivan Petrovich``) or in -the middle (``Ivan Petrovich Sidorov``): +round, so the order is left to the names' own votes. Where an East +Slavic patronymic stands is itself a vote on the order, last +(``Sidorov Ivan Petrovich``) for family first and in the middle +(``Ivan Petrovich Sidorov``) for given first, so a list that writes its +patronymics one way gets that order with the rule: .. list-table:: :header-rows: 1 @@ -383,18 +388,30 @@ the middle (``Ivan Petrovich Sidorov``): - The list writes the patronymic - Order suggested with the rule * - ``GIVEN_FIRST`` - - last or in the middle + - last + - ``FAMILY_FIRST`` + * - ``GIVEN_FIRST`` + - in the middle - none: the base's stays * - ``FAMILY_FIRST`` - - last in more names than in the middle + - last - none: the base's stays * - ``FAMILY_FIRST`` - - in the middle in as many names, or more + - in the middle - ``GIVEN_FIRST`` * - ``FAMILY_FIRST_GIVEN_LAST`` - - last or in the middle + - last + - ``FAMILY_FIRST``, since its own order would read the + patronymic as the given name + * - ``FAMILY_FIRST_GIVEN_LAST`` + - in the middle - ``GIVEN_FIRST`` +The rule reorders a name only under a given-first order, and reads a +name written family first under a family-first one, where it reorders +none and fills the ``patronymic`` view. A name of two words in the same +list (``Sidorov Ivan``) is read in the order suggested. + .. doctest:: >>> family_first = Parser(policy=Policy(name_order=FAMILY_FIRST)) @@ -406,21 +423,13 @@ the middle (``Ivan Petrovich Sidorov``): >>> family_first.suggest(spoken).patch PolicyPatch(name_order=GIVEN_FIRST, patronymic_rules=frozenset({})) -The names' own order votes come before the table in two cases: - -- **They decide a family-first order.** The rule never overrides it: - the list gets the rule with that order, under which the rule - reorders no name. A ``FAMILY_FIRST_GIVEN_LAST`` base gets - ``FAMILY_FIRST`` there, since its own order would read the - patronymic as the given name (``Popov Ivan Ivanovich``). -- **They decide given-first under a** ``FAMILY_FIRST`` **base.** The - second row does not apply, and the list gets ``GIVEN_FIRST`` with - the rule. - -Where a ``FAMILY_FIRST`` base keeps its order, the rule reorders no -name there and fills the ``patronymic`` view. The names written the -other way, patronymic in the middle, get no given-first order, and the -note under ``patronymic_rules`` counts them. +Where the names' votes decide no order (a list writing as many +patronymics one way as the other, or too few one way, or other +evidence contradicting them), the rule brings the given-first order it reorders each name +under, save under a ``FAMILY_FIRST`` base whose list writes the +patronymic last in more names than in the middle, which keeps its +order; the note under ``patronymic_rules`` counts the names written the +other way. What counts for and against ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -445,13 +454,14 @@ What the report shows ~~~~~~~~~~~~~~~~~~~~~ The ``patronymic_rules`` line has a row for each rule the names voted -for, and the ``name_order`` line a note where the rule decided the -order: +for, the ``name_order`` line a ``patronymic-position`` row for where +the patronymics stand, and a note on how the order and the rule were +decided together: .. doctest:: >>> [e.note for e in slavic.evidence if e.setting == "name_order"] - ['the East Slavic rule reorders each name; it needs a given-first order'] + ["the East Slavic rule is decided too, but the names' order votes decide a family-first order, under which the rule reorders no name"] .. _suggest-initials: @@ -664,9 +674,9 @@ and how it varies, and will differ for every dataset. of groups from 2 to 2,000 names, and 97% for nearly every kind, save the three kinds of list below. - **A list written the other way round** takes more names to move the - base, from 5 for Chinese, Taiwanese, Korean, Czech, Polish and - Italian names to 50 for Russian and Indian ones and 200 for - Bangladeshi ones. A group whose votes fall short of the thresholds + base, from 5 for Chinese, Taiwanese, Korean, Czech, Polish, Italian + and Russian names to 50 for Indian ones and 200 for Bangladeshi + ones. A group whose votes fall short of the thresholds keeps the base rather than guess (:ref:`suggest-deciding`). Three kinds of list keep their order less often: diff --git a/nameparser/_parser.py b/nameparser/_parser.py index 9c7a7e328..4234f56ec 100644 --- a/nameparser/_parser.py +++ b/nameparser/_parser.py @@ -320,8 +320,11 @@ def suggest(self, names: Iterable[str]) -> Suggestion: name of fewer than two words once those are read past casts none, and so does a name with a comma, unless only post-nominals follow the comma. A patronymic votes only where - the patronymic rule reads one, and a trailing initial - (``Smith J.``) only where at least three names, and 60% of the + the patronymic rule reads one, and an East Slavic one votes on + the order too, by where it stands: last for family-first + (``Sidorov Ivan Petrovich``), in the middle for given-first + (``Ivan Petrovich Sidorov``). A trailing initial + (``Smith J.``) votes only where at least three names, and 60% of the group's names holding a name word, end in initials no other signal in the same name contradicts. A capitals word of two or three letters ending a name in mixed case (``Armitage JO``), @@ -347,11 +350,12 @@ def suggest(self, names: Iterable[str]) -> Suggestion: note says how many. A group decided East Slavic gets the rule and reads given-first, the order the rule reorders each name under, - unless its names' own votes decide family-first, which the rule - never overrides: there a ``FAMILY_FIRST_GIVEN_LAST`` parser gets - ``FAMILY_FIRST``, under which the patronymic is not read as the - given name (``Popov Ivan Ivanovich``). One case keeps a - declared order instead: under a ``FAMILY_FIRST`` parser whose names' votes do not decide + unless its names' own votes decide family-first, as a list of + patronymics written last does, which the rule never overrides: there a + ``FAMILY_FIRST_GIVEN_LAST`` parser gets ``FAMILY_FIRST``, under + which the patronymic is not read as the given name (``Popov Ivan + Ivanovich``). One case keeps a declared order instead: under a + ``FAMILY_FIRST`` parser whose names' votes do not decide given-first, where more of the names carrying the patronymic write it last (``Sidorov Ivan Petrovich``) than in the middle (``Ivan Petrovich Sidorov``), the group keeps that order and @@ -394,8 +398,8 @@ def suggest(self, names: Iterable[str]) -> Suggestion: 2026-11-14, 2026-11-15, 2026-11-16 and 2026-11-19, with tools/differential/suggest_measure.py on groups drawn from real names written in a known order, 300 groups a size - (decisions/group-suggestion's 2026-11-19 #1364 entry holds - the sizes): a group written in this parser's own order kept it + (decisions/group-suggestion's 2026-11-19 #1364 and #1447 + entries hold the sizes): a group written in this parser's own order kept it in at least 97% of groups at every size from 2 to 2,000 names, under either base order, save three lists. ORCID holders who typed their given name in capitals (``ANNA Smith``), which the @@ -414,12 +418,13 @@ def suggest(self, names: Iterable[str]) -> Suggestion: Moving the base takes more names, and how many depends on what the names carry: groups of Chinese, Taiwanese, Korean, Czech, Polish or Italian names (the romanized - surnames and the common given names) were read right in 95% of - groups from 5 names; German, Dutch, Spanish, British, French, + surnames and the common given names) and of Russian ones (where + their patronymics stand) were read right in 95% of groups from 5 + names; German, Dutch, Spanish, British, French, Romanian, Vietnamese and Japanese from 10; US, Turkish, - Nigerian and Brazilian from 20; Russian and Indian from 50; - PatentsView's Philippine inventors from 100; and PSC's - Bangladeshi filers from 200. A group whose votes fall short of + Nigerian and Brazilian from 20; Indian from 50; and PSC's + Bangladeshi filers from 200 (PatentsView's Philippine inventors + from 20, through the Russian names among them). A group whose votes fall short of the thresholds keeps the base rather than guess, so a smaller group moves it in fewer of the draws. ``capitals_as_family``, measured 2026-11-12 (decisions/group-suggestion's CAPITALS entry): ORCID holders who diff --git a/nameparser/_suggest.py b/nameparser/_suggest.py index dd053a395..abbf0f193 100644 --- a/nameparser/_suggest.py +++ b/nameparser/_suggest.py @@ -27,14 +27,18 @@ (Hangul, Han) simply matches nothing. A patronymic votes, Latin or Cyrillic, only where the pipeline's rule reads one (rules/O1's three name words, rules/O2's four), through the pipeline's -own predicates, never a copy of them. No signal raises on any string. +own predicates, never a copy of them, and an East Slavic one casts a +second vote, on the order, by where it stands as rules/O1 reads it +(``Signal.PATRONYMIC_POSITION``: last family-first, in the middle +given-first). No signal raises on any string. ``suggest`` tallies the group's votes and decides two settings together, ``patronymic_rules`` first and ``name_order`` second: a decided East Slavic rule reorders each name itself, and reorders none under a family-first order, so it decides the order as given-first, -unless the names' own votes decide family-first, which it never -overrides (a ``FAMILY_FIRST_GIVEN_LAST`` base then gets ``FAMILY_FIRST``), +unless the names' own votes decide family-first, as a list of +patronymics written last does, which it never overrides (a ``FAMILY_FIRST_GIVEN_LAST`` base +then gets ``FAMILY_FIRST``), or the base reads ``FAMILY_FIRST`` and the patronymics are mostly written last, whose order it keeps (decisions/group-suggestion). Before either it decides @@ -140,6 +144,13 @@ class Signal(StrEnum): #: A patronymic one rule reads (Russian ``Petrovich``, Azerbaijani #: ``Huseyn oglu``), the evidence on ``patronymic_rules``. PATRONYMIC = "patronymic" + #: Where an East Slavic patronymic of three name words stands, read + #: where rules/O1 reads it, the evidence on ``name_order``: in the + #: middle (``Ivan Petrovich Sidorov``) the family is written last, + #: the middle word winning where the last ends as a patronymic too; + #: last (``Sidorov Ivan Petrovich``) it is written first. Cast only + #: beside an East Slavic ``PATRONYMIC`` vote. + PATRONYMIC_POSITION = "patronymic-position" _INITIAL_JOINS = re.compile(r"[.-]+") @@ -361,6 +372,18 @@ def _patronymic(words: list[str]) -> PatronymicRule | None: return None +def _patronymic_end(words: list[str]) -> tuple[Role, Role, Role]: + """The end a name casting the East Slavic vote writes its family at, + read where rules/O1 reads it: the ending on the middle word is the + given-first shape (given, patronymic, family), whatever the last + word ends in, and otherwise the patronymic stands last, the + family-first shape the rule restores (family, given, patronymic). + Asked only of a name `_patronymic` votes East Slavic for, three + words long.""" + middle = words[1].rstrip(".") or words[1] + return GIVEN_FIRST if has_patronymic_ending(middle) else FAMILY_FIRST + + def _letter_run(text: str, readers: tuple[Parser, Parser]) -> str | None: """The letters ending `text` that are evidence of the convention rules/O8 reads, folded and run together (`Lakshmi R. S.` gives @@ -443,6 +466,8 @@ def _read(text: str, lexicon: Lexicon patronymic = _patronymic(words) if patronymic is not None: votes[Signal.PATRONYMIC] = patronymic + if patronymic is PatronymicRule.EAST_SLAVIC: + votes[Signal.PATRONYMIC_POSITION] = _patronymic_end(words) return votes, False, words @@ -1191,14 +1216,18 @@ def _keeps_family_first( with the ending on both its middle and its last word counts as middle, as rules/O1 reads it. ``FAMILY_FIRST_GIVEN_LAST`` is never kept: that order takes the patronymic of such a list for the given - name, and the given-first order with the rule reads it.""" + name; the names' position votes give it ``FAMILY_FIRST`` + (`_decide_order`), and where they decide no order the given-first + order with the rule reads it. Since the position votes (#1447) the + question is asked only where the votes decide no order or decide + the base's own.""" if policy.name_order != FAMILY_FIRST or order_end == GIVEN_FIRST: return None last = middle = 0 for _, votes, _, words in with_words: if votes.get(Signal.PATRONYMIC) is PatronymicRule.EAST_SLAVIC: # _patronymic votes East Slavic on three words alone - if has_patronymic_ending(words[1].rstrip(".") or words[1]): + if _patronymic_end(words) == GIVEN_FIRST: middle += 1 else: last += 1 diff --git a/tests/v2/test_suggest.py b/tests/v2/test_suggest.py index e069e6e4d..0821b7db4 100644 --- a/tests/v2/test_suggest.py +++ b/tests/v2/test_suggest.py @@ -321,10 +321,17 @@ def test_joined_initials_keep_a_family_first_base() -> None: assert s.parser.policy.name_order == FAMILY_FIRST -def test_a_patronymic_casts_no_order_vote_of_its_own() -> None: +def test_a_patronymic_votes_its_rule_and_its_position_apart() -> None: + # the rule on patronymic_rules, where it stands on name_order + # (#1447): two signals, one vote each votes = name_votes("Ivan Petrovich Sidorov", L) assert votes[Signal.PATRONYMIC] == PatronymicRule.EAST_SLAVIC - assert set(votes) - {Signal.PATRONYMIC, Signal.GIVEN_NAME} == set() + assert votes[Signal.PATRONYMIC_POSITION] == GIVEN_FIRST + assert set(votes) - {Signal.PATRONYMIC, Signal.PATRONYMIC_POSITION, + Signal.GIVEN_NAME} == set() + # a Turkic patronymic casts no position vote + assert Signal.PATRONYMIC_POSITION not in name_votes( + "Mamedov Ali Huseyn oglu", L) def test_a_name_with_both_patronymic_shapes_reports_turkic() -> None: @@ -417,6 +424,11 @@ def test_a_group_holding_a_name_with_nothing_to_read_does_not_raise( _EAST_SLAVIC = ["Сидоров Иван Петрович", "Иванов Пётр Сергеевич", "Петров Олег Иванович", "Смирнов Павел Андреевич", "Попов Илья Ильич"] +#: The same names written given first, the patronymic in the middle, +#: whose position votes the given-first order the rule reads under +#: (#1447): a list deciding the rule with no order to move. +_EAST_SLAVIC_GIVEN_FIRST = [ + " ".join((g, p, f)) for f, g, p in map(str.split, _EAST_SLAVIC)] _TURKIC = ["Mamedov Ali Huseyn oglu", "Aliyev Rauf Ilham oglu", "Quliyev Elman Rasim oglu", "Hasanova Afet Abil qizi", "Mikayilova Sevil Alirza qizi"] @@ -564,7 +576,7 @@ def test_a_set_aside_name_still_counts_in_the_patronymic_share() -> None: # evidence, so the rule holds 5 of 7 voting names, under four in # five, and decides nothing (it decided East Slavic, 5 of 5, while # a set-aside name left the denominator) - s = Parser().suggest(_EAST_SLAVIC + ["Zorvov Ivan I.", "Orlov Oleg P."]) + s = Parser().suggest(_EAST_SLAVIC_GIVEN_FIRST + ["Zorvov Ivan I.", "Orlov Oleg P."]) assert not _patronymic_evidence(s).decided assert s.patch == PolicyPatch() @@ -685,23 +697,25 @@ def test_strays_for_the_rules_order_leave_no_floor_note( assert "too few" not in order.note -@pytest.mark.parametrize("base_order, patronymics", [ - (GIVEN_FIRST, _MIDDLE_PATRONYMICS), - (FAMILY_FIRST, _MIDDLE_PATRONYMICS), - # under this order the rule is needed with the patronymic written - # last too (#1356): it takes the patronymic for the given name - (FAMILY_FIRST_GIVEN_LAST, _MIDDLE_PATRONYMICS), - (FAMILY_FIRST_GIVEN_LAST, ["Zzyvova Qqsan Petrovich"] * 10), -]) +#: The patronymic written in the middle, the name's capitals voting +#: family-first: each name is contested and casts no order vote, though +#: it votes East Slavic, so the rule decides the order alone. +_CONTESTED_PATRONYMICS = ["QQSAN Petrovich Zzyvova"] * 10 + + +@pytest.mark.parametrize("base_order", [ + GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) def test_strays_against_the_rules_order_no_longer_decide_it( - base_order: tuple[Role, Role, Role], patronymics: list[str]) -> None: + base_order: tuple[Role, Role, Role]) -> None: # two stray family-first votes among 1,012 names: before the floor # they decided a family-first order, under which the rule reorders # no name; now the rule's given-first order stands s = Parser(policy=Policy(name_order=base_order)).suggest( - patronymics + ["Smith Mary", "Kim Minjun"] + [_SILENT] * 1000) + _CONTESTED_PATRONYMICS + ["Smith Mary", "Kim Minjun"] + + [_SILENT] * 1000) order = _order_evidence(s) assert order.decided and order.value == GIVEN_FIRST + assert order.contested == 10 assert s.patch.patronymic_rules == frozenset({PatronymicRule.EAST_SLAVIC}) assert order.note.endswith( "2 of the group's 1012 names vote FAMILY_FIRST, too few to decide " @@ -709,6 +723,33 @@ def test_strays_against_the_rules_order_no_longer_decide_it( "voting for one end are at least 1% of those names") +@pytest.mark.parametrize("base_order, patronymics, end", [ + (GIVEN_FIRST, _MIDDLE_PATRONYMICS, GIVEN_FIRST), + (FAMILY_FIRST, _MIDDLE_PATRONYMICS, GIVEN_FIRST), + (FAMILY_FIRST_GIVEN_LAST, _MIDDLE_PATRONYMICS, GIVEN_FIRST), + # written last, the patronymics vote family-first (#1447), and this + # base, which would read each patronymic as the given name, gets + # FAMILY_FIRST (2026-11-19 #1364) + (FAMILY_FIRST_GIVEN_LAST, ["Zzyvova Qqsan Petrovich"] * 10, + FAMILY_FIRST), +]) +def test_patronymics_and_strays_by_where_they_stand( + base_order: tuple[Role, Role, Role], patronymics: list[str], + end: tuple[Role, Role, Role]) -> None: + # each patronymic votes the order its position writes (#1447). In + # the middle, the ten given-first votes are 10 of 1,012, held back by + # the floor, and the rule gives that order, so no note names them; + # written last, the two strays vote family-first with them, the + # twelve clear the floor, and the given-last base gets FAMILY_FIRST + s = Parser(policy=Policy(name_order=base_order)).suggest( + patronymics + ["Smith Mary", "Kim Minjun"] + [_SILENT] * 1000) + order = _order_evidence(s) + assert order.decided and s.parser.policy.name_order == end + assert s.patch.patronymic_rules == frozenset({PatronymicRule.EAST_SLAVIC}) + assert "too few" not in order.note + assert {s.parser.parse(n).family for n in patronymics} == {"Zzyvova"} + + #: #1442's group: written family first, with a patronymic, under a #: family-first base; two of its surnames (Adam, Alexander) are given #: names, the only order votes it casts. @@ -717,22 +758,26 @@ def test_strays_against_the_rules_order_no_longer_decide_it( "Emanuel Qqsan Petrovich"] -@pytest.mark.parametrize("copies, order", [ - # thirteen names: the two votes are 15% of the group, and decide - (5, GIVEN_FIRST), - # 1,003 names: 0.2%, and the base keeps its order - (500, UNSET), -]) +@pytest.mark.parametrize("copies", [5, 500]) def test_stray_votes_in_a_long_family_first_patronymic_group( - copies: int, order: object) -> None: + copies: int) -> None: + # both sizes now read alike; the floor's own case is held by + # test_strays_against_the_rules_order_no_longer_decide_it + # the patronymics, written last, vote family-first (#1447), so the + # two given names among the surnames (`Adam`, `Alexander`) no longer + # decide a given-first order: at thirteen names they were 15% of the + # group and did, before the vote; at 1,003 the floor held them back base = Parser(policy=Policy(name_order=FAMILY_FIRST)) s = base.suggest(_QUIET * copies + _STRAYS) - assert s.patch.name_order == order - # the patronymics, written last, decide the rule either way, and - # under the kept order it reorders no name (#1356) + assert s.patch.name_order is UNSET + order = _order_evidence(s) + assert order.decided and order.value == FAMILY_FIRST + assert (order.votes_for, order.votes_against, order.contested) == ( + 2 * copies + 1, 0, 2) + # the rule is decided either way, and under the kept order it + # reorders no name (#1356) assert s.patch.patronymic_rules == frozenset({PatronymicRule.EAST_SLAVIC}) - if order is UNSET: - assert s.parser.parse("Zzyvov Qqsan").family == "Zzyvov" + assert s.parser.parse("Zzyvov Qqsan").family == "Zzyvov" def test_a_family_first_group_suggests_family_first() -> None: @@ -779,9 +824,11 @@ def test_a_tie_decides_nothing() -> None: assert s.disagreeing() == () -def test_an_east_slavic_group_gets_the_rule_and_a_given_first_order( +def test_an_east_slavic_group_written_given_first_gets_the_rule( ) -> None: - s = Parser().suggest(_EAST_SLAVIC) + # the patronymic in the middle votes given-first, the rule's order + names = _EAST_SLAVIC_GIVEN_FIRST + s = Parser().suggest(names) assert s.patch.patronymic_rules == frozenset({PatronymicRule.EAST_SLAVIC}) # the base is given-first already, so the patch leaves the order out assert s.patch.name_order is UNSET @@ -789,10 +836,27 @@ def test_an_east_slavic_group_gets_the_rule_and_a_given_first_order( order = _order_evidence(s) assert order.decided assert order.value == GIVEN_FIRST + assert (Signal.PATRONYMIC_POSITION, GIVEN_FIRST, 5) in order.by_signal assert "East Slavic" in order.note assert s.parser.parse("Ivan Petrovich Sidorov").family == "Sidorov" +def test_an_east_slavic_group_written_family_first_gets_family_first( + ) -> None: + # the patronymic last votes family-first (#1447): the names' votes + # decide that order, which the rule never overrides, and a name of + # two words in the list is read family first too + s = Parser().suggest(_EAST_SLAVIC) + assert s.patch == PolicyPatch(name_order=FAMILY_FIRST, + patronymic_rules=_EAST_SLAVIC_RULE) + order = _order_evidence(s) + assert order.decided + assert (Signal.PATRONYMIC_POSITION, FAMILY_FIRST, 5) in order.by_signal + assert "reorders no name" in order.note + assert s.parser.parse("Сидоров Иван").family == "Сидоров" + assert s.parser.parse("Сидоров Иван Петрович").patronymic == "Петрович" + + # -- the East Slavic rule and a family-first base (#1356) ------------------ # a list written family first: nine East Slavic patronymics, a Turkic @@ -850,7 +914,9 @@ def test_patronymics_written_last_keep_a_family_first_base_and_get_the_rule( s = base.suggest(_FAMILY_FIRST_PATRONYMICS) assert s.patch == _THE_RULE_ALONE order = _order_evidence(s) - assert not order.decided + # the patronymics written last vote the base's own order (#1447) + assert order.decided + assert (Signal.PATRONYMIC_POSITION, FAMILY_FIRST, 9) in order.by_signal assert order.value == FAMILY_FIRST assert order.note == "" rules = _patronymic_evidence(s) @@ -919,12 +985,14 @@ def test_patronymics_written_in_the_middle_move_a_family_first_base( def test_a_given_last_base_is_moved_by_patronymics_written_last() -> None: # FAMILY_FIRST_GIVEN_LAST takes the patronymic of such a list for - # the given name, so its order is not kept: the given-first order - # with the rule reads the list + # the given name, so its order is not kept: the patronymics vote + # family-first (#1447), and FAMILY_FIRST with the rule reads the list + # (2026-11-19 #1364) names = _written("last", 0, 8) base = Parser(policy=Policy(name_order=FAMILY_FIRST_GIVEN_LAST)) s = base.suggest(names) - assert s.patch == _GIVEN_FIRST_WITH_THE_RULE + assert s.patch == PolicyPatch(name_order=FAMILY_FIRST, + patronymic_rules=_EAST_SLAVIC_RULE) assert _wholly_right(base, names) == 0 assert _wholly_right(s.parser, names) == 8 @@ -1022,12 +1090,15 @@ def test_only_the_names_carrying_the_patronymic_are_counted() -> None: @pytest.mark.parametrize(("base_order", "shape", "patch", "decided"), [ - # written last under FAMILY_FIRST: nothing to change - (FAMILY_FIRST, "last", PolicyPatch(), False), - # every other case: the given-first order, as before + # written last under FAMILY_FIRST: nothing to change, the + # patronymics voting the base's order (#1447) + (FAMILY_FIRST, "last", PolicyPatch(), True), + # written in the middle: the given-first order, as before (FAMILY_FIRST, "middle", PolicyPatch(name_order=GIVEN_FIRST), True), + # written last under the given-last base: FAMILY_FIRST, which reads + # the patronymic where it stands (2026-11-19 #1364) (FAMILY_FIRST_GIVEN_LAST, "last", - PolicyPatch(name_order=GIVEN_FIRST), True), + PolicyPatch(name_order=FAMILY_FIRST), True), (FAMILY_FIRST_GIVEN_LAST, "middle", PolicyPatch(name_order=GIVEN_FIRST), True), ]) @@ -1049,7 +1120,9 @@ def test_a_family_first_base_carrying_the_rule_keeps_its_rule( @pytest.mark.parametrize(("base_order", "patch"), [ (FAMILY_FIRST, _THE_RULE_ALONE), - (FAMILY_FIRST_GIVEN_LAST, _GIVEN_FIRST_WITH_THE_RULE)]) + # written family first, the patronymics vote that order (#1447) + (FAMILY_FIRST_GIVEN_LAST, PolicyPatch( + name_order=FAMILY_FIRST, patronymic_rules=_EAST_SLAVIC_RULE))]) def test_a_family_first_base_carrying_the_turkic_rule_gets_both( base_order: tuple[Role, Role, Role], patch: PolicyPatch) -> None: base = Parser(policy=Policy( @@ -1084,19 +1157,21 @@ def test_given_first_order_votes_move_a_family_first_base_with_the_rule( assert s.parser.parse("Иван Петрович СИДОРОВ").family == "СИДОРОВ" -def test_given_first_votes_are_not_kept_out_by_patronymics_written_last( +def test_given_names_as_surnames_contest_patronymics_written_last( ) -> None: - # every patronymic written last, but each family name is a common - # given name, which votes given-first: the votes decide the order, - # and the rule, which rotates each name, comes with it + # every patronymic written last, each family name a common given + # name: the given name votes given-first, the patronymic's position + # family-first (#1447), so each name is contested and casts no order + # vote; the FAMILY_FIRST base is kept on the patronymics written last + # (#1356), and reads each family as written names = [f"{family} {given} {father}" for family, given, father in zip( ["Boris", "Viktor", "Oleg", "Igor", "Anna"], _GIVEN, _FATHERS)] s = Parser(policy=Policy(name_order=FAMILY_FIRST)).suggest(names) - assert _order_evidence(s).votes_for == 5 - assert s.patch == _GIVEN_FIRST_WITH_THE_RULE - # and no note says the base's order was kept - assert "it needs a given-first order" in _order_evidence(s).note - assert _patronymic_evidence(s).note == "" + order = _order_evidence(s) + assert (order.votes_for, order.contested, order.decided) == (0, 5, False) + assert s.patch == _THE_RULE_ALONE + assert _patronymic_evidence(s).note.startswith( + "the base's family-first order is kept") assert [s.parser.parse(n).family for n in names] == [ "Boris", "Viktor", "Oleg", "Igor", "Anna"] @@ -1113,19 +1188,27 @@ def test_a_turkic_group_gets_the_rule_alone_under_every_base( assert s.disagreeing() == () -@pytest.mark.parametrize("names", [ - _FAMILY_FIRST_PATRONYMICS, _written("last", 0, 8), - _written("middle", 0, 8), - _written("last", 0, 5) + _written("middle", 5, 8)]) -def test_an_east_slavic_group_moves_no_order_under_a_given_first_base( - names: list[str]) -> None: - # the default base: the rule, and the given-first order it reads - # under, which is the base's own, however the names are written +@pytest.mark.parametrize("names, patch, note", [ + # written last: the patronymics vote family-first (#1447) + (_FAMILY_FIRST_PATRONYMICS, PolicyPatch( + name_order=FAMILY_FIRST, patronymic_rules=_EAST_SLAVIC_RULE), + "reorders no name"), + (_written("last", 0, 8), PolicyPatch( + name_order=FAMILY_FIRST, patronymic_rules=_EAST_SLAVIC_RULE), + "reorders no name"), + # in the middle, or five last and three in the middle (62%, under + # two thirds): the rule, and the base's given-first order it needs + (_written("middle", 0, 8), _THE_RULE_ALONE, + "it needs a given-first order"), + (_written("last", 0, 5) + _written("middle", 5, 8), _THE_RULE_ALONE, + "it needs a given-first order")]) +def test_an_east_slavic_group_under_a_given_first_base( + names: list[str], patch: PolicyPatch, note: str) -> None: s = Parser().suggest(names) - assert s.patch == _THE_RULE_ALONE + assert s.patch == patch order = _order_evidence(s) - assert order.decided and order.value == GIVEN_FIRST - assert "it needs a given-first order" in order.note + assert order.decided + assert note in order.note assert _patronymic_evidence(s).note == "" @@ -1239,7 +1322,7 @@ def test_a_base_holding_the_turkic_rule_leaves_the_patch_empty() -> None: def test_a_base_holding_the_rule_already_leaves_the_patch_empty() -> None: base = Parser(policy=Policy( patronymic_rules=frozenset({PatronymicRule.EAST_SLAVIC}))) - s = base.suggest(_EAST_SLAVIC) + s = base.suggest(_EAST_SLAVIC_GIVEN_FIRST) assert s.patch == PolicyPatch() assert _patronymic_evidence(s).decided @@ -1455,7 +1538,7 @@ def test_the_counts_add_up_to_the_group(names: list[str]) -> None: def test_an_east_slavic_name_never_disagrees_on_order() -> None: # `SIDOROV Ivan Petrovich` votes family-first by its capitals, but # the decided East Slavic rule reorders it - s = Parser().suggest([*_EAST_SLAVIC, "SIDOROV Ivan Petrovich"]) + s = Parser().suggest([*_EAST_SLAVIC_GIVEN_FIRST, "SIDOROV Ivan Petrovich"]) assert s.patch.patronymic_rules == frozenset({PatronymicRule.EAST_SLAVIC}) assert _order_evidence(s).votes_against == 1 assert s.disagreeing() == () @@ -1463,7 +1546,7 @@ def test_an_east_slavic_name_never_disagrees_on_order() -> None: def test_a_non_east_slavic_name_still_disagrees_in_an_east_slavic_group( ) -> None: - s = Parser().suggest([*_EAST_SLAVIC, "Kim Minjun"]) + s = Parser().suggest([*_EAST_SLAVIC_GIVEN_FIRST, "Kim Minjun"]) assert [n.text for n in s.disagreeing()] == ["Kim Minjun"] @@ -1476,6 +1559,8 @@ def test_a_non_east_slavic_name_still_disagrees_in_an_east_slavic_group( ({Signal.SURNAME: PatronymicRule.TURKIC}, TypeError, "must be an order"), ({Signal.PATRONYMIC: FAMILY_FIRST}, TypeError, "PatronymicRule"), ({Signal.PATRONYMIC: "turkic"}, TypeError, "PatronymicRule"), + ({Signal.PATRONYMIC_POSITION: PatronymicRule.EAST_SLAVIC}, TypeError, + "must be an order"), ({"no-such-signal": FAMILY_FIRST}, ValueError, "no-such-signal"), ]) def test_name_evidence_refuses_a_vote_of_the_wrong_kind( @@ -1535,6 +1620,10 @@ def test_setting_evidence_accepts_a_well_formed_value() -> None: "must be an order"), ({"by_signal": [(Signal.PATRONYMIC, FAMILY_FIRST, 1)]}, TypeError, "PatronymicRule"), + # the position votes an order, never a rule (#1447) + ({"by_signal": [(Signal.PATRONYMIC_POSITION, + PatronymicRule.EAST_SLAVIC, 1)]}, + TypeError, "must be an order"), ({"by_signal": [(Signal.SURNAME, FAMILY_FIRST, -1)]}, ValueError, "count must not be negative, got -1"), ({"by_signal": [(Signal.SURNAME, FAMILY_FIRST, True)]}, TypeError, @@ -1668,6 +1757,7 @@ def test_a_decided_rule_never_overrides_an_order_decided_against_it( order = _order_evidence(s) assert order.decided assert (order.votes_for, order.votes_against) == (5, 0) + assert (Signal.PATRONYMIC_POSITION, FAMILY_FIRST, 5) in order.by_signal if base_order == FAMILY_FIRST: # the base's own order, kept by the patronymics written last # too: the patronymic evidence says so @@ -1885,6 +1975,7 @@ def test_a_vote_is_the_shared_order_constant() -> None: @pytest.mark.parametrize("setting, row", [ ("name_order", (Signal.PATRONYMIC, PatronymicRule.EAST_SLAVIC, 1)), ("patronymic_rules", (Signal.SURNAME, FAMILY_FIRST, 1)), + ("patronymic_rules", (Signal.PATRONYMIC_POSITION, FAMILY_FIRST, 1)), ("middle_as_family", (Signal.SURNAME, FAMILY_FIRST, 1)), ]) def test_setting_evidence_refuses_a_signal_of_another_setting( @@ -2003,7 +2094,7 @@ def test_a_family_first_group_on_a_family_first_base_leaves_the_patch_empty( def test_the_ru_pack_and_an_east_slavic_group_leave_the_patch_empty() -> None: from nameparser import locales, parser_for - s = parser_for(locales.RU).suggest(_EAST_SLAVIC) + s = parser_for(locales.RU).suggest(_EAST_SLAVIC_GIVEN_FIRST) assert s.patch == PolicyPatch() assert _patronymic_evidence(s).decided assert _order_evidence(s).decided @@ -2267,10 +2358,13 @@ def test_a_list_of_orcid_surnames_decides_its_order_on_every_base( GIVEN_FIRST, FAMILY_FIRST), (["Popov", "Popova", "Petrova", "Zorvov", "Qelova"], FAMILY_FIRST, FAMILY_FIRST), - # the control: no name votes, and the rule brings its given-first - # order to a FAMILY_FIRST_GIVEN_LAST base, as before + # no surname listed: the patronymics, written last, vote + # family-first themselves (#1447), where on c5e58aa2 no name voted + # and the rule brought its given-first order + (["Zorvov", "Qelova", "Plughov", "Xyzzova", "Frotzov"], + FAMILY_FIRST_GIVEN_LAST, FAMILY_FIRST), (["Zorvov", "Qelova", "Plughov", "Xyzzova", "Frotzov"], - FAMILY_FIRST_GIVEN_LAST, GIVEN_FIRST), + GIVEN_FIRST, FAMILY_FIRST), ]) def test_an_east_slavic_list_voting_family_first_reads_its_patronymics( surnames: list[str], base_order: tuple[Role, Role, Role], @@ -2416,12 +2510,15 @@ def test_a_decomposed_name_votes_as_its_composed_twin( ("_MIN_ORDER_GROUP_SHARE", 0.0, ["Smith Mary", "Kim Minjun"] + [_SILENT] * 199, GIVEN_FIRST, (UNSET, UNSET, UNSET), (FAMILY_FIRST, UNSET, UNSET)), + # the five patronymics written last vote family-first (#1447), five + # of the seven names, so the order moves guarded or not ("_MIN_PATRONYMIC_SHARE", 0.5, _east_slavic(5) + _OTHERS[:2], - GIVEN_FIRST, (UNSET, UNSET, UNSET), - (UNSET, frozenset({PatronymicRule.EAST_SLAVIC}), UNSET)), + GIVEN_FIRST, (FAMILY_FIRST, UNSET, UNSET), + (FAMILY_FIRST, frozenset({PatronymicRule.EAST_SLAVIC}), UNSET)), # under a FAMILY_FIRST base the rule comes without an order where the - # patronymics are written last, as these are (#1356); - # under the default one the order it needs is the base's own + # patronymics are written last, as these are (#1356); under the + # default base the two would vote family-first by their position + # (#1447) ("_MIN_PATRONYMIC_VOTES", 2, _east_slavic(2), FAMILY_FIRST, (UNSET, UNSET, UNSET), (UNSET, frozenset({PatronymicRule.EAST_SLAVIC}), UNSET)), @@ -2511,7 +2608,7 @@ def test_the_report_writes_a_setting_value_of_any_kind() -> None: def test_the_report_writes_the_order_note() -> None: - report = str(Parser().suggest(_EAST_SLAVIC)) + report = str(Parser().suggest(_EAST_SLAVIC_GIVEN_FIRST)) assert "it needs a given-first order" in report @@ -3057,3 +3154,195 @@ def counting(self: Parser, text: str) -> object: assert calls == [] Parser().suggest(["MISS Ann Berg", "Jean DUPONT"]) assert calls == ["MISS Ann Berg"] + + +# -- #1447: where an East Slavic patronymic stands is an order vote -------- +# read exactly where rules/O1 reads the patronymic: the ending on the +# middle word is the given-first shape, whatever the last word ends in, +# and otherwise the family-first shape the rule restores; a name the +# rule does not read (an initial first or in the middle, four words, a +# Turkic marker) casts none. On c5e58aa2 every row casts no order vote +# by its patronymic. +@pytest.mark.parametrize("text, end", [ + ("Qqsan Petrovich Zzyvova", GIVEN_FIRST), + ("Zzyvova Qqsan Petrovich", FAMILY_FIRST), + ("Иван Петрович Сидорров", GIVEN_FIRST), + ("Сидорров Иван Петрович", FAMILY_FIRST), + # the ending on both: the middle word, as rules/O1 reads it + ("Qqsan Petrovich Abramovich", GIVEN_FIRST), + # a surname ending as a patronymic does, first: family-first + ("Abramovich Qqsan Arkadyevich", FAMILY_FIRST), + # a final full stop is read past on either word + ("Zzyvova Qqsan Petrovich.", FAMILY_FIRST), + ("Qqsan Petrovich. Zzyvova", GIVEN_FIRST), + # no vote where the rule reads none + ("Q. Petrovich Zzyvova", None), + ("Zzyvova Q. Petrovich", None), + ("Zzyvova Qqsan Xxmir Petrovich", None), + ("Mamedov Ali Huseyn oglu", None), + ("Zzyvova Qqsan", None), + # letters NFD decomposes (`й`, `ї`) + ("Сидоров Олексій Андрійович", FAMILY_FIRST), + ("Олексій Андрійович Сидоров", GIVEN_FIRST), + # read past a title, a post-nominal and a comma followed by one + ("Dr. Zzyvova Qqsan Petrovich", FAMILY_FIRST), + ("Zzyvova Qqsan Petrovich Jr.", FAMILY_FIRST), + ("Qqsan Petrovich Zzyvova, PhD", GIVEN_FIRST), + # a comma states its own order: no vote + ("Zzyvova, Qqsan Petrovich", None), +]) +def test_an_east_slavic_patronymic_votes_the_order_its_position_writes( + text: str, end: tuple[Role, Role, Role] | None) -> None: + for name in (text, unicodedata.normalize("NFD", text)): + rows = [row for row in _order_evidence( + Parser().suggest([name, name])).by_signal + if row[0] is Signal.PATRONYMIC_POSITION] + assert rows == ([] if end is None else + [(Signal.PATRONYMIC_POSITION, end, 2)]) + assert name_votes(name, L).get(Signal.PATRONYMIC_POSITION) == end + + +def test_a_patronymic_position_against_a_given_name_is_contested() -> None: + # `David` votes given-first at the head, the patronymic's position + # family-first: the name casts no order vote + s = Parser().suggest(["David Michael Abramovich"] * 3) + order = _order_evidence(s) + assert (order.votes_for, order.votes_against, order.contested) == ( + 0, 0, 3) + assert s.patch.name_order is UNSET + + +def test_two_word_names_in_a_family_first_patronymic_list_read_right( + ) -> None: + # #1447's list: twenty names written family first with a patronymic + # and one without, which master read given-first + names = _written("last", 0, 5) * 4 + ["Qqsidorov Zzyvan"] + s = Parser().suggest(names) + assert s.parser.policy.name_order == FAMILY_FIRST + assert s.parser.parse("Qqsidorov Zzyvan").family == "Qqsidorov" + assert _wholly_right(s.parser, names) == 21 + + +@pytest.mark.parametrize("count", [2, 3, 4]) +def test_a_short_given_last_list_with_patronymics_last_keeps_its_base( + count: int) -> None: + # recorded, not intended: the patronymics vote family-first, the + # base's own end, and five names are needed to decide the rule, so + # nothing moves and the base reads each patronymic as the given + # name, as on c5e58aa2 (decisions/group-suggestion, 2026-11-19 #1447) + names = _written("last", 0, count) + s = Parser(policy=Policy(name_order=FAMILY_FIRST_GIVEN_LAST)).suggest( + names) + assert s.patch == PolicyPatch() + assert _wholly_right(s.parser, names) == 0 + + +def test_votes_deciding_given_first_take_no_family_first_base_keep() -> None: + # five written last but contested (a given name as the surname), four + # in the middle: the votes decide given-first (4 for), and the base is + # not kept though more write the patronymic last, so no note says it + # was (`_keeps_family_first`'s guard on a given-first order) + names = ([f"{family} {given} {father}" for family, given, father in zip( + ["Boris", "Viktor", "Oleg", "Igor", "Anna"], _GIVEN, _FATHERS)] + + _written("middle", 5, 8) + ["Qqolek Sergeevich Zzlebedin"]) + s = Parser(policy=Policy(name_order=FAMILY_FIRST)).suggest(names) + order = _order_evidence(s) + assert (order.votes_for, order.contested) == (4, 5) + assert s.patch == _GIVEN_FIRST_WITH_THE_RULE + assert "it needs a given-first order" in order.note + assert _patronymic_evidence(s).note == "" + + +@pytest.mark.parametrize("base_order", [ + GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +def test_a_name_written_against_a_family_first_list_disagrees( + base_order: tuple[Role, Role, Role]) -> None: + # six written last decide family-first by their position, under which + # the rule reorders no name: the one written in the middle reads its + # given name as the family, and is listed (#1447); written the other + # way round, the decided rule reorders the odd one, which agrees + base = Parser(policy=Policy(name_order=base_order)) + odd = "Zzyvan Petrovich Qqsidorov" + s = base.suggest(_written("last", 0, 6) + [odd]) + assert [n.text for n in s.disagreeing()] == [odd] + assert s.parser.parse(odd).family == "Zzyvan" + s = base.suggest(_written("middle", 0, 6) + ["Qqsidorov Zzyvan Petrovich"]) + assert s.disagreeing() == () + + +@pytest.mark.parametrize("base_order", [ + GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +def test_a_patronymic_before_a_final_initial_is_read_given_first( + base_order: tuple[Role, Role, Role]) -> None: + # `Zzyvan Petrovich Q.`: the trailing initial votes family-first, the + # patronymic in the middle given-first, so the name is contested and + # counts as no name ending in initials; the decided rule reads it + # given-first, its initial the family (on c5e58aa2 the trailing + # initials decided family-first, reading `Zzyvan` as the family) + names = [f"{g} {p} {f[0]}." for g, p, f in zip(_GIVEN, _FATHERS, _FAMILY)][:6] + s = Parser(policy=Policy(name_order=base_order)).suggest(names) + assert s.parser.policy.name_order == GIVEN_FIRST + assert s.parser.policy.patronymic_rules == _EAST_SLAVIC_RULE + assert {s.parser.parse(n).family for n in names} == { + f[0] + "." for f in _FAMILY[:6]} + + +def test_patronymics_before_initials_can_hold_back_a_byline_list() -> None: + # recorded, not intended: three bylines and three names with a + # patronymic before a final initial; the three contested names no + # longer count as ending in initials, so three of six is under 60% + # and no trailing initial votes, where on c5e58aa2 the list decided + # family-first (decisions/group-suggestion, 2026-11-19 #1447) + s = Parser().suggest(["Qqsmith J.", "Zzjones K.", "Xxbrown L.", + "Zzyvan Petrovich Q.", "Qqolek Sergeevich Z.", + "Xxpavel Ivanovich X."]) + assert s.patch == PolicyPatch() + assert "too few for the trailing-initial signal" in ( + _order_evidence(s).note) + + +def test_an_ovich_surname_after_an_unlisted_given_name_votes_family_first( + ) -> None: + # recorded, not intended: the vote reads the shape alone, so a + # given-first name of three words whose surname ends as a patronymic + # votes family-first unless a listed given name opens it (measured on + # real lists: 72 of 2,570,746 US inventors, decisions/group-suggestion, + # 2026-11-19 #1447) + assert name_votes("Tal Noa Rabinovich", L)[ + Signal.PATRONYMIC_POSITION] == FAMILY_FIRST + names = ["Tal Noa Rabinovich", "Yael Shira Abramovich", + "Noam Ido Berkovich", "Ori Gal Leibovich", "Dvir Amit Rabinovich", + "Avi Cohen", "Dana Levi", "Qqsan Xxmir", "Zzyvan Brown"] + s = Parser().suggest(names) + order = _order_evidence(s) + assert (order.votes_for, order.votes_against, order.contested) == ( + 2, 2, 3) + assert s.patch == PolicyPatch() + + +def test_a_list_mixing_east_slavic_and_turkic_patronymics() -> None: + # recorded: neither rule is decided (4 of 7, 3 of 7), and the East + # Slavic names' positions decide the order alone; written last they + # move a given-first base to family-first, which reads both kinds; + # written in the middle beside Turkic names written family first they + # move a family-first base to given-first, which reads the Turkic + # names' marker as the family (an open question, 2026-11-15 #1356) + turkic = _TURKIC[:3] + s = Parser().suggest(_written("last", 0, 4) + turkic) + assert s.patch == PolicyPatch(name_order=FAMILY_FIRST) + s = Parser(policy=Policy(name_order=FAMILY_FIRST)).suggest( + _written("middle", 0, 4) + turkic) + assert s.patch == PolicyPatch(name_order=GIVEN_FIRST) + assert s.parser.parse(turkic[0]).family == "oglu" + + +def test_a_suggestion_holding_a_position_vote_round_trips() -> None: + # within one release; a pickle holding the member does not load + # under 3.1, which does not know it (decisions/group-suggestion, + # 2026-11-19 #1447) + import pickle + s = Parser().suggest(_written("last", 0, 5)) + assert Signal.PATRONYMIC_POSITION in s.names[0].votes + again = pickle.loads(pickle.dumps(s)) + assert again.names == s.names + assert again.patch == s.patch diff --git a/tools/differential/suggest_measure.py b/tools/differential/suggest_measure.py index 77f2061cc..5ee997cdd 100644 --- a/tools/differential/suggest_measure.py +++ b/tools/differential/suggest_measure.py @@ -179,10 +179,14 @@ #: The names each population's signal counts read. SIGNAL_NAMES = 3_000 PV_COUNTRIES = ("US", "DE", "FR", "CN", "JP", "KR", "IN", "IT", "ES", "RU", - "BR", "TW", "NL", "MX", "AR", "CO", "PH", "PT", "TR") + "BR", "TW", "NL", "MX", "AR", "CO", "PH", "PT", "TR", + # IL and the last four nationalities: #1447's check of a + # surname ending as a patronymic does (`-ovich`) + "IL") PSC_NATIONALITIES = ("British", "Romanian", "Indian", "Chinese", "Polish", "Nigerian", "Turkish", "Spanish", "Filipino", - "Portuguese", "Bangladeshi", "Pakistani", "Brazilian") + "Portuguese", "Bangladeshi", "Pakistani", "Brazilian", + "Israeli", "Serbian", "Croatian", "Belarusian") #: `pv-surname-given`: the inventors of PV_COUNTRIES less these whose #: given box opens with a word PatentsView's own boxes write in the #: family box at least as often as in the given box, by at least