From 66c827d93aa475d94e3eb4aacf327413712cca20 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 16 Nov 2026 13:38:03 -0800 Subject: [PATCH 1/2] Decide a list's order only where its votes are at least 1% of the list Parser.suggest decided name_order on at least two names and more than two thirds of 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: Russian inventors with patronymics, written family first under a family-first base, kept that order in 87% of groups of 1,000 and 2,000 names. The names voting for the winning end must now also be at least 1% of the whole list (_MIN_ORDER_GROUP_SHARE); where that alone holds the order back, the order evidence's note says so. At 200 names or fewer the floor asks no more than the two names _MIN_VOTES does. Measured over 2 to 2,000 names, 300 groups a size, it moves two order rows and nothing else: the Russian row reads 100% from 500 names, and the same names under a given-first base lose the 10 to 15% they reached by the same accident. 0.5%, 2% and 5% were measured and declined (decisions/group-suggestion, 2026-11-16 ORDER FLOOR). The docstring, docs/suggest.rst and root AGENTS.md are re-taken from the extended table, which also corrects the byline figures: the bare initials list reads 94.7% and 93.3% at 50 and 100 names, ORCID's bylines 95.3% at 100. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- docs/design/decisions/group-suggestion.md | 57 +++++++++++++++-- docs/release_log.rst | 2 +- docs/suggest.rst | 37 +++++++---- nameparser/_parser.py | 27 ++++---- nameparser/_suggest.py | 39 ++++++++++-- tests/v2/test_suggest.py | 75 +++++++++++++++++++++++ tools/differential/suggest_measure.py | 4 +- 8 files changed, 205 insertions(+), 38 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f122d3380..42f46d1d3 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, 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 `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 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 a re-taken table, 2026-11-15 #1357's, holds the table 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 `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 a re-taken table, 2026-11-15 #1357's, holds the table 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-three 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 Indonesia's 2018 regional heads, read through OpenSanctions, 24,302 spellings of 19,283 members on 2026-11-12 (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); `config_diff.py --group ` keeps one parliament. 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 5152a35ee..6ef9597de 100644 --- a/docs/design/decisions/group-suggestion.md +++ b/docs/design/decisions/group-suggestion.md @@ -15,7 +15,7 @@ - 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. - 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 order is decided by at least two names and more than two thirds of the names casting an order vote; 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. +- 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 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. @@ -24,9 +24,9 @@ - A capitals word of two or three letters ending a name that holds a lowercase letter casts no surname vote of its own, and where it is itself a listed surname (`Zhou NG`) the name casts no surname vote; otherwise the word in front votes as before; its capitals vote stays silent — 2026-11-14 #1397. - That rule's reach as implemented, the opening word standing alone: a run of capitals words in front votes as before, whatever its first word (`DE SOUZA Maria`) — 2026-11-14 #1355. - 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 to give a sample of a few hundred names from each source, not the whole list: nearly every kind of list measured is read right from 200 names, and a longer list is rarely better (bylines written given first under a family-first base are the one kind measured that kept improving) and can be worse where few of its names vote — 2026-11-16 #1442. +- 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: [#1442](https://github.com/derek73/python-nameparser/issues/1442), whether deciding needs a floor on votes as a share of the whole list (two stray votes decide a list of any length). 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, a surname table for names outside zh, ko and vi, is open for 3.2: 2026-11-15 #1357 holds what a gate measured for it (a dated snapshot), the cost no population of the tool shows (a list whose given names are listed surnames) and the sources no entry of decisions/shipped-data-licences clears. 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 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, a surname table for names outside zh, ko and vi, is open for 3.2: 2026-11-15 #1357 holds what a gate measured for it (a dated snapshot), the cost no population of the tool shows (a list whose given names are listed surnames) and the sources no entry of decisions/shipped-data-licences clears. Not measured, and without an issue: the table's 20-use floor (`MIN_USES`), and a family share between 10% and 15%. ## Log @@ -444,8 +444,57 @@ Open: [#1442](https://github.com/derek73/python-nameparser/issues/1442), whether - The twelve Standing statements, each by the entry it points at: the parser never detects language and the suggester may over a declared group (2026-11-10 SCOPE); the given-name table derived from ORCID's public data file (2026-11-12 GIVEN NAMES FROM ORCID); the table's size, the rest of its filter and the hand-kept surname lists (2026-11-10 TABLES and GIVEN NAMES FROM ORCID); the evidence declined (2026-11-10 DECLINED); a comma name does not vote on order (2026-11-10 SIGNALS); an East Slavic group gets the rule with a given-first order, save the case 2026-11-15 #1356 keeps (SIGNALS and 2026-11-10 FIX WAVE); a patronymic votes only where the pipeline's rule reads one (FIX WAVE); the order and patronymic thresholds (2026-11-10 THRESHOLDS); the trailing-initial gate (2026-11-11 TRAILING INITIAL); `initials_as_family` (2026-11-11 LETTER RUNS); `capitals_as_family` (2026-11-12 CAPITALS); and the reach of the opening-word rule (2026-11-14 #1355), which that entry called implementation and record, not decision: what the Standing statement words (the opening word standing alone, a run of capitals words in front voting as before) is a decision now, and a change to it takes an entry; the rest of that entry's reach bullet stays record, as later entries have amended it. - Eleven entry heads carried the marker: ten of the eleven entries those statements point at, #1355's head carrying none, and 2026-11-10 TURKIC, which no Standing statement points at (a Turkic group gets the rule alone, its order decided by its names' own votes); each head now points here, TURKIC decided with the rest. The entries' bodies are as written, save SCOPE's closing sentence, which said the rest of the file "is proposed" and now says it was. - Unchanged: `_MIN_PATRONYMIC_VOTES` stays five, and the Open paragraph's note on it stands as written. What the Open paragraph and the Not taken bullets leave open stays open. -- **2026-11-16 #1442 — THE TABLE READ PAST 200 NAMES: MOST LISTS SETTLE BY 50, AND ONE SAME-ORDER ROW FALLS AS THE LIST GROWS.** Measured for docs/suggest.rst's "How many names to give it" with `uv run python tools/differential/suggest_measure.py --sizes 5,10,20,50,100,200,500,1000,2000 --trials 200` on master 05689a4c (2026-11-16; seed 20261110; a population smaller than a size prints no cell there). +- **2026-11-16 #1442 (its "Not decided: a floor" decided by 2026-11-16 ORDER FLOOR) — THE TABLE READ PAST 200 NAMES: MOST LISTS SETTLE BY 50, AND ONE SAME-ORDER ROW FALLS AS THE LIST GROWS.** Measured for docs/suggest.rst's "How many names to give it" with `uv run python tools/differential/suggest_measure.py --sizes 5,10,20,50,100,200,500,1000,2000 --trials 200` on master 05689a4c (2026-11-16; seed 20261110; a population smaller than a size prints no cell there). - The size from which a row of the order table is right in every trial at every larger size, over its 120 rows (30 populations, each written both ways under both bases): 5 names for 63 rows, 10 for 21 more, 20 for 11, 50 for 10, 100 for 3, 200 for 2, 500 for 2, and never for 8. So 105 of 120 are settled by 50 names and 110 by 200. - 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 — 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 (`_Tally.winner`); where this alone holds an order back, the order evidence's note says how many names voted for which end and why that is too few. `_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. + - One rule, no size regime: at 1% the floor asks at most two names of a group of 200 or fewer, which `_MIN_VOTES` asks already, so every size the earlier tables measured reads as before by construction, and the floor acts only where the list is long enough for stray votes to accumulate. A second rule switching it on above a size would add a boundary the measurement gives no reason for. + - Measured with `uv run python tools/differential/suggest_measure.py --sizes 2,3,4,5,10,20,50,100,200,500,1000,2000 --trials 300` (2026-11-16; seed 20261110; a population smaller than a size prints no cell there), the base an export of master 06e90204, each candidate on the branch by `--set _MIN_ORDER_GROUP_SHARE=` (the constant added at 0 to measure, so 0 reads as master). Of the 120 order rows (30 populations, each written both ways under both bases), the 12 capitals rows, the TURKIC table and the 22 parliament lists under three bases, the 1% floor moves two order rows and nothing else: + - `pv-RU-patronymic` written family first under a family-first base, the same-order row #1442 is about: 100 / 100 / 100 / 100 / 100 / 99.7 / 99.7 / 98.7 / 99.0 / 90.7 / 86.7 / 86.7% at 2 to 2,000 names before, and the same through 200 then 100 / 100 / 100% at 500 / 1,000 / 2,000 after. + - The same population written family first under a given-first base, a row written against its base that reaches 95% at no size before or after: 1 / 2 / 10 / 15 / 14% at 100 / 200 / 500 / 1,000 / 2,000 before, 1 / 2 / 0 / 0 / 0% after. Its 10 to 15% were groups where the stray right votes (a capitals or surname vote, about 1 name in 1,000) outnumbered the stray wrong ones by more than two to one, the same accident the same-order row lost to, now decided by neither. + - No same-order row moves; every row written against its base reaches 95% from the same size as before (3 names for Czech, ORCID's capitals and PSC's Polish names; 4 to 50 for the rest, as the table below reads; 200 for `orcid-byline-joined` written family first under a given-first base; 2,000 for `orcid-byline` written given first under a family-first base, the sparse list #1442 named, 46 / 53 / 60 / 72 / 98% at 100 to 2,000 names before and after); the capitals decision rates and the counts of groups deciding `initials_as_family` and the East Slavic rule are unchanged; no parliament list's suggestion moves (`mn_parliament`, 2 order votes among 126 names, 1.6%, stays decided). + - Declined, each measured the same way: + - 0.5%: fixes the row less surely, 97 / 100 / 100% at 500 / 1,000 / 2,000 (the 500 cell three points from the bar on one run), the row against its base reading 4 / 1 / 0%; nothing else moves. + - 2%: `orcid-byline` written given first under a family-first base falls from 53 / 60 / 72% to 47 / 50 / 65% at 200 / 500 / 1,000 names (98% at 2,000 kept) and `orcid-byline-joined` the same way from 39 / 28% to 35 / 26% at 200 / 500; `mn_parliament` is no longer decided under any base (its two votes are under 2.52); the two byline same-order rows rise at 200 names (97% to 99%). + - 5%: `orcid-byline` written given first under a family-first base reaches 95% at no size (22 / 46 / 53 / 60 / 72 / 98% at 50 to 2,000 names to 8 / 7 / 0 / 0 / 0 / 0%); `orcid-byline-joined` written family first under a given-first base reaches 95% from 500 names instead of 200 (75 / 90 / 97% at 50 / 100 / 200 to 65 / 84 / 93%); PatentsView's Russian inventors written family first under a given-first base 99% to 98% at 50; `mn_parliament` undecided. It is the one candidate that lifts `orcid-byline-joined` written given first under a given-first base over 95% (94.7 / 93.3% at 50 / 100 to 99 / 100%), by deciding none of those groups, which keeps their base: a cost to the sparse lists' other rows, so not taken for that. + - #1442's made-up list (`Zzyvov Qqsan Petrovich` and `Qqsidorov Xxmir Ivanovich` repeated, with `Adam Qqsan Petrovich`, `Alexander Xxmir Ivanovich` and `Emanuel Qqsan Petrovich`, under a `FAMILY_FIRST` base): at 13 names every candidate suggests `GIVEN_FIRST` with the East Slavic rule, as master does, the two stray votes being 15% of the group; at 1,003 and 100,003 names master suggests `GIVEN_FIRST` with the rule and each of 0.5%, 1%, 2% and 5% suggests the rule alone, the base's family-first order kept (#1356), so `Zzyvov Qqsan` reads family `Zzyvov` under the suggested parser. A short list decided by two stray votes stays accepted: two names of thirteen are evidence the thresholds were set to take. + - The other three settings have the same hole, each counting its share among the names with evidence on it, never the group, shown with made-up names (2026-11-16): five `Qqsan Petrovich Zzyvova` among 1,000 or 100,000 silent `Zzyvov Qqsan` decide the East Slavic rule (5 of 5 names casting any vote) and, under a `FAMILY_FIRST` base, the given-first order it brings, the patronymic written in the middle; two `Qqsan Zzyvov B K` among 1,000 or 100,000 silent names decide `initials_as_family` under a given-first base (2 of the 2 names ending in a run); two `Qqsan ZZYVOVA` among 1,000 or 10,000 names written wholly in capitals, or wholly in lower case, decide `capitals_as_family` (2 of the 2 names with evidence: a name in one case carries none). Not taken here: no measured population moves on any of them, the patronymic case moves the order through the rule, which the order floor does not reach, and each needs its own measurement. + - The table (share of groups right; sizes 2 / 3 / 4 / 5 / 10 / 20 / 50 / 100 / 200 / 500 / 1,000 / 2,000), which supersedes 2026-11-15 #1357's and extends it past 200 names: + + | population | names | written in the base's order, lowest of both bases | given-first written, family-first base | family-first written, given-first base | + |---|---|---|---|---| + | cz | 20000 | 100% | 75 / 97 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 79 / 95 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | orcid-byline | 2215 | 95% | 0 / 0 / 0 / 0 / 1 / 9 / 22 / 46 / 53 / 60 / 72 / 98 | 0 / 32 / 61 / 82 / 84 / 91 / 97 / 100 / 100 / 100 / 100 / 100 | + | orcid-byline-joined | 644 | 93% | 0 / 0 / 0 / 0 / 1 / 4 / 18 / 33 / 39 / 28 / - / - | 1 / 2 / 3 / 8 / 16 / 38 / 75 / 90 / 97 / 100 / - / - | + | orcid-famcaps | 20000 | 100% | 85 / 97 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 80 / 97 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | orcid-famcaps-ea | 1411 | 100% | 24 / 51 / 67 / 82 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / - | 22 / 54 / 67 / 80 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / - | + | orcid-famcaps-short | 5013 | 100% | 4 / 10 / 24 / 28 / 63 / 89 / 100 / 100 / 100 / 100 / 100 / 100 | 6 / 11 / 17 / 27 / 66 / 95 / 100 / 100 / 100 / 100 / 100 / 100 | + | orcid-givcaps | 5218 | 0% | 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 | 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 / 0 | + | psc-British | 20000 | 100% | 39 / 67 / 82 / 92 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 37 / 61 / 76 / 87 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | psc-Chinese | 18453 | 100% | 63 / 86 / 93 / 96 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 68 / 84 / 96 / 97 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | psc-Indian | 20000 | 99% | 6 / 17 / 28 / 38 / 64 / 93 / 100 / 100 / 100 / 100 / 100 / 100 | 4 / 8 / 21 / 26 / 53 / 80 / 99 / 100 / 100 / 100 / 100 / 100 | + | psc-Nigerian | 11648 | 100% | 14 / 29 / 41 / 54 / 90 / 98 / 100 / 100 / 100 / 100 / 100 / 100 | 8 / 22 / 38 / 45 / 82 / 96 / 100 / 100 / 100 / 100 / 100 / 100 | + | psc-Polish | 15099 | 100% | 79 / 98 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 76 / 96 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | psc-Romanian | 20000 | 100% | 20 / 37 / 55 / 65 / 96 / 99 / 100 / 100 / 100 / 100 / 100 / 100 | 20 / 41 / 56 / 70 / 95 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | psc-Spanish | 6101 | 100% | 46 / 80 / 90 / 94 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 35 / 65 / 78 / 89 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | psc-Turkish | 9081 | 100% | 12 / 30 / 45 / 60 / 93 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 10 / 27 / 47 / 53 / 89 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-BR | 15029 | 99% | 52 / 75 / 89 / 96 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 13 / 40 / 52 / 58 / 87 / 95 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-CN | 20000 | 100% | 75 / 91 / 97 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 74 / 89 / 97 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-DE | 20000 | 100% | 44 / 68 / 84 / 94 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 35 / 65 / 76 / 91 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-ES | 20000 | 100% | 58 / 88 / 95 / 98 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 32 / 66 / 83 / 90 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-FR | 20000 | 100% | 39 / 69 / 83 / 89 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 33 / 63 / 77 / 90 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-IN | 20000 | 100% | 9 / 21 / 36 / 44 / 83 / 98 / 100 / 100 / 100 / 100 / 100 / 100 | 5 / 14 / 22 / 31 / 65 / 90 / 99 / 100 / 100 / 100 / 100 / 100 | + | pv-IT | 20000 | 100% | 57 / 82 / 89 / 97 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 49 / 81 / 91 / 95 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-JP | 20000 | 100% | 19 / 41 / 54 / 69 / 94 / 99 / 100 / 100 / 100 / 100 / 100 / 100 | 24 / 36 / 60 / 69 / 94 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-KR | 20000 | 100% | 63 / 82 / 91 / 97 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 62 / 82 / 95 / 97 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-NL | 20000 | 100% | 38 / 61 / 81 / 88 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 26 / 49 / 65 / 81 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-RU | 20000 | 100% | 64 / 89 / 99 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 1 / 8 / 26 / 42 / 55 / 85 / 99 / 100 / 100 / 100 / 100 / 100 | + | pv-RU-patronymic | 8393 | 99% | 65 / 92 / 99 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 0 / 0 / 0 / 0 / 0 / 0 / 0 / 1 / 2 / 0 / 0 / 0 | + | pv-TW | 20000 | 100% | 58 / 91 / 91 / 97 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 62 / 85 / 95 / 98 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + | pv-US | 20000 | 100% | 36 / 62 / 79 / 86 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 9 / 31 / 54 / 70 / 90 / 97 / 100 / 100 / 100 / 100 / 100 / 100 | + | vi | 20000 | 100% | 49 / 71 / 87 / 95 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 52 / 77 / 90 / 94 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + - 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, and no longer says a longer list can be read worse, which the floor ends for every same-order row measured; its deciding table and the order paragraph state the floor. diff --git a/docs/release_log.rst b/docs/release_log.rst index 96e2ea05e..df803ade4 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -23,7 +23,7 @@ Release Log - **Add the order report, on a name of one word followed by initials.** ``parse("Kavitha S").ambiguities`` holds an ``order`` ambiguity, which names no ``alternative`` (the other reading lays out the whole name: ``name_order=FAMILY_FIRST`` reads it), where 2.0.0 through 3.0.1 report nothing; the reading itself does not change. Capitals written as one word with no full stops (``Armitage JO``) are not reported, being written as a short surname is (``Zhi LI``). :issue:`1137`, :issue:`1254` - **Add Policy.capitals_as_family, to read the words a name writes in capitals as its family name.** ``Parser(policy=Policy(capitals_as_family=True)).parse("DUPONT Marie")`` gives given ``Marie``, family ``DUPONT``, where 1.4.0 through 3.0.1, and the default still, give given ``DUPONT``, family ``Marie``. ``Parser.suggest()`` suggests it for a list whose names write the family in capitals of four letters or more. In lists that do not follow the convention capitals also write a given name or a credential, so it is off by default, and it cannot be set with ``unlisted_caps_suffixes=CapsSuffixes.EVERYWHERE``. See :ref:`capitals-as-family` and :ref:`Settings for a list of names `. :issue:`659` - **Add Policy.initials_as_family, to read the letters ending a name as its family name.** ``Parser(policy=Policy(initials_as_family=True)).parse("Lakshmi R S")`` gives given ``Lakshmi``, family ``R S``, where 1.4.0 through 3.0.1, and the default still, give middle ``R``, family ``S``. ``locales.NE`` turns it on, and ``Parser.suggest()`` suggests it for a list whose names repeat one run of letters (Nepal's ``B K``). The same string is a middle and a family initial in many lists and a byline written surname first in a bibliography, so it is off by default. :issue:`1163`, :issue:`1254` - - **Add Parser.suggest(), to read the settings a list of names is written in.** ``Parser().suggest(["Taylor Morgan", "Kim Minjun", "Wang Xiaoming", "Nguyen Anh", "Garcia Emily"]).parser.parse("Taylor Morgan")`` gives given ``Morgan``, family ``Taylor``, where ``Parser().parse("Taylor Morgan")`` gives given ``Taylor``, family ``Morgan``, the list carrying the evidence for a family-first ``name_order``; a group of East Slavic or Turkic patronymics gets the patronymic rule too. A list of names with no common surname, nor a common given name that is rarely a surname, carries no evidence and keeps the base, and moving the base takes from 5 names (Chinese, Korean, Czech) to 50 (Indian, Russian). A later release may suggest other settings for the same list, so keep the ones you applied with your data. See :ref:`suggest-settings`. :issue:`1308`, :issue:`1355`, :issue:`1356`, :issue:`1357`, :issue:`1397`, :issue:`1403` + - **Add Parser.suggest(), to read the settings a list of names is written in.** ``Parser().suggest(["Taylor Morgan", "Kim Minjun", "Wang Xiaoming", "Nguyen Anh", "Garcia Emily"]).parser.parse("Taylor Morgan")`` gives given ``Morgan``, family ``Taylor``, where ``Parser().parse("Taylor Morgan")`` gives given ``Taylor``, family ``Morgan``, the list carrying the evidence for a family-first ``name_order``; a group of East Slavic or Turkic patronymics gets the patronymic rule too. A list of names with no common surname, nor a common given name that is rarely a surname, carries no evidence and keeps the base, and moving the base takes from 5 names (Chinese, Korean, Czech) to 50 (Indian, Russian). A later release may suggest other settings for the same list, so keep the ones you applied with your data. See :ref:`suggest-settings`. :issue:`1308`, :issue:`1355`, :issue:`1356`, :issue:`1357`, :issue:`1397`, :issue:`1403`, :issue:`1442` - **Fix the commas of Ethiopic, Burmese, N'Ko, Mongolian, Manchu, Lisu, Vai and Bamum, and the Ethiopic wordspace, which did not divide a name.** ``parse("ከበደ፣ አበበ")`` gives family ``ከበደ``, given ``አበበ``, where 1.4.0 through 3.0.1 gave given ``ከበደ፣``, family ``አበበ``; the other scripts' commas read the same way, every non-ASCII comma also divides the words of a bracketed credential as the ASCII one does, and ``አበበ፡ከበደ፡ተሰማ`` divides into three words at the wordspace ``፡``. :issue:`1202` - **Fix a Mongolian case suffix joined by a narrow no-break space, which read as a word of its own.** ``Parser(policy=Policy(name_order=FAMILY_FIRST)).parse("ᠬᠣᠷᠯᠤ᠎ᠠ ᠶ᠋ᠢᠨ ᠴᠣᠢᠢᠪᠠᠯᠰᠠᠩ")`` gives family ``ᠬᠣᠷᠯᠤ᠎ᠠ ᠶ᠋ᠢᠨ``, given ``ᠴᠣᠢᠢᠪᠠᠯᠰᠠᠩ``, where 2.0.0 through 3.0.1 split at the U+202F and gave given ``ᠶ᠋ᠢᠨ``. 1.4.0, which has no name order, split there too, reading middle ``ᠶ᠋ᠢᠨ``. Elsewhere U+202F still divides like a space. :issue:`1236` - **Fix the unbalanced-delimiter report on Dutch 't and 's, and read 's as part of the surname.** ``parse("Pieter 't Hart")`` and ``parse("Arent van 's-Gravesande")`` report nothing, where 2.0.0 through 3.0.1 reported ``unbalanced-delimiter``; ``Willem Jacob 's Gravesande`` gives family ``'s Gravesande``, where 1.4.0 through 3.0.1 gave middle ``Jacob 's``; and ``Jan van 't Hof 'Jantje'`` gives nickname ``Jantje`` as 1.4.0 did, where 2.0.0 through 3.0.1 gave ``t Hof 'Jantje``. :issue:`1241` diff --git a/docs/suggest.rst b/docs/suggest.rst index a1ffedbfc..3c3281817 100644 --- a/docs/suggest.rst +++ b/docs/suggest.rst @@ -47,14 +47,14 @@ the base parser's value. How many names to give it ------------------------- -Give it names from one source, written one way, and a few hundred of -them at most: +Give it names from one source, written one way. A few hundred is +enough: - **Under five names** often gets no suggestion. That is safe: a list short of evidence keeps the parser it was given. - **Fifty names** settles most kinds of list. - **A few hundred** settles nearly every kind measured. More rarely - helps, and can hurt. + helps. For a large dataset, take a sample from each source instead of passing everything: @@ -69,10 +69,12 @@ everything: PolicyPatch(name_order=FAMILY_FIRST) A sample is quicker, a suggestion costing about what parsing the same -names does, but that is not the main reason. A very long list can be -read less well than a sample of it, because the order is decided among -the names that vote, and in a list where few names vote a handful of -stray votes weigh more the longer the list is. +names does. A longer list is not read worse for being long: the order +needs its votes to be at least 1% of the list +(:ref:`suggest-deciding`), so a few stray votes in a long list where +few names vote decide nothing, and every list measured that was +written in its base's own order kept it as well at 2,000 names as at +a few hundred. The one kind of list measured that more names kept helping is bylines written initials first (``AM Hoy``) under a family-first base, where @@ -196,7 +198,8 @@ and enough of them agree: - Section * - ``name_order`` - 2 voting for one end - - more than two thirds of the names that cast an order vote + - more than two thirds of the names that cast an order vote, and + at least 1% of the whole list - this one * - ``patronymic_rules`` - 5 carrying one rule's patronymic @@ -217,6 +220,13 @@ vote: a tie, or two names against one, decides nothing. A name with no evidence on the order, and a name whose evidence is contested, casts no order vote and is outside that share. +The names voting for one end must also be at least 1% of the whole +list, voting or not. A list of 200 names or fewer needs no more than +the two names it needs anyway; in a longer list where few names vote, +it keeps a handful of stray votes (a surname that is also a given name, +written first) from deciding the order for every name. Where this +alone holds the order back, the order evidence's note says so. + Two is the floor, not what a typical list needs. Two names decide a list only where no other name votes against them, and how many names a list needs before enough of them vote depends on what its names carry: @@ -635,8 +645,9 @@ The figures below were measured on groups drawn from real names written in a known order. They give a general idea of what to expect and how it varies, and will differ for every dataset. -- **A list written in the base's own order** keeps it in at least 97% - of groups from 2 to 200 names, save the two kinds of list below. +- **A list written in the base's own order** keeps it in at least 95% + of groups from 2 to 2,000 names, and 97% for nearly every kind, save + the two 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. A group whose votes @@ -652,10 +663,10 @@ Two kinds of list keep their order less often: - **Two or three capitals at one end** cast no capitals vote (:ref:`suggest-evidence`), so a list of such names carries little evidence either way. Researchers' bylines written initials first kept a - given-first base in at least 97% of groups, but a list of nothing + given-first base in at least 95% of groups, but a list of nothing but two or three joined initials (``AM Hoy``) kept it in just under - 95% of groups of 50. Where you know how such a list is written, set - ``name_order`` yourself. + 95% of groups of 50 and 93% of groups of 100. Where you know how such + a list is written, set ``name_order`` yourself. ``capitals_as_family`` was suggested in at least 95% of groups from 4 names for researchers who typed their family name in capitals, and diff --git a/nameparser/_parser.py b/nameparser/_parser.py index 4d6be76d1..e6ef610fc 100644 --- a/nameparser/_parser.py +++ b/nameparser/_parser.py @@ -335,8 +335,10 @@ def suggest(self, names: Iterable[str]) -> Suggestion: ``name_order`` is decided in either direction, keeping this parser's family-first spelling where it has one, where at least two names vote for - one end and they are more than two thirds of the names casting - an order vote. A patronymic rule is decided where more than four + one end, they are more than two thirds of the names casting + an order vote, and they are at least 1% of the group: in a long + list where few names vote, a few stray votes decide nothing, and + the order evidence's note says so. A patronymic rule is decided where more than four in five of the names that cast a vote carry its patronymic (and at least five do), for the East Slavic and the Turkic rule alike; a name whose only vote was a set-aside trailing initial counts @@ -385,22 +387,23 @@ def suggest(self, names: Iterable[str]) -> Suggestion: bare str, bytes, a mapping or a non-str item raises TypeError. Measured 2026-11-10, re-taken 2026-11-11, 2026-11-12, - 2026-11-14 and 2026-11-15, 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-15 #1357 - entry holds the table): a group written in this parser's own - order kept - it in at least 97% of groups at every size from 2 to 200 names, - under either base order, save two lists. ORCID holders who + 2026-11-14, 2026-11-15 and 2026-11-16, 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-16 ORDER FLOOR entry holds + the table): 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 capitals signal reads as a family name, kept their given-first order in 52% of groups of two and 4% of five (why, in that file's 2026-11-12 CAPITALS entry). A list of nothing but bylines written two or three joined initials first (``AM Hoy``) kept it in at least 97% of groups at every size - but 50 names, where it kept it in 95% (94.7), the name tables - voting on a few of its names; ORCID's bylines of every writing - kept it in at least 97%. + measured, to 500 names (it holds 644), but 50 and 100 names, where it kept it in 94.7% and 93.3%, the + name tables voting on a few of its names; ORCID's bylines of + every writing kept it in 95.3% and 96.7% at 100 and 200 names + and at least 97% at every other size. 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 diff --git a/nameparser/_suggest.py b/nameparser/_suggest.py index ee10a805c..d9a7f5a2d 100644 --- a/nameparser/_suggest.py +++ b/nameparser/_suggest.py @@ -473,6 +473,13 @@ def name_votes(text: str, lexicon: Lexicon #: STRICTLY MORE THAN to decide the order: more than two thirds, so a #: tie, or two names against one, decides nothing. _MIN_SHARE = 2 / 3 +#: The share of ALL the group's names, voting or not, that the names +#: voting for one end must be at least to decide the order: in a long +#: list where few names vote, two stray votes are more than two thirds +#: of the voters and would decide it. At 200 names or fewer it asks no more +#: than _MIN_VOTES does (decisions/group-suggestion, 2026-11-16 +#: ORDER FLOOR, #1442). +_MIN_ORDER_GROUP_SHARE = 0.01 #: The share of the names casting any vote that one patronymic rule #: (East Slavic or Turkic) must hold strictly more than to decide it, #: higher than _MIN_SHARE because a decided East Slavic rule brought a @@ -1027,10 +1034,20 @@ def add(self, pairs: list[tuple[Signal, Vote]]) -> None: self.contested += 1 def winner(self) -> Vote | None: - """The value whose names are at least _MIN_VOTES and strictly - more than _MIN_SHARE of the names that cast a vote, if one - is.""" - return self.top(_MIN_VOTES, _MIN_SHARE, sum(self.by_name.values())) + """The value whose names are at least _MIN_VOTES, strictly + more than _MIN_SHARE of the names that cast a vote and at least + _MIN_ORDER_GROUP_SHARE of the group, if one is.""" + end = self.top(_MIN_VOTES, _MIN_SHARE, sum(self.by_name.values())) + return None if end is None or self._short_of_group(end) else end + + def held_back(self) -> Vote | None: + """The value the votes would decide but for + _MIN_ORDER_GROUP_SHARE, if one is.""" + end = self.top(_MIN_VOTES, _MIN_SHARE, sum(self.by_name.values())) + return end if end is not None and self._short_of_group(end) else None + + def _short_of_group(self, end: Vote) -> bool: + return self.by_name[end] < _MIN_ORDER_GROUP_SHARE * self.names def top(self, min_votes: int, min_share: float, total: int ) -> Vote | None: @@ -1183,6 +1200,17 @@ def _comma_note(left_out: int) -> str: f"so only a comma followed by post-nominals alone is read past") +def _floor_note(tally: _Tally) -> str: + """The note on an order the group share alone held back.""" + end = tally.held_back() + if end is None: + return "" + return (f"{tally.by_name[end]} of the group's {tally.names} names vote " + f"{_label(end)}, too few to decide the order: it is decided " + f"where the names voting for one end are at least " + f"{_MIN_ORDER_GROUP_SHARE:.0%} of the group") + + def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role], rule_needs_given_first: bool, comma_left_out: int, trailing_note: str = "" @@ -1196,7 +1224,8 @@ def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role], rule that keeps a ``FAMILY_FIRST`` base's order (`_keeps_family_first`) is not passed here: the order is then the votes' or the base's.""" - notes = [_comma_note(comma_left_out), trailing_note] + notes = [_comma_note(comma_left_out), _floor_note(tally), + trailing_note] end = tally.winner() if rule_needs_given_first and end != FAMILY_FIRST: end = GIVEN_FIRST diff --git a/tests/v2/test_suggest.py b/tests/v2/test_suggest.py index 251de143a..ae2a467cd 100644 --- a/tests/v2/test_suggest.py +++ b/tests/v2/test_suggest.py @@ -595,6 +595,77 @@ def test_an_order_needs_more_than_two_thirds_of_the_voting_names() -> None: assert s.patch == PolicyPatch(name_order=FAMILY_FIRST) +#: Names that cast no vote on any setting. +_SILENT = "Xyzzy Plugh" + + +def test_an_order_needs_one_percent_of_the_group() -> None: + # two names for family-first are 1% of a group of 200 and decide it; + # in a group of 201 they are under 1% and decide nothing (#1442). + # The boundary is exact in floats: 0.01 * 200 == 2.0 + assert 0.01 * 200 == 2.0 + voting = ["Smith Mary", "Kim Minjun"] + at = Parser().suggest(voting + [_SILENT] * 198) + assert at.patch == PolicyPatch(name_order=FAMILY_FIRST) + under = Parser().suggest(voting + [_SILENT] * 199) + assert under.patch == PolicyPatch() + order = _order_evidence(under) + assert not order.decided + assert (order.votes_for, order.votes_against, order.no_evidence) == ( + 0, 2, 199) + assert order.note == ( + "2 of the group's 201 names vote FAMILY_FIRST, too few to decide " + "the order: it is decided where the names voting for one end are " + "at least 1% of the group") + + +def test_a_short_group_still_decides_on_two_names() -> None: + # the floor asks no more than _MIN_VOTES of a group of 200 or fewer + s = Parser().suggest(["Smith Mary", "Kim Minjun"] + [_SILENT] * 11) + assert s.patch == PolicyPatch(name_order=FAMILY_FIRST) + assert _order_evidence(s).note == "" + + +@pytest.mark.parametrize("base_order, strays", [ + (GIVEN_FIRST, ["Smith Mary", "Kim Minjun"]), + (FAMILY_FIRST, ["Mary Smith", "Jason Smith"]), +]) +def test_two_stray_votes_do_not_move_a_long_silent_group( + base_order: tuple[Role, Role, Role], strays: list[str]) -> None: + base = Parser(policy=Policy(name_order=base_order)) + # each pair decides the other order on its own + assert base.suggest(strays).patch.name_order not in (UNSET, base_order) + s = base.suggest([_SILENT] * 1000 + strays) + assert s.patch == PolicyPatch() + assert "too few to decide the order" in _order_evidence(s).note + + +#: #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. +_QUIET = ["Zzyvov Qqsan Petrovich", "Qqsidorov Xxmir Ivanovich"] +_STRAYS = ["Adam Qqsan Petrovich", "Alexander Xxmir Ivanovich", + "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), +]) +def test_stray_votes_in_a_long_family_first_patronymic_group( + copies: int, order: object) -> None: + 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.patronymic_rules == frozenset({PatronymicRule.EAST_SLAVIC}) + if order is UNSET: + assert s.parser.parse("Zzyvov Qqsan").family == "Zzyvov" + + def test_a_family_first_group_suggests_family_first() -> None: s = Parser().suggest(["Smith Mary", "Kim Minjun", "Wang Xiaoming"]) assert s.patch.name_order == FAMILY_FIRST @@ -2120,6 +2191,10 @@ def test_a_decomposed_name_votes_as_its_composed_twin( (UNSET, UNSET, UNSET), (FAMILY_FIRST, UNSET, UNSET)), ("_MIN_SHARE", 0.5, ["Smith Mary", "Kim Minjun", "Jason Smith"], GIVEN_FIRST, (UNSET, UNSET, UNSET), (FAMILY_FIRST, UNSET, UNSET)), + # two votes in a group of 201 are under 1% of it (#1442) + ("_MIN_ORDER_GROUP_SHARE", 0.0, + ["Smith Mary", "Kim Minjun"] + [_SILENT] * 199, GIVEN_FIRST, + (UNSET, UNSET, UNSET), (FAMILY_FIRST, UNSET, UNSET)), ("_MIN_PATRONYMIC_SHARE", 0.5, _east_slavic(5) + _OTHERS[:2], GIVEN_FIRST, (UNSET, UNSET, UNSET), (UNSET, frozenset({PatronymicRule.EAST_SLAVIC}), UNSET)), diff --git a/tools/differential/suggest_measure.py b/tools/differential/suggest_measure.py index 79b4d8779..cdfd11bdf 100644 --- a/tools/differential/suggest_measure.py +++ b/tools/differential/suggest_measure.py @@ -3,7 +3,7 @@ `Parser.suggest(names)` reads a group of names a caller declares to share one convention and suggests a `name_order` (and `patronymic_rules`). Its decision rule (`_suggest._MIN_VOTES`, `_MIN_SHARE`, -`_MIN_PATRONYMIC_SHARE`, `_MIN_PATRONYMIC_VOTES`, the trailing-initial +`_MIN_ORDER_GROUP_SHARE`, `_MIN_PATRONYMIC_SHARE`, `_MIN_PATRONYMIC_VOTES`, the trailing-initial signal's `_MIN_TRAILING_NAMES` and `_MIN_TRAILING_SHARE`, and for `initials_as_family`, `_MIN_RUN_NAMES` and `_MIN_RUN_SHARE`) and its word tables (`config/_order_names.py`, written by tools/vocab/order_names.py) were @@ -173,7 +173,7 @@ SETTABLE = ("_MIN_VOTES", "_MIN_SHARE", "_MIN_PATRONYMIC_SHARE", "_MIN_PATRONYMIC_VOTES", "_MIN_TRAILING_NAMES", "_MIN_TRAILING_SHARE", "_MIN_RUN_NAMES", "_MIN_RUN_SHARE", - "_MIN_CAPITALS_LETTERS") + "_MIN_CAPITALS_LETTERS", "_MIN_ORDER_GROUP_SHARE") #: The thresholds that count names (or letters), read as int. _COUNTS = ("_MIN_VOTES", "_MIN_PATRONYMIC_VOTES", "_MIN_TRAILING_NAMES", "_MIN_RUN_NAMES", "_MIN_CAPITALS_LETTERS") From 250c2f358e087a133326bc74ddb2e2dd40ec883b Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Mon, 16 Nov 2026 14:51:24 -0800 Subject: [PATCH 2/2] Say what the order floor held back only where it held something back The floor's note was added to every order evidence the floor touched, including one a decided East Slavic rule then decided given-first, so it called an order decided "too few to decide". It now speaks where the floor alone leaves the order undecided, and where the votes it holds back are for family-first against the rule's given-first order, the one case the floor moves an outcome; it says nothing of held-back votes for the order the rule sets. The floor's denominator leaves out the names a comma left out: they state their own order and the order decided reads none of them. The full table and every parliament suggestion are unchanged, re-run. docs/suggest.rst scopes "not read worse for being long" to the order's own votes and the lists measured, and says a handful of names can still decide the other three settings in a long list. The decisions entry records the rule case the floor changes, the denominator, and every cell of the bare-initials byline row, whose 200-name cell is 97.3%. Two docstring lines reflowed. Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/group-suggestion.md | 9 ++- docs/suggest.rst | 36 +++++++---- nameparser/_parser.py | 12 ++-- nameparser/_suggest.py | 62 ++++++++++++------- tests/v2/test_suggest.py | 73 ++++++++++++++++++++++- 5 files changed, 148 insertions(+), 44 deletions(-) diff --git a/docs/design/decisions/group-suggestion.md b/docs/design/decisions/group-suggestion.md index 6ef9597de..b3114555e 100644 --- a/docs/design/decisions/group-suggestion.md +++ b/docs/design/decisions/group-suggestion.md @@ -15,7 +15,7 @@ - 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. - 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 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 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. +- 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. @@ -450,7 +450,9 @@ Open: the other three settings count their shares among the names with evidence - `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 — 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 (`_Tally.winner`); where this alone holds an order back, the order evidence's note says how many names voted for which end and why that is too few. `_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. + - 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. - One rule, no size regime: at 1% the floor asks at most two names of a group of 200 or fewer, which `_MIN_VOTES` asks already, so every size the earlier tables measured reads as before by construction, and the floor acts only where the list is long enough for stray votes to accumulate. A second rule switching it on above a size would add a boundary the measurement gives no reason for. - Measured with `uv run python tools/differential/suggest_measure.py --sizes 2,3,4,5,10,20,50,100,200,500,1000,2000 --trials 300` (2026-11-16; seed 20261110; a population smaller than a size prints no cell there), the base an export of master 06e90204, each candidate on the branch by `--set _MIN_ORDER_GROUP_SHARE=` (the constant added at 0 to measure, so 0 reads as master). Of the 120 order rows (30 populations, each written both ways under both bases), the 12 capitals rows, the TURKIC table and the 22 parliament lists under three bases, the 1% floor moves two order rows and nothing else: - `pv-RU-patronymic` written family first under a family-first base, the same-order row #1442 is about: 100 / 100 / 100 / 100 / 100 / 99.7 / 99.7 / 98.7 / 99.0 / 90.7 / 86.7 / 86.7% at 2 to 2,000 names before, and the same through 200 then 100 / 100 / 100% at 500 / 1,000 / 2,000 after. @@ -496,5 +498,6 @@ Open: the other three settings count their shares among the names with evidence | pv-TW | 20000 | 100% | 58 / 91 / 91 / 97 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 62 / 85 / 95 / 98 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | | pv-US | 20000 | 100% | 36 / 62 / 79 / 86 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 9 / 31 / 54 / 70 / 90 / 97 / 100 / 100 / 100 / 100 / 100 / 100 | | vi | 20000 | 100% | 49 / 71 / 87 / 95 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | 52 / 77 / 90 / 94 / 100 / 100 / 100 / 100 / 100 / 100 / 100 / 100 | + - `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, and no longer says a longer list can be read worse, which the floor ends for every same-order row measured; its deciding table and the order paragraph state the floor. + - 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. diff --git a/docs/suggest.rst b/docs/suggest.rst index 3c3281817..a4f8e3e9c 100644 --- a/docs/suggest.rst +++ b/docs/suggest.rst @@ -69,12 +69,19 @@ everything: PolicyPatch(name_order=FAMILY_FIRST) A sample is quicker, a suggestion costing about what parsing the same -names does. A longer list is not read worse for being long: the order -needs its votes to be at least 1% of the list -(:ref:`suggest-deciding`), so a few stray votes in a long list where -few names vote decide nothing, and every list measured that was -written in its base's own order kept it as well at 2,000 names as at -a few hundred. +names does. The order's own votes are not read worse in a long list: +they must be at least 1% of the names (:ref:`suggest-deciding`), so a +few stray order votes in a list where few names vote decide nothing, +and every kind of list measured that was written in its base's own +order kept it as well at 2,000 names as at a few hundred. + +The other settings have no such floor. In a long list where almost no +name carries their evidence, a handful of names can still decide +``patronymic_rules``, ``initials_as_family`` or ``capitals_as_family``: +five names written given name, patronymic, family name among a +thousand written family first without one decide the East Slavic rule, +and with it a given-first order for all of them. A sample of a few +hundred names makes that rarer. The one kind of list measured that more names kept helping is bylines written initials first (``AM Hoy``) under a family-first base, where @@ -199,7 +206,7 @@ and enough of them agree: * - ``name_order`` - 2 voting for one end - more than two thirds of the names that cast an order vote, and - at least 1% of the whole list + at least 1% of the list's names - this one * - ``patronymic_rules`` - 5 carrying one rule's patronymic @@ -220,12 +227,15 @@ vote: a tie, or two names against one, decides nothing. A name with no evidence on the order, and a name whose evidence is contested, casts no order vote and is outside that share. -The names voting for one end must also be at least 1% of the whole -list, voting or not. A list of 200 names or fewer needs no more than -the two names it needs anyway; in a longer list where few names vote, -it keeps a handful of stray votes (a surname that is also a given name, -written first) from deciding the order for every name. Where this -alone holds the order back, the order evidence's note says so. +The names voting for one end must also be at least 1% of the list's +names, voting or not, save the names a comma leaves out, which state +their own order. A list of 200 names or fewer needs no more than the +two names it needs anyway; in a longer list where few names vote, it +keeps a handful of stray votes (a surname that is also a given name, +written first) from deciding the order for every name. Where this alone +holds the order back, the order evidence's note says so, and it says +so too where the votes it holds back are against the given-first order +a decided East Slavic rule sets. Two is the floor, not what a typical list needs. Two names decide a list only where no other name votes against them, and how many names a diff --git a/nameparser/_parser.py b/nameparser/_parser.py index e6ef610fc..ff82edecb 100644 --- a/nameparser/_parser.py +++ b/nameparser/_parser.py @@ -336,9 +336,10 @@ def suggest(self, names: Iterable[str]) -> Suggestion: decided in either direction, keeping this parser's family-first spelling where it has one, where at least two names vote for one end, they are more than two thirds of the names casting - an order vote, and they are at least 1% of the group: in a long - list where few names vote, a few stray votes decide nothing, and - the order evidence's note says so. A patronymic rule is decided where more than four + an order vote, and they are at least 1% of the group's names a + comma does not leave out: in a long list where few names vote, a + few stray votes decide nothing, and the order evidence's note + says so. A patronymic rule is decided where more than four in five of the names that cast a vote carry its patronymic (and at least five do), for the East Slavic and the Turkic rule alike; a name whose only vote was a set-aside trailing initial counts @@ -400,8 +401,9 @@ def suggest(self, names: Iterable[str]) -> Suggestion: file's 2026-11-12 CAPITALS entry). A list of nothing but bylines written two or three joined initials first (``AM Hoy``) kept it in at least 97% of groups at every size - measured, to 500 names (it holds 644), but 50 and 100 names, where it kept it in 94.7% and 93.3%, the - name tables voting on a few of its names; ORCID's bylines of + measured, to 500 names (it holds 644), but 50 and 100 names, + where it kept it in 94.7% and 93.3%, the name tables voting on + a few of its names; ORCID's bylines of every writing kept it in 95.3% and 96.7% at 100 and 200 names and at least 97% at every other size. Moving the base takes more names, and diff --git a/nameparser/_suggest.py b/nameparser/_suggest.py index d9a7f5a2d..89fc0ea1e 100644 --- a/nameparser/_suggest.py +++ b/nameparser/_suggest.py @@ -473,12 +473,13 @@ def name_votes(text: str, lexicon: Lexicon #: STRICTLY MORE THAN to decide the order: more than two thirds, so a #: tie, or two names against one, decides nothing. _MIN_SHARE = 2 / 3 -#: The share of ALL the group's names, voting or not, that the names -#: voting for one end must be at least to decide the order: in a long -#: list where few names vote, two stray votes are more than two thirds -#: of the voters and would decide it. At 200 names or fewer it asks no more -#: than _MIN_VOTES does (decisions/group-suggestion, 2026-11-16 -#: ORDER FLOOR, #1442). +#: The share of ALL the group's names, voting or not, save those a +#: comma left out (which state their own order, and which the order +#: decided reads none of), that the names voting for one end must be at +#: least to decide the order: in a long list where few names vote, two +#: stray votes are more than two thirds of the voters and would decide +#: it. At 200 names or fewer it asks no more than _MIN_VOTES does +#: (decisions/group-suggestion, 2026-11-16 ORDER FLOOR, #1442). _MIN_ORDER_GROUP_SHARE = 0.01 #: The share of the names casting any vote that one patronymic rule #: (East Slavic or Turkic) must hold strictly more than to decide it, @@ -1011,20 +1012,25 @@ class _Tally: pass. A plain class rather than a dataclass: it is never pickled or returned.""" - __slots__ = ("names", "contested", "by_name", "by_signal") + __slots__ = ("names", "left_out", "contested", "by_name", "by_signal") def __init__(self) -> None: self.names = 0 + #: names a comma left out (`_comma_note`), which cast no vote + self.left_out = 0 self.contested = 0 #: names per value voted for self.by_name: Counter[Vote] = Counter() #: signal votes per (signal, value) self.by_signal: Counter[tuple[Signal, Vote]] = Counter() - def add(self, pairs: list[tuple[Signal, Vote]]) -> None: + def add(self, pairs: list[tuple[Signal, Vote]], left_out: bool = False + ) -> None: """One name's votes on this setting: its signals' votes, and - one name vote where they agree.""" + one name vote where they agree. ``left_out`` is a name a comma + left out.""" self.names += 1 + self.left_out += left_out for pair in pairs: self.by_signal[pair] += 1 values = {vote for _, vote in pairs} @@ -1036,7 +1042,8 @@ def add(self, pairs: list[tuple[Signal, Vote]]) -> None: def winner(self) -> Vote | None: """The value whose names are at least _MIN_VOTES, strictly more than _MIN_SHARE of the names that cast a vote and at least - _MIN_ORDER_GROUP_SHARE of the group, if one is.""" + _MIN_ORDER_GROUP_SHARE of the group's names a comma did not + leave out, if one is.""" end = self.top(_MIN_VOTES, _MIN_SHARE, sum(self.by_name.values())) return None if end is None or self._short_of_group(end) else end @@ -1047,7 +1054,10 @@ def held_back(self) -> Vote | None: return end if end is not None and self._short_of_group(end) else None def _short_of_group(self, end: Vote) -> bool: - return self.by_name[end] < _MIN_ORDER_GROUP_SHARE * self.names + # a name a comma left out states its own order, and the order + # decided reads none of them, so it is no name of the floor's + return (self.by_name[end] + < _MIN_ORDER_GROUP_SHARE * (self.names - self.left_out)) def top(self, min_votes: int, min_share: float, total: int ) -> Vote | None: @@ -1200,15 +1210,24 @@ def _comma_note(left_out: int) -> str: f"so only a comma followed by post-nominals alone is read past") -def _floor_note(tally: _Tally) -> str: - """The note on an order the group share alone held back.""" +def _floor_note(tally: _Tally, rule_decides: bool) -> str: + """The note on votes _MIN_ORDER_GROUP_SHARE held back: where they + alone leave the order undecided, and where a decided East Slavic + rule sets the given-first order they voted against. None where the + rule sets the order they voted for, which they did not decide.""" end = tally.held_back() - if end is None: + if end is None or (rule_decides and end == GIVEN_FIRST): return "" - return (f"{tally.by_name[end]} of the group's {tally.names} names vote " - f"{_label(end)}, too few to decide the order: it is decided " - f"where the names voting for one end are at least " - f"{_MIN_ORDER_GROUP_SHARE:.0%} of the group") + counted = tally.names - tally.left_out + whose = (f"of the group's {counted} names" if not tally.left_out else + f"of the {counted} names no comma left out") + floor = (f"an order is decided where the names voting for one end are " + f"at least {_MIN_ORDER_GROUP_SHARE:.0%} of those names") + if rule_decides: + return (f"{tally.by_name[end]} {whose} vote {_label(end)}, too few " + f"to decide that order against the rule: {floor}") + return (f"{tally.by_name[end]} {whose} vote {_label(end)}, too few to " + f"decide the order: {floor}") def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role], @@ -1224,9 +1243,10 @@ def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role], rule that keeps a ``FAMILY_FIRST`` base's order (`_keeps_family_first`) is not passed here: the order is then the votes' or the base's.""" - notes = [_comma_note(comma_left_out), _floor_note(tally), - trailing_note] end = tally.winner() + notes = [_comma_note(comma_left_out), + _floor_note(tally, rule_needs_given_first and end is None), + trailing_note] if rule_needs_given_first and end != FAMILY_FIRST: end = GIVEN_FIRST notes.insert(0, "the East Slavic rule reorders each name; it needs " @@ -1568,7 +1588,7 @@ def capitals_reader() -> Parser: for signal, vote in votes.items(): per_setting[_setting_of(signal)].append((signal, vote)) for setting, tally in tallies.items(): - tally.add(per_setting[setting]) + tally.add(per_setting[setting], comma) policy = parser.policy # a FAMILY_FIRST base keeps its order where the group's East Slavic # patronymics are mostly written last (#1356) diff --git a/tests/v2/test_suggest.py b/tests/v2/test_suggest.py index ae2a467cd..58b4e5e26 100644 --- a/tests/v2/test_suggest.py +++ b/tests/v2/test_suggest.py @@ -615,8 +615,33 @@ def test_an_order_needs_one_percent_of_the_group() -> None: 0, 2, 199) assert order.note == ( "2 of the group's 201 names vote FAMILY_FIRST, too few to decide " - "the order: it is decided where the names voting for one end are " - "at least 1% of the group") + "the order: an order is decided where the names voting for one " + "end are at least 1% of those names") + + +def test_the_floor_is_exact_at_three_votes() -> None: + # 0.01 * 300 == 3.0: three votes decide a group of 300, not of 301 + assert 0.01 * 300 == 3.0 + voting = ["Smith Mary", "Kim Minjun", "Wang Xiaoming"] + assert Parser().suggest(voting + [_SILENT] * 297).patch == ( + PolicyPatch(name_order=FAMILY_FIRST)) + assert Parser().suggest(voting + [_SILENT] * 298).patch == PolicyPatch() + + +def test_a_name_a_comma_leaves_out_is_no_name_of_the_floor() -> None: + # a comma states its own order, and the order decided reads none of + # those names: two votes among the two names it reads decide + commas = ["Smith, John"] * 199 + voting = ["Smith Mary", "Kim Minjun"] + s = Parser().suggest(commas + voting) + assert s.patch == PolicyPatch(name_order=FAMILY_FIRST) + assert "too few" not in _order_evidence(s).note + held = Parser().suggest(commas + voting + [_SILENT] * 199) + assert held.patch == PolicyPatch() + assert _order_evidence(held).note.endswith( + "2 of the 201 names no comma left out vote FAMILY_FIRST, too few " + "to decide the order: an order is decided where the names voting " + "for one end are at least 1% of those names") def test_a_short_group_still_decides_on_two_names() -> None: @@ -629,6 +654,7 @@ def test_a_short_group_still_decides_on_two_names() -> None: @pytest.mark.parametrize("base_order, strays", [ (GIVEN_FIRST, ["Smith Mary", "Kim Minjun"]), (FAMILY_FIRST, ["Mary Smith", "Jason Smith"]), + (FAMILY_FIRST_GIVEN_LAST, ["Mary Smith", "Jason Smith"]), ]) def test_two_stray_votes_do_not_move_a_long_silent_group( base_order: tuple[Role, Role, Role], strays: list[str]) -> None: @@ -640,6 +666,49 @@ def test_two_stray_votes_do_not_move_a_long_silent_group( assert "too few to decide the order" in _order_evidence(s).note +#: Ten names carrying an East Slavic patronymic in the middle (given, +#: patronymic, family), which decide the rule and its given-first order. +_MIDDLE_PATRONYMICS = ["Qqsan Petrovich Zzyvova"] * 10 + + +@pytest.mark.parametrize("base_order", [ + GIVEN_FIRST, FAMILY_FIRST, FAMILY_FIRST_GIVEN_LAST]) +def test_strays_for_the_rules_order_leave_no_floor_note( + base_order: tuple[Role, Role, Role]) -> None: + # the rule decides the order the strays voted for: they decided + # nothing, and the note says nothing of them + s = Parser(policy=Policy(name_order=base_order)).suggest( + _MIDDLE_PATRONYMICS + ["Mary Smith", "Jason Smith"] + + [_SILENT] * 1000) + order = _order_evidence(s) + assert order.decided and order.value == GIVEN_FIRST + 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), +]) +def test_strays_against_the_rules_order_no_longer_decide_it( + base_order: tuple[Role, Role, Role], patronymics: list[str]) -> 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) + order = _order_evidence(s) + assert order.decided and order.value == GIVEN_FIRST + 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 " + "that order against the rule: an order is decided where the names " + "voting for one end are at least 1% of those names") + + #: #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.