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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/design/decisions/O6-two-family-names.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Open: [#1402](https://github.com/derek73/python-nameparser/issues/1402) (a bare
- **2026-11-12 #659, the FOURTH REVIEW — THE PEEL COMES BEFORE THE RUN IS CHOSEN, AND A MARKER IS NO CAPITALS WORD.** (A marker excluded in any position superseded by the FIFTH REVIEW entry, which excludes it only where another capitals word is left to be the family.) An independent code review of PR #1363 at 8b3ca491 (switch off byte-identical to the base over 591,210 rows) found three defects, each reproduced on that head. The run chosen was the last, and the peel worked inside it, so a credential a name word cut off from the family became the family (`DUPONT Marie MBA` read given `DUPONT`, family `MBA`; `DUPONT Marie JR`, `Marie DUPONT Jr. MBA`, `Marie DUPONT M.D. PHD` and `Marie DUPONT Esq. MBA` the same): the suffix slot is now read from the end before any run is chosen, past a suffix written otherwise, peeling a listed credential, generation or numeral in capitals wherever a capitals word that is no particle is left, and the last run of the words left is the family. Under a patronymic rule a marker written in capitals joined the family while the patronymic view claimed it (`ALIYEV Ilham Heydar OGLU` under `locales.TR_AZ` read family `OGLU`, patronymic `Heydar OGLU`; `Mehriban Arif QIZI PAŞAYEVA` family `QIZI PAŞAYEVA`; `ИВАНОВ Иван ИВАНОВИЧ` under the East Slavic rule family `ИВАНОВИЧ`): a word the rule in force reads as its marker is no capitals word, and a grid test holds that the switch moves no such word into the family. The invariant the review proposed, that the family and the patronymic view never share a word, does not hold with the switch off: R9 reads a Turkic marker with the word before it whatever field that word is in, and 5,648 of the grid's three-word rows share one with the switch off (measured 2026-11-12), which is R9's own reading. And `_assign`'s `order` report, which stands down for `initials_as_family`, survived where this rule acted (`Anna Q. MD`, `Vega Y. JR`): the THIRD REVIEW entry's drop covers it. The review's scaling finding: a quadratic in one run's length passed the row of four-word runs, so a long-run row holds one run's length at a base of 3,200 units, where a planted copy per word read 7.50x against the tree's 4.39x (the shared base of 800 let it pass at 4.83x), and the leading-conjunction trim no longer pops from the front. Recorded as accepted rather than changed: a lowercase conjunction chained into a unit beside the given name (`MARTIN y Ana Maria` → given `y Ana`, `MARTIN y Ana` → given `Ana`); a capitals word with any letters glued in front, a capital among them or not (`Jean-PIERRE`, `DuPONT`, `eBAY`); an empty part before a comma read by nothing (`, DUPONT Marie`); and shapes no list writes (`MARY III Smith`, `Mary AND AND AND SMITH`, `Anna Y MD Mary`, `de Marie DUPONT`'s initials `d. M. D.`).
- **2026-11-12 #659, the FIFTH REVIEW — A MARKER STAYS THE FAMILY WHERE NOTHING ELSE CAN BE, AND A CONJUNCTION IS NO NAME WORD FOR THE PEEL.** An independent review of 39bf6d34 (switch off byte-identical to its parent over 893,256 parses) found three defects and a rule-text error. The FOURTH REVIEW's marker exclusion tested the spelling in any position, so a surname spelled like a marker lost the family where R9 reads no patronymic (`ABRAMOVICH Roman` and `АБРАМОВИЧ Роман` under the East Slavic rule read given `ABRAMOVICH`; `Ivan PETROVICH Smith` family `Smith`; `OGLU Ahmed` under the Turkic rule given `OGLU`): a marker is now left out of the run only where another capitals word that is no particle, conjunction or marker is left to be the family, and the grid test holds both directions. The peel's count of capitals words it must leave counted a conjunction, which the run then trims, so the switch stood down (`Hugo AND LAC` read given `Hugo AND LAC`; `Marie AND CPA`, `Anna OF MA`, `Marie THE LAC` the same; `John Smith AND MD` family `Smith AND`, suffix `MD`): it now passes a conjunction over by the same predicate the runs use. The peel tested membership against its list of peeled words, a quadratic (`Ann DUPONT` + `MBA` × N read 8.22x for 4x at 3,200): a set now, and a scaling row of trailing credentials holds it. The rule text that scoped S6's, S11's and O9's precedence to "the only word of its run" was wrong once the peel crosses the name (`DUPONT Marie MA`, `DUPONT Marie KC`, `DUPONT Jean FILS` read suffix): the scope is the only capitals word before the first comma that is no particle, conjunction or marker. Recorded as accepted: a lowercase joining word the parse read as a suffix ends the peel (`Ivan FAN R IVANOV MD de` → family `IVANOV MD`); `SIR John MD` → family `SIR`, suffix `MD`; a capitals word right before a marker in other case is both the family and the patronymic view's father's name (`AHMED Kyzy` under the Turkic rule, present in the parent too), so O9's precedence sentence now says the view is read over the words in their written order; and a joining word before a letter leaves the reports and the given-middle split to the order (`ALLIOT-MARIE Anna y V PhD`, present in the parent too). After this entry the rule is frozen for the first PR: a further unwritten shape is recorded, not handled.
- **2026-11-12 #659, the RECORDED SHAPES — FOUR UNWRITTEN SHAPES KEPT AS THEY READ, AND THE PRECEDENCE SCOPE CORRECTED.** With the rule frozen, the shapes found after the FIFTH REVIEW are recorded in rules/O9's Accepted bullets rather than handled, the readings taken from the tree at c61f64b9: under the East Slavic rule `ABRAMOVICH Roman MBA` reads given `ABRAMOVICH`, middle `Roman`, family `MBA`, the marker exclusion asking whether another capitals word is left before the peel takes the credential (`ABRAMOVICH Roman, MBA` and `IVANOV Roman MBA` read family `ABRAMOVICH` and `IVANOV`); under the Turkic rule, with O2's three-word reading merged from #1187, `Aidai MEDERBEK kyzy` reads family `MEDERBEK`, middle `kyzy`, and `Aidai Mederbek KYZY` family `KYZY`, middle `Mederbek`, where the switch off reads family `MEDERBEK kyzy` and `Mederbek KYZY` (the four-word `ALIYEV Ali Ahmad oglu` is unchanged, family `ALIYEV`); `Hugo AND LAC` reads given `Hugo AND`; `Ivan PETROVICH IVANOVICH` under the East Slavic rule reads family `PETROVICH IVANOVICH` and no patronymic; and `DR ABRAMOVICH Roman` reads family `DR`, given `ABRAMOVICH` under that rule and family `DR ABRAMOVICH` without it. None is written in any cached list (the parliaments' Turkic names are four words, the family in capitals). The first two are pinned by test rows stating the accepted reading. The FIFTH REVIEW's scope for S6's, S11's and O9's precedence, "the only capitals word before the first comma that is no particle, conjunction or marker", misdescribed two shapes: a numeral after the word is no capitals word the peel must leave (`Jean Pierre FILS III` → family `FILS`, suffix `III`), and of two listed credentials ending the name the first is the family where nothing before it can be (`Marie MA MBA` → family `MA`, suffix `MBA`). The scope now reads: the word ending the name is the family where no other capitals word before it and before the first comma can be, the listed credentials and numerals after it coming off first. No reading moved.
- 2026-11-19 #1456, #1479, decided 2026-11-19 — O6 DIVIDES THE FAMILY THE CAPITALS NAMED. With both switches on, O6 still takes no word into a family this rule named, and now divides that family by its own words where it holds two units (`Ana GARCÍA LÓPEZ` gives surname1 `GARCÍA`, surname2 `LÓPEZ`), as it divides every family since decisions/O6's 2026-11-19 #1456, #1479 entry: the division is a function of the family's words, so it does not ask which rule read them. No field moves. Where this rule misreads given names in capitals as the family (`ABRAHAM ELEAZAR Quipuscoa Jiménez`), the division divides them too.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ Open: Catalan `dels` (`Maria dels Àngels Puig`). decisions/O7 kept it out of `c
- **The strict Portuguese readings.** `pt.toml` gains its own reading of the words `es.toml` marks that pass on the Portuguese-speaking countries' names, scored under `parser_for(locales.PT, strict=True)` with and without the reading: `fátima` 479 to 88 (84%), `fatima` 134 to 36 (79%), `socorro` 149 to 24 (86%), `lourdes` 149 to 16 (90%), `maria` 21 to 6 (78%). The first draft scored them under the default's particles and also marked `carmen` (35 to 0) and `pilar` (20 to 3), whose names there are Spanish `del Carmen` and `del Pilar`: under the strict choice, which holds no `del`, they score 1 to 0 and 0 to 2, and `angeles` (10 to 0 by default, `de los Angeles`) 1 to 0 (found by the design-docs review). Still failing under it: `rocio` 16 to 9, `rosario` 6 to 8, `jesús` 6 to 3. A word may hold a `given` reading in two files: a name reading triggers no preference between them, and the build refuses it only beside a `mul.toml` reading (check 13). Weighed: leaving it, a strict choice reading only the files it names, against the readings, chosen, since the words are Portuguese names' too and the counts that mark them are Portuguese.
- **Measured** (2026-11-06, the tree against `origin/master` `b1d3d210` read with `--base`, py3.11). ORCID's capped corpus by default: 24 fixed, 6 broken, 12 changed agreeing in neither; under `--locale pt_br`: 0 fixed, 1 broken (`Karina | de Kassia Abreu`, `kassia` unmarked). PSC: 6 fixed (`Francisco | Da Graca | Geraldes`), 1 broken (`Angelita | Da Graca Brenzink`), 1 changed. `snapshot.py --local tse-donors --base` moves 1,187 of 854,531 names, in family and middle alone (`ADRIANA DAS GRACAS LIMA`, `AMANDA DE CASSIA LOPES`). The committed snapshot moves the rule's two default examples, and the `da Piedade` examples join it.
- Recompute: for each word, the ORCID extract's records (`local_orcid.extract_path()`) from BR PT AO MZ CV GW ST TL, and from ES MX AR CO CL PE VE EC UY BO PY CR GT CU DO HN SV NI PA PR AD, with both boxes filled, whose `given family`, NFC lower case with edge periods and commas stripped, holds the word behind a word of `Lexicon.default()._sets.particles`; each parsed with `Lexicon.default()` and with `.remove(word, kind="given")` (for the pack words, `parser_for(locales.PT).lexicon` and its removal; for the strict readings, the Portuguese-speaking countries alone, `parser_for(locales.PT, strict=True)`, its lexicon's particles, and its lexicon with `.remove(word, kind="given")`, or `.add(word, kind="given", after_particle=True)` for a word it does not mark, each beside its policy), a parse agreeing where its given and middle joined equal the given box and its family the family box, case-folded; fixed where only the reading's parse agrees, broken where only the other's. The rows with the commands above, `--base` a `git archive` export of `b1d3d210`.
- 2026-11-19 #1479 — THE FAMILY A PHRASE LEAVES IS DIVIDED AS ANY FAMILY IS. #1479 asked whether the second surname missing behind a P10 phrase (`María del Carmen García López` under `two_family_names`, surname2 '') was a defect or a decision. Neither this file nor decisions/O6 or decisions/R10 recorded a decision: the Accepted clause it rested on described how the parse got there, P2's chain `del Carmen García López` leaving O6 a family of two words that O6 took nothing into and so marked nothing in, and gave no reason to want it. A defect, then, fixed with #1456 by dividing every family by its own words (decisions/O6's 2026-11-19 #1456, #1479 entry): the family gives surname1 `García`, surname2 `López`. Measured on Spanish-speaking ORCID holders under `locales.ES`, the shape held 3,204 records whose family the parser read as the holder's family box, all but 7 (three name words behind the phrase) divided now. The clause is replaced by an example under the rule's O6 Precedence.
2 changes: 2 additions & 0 deletions docs/design/decisions/R10-second-surname-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- `ParsedName.surname2` holds the family's second name unit where rules/O6 read the family as two (and, since 2026-11-06 #845, where rules/W5 reads a Han surname pair, decisions/W5), and is empty otherwise; it is a view, not a role, so `family`, `surnames`, `as_dict()`, `replace()`'s fields and the repr are unchanged, item 5 of decisions/vocabulary-model's 2026-10-28 #754 output-model entry — 2026-10-29 #754, sub-phase 4d.
- O6's mark is a private tag that assemble drops, carried out on `Reading.second_surname`, a field `Token.reading`'s readings gained and that is not compared, where the RFC had a stable tag: a published tag would make an O6 parse unequal to its own 2.x pickle — 2026-10-29 #754, sub-phase 4d.
- The view is filled wherever O6 divides the family into two units, and O6 divides a family by its own words however it was read: before a family comma, where a particle chain made it, and behind a given name a particle completes, as without them; a family a connective joins, or a hyphen makes one word, stays one unit (Open), where a hyphenated word beside a plain word is a unit of its own and divides, as the take always counted it (decisions/O6's entry of the same date, item 10) — 2026-11-19 #1456, #1479.

Elsewhere: why the second surname is a view of `family` rather than a role, the ORCID measurements behind it, and the `surnames` redefinition declined, decisions/vocabulary-model's 2026-10-28 #754 entry, item 5; how O6 counts a family's words and which names it declines, decisions/O6; the first unit's views, `surname1` and its particles and base, decisions/R11 (#1022).

Expand All @@ -17,3 +18,4 @@ Open: whether a family a connective or a hyphen joins (`Ortega y Gasset`, `Garc
3. **The word keeps the reading it took**, the mark set on it, so a patronymic run in the second unit reads in both views (`Ali Hassan bin Ahmad` gives surname2 and patronymic `bin Ahmad`), as does a word P6's attached patronymic particle makes the parent's name (`Mohamad Ali Mahathir bin` under FAMILY_FIRST). Assemble reads the word as it reads without the mark, so no reading's kind, source or files moves: over 1,296 parses of 36 names under each order, with and without `middle_as_family`, `two_family_names` and the RU and TR_AZ packs, tokens, tags and readings match the base apart from the new field.
4. **The view stays out of `as_dict()`, `--json`, `comparison_key()` and the repr**, as R8's and R9's do, and is a `render()` key and an assertable field of a rule's example lines, whose grammar now takes a digit in a field name. The snapshot records it where it is not empty (`tools/differential/snapshot.py`'s `SURNAME2_VIEW`), which no row is, since the snapshot parses the default policy; `tools/differential/cldr_agreement.py` scores it on its own beside the merged `family`, as its PENDING_ROLES were written to.
- Measured 2026-10-29 on the 4d branch over `8a1e6f5f`. The committed snapshot's 6,601 readings of the base: no row moves and none gains the key; the header names `surname2` among the recorded views, and rules/R10's examples add two names, 6,603 readings in all. The agreement records gain only `surname2` entries, each a second surname stated and not read, the default never reading one: CLDR 117 (`cldr_agreement.json`, most of them the `foreignFull` samples' two-word second surnames, `González Domingo`) and 22 more lines in the locale record, Wikidata 330 (its `surname2-es` 150, `surname2-mx` 100, `surname2-co` 80), conventions 2. With `two_family_names` on and each rendering's order kept, the view agrees on 263 of Wikidata's 330 (es 97, mx 91, co 75), on 7 of CLDR's 117 and on neither conventions row, and `family` on 318 of Wikidata's 330 against 55 under the default. The switch's cost on the renderings stating none: of each source's renderings whose expected `surname2` is empty, it gives one to CLDR 700 of 2,523 (`Prof. dr. Cornelia Margarita Sofia Aletta van den Berg jnr., MBChB PhD` reads 'van den Berg'), 102 of them the 252 renderings of a name CLDR states a second surname for that leave it out, Wikidata 160 of 338 (its patronymic strata, `Любовь Митрофановна Шуляк` reading 'Шуляк'), GND 107 of 801, the native-script source 39 of 1,027 and conventions 15 of 28. Recompute: for each row of a fields file, parse its text with `cldr_agreement._parser(None, shape)` and with the same parser's policy given `two_family_names=True`; where `expected_roles(...)` states a `surname2`, compare `.surname2` and `.family` with it by `same`, and where it states none, count the renderings whose `.surname2` is not empty. Frames per parse (`sys.setprofile` call events, a warm parse): the reference row `Dr. Juan0001 de la Vega III` 310.1 and `Gabriel García Márquez` 258 on both trees under the default policy; under `two_family_names`, `Gabriel García Márquez` 284 to 286 and `Juan Pérez de la Vega` 330 to 334, one copy per marked word and one for the marking call, and `García Márquez Gabriel` under FAMILY_FIRST 291 on both. A first draft that rebuilt each marked token at the end of assemble, and read the word with the mark among its tags, cost 13 frames for one word and 35 for three.
- 2026-11-19 #1456, #1479 — THE VIEW FOLLOWS ONE DIVISION, WHICHEVER WAY THE FAMILY WAS WRITTEN. Decided on the two issues (each issue's last comment): the two writings of one name return the same units wherever they yield the same family. The two Accepted clauses that left the view empty go: "a family comma marks nothing", and the particle chain in "where a connective, a hyphen or a particle chain already joins two family names". The connective and the hyphen that makes two names one word (`García-López`) stay, as the Open line asks, decided apart (a hyphenated word beside a plain one, `Sánchez-Cid Torres`, is a unit of its own and divides, decisions/O6's entry of the same date, item 10): both are written by the writer with the switch off too, and neither was measured here beyond its count in #1479's table (95 records with a connective, 17 with a hyphen beside other words, a hyphenated word counted as one; decisions/O6's entry of the same date counts the hyphen class otherwise, by its parts, and gives that recipe). How the family is divided and what was measured: decisions/O6's 2026-11-19 #1456, #1479 entry. The view itself is unchanged: it still reads the mark O6 leaves, and no reading of the family's words happens inside it.
Loading