From 5f878ca1f8ac22e500168ad882b9637849cd91ee Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 16:19:28 -0800 Subject: [PATCH 1/4] =?UTF-8?q?Read=20the=20Cyrillic=20doctorate=20=D0=B4-?= =?UTF-8?q?=D1=80=20ending=20a=20name,=20and=20the=20Bulgarian=20=D0=B4.?= =?UTF-8?q?=D0=BC.,=20as=20credentials=20(#1128)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit д-р gains a credential reading in ru.toml, uk.toml and bg.toml beside its academic one, a title/suffix dual position decides, as CLDR writes it: "Іван Петренко д-р" gives family Петренко, suffix д-р, and in front it stays the title. bg.toml lists д.м. as дм, its stops removed as for md, so "доц. д-р Мария Петрова, д.м." reads title "доц. д-р", family Петрова, suffix д.м. A lowercase mask keeps д-р lowercase under case repair. к.м.н. and д.м.н. already read by the dotted shape (rules/S3); the spaced к. м. н. is left as initials. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- .../design/decisions/H5-trailing-title-run.md | 9 +++ docs/release_log.rst | 1 + nameparser/config/_compiled.py | 3 + nameparser/config/_index.py | 3 +- nameparser/vocab/bg.toml | 5 ++ nameparser/vocab/ru.toml | 1 + nameparser/vocab/uk.toml | 1 + tests/v2/cases.py | 67 +++++++++++++++++++ tests/v2/test_cases.py | 7 +- tools/differential/cldr_agreement.json | 56 +++------------- tools/differential/snapshot.jsonl | 36 +++++----- 12 files changed, 122 insertions(+), 69 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d82bed325..46af78205 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -385,7 +385,7 @@ Don't use the bare `python3 -m doctest .rst` CLI (no `optionflags`) to che **`pr/NNN` local branches** track upstream PRs — don't commit to them by accident. Check `git branch --show-current` before starting work. -**Title vs suffix is positional for BARE words, and the leading period-abbreviation rule overrides even that** — a word matching `TITLES` at the front of a name becomes `title`; the same word matching `SUFFIX_ACRONYMS`/`SUFFIX_WORDS` at the end becomes `suffix` (never both, regardless of the word's real-world meaning). The `TITLES`/suffix overlap was audited in #296 (2026-08-23): the pure postnominals (`jr`, `junior`, `phd`, `do`, `se`) left `TITLES`, the v1-residue `dr`/`sra` left the suffix sets, and the ten words still in both (`ms`, `sr`, `lt`, `ra`, `vc`, and the ranks `cpl`, `cpo`, `cpt`, `csm`, `sgm`; `md` and `sa` were duals too until #853 took `md`'s title reading out, a leading `Md` being the given name Muhammad, and #857 took `sa` out of the vocabulary) are deliberate duals that position decides. External test sources (old issue gists, etc.) sometimes assert `suffix` for a leading professional abbreviation like `RA`/`PD`/`Dipl.-Ing.` — that's the source data being wrong, not a parser bug. Verify position before "fixing" it. Two qualifications the older "purely positional" wording papered over, the first measured 2026-08-01 and the second answered 2026-09-08 (#316): a PERIOD-marked leading word is claimed by the shape rule before any vocabulary is read (`"Esq. Smith"` → `title`, though `esq` is suffix-only), save a listed title and, since #789, a given name written short (`"Chas. Smith"` → `given`), while a run of single letters, which the shape rule never takes, is a title at the head only by rules/H10's vocabulary (`"U.S. Senator John Smith"` → `title='U.S. Senator'`), and a PERIOD-marked trailing word is claimed by VOCABULARY — first the suffix sets, which the peel reads before anything else (`"John Smith Esq."` → `suffix`), then the titles (`"John Smith Prof."` → `title='Prof.'`, `rules/H5`) — while an unlisted abbreviation there stays a name part (`"John Smith Xyz."` → `family='Xyz.'`) unless it is written as two or more period-separated chunks, which since 2.4 IS a trailing shape rule (`Policy.unlisted_dotted_suffixes`, default on: `"John Smith X.Y.Z."` → `suffix='X.Y.Z.'`, read by the same words-to-spare count a bare ambiguous acronym takes, `rules/S3`), except paired initials in a script with capitals, which stay a name word (`"Ram Bahadur B.K."` → `family='B.K.'`, #864). The SINGLE trailing period is still not one, deliberately — it is the abbreviation shape any word can wear. The bare word is where "positional" still holds whole -- outside a part past the second comma, which holds no name word, so C2 reads a bare title word there as a title since #603 (`Eric H. Holder, Jr., Attorney General`), and outside a listed salutation ending the given part after a family comma, which rules/H8 reads as the title since #835 (`Doe, Jane Mrs`), the comma having marked the surname's place -- and the reason it must: `TITLES` holds words that are in no suffix set — 787 of them on 2026-10-11 (746 before #606's salutations), measured with `L = Parser().lexicon._sets; len(L.titles - L.suffix_acronyms - L.suffix_words)`, a figure that grows with the vocabulary and never shrinks the argument — and many are ordinary surnames (`pope`, `bishop`, `judge`, `sheriff`, `baron`, `master`, ...), so a vocabulary-first rule over BARE trailing words would read `"Mary Jane Pope"` as `title='Pope'`, `family='Jane'`. The period is what separates the safe case from that one, and it separates it by being a WRITING convention rather than by making the collision go away: `"Mary Jane Pope"` keeps `family='Pope'` while `"Mary Jane Pope."` reads `title='Pope.'`, `family='Jane'`, a cost accepted under the input-is-a-name premise rather than one the rule prevents (the trailing-position bullet in decisions/vocabulary-exclusions, measured 2026-09-09). Since #316 that sentence describes the shipped rule rather than an aspiration. +**Title vs suffix is positional for BARE words, and the leading period-abbreviation rule overrides even that** — a word matching `TITLES` at the front of a name becomes `title`; the same word matching `SUFFIX_ACRONYMS`/`SUFFIX_WORDS` at the end becomes `suffix` (never both, regardless of the word's real-world meaning). The `TITLES`/suffix overlap was audited in #296 (2026-08-23): the pure postnominals (`jr`, `junior`, `phd`, `do`, `se`) left `TITLES`, the v1-residue `dr`/`sra` left the suffix sets, and the eleven words in both on 2026-11-21 (`ms`, `sr`, `lt`, `ra`, `vc`, the ranks `cpl`, `cpo`, `cpt`, `csm`, `sgm`, and since #1128 the Cyrillic `д-р`; `md` and `sa` were duals too until #853 took `md`'s title reading out, a leading `Md` being the given name Muhammad, and #857 took `sa` out of the vocabulary) are deliberate duals that position decides (recount with `L = Parser().lexicon._sets; sorted(L.titles & (L.suffix_acronyms | L.suffix_words))`). External test sources (old issue gists, etc.) sometimes assert `suffix` for a leading professional abbreviation like `RA`/`PD`/`Dipl.-Ing.` — that's the source data being wrong, not a parser bug. Verify position before "fixing" it. Two qualifications the older "purely positional" wording papered over, the first measured 2026-08-01 and the second answered 2026-09-08 (#316): a PERIOD-marked leading word is claimed by the shape rule before any vocabulary is read (`"Esq. Smith"` → `title`, though `esq` is suffix-only), save a listed title and, since #789, a given name written short (`"Chas. Smith"` → `given`), while a run of single letters, which the shape rule never takes, is a title at the head only by rules/H10's vocabulary (`"U.S. Senator John Smith"` → `title='U.S. Senator'`), and a PERIOD-marked trailing word is claimed by VOCABULARY — first the suffix sets, which the peel reads before anything else (`"John Smith Esq."` → `suffix`), then the titles (`"John Smith Prof."` → `title='Prof.'`, `rules/H5`) — while an unlisted abbreviation there stays a name part (`"John Smith Xyz."` → `family='Xyz.'`) unless it is written as two or more period-separated chunks, which since 2.4 IS a trailing shape rule (`Policy.unlisted_dotted_suffixes`, default on: `"John Smith X.Y.Z."` → `suffix='X.Y.Z.'`, read by the same words-to-spare count a bare ambiguous acronym takes, `rules/S3`), except paired initials in a script with capitals, which stay a name word (`"Ram Bahadur B.K."` → `family='B.K.'`, #864). The SINGLE trailing period is still not one, deliberately — it is the abbreviation shape any word can wear. The bare word is where "positional" still holds whole -- outside a part past the second comma, which holds no name word, so C2 reads a bare title word there as a title since #603 (`Eric H. Holder, Jr., Attorney General`), and outside a listed salutation ending the given part after a family comma, which rules/H8 reads as the title since #835 (`Doe, Jane Mrs`), the comma having marked the surname's place -- and the reason it must: `TITLES` holds words that are in no suffix set — 787 of them on 2026-10-11 (746 before #606's salutations), measured with `L = Parser().lexicon._sets; len(L.titles - L.suffix_acronyms - L.suffix_words)`, a figure that grows with the vocabulary and never shrinks the argument — and many are ordinary surnames (`pope`, `bishop`, `judge`, `sheriff`, `baron`, `master`, ...), so a vocabulary-first rule over BARE trailing words would read `"Mary Jane Pope"` as `title='Pope'`, `family='Jane'`. The period is what separates the safe case from that one, and it separates it by being a WRITING convention rather than by making the collision go away: `"Mary Jane Pope"` keeps `family='Pope'` while `"Mary Jane Pope."` reads `title='Pope.'`, `family='Jane'`, a cost accepted under the input-is-a-name premise rather than one the rule prevents (the trailing-position bullet in decisions/vocabulary-exclusions, measured 2026-09-09). Since #316 that sentence describes the shipped rule rather than an aspiration. ### Tests (`tests/`) diff --git a/docs/design/decisions/H5-trailing-title-run.md b/docs/design/decisions/H5-trailing-title-run.md index 20a57183d..eb1e2e0d5 100644 --- a/docs/design/decisions/H5-trailing-title-run.md +++ b/docs/design/decisions/H5-trailing-title-run.md @@ -18,6 +18,7 @@ Elsewhere: a maiden clause in front of a trailing title is no join that hides it (`Mary Smith née Jones Prof.` → title 'Prof.'), decisions/M2's 2026-09-26 #535 entry; a bare ambiguous acronym ending the given part after a family comma is the credential, so `Doe, John Prof. MA` reads title 'Prof.', suffix 'MA', decisions/S5's 2026-09-18 #531 entry on the comma report's reach; the bound join after a family comma declines a title word this run takes (`Berg, abdul Prof.` → title 'Prof.'), decisions/P5's 2026-10-11 #637 entry; a part past the second comma makes no particle chain, so `John Smith, Jr., van der Berg Prof.` reads title 'Prof.', decisions/C7's 2026-10-11 #636 entry; a report names the field its word lands in, closing the `Dr. John of Prince` detail mismatch, decisions/A1's 2026-10-08 #626 entry; the cost of a period behind an ordinary surname that is title vocabulary (`Mary Jane Pope.` → title 'Pope.', family 'Jane') is the trailing-position bullet of decisions/vocabulary-exclusions. Open: none in this file. +- The Cyrillic doctorate `д-р` is a title/suffix dual position decides, not a trailing title: a title in front (`д-р Іван Петренко`), a credential ending the name, after a comma and ending the given part (`Іван Петренко д-р`, `Іван Петренко, д-р`, `Петренко, Іван д-р` → suffix 'д-р'); the Bulgarian `д.м.` is a credential listed as `дм` — 2026-11-21 #1128. ## Log @@ -77,3 +78,11 @@ Open: none in this file. - **Measured** against `34812254` (2026-11-06, `tools/differential/measure.py --base`): the committed corpora move only rules/H5's own example (`Maria Rossi Dott.ssa`); CLDR, GND and Wikidata agreement match their records; no local corpus moves. A rare writing, then, settled for its consistency with the listing, which already read it as a title in front. In brackets only the academic five read as the title (`John Smith (Dott.ssa)`, `(Prof.ssa)`, `(Univ.Prof)`, `(Dipl.-Ing)`, `(Priv.-Doz)`); the salutations and styles read as a nickname there on both trees (`Maria Rossi (Sig.ra)` → nickname 'Sig.ra', as `(Mrs)` does), so for those eleven the bare and bracketed spellings disagree as title and nickname where they disagreed as family and nickname, found by the design-docs review and left to S1, with #1104. - 2026-11-07 #1131 — A WORD EVERY CHUNK OF WHICH IS A TITLE CHAINS WITHOUT A FINAL PERIOD. The question the 2026-11-06 #1104 entry left for brackets and the end of a name, answered with decisions/S3's entry of this date: every chunk, not any. Classify marks a word with interior periods every chunk of which is title vocabulary with `JOINED_TITLE_TAG`, as it marks a title listed whole (`_vocab.period_joined_title`), so the chain, `_weighed` and P13's trailing title take `John Smith Lt.Gov` (title 'Lt.Gov', where 1.4.0 through 2.8.2 read family 'Lt.Gov') and `Smith, John Lt.Col`, and in brackets rules/S1 reads it as the title (`John Smith (Lt.Gov)`). A word a title only by some chunk (`Dr.PhD`, `St.John`) still needs the final period, the chunk beside the title being no title. ctgov-officials' `Reva PROF.DR` reads title 'PROF.DR' (measured with decisions/S3's entry). - 2026-11-09 #1171 — ONE TAG FOR THE CHAIN'S WORD TEST. Which words rules/H5's chain takes was spelled at three sites kept in step by comments -- `_pieces.trailing_titles` inline, `_pieces.is_trailing_title_word` (the maiden take, and P13's walk back since #1168 deleted the fourth copy, `_group._is_trailing_title`, which had drifted, decisions/P13) and `_pieces._weighed`. Classify now writes it once, as `CHAIN_TITLE_TAG`: a word carrying `JOINED_TITLE_TAG`, or one wearing `_vocab._TRAILING_TITLE_SHAPE` that carries "vocab:title" or `TRAILING_TITLE_TAG`; each site reads the tag. It is written after rules/H9's phrase test, which settles "vocab:title" (`Associate Dean.` carries it, `John Smith Dean.` does not), and against the text as written, so a glued delimiter (`Prof.;`) wears no shape, as before; assemble drops it. No reading moves: the suite and `snapshot.jsonl` hold byte-identical. Cost, measured against `1c5a220c` on py3.11 (2026-11-09): an ordinary name no longer pays the shape regex; every title word that wears the shape, or that carries the joined mark, pays one frame for its write, in any position, so the benchmark's reference row (`tools/perf/call_count.py`) goes 284.80 → 285.80 for its leading `Dr.` and a title run pays per word (`Dr. Prof. John Smith` 223 → 225); a name ending in a plain listed title saves the `is_title_piece` call the chain made, netting zero (`John Smith Prof.` 186 → 186) or one fewer where a second reader asked it (`John Smith y Prof.` 228 → 227), while one ending in a word with the written-short or joined mark, which made no such call, pays the frame (`John Smith Maj.` 198 → 199). Pinned by tests/v2/pipeline/test_classify.py's test_chain_title_tag_marks_the_words_h5s_chain_takes; with the tag's written-short arm removed, 23 tests fail. +- 2026-11-21 #1128 — `Д-Р` ENDING A NAME IS A CREDENTIAL: A TITLE/SUFFIX DUAL, NOT A TRAILING TITLE. Decided 2026-11-21. `ru.toml`, `uk.toml` and `bg.toml` give `д-р` a credential reading beside its academic one, a deliberate dual as `sr` and `lt` are, so position decides: `Іван Петренко д-р` → family 'Петренко', suffix 'д-р' (master: middle 'Петренко', family 'д-р'); `Іван Петренко, д-р` and `Петренко, Іван д-р` → suffix; `д-р Іван Петренко` and `проф. д-р Іван Петренко` keep the title; `Іван Петренко, проф. д-р` → title 'проф.', suffix 'д-р'; `Іван д-р` → given 'Іван', suffix 'д-р', reported `given-or-family`, as `John Sr` and `John Lt` read. The period-marked `д-р.`, H5's shape until now, is the suffix too, the suffix sets being read before the chain. + WHY NOT THE TRAILING TITLE. The 2026-11-06 #1116 entry's withdrawn build read a hyphen-joined listed title as the trailing title (option 2 of #1128), moving the family toward CLDR's and the title away from it: CLDR 48 writes the doctorate after the name in `credentials` in Belarusian and Ukrainian (`... фон Бруль д-р`, `..., д-р`) and Bulgarian (`, проф. д-р`), and in front in `title`. The dual puts it in the field CLDR states in both places. Option 3 (leave it) kept a family name of `д-р`. + MEASURED (on master efdf0e16 against the tree): `cldr_agreement.py` gains 9 field agreements and loses none, title 2,414 → 2,416, suffix 2,381 → 2,386, family_base 395 → 396, surname1_base 186 → 187 of 2,640 renderings, the figures the issue took on 2026-11-06 at 9cdc64bc; the Bulgarian `г-н Иван Асен Вернер, проф. д-р` now reads title 'г-н проф.', suffix 'д-р', where CLDR states both words as credentials, and under FAMILY_FIRST `фон Бруль Ада ...` reads family 'фон', a particle question apart. The committed snapshot moves 7 readings, all CLDR renderings of `д-р`, and 11 forced case views (below); GND, Wikidata native and the per-locale views match their records. `tools/name_usage.py д-р`: one record in every local corpus holds it, an ORCID name, and no Wikidata person. + THE ABBREVIATIONS. `д.м.` (доктор по медицина) is listed in `bg.toml` as `дм`: an acronym credential is matched with every full stop removed, as `M.D.` is `md`, so a `Lexicon.add("д.м.", kind="credential")` stores `д.м` and never matches, which is why the issue's probe moved nothing. Two single letters with stops are paired initials (rules/C5), which no shape reads as a credential, so the listing is the only route. With it the ORCID record's shape reads whole: `доц. д-р Мария Петрова, д.м.` → title 'доц. д-р', given 'Мария', family 'Петрова', suffix 'д.м.' (master: family 'доц. д-р Мария Петрова', given 'д.м.'), the comma a suffix comma and the title run peeled; with the dual alone it read family 'доц. Мария Петрова', suffix 'д-р'. `config_diff.py diff` adding `дм`, over every name in `orcid-researchers`, `opensanctions-parliaments` and `jrc-names` holding the letters (29,666), moved 1, that one. `к.м.н.` and `д.м.н.`, which the issue named and CLDR's cv and ru files write, need no entry: three dotted chunks are rules/S3's shape, read as the credential on master (`Пётр Сидоров, к.м.н.` → suffix). CLDR's Russian and Bashkir files space them (`к. м. н.`, `м. ф. д.`), which reads as initials as `John Smith, M. D.` does; reading spaced letters as one credential would be a new rule, and none was written. `к.ф.-м.н.` (a hyphen inside), which no source here writes, is left unlisted, as are the other degree abbreviations, for want of evidence. + ACCEPTED. A pair of initials spelling `Д.М.` reads as the credential where a listed credential's initials already do: ending a name (`Иванов Д.М.` under FAMILY_FIRST → given 'Иванов', suffix 'Д.М.', where master read family 'Иванов', given 'Д.', middle 'М.'), as `Ivanov M.D.` and `Wang M.A.` read there; behind one word and a comma, in capitals, it stays the given name (`Петрова, Д.М.`, rules/C16). No Cyrillic local corpus writes it. + CASE. `д-р` carries a lowercase mask (`cased = "д-р"`), so forced and one-case repair write `д-р`, where master wrote `Д-Р` for the title and the acronym clause would write it so for the credential: 11 committed renderings move only that view. A mask cannot keep `д.м.` lowercase, rules/R4 writing a letter alone beside a full stop as an initial where its mask writes the letter in a run, so forced repair writes `Д.М.`, as it writes `M.D.`. + NOT TOUCHED. `д-p` typed with a Latin `p` is no listed word and stays a name word (`Іван Петренко д-p` → family 'д-p'). + RECOMPUTE: `uv run python tools/differential/cldr_agreement.py` in a `git archive efdf0e16` export and in the tree; `uv run python tools/differential/snapshot.py` against the record; `config_diff.py diff default 'expr:Parser(lexicon=Lexicon.default().add("дм", kind="credential"))' --local --match '[ДдDd]\.?\s?[МмMm]'` for each corpus named, on the efdf0e16 tree. diff --git a/docs/release_log.rst b/docs/release_log.rst index c2d03624e..6bdcba902 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,6 +4,7 @@ Release Log nameparser 3.2 is under development. + - **Read the Cyrillic doctorate д-р ending a name, and the Bulgarian д.м., as credentials.** ``parse("Іван Петренко д-р")`` gives family ``Петренко``, suffix ``д-р``, where 1.4.0 through 3.1.0 gave middle ``Петренко``, family ``д-р``; in front of the name ``д-р`` stays the title, and after a comma, where it read as the title, it is the suffix too (``Іван Петренко, д-р``). ``доц. д-р Мария Петрова, д.м.`` gives title ``доц. д-р``, family ``Петрова``, suffix ``д.м.``, where 1.4.0 through 3.1.0 gave given ``д.м.``; initials ``Д.М.`` ending a name read as the degree, as ``M.D.`` does. :issue:`1128` - **Read an unlisted credential written in mixed case after a full name and a comma, such as MRes or AuD.** ``parse("Jane Smith, MRes")`` gives suffix ``MRes``, where 1.4.0 through 3.1.0 gave given ``MRes``, family ``Jane Smith``; the word must open with two capitals or end in one, so ``LeBron`` and ``PhDc`` stay given names, while a given name written so after a two-word surname reads as the credential (``García López, DAndre``). Behind one word it stays the given name (``Smith, MRes``), save behind initials spelling a credential, which read as the credential with it (``Smith, M.B. ChB``, and ``Jansen, J.P. IJsbrand``, which loses its given name). The positions only ``CapsSuffixes.EVERYWHERE`` reads still take words in capitals alone (``Alex Lee ONeill`` keeps family ``ONeill``). :issue:`1517` - **Add French dit and dite as connectives under a French choice.** With ``languages=frozenset({"fr"})`` chosen, ``Jean Dupont dit Lebrun`` gives family ``Dupont dit Lebrun``, where the default, as 1.4.0 through 3.1.0, gives middle ``Dupont dit``, family ``Lebrun``; a West African alias joins the given name the same way (``Mamadou dit Madou``), and the default is unchanged, ``Dit`` and ``Dite`` being names too. :issue:`1159` - **Add Brazilian Portuguese familiar forms, found in the names Brazil's election candidates put on the ballot.** With ``familiar-form`` accepted, ``Tião Alves`` / ``Sebastião Alves`` and ``Cida Silva`` / ``Aparecida Silva`` are consistent, where 3.1.0 read a conflict. They are filed under ``pt-BR``, so a strict choice of another language leaves them out, and one name spelled two ways (``Elizangela`` / ``Elisangela``) is not among them. :issue:`1495` diff --git a/nameparser/config/_compiled.py b/nameparser/config/_compiled.py index 39f7865bc..3bee9f711 100644 --- a/nameparser/config/_compiled.py +++ b/nameparser/config/_compiled.py @@ -3835,6 +3835,8 @@ 'vrd', 'whnp', 'whnp-bc', + 'д-р', + 'дм', }) CAPITALIZATION_EXCEPTIONS: dict[str, str] = { @@ -4021,6 +4023,7 @@ 'thmgr': 'ThMgr', 'ua': 'Ua', 'ó': 'Ó', + 'д-р': 'д-р', } GENERATION_WORDS: frozenset[str] = frozenset({ diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index d87b1ff5e..00a497956 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -3771,8 +3771,9 @@ ('воја', (('sr', 'familiar', (('short_for', ('војислав',)),)),)), ('г-жа', (('bg', 'salutation', (('after_given', True),)), ('ru', 'salutation', (('after_given', True),)))), ('г-н', (('bg', 'salutation', (('after_given', True),)), ('ru', 'salutation', (('after_given', True),)))), - ('д-р', (('bg', 'academic', ()), ('ru', 'academic', ()), ('uk', 'academic', ()))), + ('д-р', (('bg', 'academic', ()), ('bg', 'credential', (('cased', 'д-р'),)), ('ru', 'academic', ()), ('ru', 'credential', (('cased', 'д-р'),)), ('uk', 'academic', ()), ('uk', 'credential', (('cased', 'д-р'),)))), ('даша', (('ru', 'familiar', (('short_for', ('дарья',)),)),)), + ('дм', (('bg', 'credential', ()),)), ('женя', (('ru', 'familiar', (('short_for', ('евгений',)),)),)), ('жика', (('sr', 'familiar', (('short_for', ('живорад',)),)),)), ('и', (('bg', 'conjunction', ()), ('ru', 'conjunction', ()))), diff --git a/nameparser/vocab/bg.toml b/nameparser/vocab/bg.toml index 3b4d46860..dce443d32 100644 --- a/nameparser/vocab/bg.toml +++ b/nameparser/vocab/bg.toml @@ -15,6 +15,7 @@ academic = { issue = 269, expands = "academician" } [[word]] text = "д-р" academic = { issue = 269, expands = "doctor" } +credential = { cased = "д-р", expands = "doctor", issue = 1128, note = "a title/suffix dual decided by position (decisions/H5, 2026-11-21 #1128): CLDR 48 writes it after the name in credentials in Belarusian, Ukrainian and Bulgarian; borne by no name in any local corpus or Wikidata (tools/name_usage.py, 2026-11-21), the one ORCID record holding it writing the degree" } [[word]] text = "проф" @@ -56,6 +57,10 @@ generation = { issue = 661 } text = "старши" generation = { issue = 661 } +[[word]] +text = "дм" +credential = { expands = "доктор по медицина (doctor of medicine)", issue = 1128, note = "written д.м. after the name and a comma by the one ORCID record holding it (tools/name_usage.py, 2026-11-21); no name in any local corpus or Wikidata. Listed with its full stops removed, as m.d. is md: listed as д.м. it never matched. Two letters with stops are paired initials (rules/C5), which no shape reads as a credential, so only the listing does; behind one word ending a name it takes the trailing slot as md does (Иванов Д.М.), a shape no Cyrillic local corpus writes (config_diff.py, 2026-11-21: 1 of 29,666 names holding the letters moved, this one). к.м.н. and д.м.н. need no entry, rules/S3 reading three dotted chunks" } + [[word]] text = "и" conjunction = {} diff --git a/nameparser/vocab/ru.toml b/nameparser/vocab/ru.toml index fadbda9c4..63ebd0fff 100644 --- a/nameparser/vocab/ru.toml +++ b/nameparser/vocab/ru.toml @@ -19,6 +19,7 @@ academic = { issue = 269, expands = "academician" } [[word]] text = "д-р" academic = { issue = 269, expands = "doctor", note = "a plain title, the family name following it as after 'dr' (not GIVEN_NAME_TITLES: 'д-р Петров' families the surname just as 'Dr. Smith' does)" } +credential = { cased = "д-р", expands = "doctor", issue = 1128, note = "a title/suffix dual decided by position (decisions/H5, 2026-11-21 #1128): CLDR 48 writes it after the name in credentials in Belarusian, Ukrainian and Bulgarian; borne by no name in any local corpus or Wikidata (tools/name_usage.py, 2026-11-21), the one ORCID record holding it writing the degree" } [[word]] text = "проф" diff --git a/nameparser/vocab/uk.toml b/nameparser/vocab/uk.toml index a6e9eaa83..96c84864a 100644 --- a/nameparser/vocab/uk.toml +++ b/nameparser/vocab/uk.toml @@ -16,6 +16,7 @@ academic = { issue = 269, expands = "academician" } [[word]] text = "д-р" academic = { issue = 269, expands = "doctor" } +credential = { cased = "д-р", expands = "doctor", issue = 1128, note = "a title/suffix dual decided by position (decisions/H5, 2026-11-21 #1128): CLDR 48 writes it after the name in credentials in Belarusian, Ukrainian and Bulgarian; borne by no name in any local corpus or Wikidata (tools/name_usage.py, 2026-11-21), the one ORCID record holding it writing the degree" } [[word]] text = "проф" diff --git a/tests/v2/cases.py b/tests/v2/cases.py index f3cb651bd..b91a946d1 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -7296,6 +7296,73 @@ def _check_cjk_shape_purity(self) -> None: "Alex Lee McCAFFREY", {"given": "Alex", "middle": "Lee", "family": "McCAFFREY"}, policy=Policy(unlisted_caps_suffixes=CapsSuffixes.EVERYWHERE)), + # #1128: д-р is a title/suffix dual, a title in front and a + # credential after the name, as CLDR writes it in be, uk and bg; + # д.м. is listed as дм, the stops removed as for md + Case("a_cyrillic_doctorate_ending_a_name_is_a_credential", + "Іван Петренко д-р", + {"given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)", + notes="master read middle 'Петренко', family 'д-р'"), + Case("a_cyrillic_doctorate_after_a_comma_is_a_credential", + "Іван Петренко, д-р", + {"given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_ending_the_given_part_is_a_credential", + "Петренко, Іван д-р", + {"given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_in_front_stays_the_title", + "д-р Іван Петренко", + {"title": "д-р", "given": "Іван", "family": "Петренко"}, + classification="feat(#269)"), + Case("a_professor_before_a_trailing_doctorate_stays_the_title", + "Іван Петренко, проф. д-р", + {"title": "проф.", "given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_behind_one_name_word", + "Іван д-р", + {"given": "Іван", "suffix": "д-р"}, + classification="fix(#1128)", + ambiguities=("given-or-family",), + notes="as 'John Sr' and 'John Lt' read, the other duals"), + Case("a_bulgarian_medical_degree_makes_the_comma_a_suffix_comma", + "доц. д-р Мария Петрова, д.м.", + {"title": "доц. д-р", "given": "Мария", "family": "Петрова", "suffix": "д.м."}, + classification="fix(#1128)", + notes="the shape of the one ORCID record holding д-р: master read " + "family 'доц. д-р Мария Петрова', given 'д.м.'"), + Case("a_bulgarian_medical_degree_behind_one_word", + "Петрова, д.м.", + {"family": "Петрова", "suffix": "д.м."}, + classification="fix(#1128)"), + Case("cyrillic_initials_spelling_the_degree_behind_one_word", + "Петрова, Д.М.", + {"given": "Д.", "middle": "М.", "family": "Петрова"}, + classification="fix(#1238)", + ambiguities=("suffix-or-name",), + notes="in capitals, initials behind one word whatever they spell (rules/C16)"), + Case("cyrillic_initials_spelling_the_degree_family_first", + "Иванов Д.М.", + {"given": "Иванов", "suffix": "Д.М."}, + policy=Policy(name_order=FAMILY_FIRST), + classification="fix(#1128)", + ambiguities=("given-or-family",), + notes="accepted, as 'Ivanov M.D.' reads under FAMILY_FIRST " + "(decisions/H5, 2026-11-21 #1128)"), + Case("a_russian_degree_in_dotted_chunks_reads_by_its_shape", + "Пётр Сидоров, к.м.н.", + {"given": "Пётр", "family": "Сидоров", "suffix": "к.м.н."}, + classification="feat(#516)", + notes="no entry needed: three dotted chunks are rules/S3's shape"), + Case("a_spaced_russian_degree_is_read_as_initials", + "Пётр Сидоров, к. м. н.", + {"given": "к.", "middle": "м. н.", "family": "Пётр Сидоров"}, + notes="as 'John Smith, M. D.' reads: no rule joins spaced letters"), + Case("a_doctorate_typed_with_a_latin_p_is_a_name_word", + "Іван Петренко д-p", + {"given": "Іван", "middle": "Петренко", "family": "д-p"}, + notes="the Latin lookalike is no listed word (#1128)"), Case("the_comma_caps_reading_can_be_switched_off", "John Smith, XYZ", {"given": "XYZ", "family": "John Smith"}, diff --git a/tests/v2/test_cases.py b/tests/v2/test_cases.py index a17039b0b..02e847bba 100644 --- a/tests/v2/test_cases.py +++ b/tests/v2/test_cases.py @@ -529,9 +529,10 @@ def test_the_field_sweep_sees_the_claims_it_checks() -> None: # -> 2296 on 2026-11-21, #1517's six caps-shape rows reporting # suffix-or-name under three orders; 2296 -> 2321 the same day, its # test review's eight rows under three orders and its family-first - # row under its declared policy. - assert claims == 2321, ( - f"the field sweep checks {claims} claims, recorded as 2321 on " + # row under its declared policy; 2321 -> 2328 the same day, #1128's + # reporting rows. + assert claims == 2328, ( + f"the field sweep checks {claims} claims, recorded as 2328 on " f"2026-11-21") diff --git a/tools/differential/cldr_agreement.json b/tools/differential/cldr_agreement.json index 0a2d015c5..3d0628794 100644 --- a/tools/differential/cldr_agreement.json +++ b/tools/differential/cldr_agreement.json @@ -680,11 +680,7 @@ "be/foreignFull/givenFirst": { "family": { "expected": "фон Бруль", - "got": "д-р" - }, - "family_base": { - "expected": "Бруль", - "got": "д-р" + "got": "Бруль" }, "family_particles": { "expected": "фон", @@ -692,15 +688,7 @@ }, "given_names": { "expected": "Ада Карнэлія Сесар Марцін", - "got": "Ада Карнэлія Сесар Марцін фон Бруль" - }, - "suffix": { - "expected": "д-р", - "got": "" - }, - "surname1_base": { - "expected": "Бруль", - "got": "д-р" + "got": "Ада Карнэлія Сесар Марцін фон" }, "surname1_particles": { "expected": "фон", @@ -742,11 +730,7 @@ }, "given_names": { "expected": "Ада Карнэлія Сесар Марцін", - "got": "Бруль Ада Карнэлія Сесар Марцін д-р" - }, - "suffix": { - "expected": "д-р", - "got": "" + "got": "Бруль Ада Карнэлія Сесар Марцін" }, "surname1_base": { "expected": "Бруль", @@ -803,12 +787,12 @@ "bg/nativeFull/givenFirst": { "suffix": { "expected": "проф. д-р", - "got": "" + "got": "д-р" }, "text": "г-н Иван Асен Вернер, проф. д-р", "title": { "expected": "г-н", - "got": "г-н проф. д-р" + "got": "г-н проф." } }, "bg/nativeFull/sorting": { @@ -833,12 +817,12 @@ "bg/nativeFull/surnameFirst": { "suffix": { "expected": "проф. д-р", - "got": "" + "got": "д-р" }, "text": "г-н Вернер, Иван Асен, проф. д-р", "title": { "expected": "г-н", - "got": "г-н проф. д-р" + "got": "г-н проф." } }, "blo/foreignFull/givenFirst": { @@ -8975,10 +8959,6 @@ "expected": "Анастасія Єва Софія", "got": "Анастасія Єва Софія фон Вольф Гонзалес" }, - "suffix": { - "expected": "д-р", - "got": "" - }, "surname1_base": { "expected": "Вольф", "got": "Домінго" @@ -8991,11 +8971,7 @@ "expected": "Гонзалес Домінго", "got": "" }, - "text": "проф. Анастасія Єва Софія фон Вольф Гонзалес Домінго, д-р", - "title": { - "expected": "проф.", - "got": "проф. д-р" - } + "text": "проф. Анастасія Єва Софія фон Вольф Гонзалес Домінго, д-р" }, "uk/foreignFull/sorting": { "family": { @@ -9014,10 +8990,6 @@ "expected": "Анастасія Єва Софія", "got": "фон Вольф Гонзалес Домінго Анастасія Єва" }, - "suffix": { - "expected": "д-р", - "got": "" - }, "surname1_base": { "expected": "Вольф", "got": "Софія" @@ -9030,11 +9002,7 @@ "expected": "Гонзалес Домінго", "got": "" }, - "text": "фон Вольф Гонзалес Домінго Анастасія Єва Софія, д-р, проф.", - "title": { - "expected": "проф.", - "got": "д-р проф." - } + "text": "фон Вольф Гонзалес Домінго Анастасія Єва Софія, д-р, проф." }, "uk/foreignFull/surnameFirst": { "family": { @@ -9051,11 +9019,7 @@ }, "given_names": { "expected": "Анастасія Єва Софія", - "got": "Вольф Гонзалес Домінго Анастасія Єва Софія д-р" - }, - "suffix": { - "expected": "д-р", - "got": "" + "got": "Вольф Гонзалес Домінго Анастасія Єва Софія" }, "surname1_base": { "expected": "Вольф", diff --git a/tools/differential/snapshot.jsonl b/tools/differential/snapshot.jsonl index 59c2abdb1..7773a63b5 100644 --- a/tools/differential/snapshot.jsonl +++ b/tools/differential/snapshot.jsonl @@ -5317,7 +5317,7 @@ {"name": "Абатуров, Константин Иванович", "given": "Константин", "middle": "Иванович", "family": "Абатуров", "initials": "К. И. А."} {"name": "Агеева, Валентина Васильевна", "given": "Валентина", "middle": "Васильевна", "family": "Агеева", "initials": "В. В. А."} {"name": "Агриппина Младшая", "given": "Агриппина", "suffix": "Младшая", "ambiguities": ["GIVEN_OR_FAMILY"], "alternatives": ["GIVEN_OR_FAMILY: name as family (position)"], "initials": "А.", "generation": "Младшая"} -{"name": "Ада Карнэлія Сесар Марцін фон Бруль д-р", "given": "Ада", "middle": "Карнэлія Сесар Марцін фон Бруль", "family": "д-р", "initials": "А. К. С. М. ф. Б. д.", "capitalized_force": "Ада Карнэлія Сесар Марцін Фон Бруль Д-Р"} +{"name": "Ада Карнэлія Сесар Марцін фон Бруль д-р", "given": "Ада", "middle": "Карнэлія Сесар Марцін фон", "family": "Бруль", "suffix": "д-р", "initials": "А. К. С. М. ф. Б.", "capitalized_force": "Ада Карнэлія Сесар Марцін Фон Бруль д-р"} {"name": "Ада Корнелия фон Брюль Джуниор, тіс дәрігері", "given": "тіс", "middle": "дәрігері", "family": "Ада Корнелия фон Брюль Джуниор", "initials": "т. д. А. К. ф. Б. Д.", "capitalized_force": "Тіс Дәрігері Ада Корнелия Фон Брюль Джуниор"} {"name": "Адамович, Михаил Михайлович", "given": "Михаил", "middle": "Михайлович", "family": "Адамович", "initials": "М. М. А."} {"name": "Адлер Ирене", "order": "FAMILY_FIRST", "given": "Ирене", "family": "Адлер", "initials": "И. А."} @@ -5907,32 +5907,32 @@ {"name": "вон Брухи Гонзалес Доминго Проф. Док. Ада Корнелиа Сезар Мартин", "order": "FAMILY_FIRST", "given": "Брухи", "middle": "Гонзалес Доминго Проф. Док. Ада Корнелиа Сезар Мартин", "family": "вон", "initials": "Б. Г. Д. П. Д. А. К. С. М. в.", "capitalized_force": "Вон Брухи Гонзалес Доминго Проф. Док. Ада Корнелиа Сезар Мартин"} {"name": "вон Брухи Гонзалес Доминго, Проф. Док. Ада Корнелиа Сезар Мартин", "title": "Проф. Док.", "given": "Ада", "middle": "Корнелиа Сезар Мартин", "family": "вон Брухи Гонзалес Доминго", "initials": "А. К. С. М. в. Б. Г. Д.", "capitalized_force": "Проф. Док. Ада Корнелиа Сезар Мартин Вон Брухи Гонзалес Доминго"} {"name": "вон Брюхл Гонзалес Доминго Проф. Др. Ада Корнелиа Эва Софиа Анагаах ухааны доктор", "order": "FAMILY_FIRST", "given": "Брюхл", "middle": "Гонзалес Доминго Проф. Др. Ада Корнелиа Эва Софиа Анагаах ухааны доктор", "family": "вон", "initials": "Б. Г. Д. П. Д. А. К. Э. С. А. у. д. в.", "capitalized_force": "Вон Брюхл Гонзалес Доминго Проф. Др. Ада Корнелиа Эва Софиа Анагаах Ухааны Доктор"} -{"name": "г-н Вернер, Иван Асен, проф. д-р", "order": "FAMILY_FIRST", "title": "г-н проф. д-р", "given": "Иван", "middle": "Асен", "family": "Вернер", "initials": "И. А. В.", "capitalized_force": "Г-Н Проф. Д-Р Иван Асен Вернер"} -{"name": "г-н Иван Асен Вернер, проф. д-р", "title": "г-н проф. д-р", "given": "Иван", "middle": "Асен", "family": "Вернер", "initials": "И. А. В.", "capitalized_force": "Г-Н Проф. Д-Р Иван Асен Вернер"} +{"name": "г-н Вернер, Иван Асен, проф. д-р", "order": "FAMILY_FIRST", "title": "г-н проф.", "given": "Иван", "middle": "Асен", "family": "Вернер", "suffix": "д-р", "initials": "И. А. В.", "capitalized_force": "Г-Н Проф. Иван Асен Вернер д-р"} +{"name": "г-н Иван Асен Вернер, проф. д-р", "title": "г-н проф.", "given": "Иван", "middle": "Асен", "family": "Вернер", "suffix": "д-р", "initials": "И. А. В.", "capitalized_force": "Г-Н Проф. Иван Асен Вернер д-р"} {"name": "г-н Иван Петров", "title": "г-н", "given": "Иван", "family": "Петров", "initials": "И. П.", "capitalized_force": "Г-Н Иван Петров"} {"name": "др Слађана Вера Миленковић дипл. инж.", "given": "др", "middle": "Слађана Вера Миленковић дипл.", "family": "инж.", "initials": "д. С. В. М. д. и.", "capitalized_force": "Др Слађана Вера Миленковић Дипл. Инж."} -{"name": "проф. Анастасія Єва Софія фон Вольф Гонзалес Домінго, д-р", "title": "проф. д-р", "given": "Анастасія", "middle": "Єва Софія фон Вольф Гонзалес", "family": "Домінго", "initials": "А. Є. С. ф. В. Г. Д.", "capitalized_force": "Проф. Д-Р Анастасія Єва Софія Фон Вольф Гонзалес Домінго"} +{"name": "проф. Анастасія Єва Софія фон Вольф Гонзалес Домінго, д-р", "title": "проф.", "given": "Анастасія", "middle": "Єва Софія фон Вольф Гонзалес", "family": "Домінго", "suffix": "д-р", "initials": "А. Є. С. ф. В. Г. Д.", "capitalized_force": "Проф. Анастасія Єва Софія Фон Вольф Гонзалес Домінго, д-р"} {"name": "проф. Анна Марія Богдан-Зиновій Петренко доц.", "title": "проф.", "given": "Анна", "middle": "Марія Богдан-Зиновій Петренко", "family": "доц.", "initials": "А. М. Б. П. д.", "capitalized_force": "Проф. Анна Марія Богдан-Зиновій Петренко Доц."} {"name": "проф. Петренко Анна Марія Богдан-Зиновій доц.", "order": "FAMILY_FIRST", "title": "проф.", "given": "Анна", "middle": "Марія Богдан-Зиновій доц.", "family": "Петренко", "initials": "А. М. Б. д. П.", "capitalized_force": "Проф. Петренко Анна Марія Богдан-Зиновій Доц."} -{"name": "проф. д-р Ада Корнелия Цезар Мартин Брюл, доктор", "title": "проф. д-р", "given": "доктор", "family": "Ада Корнелия Цезар Мартин Брюл", "initials": "д. А. К. Ц. М. Б.", "capitalized_force": "Проф. Д-Р Доктор Ада Корнелия Цезар Мартин Брюл"} -{"name": "проф. д-р Ана Марија Цезар Мартин ван ден Волф", "title": "проф. д-р", "given": "Ана", "middle": "Марија Цезар Мартин ван ден", "family": "Волф", "initials": "А. М. Ц. М. в. д. В.", "capitalized_force": "Проф. Д-Р Ана Марија Цезар Мартин Ван Ден Волф"} -{"name": "проф. д-р Брюл, Ада Корнелия Цезар Мартин, доктор", "order": "FAMILY_FIRST", "title": "проф. д-р", "given": "Ада", "middle": "Корнелия Цезар Мартин", "family": "Брюл", "suffix": "доктор", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. Ц. М. Б.", "capitalized_force": "Проф. Д-Р Ада Корнелия Цезар Мартин Брюл Доктор"} -{"name": "проф. д-р Крсте Петков Мисирков", "title": "проф. д-р", "given": "Крсте", "middle": "Петков", "family": "Мисирков", "initials": "К. П. М.", "capitalized_force": "Проф. Д-Р Крсте Петков Мисирков"} -{"name": "проф. д-р Мисирков Крсте Петков", "order": "FAMILY_FIRST", "title": "проф. д-р", "given": "Крсте", "middle": "Петков", "family": "Мисирков", "initials": "К. П. М.", "capitalized_force": "Проф. Д-Р Мисирков Крсте Петков"} -{"name": "проф. д-р ван ден Волф Ана Марија Цезар Мартин", "order": "FAMILY_FIRST", "title": "проф. д-р", "given": "ден", "middle": "Волф Ана Марија Цезар Мартин", "family": "ван", "initials": "д. В. А. М. Ц. М. в.", "capitalized_force": "Проф. Д-Р Ван Ден Волф Ана Марија Цезар Мартин"} +{"name": "проф. д-р Ада Корнелия Цезар Мартин Брюл, доктор", "title": "проф. д-р", "given": "доктор", "family": "Ада Корнелия Цезар Мартин Брюл", "initials": "д. А. К. Ц. М. Б.", "capitalized_force": "Проф. д-р Доктор Ада Корнелия Цезар Мартин Брюл"} +{"name": "проф. д-р Ана Марија Цезар Мартин ван ден Волф", "title": "проф. д-р", "given": "Ана", "middle": "Марија Цезар Мартин ван ден", "family": "Волф", "initials": "А. М. Ц. М. в. д. В.", "capitalized_force": "Проф. д-р Ана Марија Цезар Мартин Ван Ден Волф"} +{"name": "проф. д-р Брюл, Ада Корнелия Цезар Мартин, доктор", "order": "FAMILY_FIRST", "title": "проф. д-р", "given": "Ада", "middle": "Корнелия Цезар Мартин", "family": "Брюл", "suffix": "доктор", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. Ц. М. Б.", "capitalized_force": "Проф. д-р Ада Корнелия Цезар Мартин Брюл Доктор"} +{"name": "проф. д-р Крсте Петков Мисирков", "title": "проф. д-р", "given": "Крсте", "middle": "Петков", "family": "Мисирков", "initials": "К. П. М.", "capitalized_force": "Проф. д-р Крсте Петков Мисирков"} +{"name": "проф. д-р Мисирков Крсте Петков", "order": "FAMILY_FIRST", "title": "проф. д-р", "given": "Крсте", "middle": "Петков", "family": "Мисирков", "initials": "К. П. М.", "capitalized_force": "Проф. д-р Мисирков Крсте Петков"} +{"name": "проф. д-р ван ден Волф Ана Марија Цезар Мартин", "order": "FAMILY_FIRST", "title": "проф. д-р", "given": "ден", "middle": "Волф Ана Марија Цезар Мартин", "family": "ван", "initials": "д. В. А. М. Ц. М. в.", "capitalized_force": "Проф. д-р Ван Ден Волф Ана Марија Цезар Мартин"} {"name": "проф. др Александра Ева Сара ван ден Волф Петровић Југовић дипл. инж.", "title": "проф.", "given": "др", "middle": "Александра Ева Сара ван ден Волф Петровић Југовић дипл.", "family": "инж.", "initials": "д. А. Е. С. в. д. В. П. Ј. д. и.", "capitalized_force": "Проф. Др Александра Ева Сара Ван Ден Волф Петровић Југовић Дипл. Инж."} -{"name": "проф. фон Вольф Гонзалес Домінго Анастасія Єва Софія д-р", "order": "FAMILY_FIRST", "title": "проф.", "given": "Вольф", "middle": "Гонзалес Домінго Анастасія Єва Софія д-р", "family": "фон", "initials": "В. Г. Д. А. Є. С. д. ф.", "capitalized_force": "Проф. Фон Вольф Гонзалес Домінго Анастасія Єва Софія Д-Р"} -{"name": "проф., д-р Ада Корнелия Сезар Мартин фон Брюль кесе, м. ф. д.", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин фон Брюль кесе", "family": "проф.", "suffix": "м. ф. д.", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. С. М. ф. Б. к. п.", "capitalized_force": "Д-Р Ада Корнелия Сезар Мартин Фон Брюль Кесе Проф. М. Ф. Д."} -{"name": "проф., д-р Ада Корнелия Сезар Мартин фон Брюль — мл., к. м. н.", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин фон Брюль —", "family": "проф.", "suffix": "мл., к. м. н.", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. С. М. ф. Б. —. п.", "capitalized_force": "Д-Р Ада Корнелия Сезар Мартин Фон Брюль — Проф. Мл., К. М. Н.", "generation": "мл.", "credentials": "к. м. н."} -{"name": "проф., д-р Ада Корнелия Сезар Мартин фон Брюль — мл., к.м.н.", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин фон Брюль —", "family": "проф.", "suffix": "мл., к.м.н.", "initials": "А. К. С. М. ф. Б. —. п.", "capitalized_force": "Д-Р Ада Корнелия Сезар Мартин Фон Брюль — Проф. Мл., К.М.Н.", "generation": "мл.", "credentials": "к.м.н."} +{"name": "проф. фон Вольф Гонзалес Домінго Анастасія Єва Софія д-р", "order": "FAMILY_FIRST", "title": "проф.", "given": "Вольф", "middle": "Гонзалес Домінго Анастасія Єва Софія", "family": "фон", "suffix": "д-р", "initials": "В. Г. Д. А. Є. С. ф.", "capitalized_force": "Проф. Фон Вольф Гонзалес Домінго Анастасія Єва Софія д-р"} +{"name": "проф., д-р Ада Корнелия Сезар Мартин фон Брюль кесе, м. ф. д.", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин фон Брюль кесе", "family": "проф.", "suffix": "м. ф. д.", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. С. М. ф. Б. к. п.", "capitalized_force": "д-р Ада Корнелия Сезар Мартин Фон Брюль Кесе Проф. М. Ф. Д."} +{"name": "проф., д-р Ада Корнелия Сезар Мартин фон Брюль — мл., к. м. н.", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин фон Брюль —", "family": "проф.", "suffix": "мл., к. м. н.", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. С. М. ф. Б. —. п.", "capitalized_force": "д-р Ада Корнелия Сезар Мартин Фон Брюль — Проф. Мл., К. М. Н.", "generation": "мл.", "credentials": "к. м. н."} +{"name": "проф., д-р Ада Корнелия Сезар Мартин фон Брюль — мл., к.м.н.", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин фон Брюль —", "family": "проф.", "suffix": "мл., к.м.н.", "initials": "А. К. С. М. ф. Б. —. п.", "capitalized_force": "д-р Ада Корнелия Сезар Мартин Фон Брюль — Проф. Мл., К.М.Н.", "generation": "мл.", "credentials": "к.м.н."} {"name": "уулу Төрөкул Махмудов, Мырза Чыңгыз Айтматов Исхак Раззаков Парламент мүчөсү", "given": "Мырза", "middle": "Чыңгыз Айтматов Исхак Раззаков Парламент мүчөсү", "family": "уулу Төрөкул Махмудов", "initials": "М. Ч. А. И. Р. П. м. у. Т. М.", "capitalized_force": "Мырза Чыңгыз Айтматов Исхак Раззаков Парламент Мүчөсү Уулу Төрөкул Махмудов"} {"name": "уулу Төрөкул Чыңгыз Айтматов Исхак Раззаков Парламент мүчөсү", "order": "FAMILY_FIRST", "given": "Төрөкул", "middle": "Чыңгыз Айтматов Исхак Раззаков Парламент мүчөсү", "family": "уулу", "initials": "Т. Ч. А. И. Р. П. м. у.", "capitalized_force": "Уулу Төрөкул Чыңгыз Айтматов Исхак Раззаков Парламент Мүчөсү"} -{"name": "фон Бруль Ада Карнэлія Сесар Марцін д-р", "order": "FAMILY_FIRST", "given": "Бруль", "middle": "Ада Карнэлія Сесар Марцін д-р", "family": "фон", "initials": "Б. А. К. С. М. д. ф.", "capitalized_force": "Фон Бруль Ада Карнэлія Сесар Марцін Д-Р"} +{"name": "фон Бруль Ада Карнэлія Сесар Марцін д-р", "order": "FAMILY_FIRST", "given": "Бруль", "middle": "Ада Карнэлія Сесар Марцін", "family": "фон", "suffix": "д-р", "initials": "Б. А. К. С. М. ф.", "capitalized_force": "Фон Бруль Ада Карнэлія Сесар Марцін д-р"} {"name": "фон Брюль Ада Корнелия", "order": "FAMILY_FIRST", "given": "Брюль", "middle": "Ада Корнелия", "family": "фон", "initials": "Б. А. К. ф.", "capitalized_force": "Фон Брюль Ада Корнелия"} {"name": "фон Брюль Ада Корнелия Сезар Мартин, к. м. н.", "order": "FAMILY_FIRST", "given": "к.", "middle": "м. н.", "family": "фон Брюль Ада Корнелия Сезар Мартин", "initials": "к. м. н. ф. Б. А. К. С. М.", "capitalized_force": "К. М. Н. Фон Брюль Ада Корнелия Сезар Мартин"} -{"name": "фон Брюль проф., д-р Ада Корнелия Сезар Мартин к.м.н.", "order": "FAMILY_FIRST", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин", "family": "фон Брюль проф.", "suffix": "к.м.н.", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as middle (position)"], "initials": "А. К. С. М. ф. Б. п.", "capitalized_force": "Д-Р Ада Корнелия Сезар Мартин Фон Брюль Проф. К.М.Н."} -{"name": "фон Брюль проф., д-р Ада Корнелия Сезар Мартин кесе, м. ф. д.", "order": "FAMILY_FIRST", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин кесе", "family": "фон Брюль проф.", "suffix": "м. ф. д.", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. С. М. к. ф. Б. п.", "capitalized_force": "Д-Р Ада Корнелия Сезар Мартин Кесе Фон Брюль Проф. М. Ф. Д."} -{"name": "фон Вольф Гонзалес Домінго Анастасія Єва Софія, д-р, проф.", "title": "д-р проф.", "given": "фон", "middle": "Вольф Гонзалес Домінго Анастасія Єва", "family": "Софія", "initials": "ф. В. Г. Д. А. Є. С.", "capitalized_force": "Д-Р, Проф. Фон Вольф Гонзалес Домінго Анастасія Єва Софія"} +{"name": "фон Брюль проф., д-р Ада Корнелия Сезар Мартин к.м.н.", "order": "FAMILY_FIRST", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин", "family": "фон Брюль проф.", "suffix": "к.м.н.", "ambiguities": ["SUFFIX_OR_NAME"], "alternatives": ["SUFFIX_OR_NAME: name as middle (position)"], "initials": "А. К. С. М. ф. Б. п.", "capitalized_force": "д-р Ада Корнелия Сезар Мартин Фон Брюль Проф. К.М.Н."} +{"name": "фон Брюль проф., д-р Ада Корнелия Сезар Мартин кесе, м. ф. д.", "order": "FAMILY_FIRST", "title": "д-р", "given": "Ада", "middle": "Корнелия Сезар Мартин кесе", "family": "фон Брюль проф.", "suffix": "м. ф. д.", "ambiguities": ["COMMA_STRUCTURE"], "initials": "А. К. С. М. к. ф. Б. п.", "capitalized_force": "д-р Ада Корнелия Сезар Мартин Кесе Фон Брюль Проф. М. Ф. Д."} +{"name": "фон Вольф Гонзалес Домінго Анастасія Єва Софія, д-р, проф.", "title": "проф.", "given": "фон", "middle": "Вольф Гонзалес Домінго Анастасія Єва", "family": "Софія", "suffix": "д-р", "initials": "ф. В. Г. Д. А. Є. С.", "capitalized_force": "Проф. Фон Вольф Гонзалес Домінго Анастасія Єва Софія, д-р"} {"name": "хосе и мария сантос", "given": "хосе и мария", "family": "сантос", "initials": "х. м. с.", "capitalized": "Хосе и Мария Сантос"} {"name": "Қайрат Болатұлы Тұрлыханов", "given": "Қайрат", "middle": "Болатұлы", "family": "Тұрлыханов", "initials": "Қ. Б. Т."} {"name": "Қасым Айдар", "order": "FAMILY_FIRST", "given": "Айдар", "family": "Қасым", "initials": "А. Қ."} From e01c00ebfdb722d6f59023b1a0e6f98b98332fa2 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 16:32:27 -0800 Subject: [PATCH 2/4] =?UTF-8?q?Read=20=D0=B4.=D0=BC.=20only=20under=20a=20?= =?UTF-8?q?Bulgarian=20choice,=20and=20address=20the=20reviews?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vocabulary review found that Дм., Дмитрий written short, folds to дм as the initials Д.М. do, so with bg.toml's readings on by default "Мережковский Дм." lost its family name under FAMILY_FIRST, locales.RU included. дм is written default = false: a Bulgarian choice reads the degree, the default and a Russian choice do not. The decisions entry records the cost and the re-taken CLDR figures, its recipe compares --since the base, and #1104's Standing line no longer lists д-р; the tests review's rows are added, with a render test for the mask. Co-Authored-By: Claude Opus 5.5 --- .../design/decisions/H5-trailing-title-run.md | 14 ++-- docs/release_log.rst | 2 +- nameparser/config/_compiled.py | 1 - nameparser/config/_index.py | 2 +- nameparser/vocab/bg.toml | 2 +- tests/v2/cases.py | 67 ++++++++++++++----- tests/v2/test_cases.py | 6 +- tests/v2/test_parser.py | 14 ++++ tests/v2/test_render.py | 17 +++++ 9 files changed, 96 insertions(+), 29 deletions(-) diff --git a/docs/design/decisions/H5-trailing-title-run.md b/docs/design/decisions/H5-trailing-title-run.md index eb1e2e0d5..7e30ef5a2 100644 --- a/docs/design/decisions/H5-trailing-title-run.md +++ b/docs/design/decisions/H5-trailing-title-run.md @@ -13,12 +13,12 @@ - Where that bound and the given part's own walk disagree behind a title, garbage shapes read off it, recorded and not fixed (`Smith, John Mc Prof. V, Jr.` → suffix 'Mc, Jr.', middle 'Prof. V'; the entry's `Smith, John Mc Prof. VI` has read title 'Prof.', suffix 'VI' since #784) — 2026-10-10 #623. - Under a family-first order too, a bare title ending the name is a name word and a title between the family and the given name is read by position, the title being written in front in real family-first names: `Wang Xiaoming Senator` → middle 'Senator', `Wang Dr. Xiaoming` → given 'Dr.' under FAMILY_FIRST; the period-marked trailing title still reads (`Wang Xiaoming Dr.` → title 'Dr.') — 2026-10-30 #938. - A title that may be a given name (rules/H9) is title vocabulary to the chain only where its title reading is written short (`abbreviation`, `maj` and `gen`): `SMITH, JOHN B. MAJ.` → title 'MAJ.', while `John Karimi Mahdi.` keeps family 'Mahdi.' — 2026-11-03 #999. -- A word ending in a period and written with a period or a hyphen inside it wears the chain's shape, so a listed title written that way chains (`Hans Meier Priv.-Doz.` → title 'Priv.-Doz.', family 'Meier'), and so does a word rules/S3 reads as a title by a chunk (`John Smith Dipl.Ing.`) — 2026-11-06 #1116. Without the final period, a title listed whole with a period inside it chains (`Maria Rossi Dott.ssa` → title 'Dott.ssa'), while a title only by a chunk and one a hyphen alone joins (`John Smith Co-Founder`, `д-р`) stay name words — 2026-11-06 #1104. A word every one of whose period chunks is a title chains without a final period too (`John Smith Lt.Gov` → title 'Lt.Gov'), while one a title only by some chunk does not (`John Smith Dr.PhD` → family 'Dr.PhD') — 2026-11-07 #1131. +- A word ending in a period and written with a period or a hyphen inside it wears the chain's shape, so a listed title written that way chains (`Hans Meier Priv.-Doz.` → title 'Priv.-Doz.', family 'Meier'), and so does a word rules/S3 reads as a title by a chunk (`John Smith Dipl.Ing.`) — 2026-11-06 #1116. Without the final period, a title listed whole with a period inside it chains (`Maria Rossi Dott.ssa` → title 'Dott.ssa'), while a title only by a chunk and one a hyphen alone joins (`John Smith Co-Founder`) stay name words — 2026-11-06 #1104. A word every one of whose period chunks is a title chains without a final period too (`John Smith Lt.Gov` → title 'Lt.Gov'), while one a title only by some chunk does not (`John Smith Dr.PhD` → family 'Dr.PhD') — 2026-11-07 #1131. +- The Cyrillic doctorate `д-р` is a title/suffix dual position decides, not a trailing title: a title in front (`д-р Іван Петренко`), a credential ending the name, after a comma and ending the given part (`Іван Петренко д-р`, `Іван Петренко, д-р`, `Петренко, Іван д-р` → suffix 'д-р'); the Bulgarian `д.м.` is a credential, listed as `дм`, only where a caller chooses Bulgarian — 2026-11-21 #1128. Elsewhere: a maiden clause in front of a trailing title is no join that hides it (`Mary Smith née Jones Prof.` → title 'Prof.'), decisions/M2's 2026-09-26 #535 entry; a bare ambiguous acronym ending the given part after a family comma is the credential, so `Doe, John Prof. MA` reads title 'Prof.', suffix 'MA', decisions/S5's 2026-09-18 #531 entry on the comma report's reach; the bound join after a family comma declines a title word this run takes (`Berg, abdul Prof.` → title 'Prof.'), decisions/P5's 2026-10-11 #637 entry; a part past the second comma makes no particle chain, so `John Smith, Jr., van der Berg Prof.` reads title 'Prof.', decisions/C7's 2026-10-11 #636 entry; a report names the field its word lands in, closing the `Dr. John of Prince` detail mismatch, decisions/A1's 2026-10-08 #626 entry; the cost of a period behind an ordinary surname that is title vocabulary (`Mary Jane Pope.` → title 'Pope.', family 'Jane') is the trailing-position bullet of decisions/vocabulary-exclusions. Open: none in this file. -- The Cyrillic doctorate `д-р` is a title/suffix dual position decides, not a trailing title: a title in front (`д-р Іван Петренко`), a credential ending the name, after a comma and ending the given part (`Іван Петренко д-р`, `Іван Петренко, д-р`, `Петренко, Іван д-р` → suffix 'д-р'); the Bulgarian `д.м.` is a credential listed as `дм` — 2026-11-21 #1128. ## Log @@ -72,7 +72,7 @@ Open: none in this file. - **2026-11-06 #1104 — A TITLE LISTED WHOLE WITH A PERIOD INSIDE IT CHAINS WITHOUT A FINAL ONE; A TITLE ONLY BY A CHUNK, AND ONE A HYPHEN ALONE JOINS, STILL NEED IT.** #1116 kept the final period, so `Maria Rossi Dott.ssa` read family 'Dott.ssa' though `dott.ssa` is listed whole, while `John Smith Msc.Ed` reads suffix 'Msc.Ed', the trailing suffix peel reading vocabulary alone. The period was required because a bare title word ending a name is often a surname (`Mary Jane Pope`), and a word with a period inside it is none: the period inside marks it as cut short as a final one would. The narrow half of the question #1104's 2026-11-06 comment set out, taken now: classify marks a title the vocabulary lists whole whose letters a period joins, a hyphen beside it or not (`JOINED_TITLE_TAG`, `_vocab._JOINED_WORD`), and the chain takes it without the shape test, as do `_weighed` and P13's trailing title. 16 listings carry it (2026-11-06; `from nameparser import Parser; from nameparser._pipeline import _vocab; L = Parser().lexicon._sets; [w for w in L.titles if '.' in w and _vocab._JOINED_WORD.match(w)]`, no locale pack adding one): the Italian abbreviated salutations and honorifics (`sig.ra`, `sig.na`, `dott.ssa`, `prof.ssa`, `gent.mo`, `gent.ma`, `gent.le`, `ill.mo`, `ill.ma`, `preg.mo`, `preg.ma`, `ch.mo`, `ch.ma`), `dipl.-ing`, `priv.-doz` and `univ.prof`. Each reads as `Prof.` does in the same name: 30 shapes × `Dott.ssa`, `Priv.-Doz`, `Sig.ra` × 3 orders, fields and reports, none apart. SUPERSEDES: the 2026-11-06 #1116 entry's required final period, for a title listed whole with a period inside it. - **Left: a title only by a chunk** (`John Smith Lt.Gov`, `Dr.PhD`, `St.John`) keeps the final period: that is the any-chunk reach #1104 asks about for brackets, one answer to serve both slots. (Answered by the 2026-11-07 #1131 entry: every chunk, so `Lt.Gov` chains and `Dr.PhD` and `St.John` keep it.) - - **Left: a title a hyphen alone joins** (`John Smith Co-Founder` → family). A hyphen joins whole words as often as abbreviations, and the one hyphenated abbreviation that ends a name in the corpora, Belarusian and Ukrainian `д-р`, is a CREDENTIAL there to CLDR (its `credentials` field; the same word is in its `title` field in front), so reading it as the title moved the family toward CLDR's and the title away from it: 9 changes against `cldr_agreement.json` in the first build, 3 title regressions among them, which this narrowing withdrew. + - **Left: a title a hyphen alone joins** (`John Smith Co-Founder` → family). (Answered for `д-р` by the 2026-11-21 #1128 entry: a title/suffix dual, the credential ending the name.) A hyphen joins whole words as often as abbreviations, and the one hyphenated abbreviation that ends a name in the corpora, Belarusian and Ukrainian `д-р`, is a CREDENTIAL there to CLDR (its `credentials` field; the same word is in its `title` field in front), so reading it as the title moved the family toward CLDR's and the title away from it: 9 changes against `cldr_agreement.json` in the first build, 3 title regressions among them, which this narrowing withdrew. - **Left: a dotted title that may be a given name** (a caller's `add("x.y", kind="title").add("x.y", kind="given")`, which compiles into `titles_ambiguous`, rules/H9): classify marks only a word of `titles`, so rules/H5's H9 precedence decides it as it decides any title that may be a given name: the chain takes it with a final period only where its title reading is written short (`abbreviation=True`, as `maj` is), and otherwise it is a name word with or without one (`John Smith X.y.` → family 'X.y.'); no shipped word is one (found by the code review, the decision bullet's first wording corrected by the second-round review). - **Pinned** by tests/v2/pipeline/test_pieces.py's test_a_listed_joined_title_reads_as_prof_does, one shape per reader of the mark (P13's connective, the maiden take, the particle run's weighed word), each of which passed the suite with its read removed until the code review's mutants found it. - **Measured** against `34812254` (2026-11-06, `tools/differential/measure.py --base`): the committed corpora move only rules/H5's own example (`Maria Rossi Dott.ssa`); CLDR, GND and Wikidata agreement match their records; no local corpus moves. A rare writing, then, settled for its consistency with the listing, which already read it as a title in front. In brackets only the academic five read as the title (`John Smith (Dott.ssa)`, `(Prof.ssa)`, `(Univ.Prof)`, `(Dipl.-Ing)`, `(Priv.-Doz)`); the salutations and styles read as a nickname there on both trees (`Maria Rossi (Sig.ra)` → nickname 'Sig.ra', as `(Mrs)` does), so for those eleven the bare and bracketed spellings disagree as title and nickname where they disagreed as family and nickname, found by the design-docs review and left to S1, with #1104. @@ -80,9 +80,9 @@ Open: none in this file. - 2026-11-09 #1171 — ONE TAG FOR THE CHAIN'S WORD TEST. Which words rules/H5's chain takes was spelled at three sites kept in step by comments -- `_pieces.trailing_titles` inline, `_pieces.is_trailing_title_word` (the maiden take, and P13's walk back since #1168 deleted the fourth copy, `_group._is_trailing_title`, which had drifted, decisions/P13) and `_pieces._weighed`. Classify now writes it once, as `CHAIN_TITLE_TAG`: a word carrying `JOINED_TITLE_TAG`, or one wearing `_vocab._TRAILING_TITLE_SHAPE` that carries "vocab:title" or `TRAILING_TITLE_TAG`; each site reads the tag. It is written after rules/H9's phrase test, which settles "vocab:title" (`Associate Dean.` carries it, `John Smith Dean.` does not), and against the text as written, so a glued delimiter (`Prof.;`) wears no shape, as before; assemble drops it. No reading moves: the suite and `snapshot.jsonl` hold byte-identical. Cost, measured against `1c5a220c` on py3.11 (2026-11-09): an ordinary name no longer pays the shape regex; every title word that wears the shape, or that carries the joined mark, pays one frame for its write, in any position, so the benchmark's reference row (`tools/perf/call_count.py`) goes 284.80 → 285.80 for its leading `Dr.` and a title run pays per word (`Dr. Prof. John Smith` 223 → 225); a name ending in a plain listed title saves the `is_title_piece` call the chain made, netting zero (`John Smith Prof.` 186 → 186) or one fewer where a second reader asked it (`John Smith y Prof.` 228 → 227), while one ending in a word with the written-short or joined mark, which made no such call, pays the frame (`John Smith Maj.` 198 → 199). Pinned by tests/v2/pipeline/test_classify.py's test_chain_title_tag_marks_the_words_h5s_chain_takes; with the tag's written-short arm removed, 23 tests fail. - 2026-11-21 #1128 — `Д-Р` ENDING A NAME IS A CREDENTIAL: A TITLE/SUFFIX DUAL, NOT A TRAILING TITLE. Decided 2026-11-21. `ru.toml`, `uk.toml` and `bg.toml` give `д-р` a credential reading beside its academic one, a deliberate dual as `sr` and `lt` are, so position decides: `Іван Петренко д-р` → family 'Петренко', suffix 'д-р' (master: middle 'Петренко', family 'д-р'); `Іван Петренко, д-р` and `Петренко, Іван д-р` → suffix; `д-р Іван Петренко` and `проф. д-р Іван Петренко` keep the title; `Іван Петренко, проф. д-р` → title 'проф.', suffix 'д-р'; `Іван д-р` → given 'Іван', suffix 'д-р', reported `given-or-family`, as `John Sr` and `John Lt` read. The period-marked `д-р.`, H5's shape until now, is the suffix too, the suffix sets being read before the chain. WHY NOT THE TRAILING TITLE. The 2026-11-06 #1116 entry's withdrawn build read a hyphen-joined listed title as the trailing title (option 2 of #1128), moving the family toward CLDR's and the title away from it: CLDR 48 writes the doctorate after the name in `credentials` in Belarusian and Ukrainian (`... фон Бруль д-р`, `..., д-р`) and Bulgarian (`, проф. д-р`), and in front in `title`. The dual puts it in the field CLDR states in both places. Option 3 (leave it) kept a family name of `д-р`. - MEASURED (on master efdf0e16 against the tree): `cldr_agreement.py` gains 9 field agreements and loses none, title 2,414 → 2,416, suffix 2,381 → 2,386, family_base 395 → 396, surname1_base 186 → 187 of 2,640 renderings, the figures the issue took on 2026-11-06 at 9cdc64bc; the Bulgarian `г-н Иван Асен Вернер, проф. д-р` now reads title 'г-н проф.', suffix 'д-р', where CLDR states both words as credentials, and under FAMILY_FIRST `фон Бруль Ада ...` reads family 'фон', a particle question apart. The committed snapshot moves 7 readings, all CLDR renderings of `д-р`, and 11 forced case views (below); GND, Wikidata native and the per-locale views match their records. `tools/name_usage.py д-р`: one record in every local corpus holds it, an ORCID name, and no Wikidata person. - THE ABBREVIATIONS. `д.м.` (доктор по медицина) is listed in `bg.toml` as `дм`: an acronym credential is matched with every full stop removed, as `M.D.` is `md`, so a `Lexicon.add("д.м.", kind="credential")` stores `д.м` and never matches, which is why the issue's probe moved nothing. Two single letters with stops are paired initials (rules/C5), which no shape reads as a credential, so the listing is the only route. With it the ORCID record's shape reads whole: `доц. д-р Мария Петрова, д.м.` → title 'доц. д-р', given 'Мария', family 'Петрова', suffix 'д.м.' (master: family 'доц. д-р Мария Петрова', given 'д.м.'), the comma a suffix comma and the title run peeled; with the dual alone it read family 'доц. Мария Петрова', suffix 'д-р'. `config_diff.py diff` adding `дм`, over every name in `orcid-researchers`, `opensanctions-parliaments` and `jrc-names` holding the letters (29,666), moved 1, that one. `к.м.н.` and `д.м.н.`, which the issue named and CLDR's cv and ru files write, need no entry: three dotted chunks are rules/S3's shape, read as the credential on master (`Пётр Сидоров, к.м.н.` → suffix). CLDR's Russian and Bashkir files space them (`к. м. н.`, `м. ф. д.`), which reads as initials as `John Smith, M. D.` does; reading spaced letters as one credential would be a new rule, and none was written. `к.ф.-м.н.` (a hyphen inside), which no source here writes, is left unlisted, as are the other degree abbreviations, for want of evidence. - ACCEPTED. A pair of initials spelling `Д.М.` reads as the credential where a listed credential's initials already do: ending a name (`Иванов Д.М.` under FAMILY_FIRST → given 'Иванов', suffix 'Д.М.', where master read family 'Иванов', given 'Д.', middle 'М.'), as `Ivanov M.D.` and `Wang M.A.` read there; behind one word and a comma, in capitals, it stays the given name (`Петрова, Д.М.`, rules/C16). No Cyrillic local corpus writes it. + MEASURED (on master efdf0e16 against the tree): `cldr_agreement.py` gains 9 field agreements and loses none, title 2,414 → 2,416, suffix 2,381 → 2,386, family_base 395 → 396, surname1_base 186 → 187 of 2,640 renderings, re-taken on efdf0e16 (the issue's, at 9cdc64bc on 2026-11-06, were title 2,410 → 2,412, suffix 2,380 → 2,385, family_base 396 → 397, surname1_base 186 → 187, the same 9); the Bulgarian `г-н Иван Асен Вернер, проф. д-р` now reads title 'г-н проф.', suffix 'д-р', where CLDR states both words as credentials, and under FAMILY_FIRST `фон Бруль Ада ...` reads family 'фон', a particle question apart. The committed snapshot moves 7 readings, all CLDR renderings of `д-р`, and 11 forced case views (below); GND, Wikidata native and the per-locale views match their records. `tools/name_usage.py д-р`: one record in every local corpus holds it, an ORCID name, and no Wikidata person. + THE ABBREVIATIONS. `д.м.` (доктор по медицина) is listed in `bg.toml` as `дм`, written `default = false`, so it is read where a caller chooses Bulgarian (`Locale(..., languages=frozenset({"bg"}))`) and not by default, nor under `locales.RU` or a Russian choice, strict or not: an acronym credential is matched with every full stop removed, as `M.D.` is `md`, so a `Lexicon.add("д.м.", kind="credential")` stores `д.м` and never matches, which is why the issue's probe moved nothing. Two single letters with stops are paired initials (rules/C5), which no shape reads as a credential, so the listing is the only route. Under a Bulgarian choice the ORCID record's shape reads whole: `доц. д-р Мария Петрова, д.м.` → title 'доц. д-р', given 'Мария', family 'Петрова', suffix 'д.м.' (master: family 'доц. д-р Мария Петрова', given 'д.м.'), the comma a suffix comma and the title run peeled; by default, with the dual alone, it reads family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', a cost accepted below. `config_diff.py diff` adding `дм`, over every name in `orcid-researchers`, `opensanctions-parliaments` and `jrc-names` holding the letters (29,666), moved 1, that one; but the review of the first build found the default reading wider than the corpora show: an acronym credential is matched with every full stop removed, so `Дм.`, Дмитрий written short in Russian bibliographies, folds to `дм` as well, and `Мережковский Дм.` under FAMILY_FIRST lost its family name (given 'Мережковский', suffix 'Дм.'), as did the paired initials `Иванов Д.М.` there, under `locales.RU` too, bg.toml's readings being on by default. One real name gained against the standard Russian forms of a common given name is why the reading is opt-in. `к.м.н.` and `д.м.н.`, which the issue named and CLDR's cv and ru files write, need no entry: three dotted chunks are rules/S3's shape, read as the credential on master (`Пётр Сидоров, к.м.н.` → suffix). CLDR's Russian and Bashkir files space them (`к. м. н.`, `м. ф. д.`), which reads as initials as `John Smith, M. D.` does; reading spaced letters as one credential would be a new rule, and none was written. `к.ф.-м.н.` (a hyphen inside), which no source here writes, is left unlisted, as are the other degree abbreviations, for want of evidence. + ACCEPTED. By default the dual alone takes `д-р` from the head before a family comma the unlisted `д.м.` makes, leaving `доц.` in the family (`доц. д-р Мария Петрова, д.м.` → family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', where master read family 'доц. д-р Мария Петрова'): both readings are wrong, and a Bulgarian choice reads it right. Under that choice, initials or a short form spelling `дм` read as the credential where a listed credential's initials already do (`Иванов Д.М.` → given 'Иванов', suffix 'Д.М.', as `Ivanov M.D.` reads), while behind one word and a comma, in capitals, initials stay the given name (`Петрова, Д.М.`, rules/C16). CASE. `д-р` carries a lowercase mask (`cased = "д-р"`), so forced and one-case repair write `д-р`, where master wrote `Д-Р` for the title and the acronym clause would write it so for the credential: 11 committed renderings move only that view. A mask cannot keep `д.м.` lowercase, rules/R4 writing a letter alone beside a full stop as an initial where its mask writes the letter in a run, so forced repair writes `Д.М.`, as it writes `M.D.`. NOT TOUCHED. `д-p` typed with a Latin `p` is no listed word and stays a name word (`Іван Петренко д-p` → family 'д-p'). - RECOMPUTE: `uv run python tools/differential/cldr_agreement.py` in a `git archive efdf0e16` export and in the tree; `uv run python tools/differential/snapshot.py` against the record; `config_diff.py diff default 'expr:Parser(lexicon=Lexicon.default().add("дм", kind="credential"))' --local --match '[ДдDd]\.?\s?[МмMm]'` for each corpus named, on the efdf0e16 tree. + RECOMPUTE: `uv run python tools/differential/cldr_agreement.py` in a `git archive efdf0e16` export and in the tree; `uv run python tools/differential/snapshot.py --since efdf0e16` in the tree; `config_diff.py diff default 'expr:Parser(lexicon=Lexicon.default().add("дм", kind="credential"))' --local --match '[ДдDd]\.?\s?[МмMm]'` for each corpus named, on the efdf0e16 tree. diff --git a/docs/release_log.rst b/docs/release_log.rst index 6bdcba902..1f3f3c4de 100644 --- a/docs/release_log.rst +++ b/docs/release_log.rst @@ -4,7 +4,7 @@ Release Log nameparser 3.2 is under development. - - **Read the Cyrillic doctorate д-р ending a name, and the Bulgarian д.м., as credentials.** ``parse("Іван Петренко д-р")`` gives family ``Петренко``, suffix ``д-р``, where 1.4.0 through 3.1.0 gave middle ``Петренко``, family ``д-р``; in front of the name ``д-р`` stays the title, and after a comma, where it read as the title, it is the suffix too (``Іван Петренко, д-р``). ``доц. д-р Мария Петрова, д.м.`` gives title ``доц. д-р``, family ``Петрова``, suffix ``д.м.``, where 1.4.0 through 3.1.0 gave given ``д.м.``; initials ``Д.М.`` ending a name read as the degree, as ``M.D.`` does. :issue:`1128` + - **Read the Cyrillic doctorate д-р ending a name as a credential, and the Bulgarian д.м. under a Bulgarian choice.** ``parse("Іван Петренко д-р")`` gives family ``Петренко``, suffix ``д-р``, where 1.4.0 through 3.1.0 gave middle ``Петренко``, family ``д-р``; in front of the name ``д-р`` stays the title, and after a comma it is the suffix too (``Іван Петренко, д-р``). With Bulgarian chosen (``languages=frozenset({"bg"})``), ``доц. д-р Мария Петрова, д.м.`` gives title ``доц. д-р``, family ``Петрова``, suffix ``д.м.``; by default it gives given ``д.м.``, family ``доц. Мария Петрова``, suffix ``д-р``, where 1.4.0 through 3.1.0 kept ``д-р`` in the family. :issue:`1128` - **Read an unlisted credential written in mixed case after a full name and a comma, such as MRes or AuD.** ``parse("Jane Smith, MRes")`` gives suffix ``MRes``, where 1.4.0 through 3.1.0 gave given ``MRes``, family ``Jane Smith``; the word must open with two capitals or end in one, so ``LeBron`` and ``PhDc`` stay given names, while a given name written so after a two-word surname reads as the credential (``García López, DAndre``). Behind one word it stays the given name (``Smith, MRes``), save behind initials spelling a credential, which read as the credential with it (``Smith, M.B. ChB``, and ``Jansen, J.P. IJsbrand``, which loses its given name). The positions only ``CapsSuffixes.EVERYWHERE`` reads still take words in capitals alone (``Alex Lee ONeill`` keeps family ``ONeill``). :issue:`1517` - **Add French dit and dite as connectives under a French choice.** With ``languages=frozenset({"fr"})`` chosen, ``Jean Dupont dit Lebrun`` gives family ``Dupont dit Lebrun``, where the default, as 1.4.0 through 3.1.0, gives middle ``Dupont dit``, family ``Lebrun``; a West African alias joins the given name the same way (``Mamadou dit Madou``), and the default is unchanged, ``Dit`` and ``Dite`` being names too. :issue:`1159` - **Add Brazilian Portuguese familiar forms, found in the names Brazil's election candidates put on the ballot.** With ``familiar-form`` accepted, ``Tião Alves`` / ``Sebastião Alves`` and ``Cida Silva`` / ``Aparecida Silva`` are consistent, where 3.1.0 read a conflict. They are filed under ``pt-BR``, so a strict choice of another language leaves them out, and one name spelled two ways (``Elizangela`` / ``Elisangela``) is not among them. :issue:`1495` diff --git a/nameparser/config/_compiled.py b/nameparser/config/_compiled.py index 3bee9f711..a047f2f9f 100644 --- a/nameparser/config/_compiled.py +++ b/nameparser/config/_compiled.py @@ -3836,7 +3836,6 @@ 'whnp', 'whnp-bc', 'д-р', - 'дм', }) CAPITALIZATION_EXCEPTIONS: dict[str, str] = { diff --git a/nameparser/config/_index.py b/nameparser/config/_index.py index 00a497956..8e643f131 100644 --- a/nameparser/config/_index.py +++ b/nameparser/config/_index.py @@ -3773,7 +3773,7 @@ ('г-н', (('bg', 'salutation', (('after_given', True),)), ('ru', 'salutation', (('after_given', True),)))), ('д-р', (('bg', 'academic', ()), ('bg', 'credential', (('cased', 'д-р'),)), ('ru', 'academic', ()), ('ru', 'credential', (('cased', 'д-р'),)), ('uk', 'academic', ()), ('uk', 'credential', (('cased', 'д-р'),)))), ('даша', (('ru', 'familiar', (('short_for', ('дарья',)),)),)), - ('дм', (('bg', 'credential', ()),)), + ('дм', (('bg', 'credential', (('default', False),)),)), ('женя', (('ru', 'familiar', (('short_for', ('евгений',)),)),)), ('жика', (('sr', 'familiar', (('short_for', ('живорад',)),)),)), ('и', (('bg', 'conjunction', ()), ('ru', 'conjunction', ()))), diff --git a/nameparser/vocab/bg.toml b/nameparser/vocab/bg.toml index dce443d32..13e8b6857 100644 --- a/nameparser/vocab/bg.toml +++ b/nameparser/vocab/bg.toml @@ -59,7 +59,7 @@ generation = { issue = 661 } [[word]] text = "дм" -credential = { expands = "доктор по медицина (doctor of medicine)", issue = 1128, note = "written д.м. after the name and a comma by the one ORCID record holding it (tools/name_usage.py, 2026-11-21); no name in any local corpus or Wikidata. Listed with its full stops removed, as m.d. is md: listed as д.м. it never matched. Two letters with stops are paired initials (rules/C5), which no shape reads as a credential, so only the listing does; behind one word ending a name it takes the trailing slot as md does (Иванов Д.М.), a shape no Cyrillic local corpus writes (config_diff.py, 2026-11-21: 1 of 29,666 names holding the letters moved, this one). к.м.н. and д.м.н. need no entry, rules/S3 reading three dotted chunks" } +credential = { default = false, expands = "доктор по медицина (doctor of medicine)", issue = 1128, note = "written д.м. after the name and a comma by the one ORCID record holding it (tools/name_usage.py, 2026-11-21); no name in any local corpus or Wikidata. Listed with its full stops removed, as m.d. is md: listed as д.м. it never matched. Two letters with stops are paired initials (rules/C5), which no shape reads as a credential, so only the listing does; behind one word ending a name it takes the trailing slot as md does (Иванов Д.М.), and Дм., Дмитрий written short, folds to дм too (Мережковский Дм. under FAMILY_FIRST), so it is read only under a Bulgarian choice (decisions/H5, 2026-11-21 #1128; config_diff.py, 2026-11-21: 1 of 29,666 local names holding the letters moved, this one). к.м.н. and д.м.н. need no entry, rules/S3 reading three dotted chunks" } [[word]] text = "и" diff --git a/tests/v2/cases.py b/tests/v2/cases.py index b91a946d1..81bcb19b8 100644 --- a/tests/v2/cases.py +++ b/tests/v2/cases.py @@ -7316,6 +7316,47 @@ def _check_cjk_shape_purity(self) -> None: "д-р Іван Петренко", {"title": "д-р", "given": "Іван", "family": "Петренко"}, classification="feat(#269)"), + Case("a_cyrillic_doctorate_with_a_period_ending_a_name", + "Іван Петренко д-р.", + {"given": "Іван", "family": "Петренко", "suffix": "д-р."}, + classification="fix(#1128)", + notes="the suffix sets are read before rules/H5's chain, which took it"), + Case("a_cyrillic_doctorate_in_capitals_ending_a_name", + "Іван Петренко Д-Р", + {"given": "Іван", "family": "Петренко", "suffix": "Д-Р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_after_one_word_and_a_comma", + "Петренко, д-р", + {"family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_after_an_empty_head", + ", д-р", + {"suffix": "д-р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_past_a_second_comma", + "Петренко, Іван, д-р", + {"given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_before_a_generation", + "Іван Петренко д-р мл.", + {"given": "Іван", "family": "Петренко", "suffix": "д-р мл."}, + classification="fix(#1128)"), + Case("a_cyrillic_doctorate_ending_a_family_first_name", + "Петренко Іван д-р", + {"given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)", + policy=Policy(name_order=FAMILY_FIRST)), + Case("a_cyrillic_doctorate_ending_a_family_first_given_last_name", + "Петренко Іван д-р", + {"given": "Іван", "family": "Петренко", "suffix": "д-р"}, + classification="fix(#1128)", + policy=Policy(name_order=FAMILY_FIRST_GIVEN_LAST)), + Case("a_cyrillic_doctorate_leaves_the_russian_patronymic_rule_its_name", + "Сидоров Иван Петрович д-р", + {"given": "Иван", "middle": "Петрович", "family": "Сидоров", "suffix": "д-р"}, + classification="fix(#1128)", + locale="ru", + notes="master read given 'Сидоров', family 'д-р'"), Case("a_professor_before_a_trailing_doctorate_stays_the_title", "Іван Петренко, проф. д-р", {"title": "проф.", "given": "Іван", "family": "Петренко", "suffix": "д-р"}, @@ -7326,30 +7367,26 @@ def _check_cjk_shape_purity(self) -> None: classification="fix(#1128)", ambiguities=("given-or-family",), notes="as 'John Sr' and 'John Lt' read, the other duals"), - Case("a_bulgarian_medical_degree_makes_the_comma_a_suffix_comma", + Case("a_doctorate_leaves_a_head_the_unlisted_degree_made_a_family", "доц. д-р Мария Петрова, д.м.", - {"title": "доц. д-р", "given": "Мария", "family": "Петрова", "suffix": "д.м."}, + {"given": "д.м.", "family": "доц. Мария Петрова", "suffix": "д-р"}, classification="fix(#1128)", - notes="the shape of the one ORCID record holding д-р: master read " - "family 'доц. д-р Мария Петрова', given 'д.м.'"), - Case("a_bulgarian_medical_degree_behind_one_word", - "Петрова, д.м.", - {"family": "Петрова", "suffix": "д.м."}, - classification="fix(#1128)"), + ambiguities=("suffix-or-name",), + notes="accepted (decisions/H5, 2026-11-21 #1128): the shape of the " + "one ORCID record holding д-р; master read family 'доц. " + "д-р Мария Петрова', and a Bulgarian choice reads it whole"), Case("cyrillic_initials_spelling_the_degree_behind_one_word", "Петрова, Д.М.", {"given": "Д.", "middle": "М.", "family": "Петрова"}, classification="fix(#1238)", ambiguities=("suffix-or-name",), notes="in capitals, initials behind one word whatever they spell (rules/C16)"), - Case("cyrillic_initials_spelling_the_degree_family_first", - "Иванов Д.М.", - {"given": "Иванов", "suffix": "Д.М."}, + Case("a_short_form_of_dmitry_keeps_the_family_first_family", + "Мережковский Дм.", + {"given": "Дм.", "family": "Мережковский"}, policy=Policy(name_order=FAMILY_FIRST), - classification="fix(#1128)", - ambiguities=("given-or-family",), - notes="accepted, as 'Ivanov M.D.' reads under FAMILY_FIRST " - "(decisions/H5, 2026-11-21 #1128)"), + notes="дм is read only under a Bulgarian choice, Дм. folding to it " + "(#1128's review)"), Case("a_russian_degree_in_dotted_chunks_reads_by_its_shape", "Пётр Сидоров, к.м.н.", {"given": "Пётр", "family": "Сидоров", "suffix": "к.м.н."}, diff --git a/tests/v2/test_cases.py b/tests/v2/test_cases.py index 02e847bba..c98985913 100644 --- a/tests/v2/test_cases.py +++ b/tests/v2/test_cases.py @@ -529,10 +529,10 @@ def test_the_field_sweep_sees_the_claims_it_checks() -> None: # -> 2296 on 2026-11-21, #1517's six caps-shape rows reporting # suffix-or-name under three orders; 2296 -> 2321 the same day, its # test review's eight rows under three orders and its family-first - # row under its declared policy; 2321 -> 2328 the same day, #1128's + # row under its declared policy; 2321 -> 2330 the same day, #1128's # reporting rows. - assert claims == 2328, ( - f"the field sweep checks {claims} claims, recorded as 2328 on " + assert claims == 2330, ( + f"the field sweep checks {claims} claims, recorded as 2330 on " f"2026-11-21") diff --git a/tests/v2/test_parser.py b/tests/v2/test_parser.py index 310112db2..cb5f5f907 100644 --- a/tests/v2/test_parser.py +++ b/tests/v2/test_parser.py @@ -2826,6 +2826,20 @@ def test_the_compiled_fields_are_the_default_lexicons() -> None: assert getattr(default._sets, name) == words, name +@pytest.mark.parametrize("strict", [False, True]) +def test_only_a_bulgarian_choice_reads_the_medical_degree(strict: bool) -> None: + # #1128: bg.toml lists д.м. as дм, written default = false, since + # Дм. (Дмитрий written short) and the initials Д.М. fold to it too + name = "доц. д-р Мария Петрова, д.м." + bg = parser_for(_choosing("bg"), strict=strict).parse(name) + assert (bg.title, bg.given, bg.family, bg.suffix) == ( + "доц. д-р", "Мария", "Петрова", "д.м.") + for parser in (Parser(), parser_for(_choosing("ru"), strict=strict), + parser_for(locales.RU)): + assert parser.parse(name).given == "д.м." + assert parser.parse("Петров Дм.").family == "Дм." + + def test_a_pack_choosing_no_language_leaves_the_vocabulary_as_it_is() -> None: base = Parser(lexicon=Lexicon.default().add("zzq", kind="title")) assert parser_for(Locale(code="xx", lexicon=Lexicon.empty()), diff --git a/tests/v2/test_render.py b/tests/v2/test_render.py index e73b6bd70..a1c61f654 100644 --- a/tests/v2/test_render.py +++ b/tests/v2/test_render.py @@ -2305,6 +2305,23 @@ def test_a_caps_credential_after_a_comma_keeps_its_capitals_in_every_setting( assert str(name.capitalized(force=True)) == rendered, (setting, text) +def test_the_cyrillic_doctorate_repairs_in_lower_case() -> None: + # #1128: д-р carries a lowercase mask, so repair writes it as it is + # written, as the title and as the credential; master wrote 'Д-Р'. + # д.м. carries none, rules/R4 writing a letter alone beside a full + # stop as an initial. + for text, rendered in ( + ("Д-Р ІВАН ПЕТРЕНКО", "д-р Іван Петренко"), + ("ІВАН ПЕТРЕНКО Д-Р", "Іван Петренко д-р")): + assert str(parse(text).capitalized()) == rendered, text + for text, rendered in ( + ("д-р Іван Петренко", "д-р Іван Петренко"), + ("Іван Петренко Д-Р", "Іван Петренко д-р")): + assert str(parse(text).capitalized(force=True)) == rendered, text + assert str(parse("Іван Петренко Д-Р").capitalized()) == ( + "Іван Петренко Д-Р") + + def test_a_mixed_case_credential_is_kept_as_written_when_forced() -> None: # rules/R4 (#1517): a word the caps shape read after a comma in mixed # case ('MRes', 'AuD') keeps its writing, forced or not: no mask From 3b1571bb9f658f8778a860373850c4eec43d10b2 Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 16:38:11 -0800 Subject: [PATCH 3/4] Record the local corpora's moves for #1128 Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/H5-trailing-title-run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/decisions/H5-trailing-title-run.md b/docs/design/decisions/H5-trailing-title-run.md index 7e30ef5a2..2a7b8ffc2 100644 --- a/docs/design/decisions/H5-trailing-title-run.md +++ b/docs/design/decisions/H5-trailing-title-run.md @@ -80,7 +80,7 @@ Open: none in this file. - 2026-11-09 #1171 — ONE TAG FOR THE CHAIN'S WORD TEST. Which words rules/H5's chain takes was spelled at three sites kept in step by comments -- `_pieces.trailing_titles` inline, `_pieces.is_trailing_title_word` (the maiden take, and P13's walk back since #1168 deleted the fourth copy, `_group._is_trailing_title`, which had drifted, decisions/P13) and `_pieces._weighed`. Classify now writes it once, as `CHAIN_TITLE_TAG`: a word carrying `JOINED_TITLE_TAG`, or one wearing `_vocab._TRAILING_TITLE_SHAPE` that carries "vocab:title" or `TRAILING_TITLE_TAG`; each site reads the tag. It is written after rules/H9's phrase test, which settles "vocab:title" (`Associate Dean.` carries it, `John Smith Dean.` does not), and against the text as written, so a glued delimiter (`Prof.;`) wears no shape, as before; assemble drops it. No reading moves: the suite and `snapshot.jsonl` hold byte-identical. Cost, measured against `1c5a220c` on py3.11 (2026-11-09): an ordinary name no longer pays the shape regex; every title word that wears the shape, or that carries the joined mark, pays one frame for its write, in any position, so the benchmark's reference row (`tools/perf/call_count.py`) goes 284.80 → 285.80 for its leading `Dr.` and a title run pays per word (`Dr. Prof. John Smith` 223 → 225); a name ending in a plain listed title saves the `is_title_piece` call the chain made, netting zero (`John Smith Prof.` 186 → 186) or one fewer where a second reader asked it (`John Smith y Prof.` 228 → 227), while one ending in a word with the written-short or joined mark, which made no such call, pays the frame (`John Smith Maj.` 198 → 199). Pinned by tests/v2/pipeline/test_classify.py's test_chain_title_tag_marks_the_words_h5s_chain_takes; with the tag's written-short arm removed, 23 tests fail. - 2026-11-21 #1128 — `Д-Р` ENDING A NAME IS A CREDENTIAL: A TITLE/SUFFIX DUAL, NOT A TRAILING TITLE. Decided 2026-11-21. `ru.toml`, `uk.toml` and `bg.toml` give `д-р` a credential reading beside its academic one, a deliberate dual as `sr` and `lt` are, so position decides: `Іван Петренко д-р` → family 'Петренко', suffix 'д-р' (master: middle 'Петренко', family 'д-р'); `Іван Петренко, д-р` and `Петренко, Іван д-р` → suffix; `д-р Іван Петренко` and `проф. д-р Іван Петренко` keep the title; `Іван Петренко, проф. д-р` → title 'проф.', suffix 'д-р'; `Іван д-р` → given 'Іван', suffix 'д-р', reported `given-or-family`, as `John Sr` and `John Lt` read. The period-marked `д-р.`, H5's shape until now, is the suffix too, the suffix sets being read before the chain. WHY NOT THE TRAILING TITLE. The 2026-11-06 #1116 entry's withdrawn build read a hyphen-joined listed title as the trailing title (option 2 of #1128), moving the family toward CLDR's and the title away from it: CLDR 48 writes the doctorate after the name in `credentials` in Belarusian and Ukrainian (`... фон Бруль д-р`, `..., д-р`) and Bulgarian (`, проф. д-р`), and in front in `title`. The dual puts it in the field CLDR states in both places. Option 3 (leave it) kept a family name of `д-р`. - MEASURED (on master efdf0e16 against the tree): `cldr_agreement.py` gains 9 field agreements and loses none, title 2,414 → 2,416, suffix 2,381 → 2,386, family_base 395 → 396, surname1_base 186 → 187 of 2,640 renderings, re-taken on efdf0e16 (the issue's, at 9cdc64bc on 2026-11-06, were title 2,410 → 2,412, suffix 2,380 → 2,385, family_base 396 → 397, surname1_base 186 → 187, the same 9); the Bulgarian `г-н Иван Асен Вернер, проф. д-р` now reads title 'г-н проф.', suffix 'д-р', where CLDR states both words as credentials, and under FAMILY_FIRST `фон Бруль Ада ...` reads family 'фон', a particle question apart. The committed snapshot moves 7 readings, all CLDR renderings of `д-р`, and 11 forced case views (below); GND, Wikidata native and the per-locale views match their records. `tools/name_usage.py д-р`: one record in every local corpus holds it, an ORCID name, and no Wikidata person. + MEASURED (on master efdf0e16 against the tree): `cldr_agreement.py` gains 9 field agreements and loses none, title 2,414 → 2,416, suffix 2,381 → 2,386, family_base 395 → 396, surname1_base 186 → 187 of 2,640 renderings, re-taken on efdf0e16 (the issue's, at 9cdc64bc on 2026-11-06, were title 2,410 → 2,412, suffix 2,380 → 2,385, family_base 396 → 397, surname1_base 186 → 187, the same 9); the Bulgarian `г-н Иван Асен Вернер, проф. д-р` now reads title 'г-н проф.', suffix 'д-р', where CLDR states both words as credentials, and under FAMILY_FIRST `фон Бруль Ада ...` reads family 'фон', a particle question apart. The committed snapshot moves 7 readings, all CLDR renderings of `д-р`, and 11 forced case views (below); GND, Wikidata native and the per-locale views match their records. `tools/name_usage.py д-р`: one record in every local corpus holds it, an ORCID name, and no Wikidata person. `snapshot.py --local --base ` on the final tree: `opensanctions-parliaments` and `jrc-names`, the corpora holding Cyrillic, match the base, and `orcid-researchers` moves that one name. THE ABBREVIATIONS. `д.м.` (доктор по медицина) is listed in `bg.toml` as `дм`, written `default = false`, so it is read where a caller chooses Bulgarian (`Locale(..., languages=frozenset({"bg"}))`) and not by default, nor under `locales.RU` or a Russian choice, strict or not: an acronym credential is matched with every full stop removed, as `M.D.` is `md`, so a `Lexicon.add("д.м.", kind="credential")` stores `д.м` and never matches, which is why the issue's probe moved nothing. Two single letters with stops are paired initials (rules/C5), which no shape reads as a credential, so the listing is the only route. Under a Bulgarian choice the ORCID record's shape reads whole: `доц. д-р Мария Петрова, д.м.` → title 'доц. д-р', given 'Мария', family 'Петрова', suffix 'д.м.' (master: family 'доц. д-р Мария Петрова', given 'д.м.'), the comma a suffix comma and the title run peeled; by default, with the dual alone, it reads family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', a cost accepted below. `config_diff.py diff` adding `дм`, over every name in `orcid-researchers`, `opensanctions-parliaments` and `jrc-names` holding the letters (29,666), moved 1, that one; but the review of the first build found the default reading wider than the corpora show: an acronym credential is matched with every full stop removed, so `Дм.`, Дмитрий written short in Russian bibliographies, folds to `дм` as well, and `Мережковский Дм.` under FAMILY_FIRST lost its family name (given 'Мережковский', suffix 'Дм.'), as did the paired initials `Иванов Д.М.` there, under `locales.RU` too, bg.toml's readings being on by default. One real name gained against the standard Russian forms of a common given name is why the reading is opt-in. `к.м.н.` and `д.м.н.`, which the issue named and CLDR's cv and ru files write, need no entry: three dotted chunks are rules/S3's shape, read as the credential on master (`Пётр Сидоров, к.м.н.` → suffix). CLDR's Russian and Bashkir files space them (`к. м. н.`, `м. ф. д.`), which reads as initials as `John Smith, M. D.` does; reading spaced letters as one credential would be a new rule, and none was written. `к.ф.-м.н.` (a hyphen inside), which no source here writes, is left unlisted, as are the other degree abbreviations, for want of evidence. ACCEPTED. By default the dual alone takes `д-р` from the head before a family comma the unlisted `д.м.` makes, leaving `доц.` in the family (`доц. д-р Мария Петрова, д.м.` → family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', where master read family 'доц. д-р Мария Петрова'): both readings are wrong, and a Bulgarian choice reads it right. Under that choice, initials or a short form spelling `дм` read as the credential where a listed credential's initials already do (`Иванов Д.М.` → given 'Иванов', suffix 'Д.М.', as `Ivanov M.D.` reads), while behind one word and a comma, in capitals, initials stay the given name (`Петрова, Д.М.`, rules/C16). CASE. `д-р` carries a lowercase mask (`cased = "д-р"`), so forced and one-case repair write `д-р`, where master wrote `Д-Р` for the title and the acronym clause would write it so for the credential: 11 committed renderings move only that view. A mask cannot keep `д.м.` lowercase, rules/R4 writing a letter alone beside a full stop as an initial where its mask writes the letter in a run, so forced repair writes `Д.М.`, as it writes `M.D.`. From 2e89222d27659007217ebebb4372461cc4a26ffa Mon Sep 17 00:00:00 2001 From: Derek Gulbranson Date: Sat, 21 Nov 2026 16:45:27 -0800 Subject: [PATCH 4/4] Say the dropped default cost reaches every order, and pin the Bulgarian readings Co-Authored-By: Claude Opus 5.5 --- docs/design/decisions/H5-trailing-title-run.md | 2 +- nameparser/vocab/bg.toml | 2 +- tests/v2/test_parser.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/design/decisions/H5-trailing-title-run.md b/docs/design/decisions/H5-trailing-title-run.md index 2a7b8ffc2..4514ea9b9 100644 --- a/docs/design/decisions/H5-trailing-title-run.md +++ b/docs/design/decisions/H5-trailing-title-run.md @@ -81,7 +81,7 @@ Open: none in this file. - 2026-11-21 #1128 — `Д-Р` ENDING A NAME IS A CREDENTIAL: A TITLE/SUFFIX DUAL, NOT A TRAILING TITLE. Decided 2026-11-21. `ru.toml`, `uk.toml` and `bg.toml` give `д-р` a credential reading beside its academic one, a deliberate dual as `sr` and `lt` are, so position decides: `Іван Петренко д-р` → family 'Петренко', suffix 'д-р' (master: middle 'Петренко', family 'д-р'); `Іван Петренко, д-р` and `Петренко, Іван д-р` → suffix; `д-р Іван Петренко` and `проф. д-р Іван Петренко` keep the title; `Іван Петренко, проф. д-р` → title 'проф.', suffix 'д-р'; `Іван д-р` → given 'Іван', suffix 'д-р', reported `given-or-family`, as `John Sr` and `John Lt` read. The period-marked `д-р.`, H5's shape until now, is the suffix too, the suffix sets being read before the chain. WHY NOT THE TRAILING TITLE. The 2026-11-06 #1116 entry's withdrawn build read a hyphen-joined listed title as the trailing title (option 2 of #1128), moving the family toward CLDR's and the title away from it: CLDR 48 writes the doctorate after the name in `credentials` in Belarusian and Ukrainian (`... фон Бруль д-р`, `..., д-р`) and Bulgarian (`, проф. д-р`), and in front in `title`. The dual puts it in the field CLDR states in both places. Option 3 (leave it) kept a family name of `д-р`. MEASURED (on master efdf0e16 against the tree): `cldr_agreement.py` gains 9 field agreements and loses none, title 2,414 → 2,416, suffix 2,381 → 2,386, family_base 395 → 396, surname1_base 186 → 187 of 2,640 renderings, re-taken on efdf0e16 (the issue's, at 9cdc64bc on 2026-11-06, were title 2,410 → 2,412, suffix 2,380 → 2,385, family_base 396 → 397, surname1_base 186 → 187, the same 9); the Bulgarian `г-н Иван Асен Вернер, проф. д-р` now reads title 'г-н проф.', suffix 'д-р', where CLDR states both words as credentials, and under FAMILY_FIRST `фон Бруль Ада ...` reads family 'фон', a particle question apart. The committed snapshot moves 7 readings, all CLDR renderings of `д-р`, and 11 forced case views (below); GND, Wikidata native and the per-locale views match their records. `tools/name_usage.py д-р`: one record in every local corpus holds it, an ORCID name, and no Wikidata person. `snapshot.py --local --base ` on the final tree: `opensanctions-parliaments` and `jrc-names`, the corpora holding Cyrillic, match the base, and `orcid-researchers` moves that one name. - THE ABBREVIATIONS. `д.м.` (доктор по медицина) is listed in `bg.toml` as `дм`, written `default = false`, so it is read where a caller chooses Bulgarian (`Locale(..., languages=frozenset({"bg"}))`) and not by default, nor under `locales.RU` or a Russian choice, strict or not: an acronym credential is matched with every full stop removed, as `M.D.` is `md`, so a `Lexicon.add("д.м.", kind="credential")` stores `д.м` and never matches, which is why the issue's probe moved nothing. Two single letters with stops are paired initials (rules/C5), which no shape reads as a credential, so the listing is the only route. Under a Bulgarian choice the ORCID record's shape reads whole: `доц. д-р Мария Петрова, д.м.` → title 'доц. д-р', given 'Мария', family 'Петрова', suffix 'д.м.' (master: family 'доц. д-р Мария Петрова', given 'д.м.'), the comma a suffix comma and the title run peeled; by default, with the dual alone, it reads family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', a cost accepted below. `config_diff.py diff` adding `дм`, over every name in `orcid-researchers`, `opensanctions-parliaments` and `jrc-names` holding the letters (29,666), moved 1, that one; but the review of the first build found the default reading wider than the corpora show: an acronym credential is matched with every full stop removed, so `Дм.`, Дмитрий written short in Russian bibliographies, folds to `дм` as well, and `Мережковский Дм.` under FAMILY_FIRST lost its family name (given 'Мережковский', suffix 'Дм.'), as did the paired initials `Иванов Д.М.` there, under `locales.RU` too, bg.toml's readings being on by default. One real name gained against the standard Russian forms of a common given name is why the reading is opt-in. `к.м.н.` and `д.м.н.`, which the issue named and CLDR's cv and ru files write, need no entry: three dotted chunks are rules/S3's shape, read as the credential on master (`Пётр Сидоров, к.м.н.` → suffix). CLDR's Russian and Bashkir files space them (`к. м. н.`, `м. ф. д.`), which reads as initials as `John Smith, M. D.` does; reading spaced letters as one credential would be a new rule, and none was written. `к.ф.-м.н.` (a hyphen inside), which no source here writes, is left unlisted, as are the other degree abbreviations, for want of evidence. + THE ABBREVIATIONS. `д.м.` (доктор по медицина) is listed in `bg.toml` as `дм`, written `default = false`, so it is read where a caller chooses Bulgarian (`Locale(..., languages=frozenset({"bg"}))`) and not by default, nor under `locales.RU` or a Russian choice, strict or not: an acronym credential is matched with every full stop removed, as `M.D.` is `md`, so a `Lexicon.add("д.м.", kind="credential")` stores `д.м` and never matches, which is why the issue's probe moved nothing. Two single letters with stops are paired initials (rules/C5), which no shape reads as a credential, so the listing is the only route. Under a Bulgarian choice the ORCID record's shape reads whole: `доц. д-р Мария Петрова, д.м.` → title 'доц. д-р', given 'Мария', family 'Петрова', suffix 'д.м.' (master: family 'доц. д-р Мария Петрова', given 'д.м.'), the comma a suffix comma and the title run peeled; by default, with the dual alone, it reads family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', a cost accepted below. `config_diff.py diff` adding `дм`, over every name in `orcid-researchers`, `opensanctions-parliaments` and `jrc-names` holding the letters (29,666), moved 1, that one; but the review of the first build found the default reading wider than the corpora show: an acronym credential is matched with every full stop removed, so `Дм.`, Дмитрий written short in Russian bibliographies, folds to `дм` as well, and a two-word `Surname Дм.` or `Surname Д.М.` lost its family name under every order (`Петров Дм.` → given 'Петров', suffix 'Дм.'; under FAMILY_FIRST `Мережковский Дм.` and `Иванов Д.М.`, which master read with the family), under `locales.RU` too, bg.toml's readings being on by default. One real name gained against the standard Russian forms of a common given name is why the reading is opt-in. `к.м.н.` and `д.м.н.`, which the issue named and CLDR's cv and ru files write, need no entry: three dotted chunks are rules/S3's shape, read as the credential on master (`Пётр Сидоров, к.м.н.` → suffix). CLDR's Russian and Bashkir files space them (`к. м. н.`, `м. ф. д.`), which reads as initials as `John Smith, M. D.` does; reading spaced letters as one credential would be a new rule, and none was written. `к.ф.-м.н.` (a hyphen inside), which no source here writes, is left unlisted, as are the other degree abbreviations, for want of evidence. ACCEPTED. By default the dual alone takes `д-р` from the head before a family comma the unlisted `д.м.` makes, leaving `доц.` in the family (`доц. д-р Мария Петрова, д.м.` → family 'доц. Мария Петрова', given 'д.м.', suffix 'д-р', where master read family 'доц. д-р Мария Петрова'): both readings are wrong, and a Bulgarian choice reads it right. Under that choice, initials or a short form spelling `дм` read as the credential where a listed credential's initials already do (`Иванов Д.М.` → given 'Иванов', suffix 'Д.М.', as `Ivanov M.D.` reads), while behind one word and a comma, in capitals, initials stay the given name (`Петрова, Д.М.`, rules/C16). CASE. `д-р` carries a lowercase mask (`cased = "д-р"`), so forced and one-case repair write `д-р`, where master wrote `Д-Р` for the title and the acronym clause would write it so for the credential: 11 committed renderings move only that view. A mask cannot keep `д.м.` lowercase, rules/R4 writing a letter alone beside a full stop as an initial where its mask writes the letter in a run, so forced repair writes `Д.М.`, as it writes `M.D.`. NOT TOUCHED. `д-p` typed with a Latin `p` is no listed word and stays a name word (`Іван Петренко д-p` → family 'д-p'). diff --git a/nameparser/vocab/bg.toml b/nameparser/vocab/bg.toml index 13e8b6857..d997a49f6 100644 --- a/nameparser/vocab/bg.toml +++ b/nameparser/vocab/bg.toml @@ -59,7 +59,7 @@ generation = { issue = 661 } [[word]] text = "дм" -credential = { default = false, expands = "доктор по медицина (doctor of medicine)", issue = 1128, note = "written д.м. after the name and a comma by the one ORCID record holding it (tools/name_usage.py, 2026-11-21); no name in any local corpus or Wikidata. Listed with its full stops removed, as m.d. is md: listed as д.м. it never matched. Two letters with stops are paired initials (rules/C5), which no shape reads as a credential, so only the listing does; behind one word ending a name it takes the trailing slot as md does (Иванов Д.М.), and Дм., Дмитрий written short, folds to дм too (Мережковский Дм. under FAMILY_FIRST), so it is read only under a Bulgarian choice (decisions/H5, 2026-11-21 #1128; config_diff.py, 2026-11-21: 1 of 29,666 local names holding the letters moved, this one). к.м.н. and д.м.н. need no entry, rules/S3 reading three dotted chunks" } +credential = { default = false, expands = "доктор по медицина (doctor of medicine)", issue = 1128, note = "written д.м. after the name and a comma by the one ORCID record holding it (tools/name_usage.py, 2026-11-21); no name in any local corpus or Wikidata. Listed with its full stops removed, as m.d. is md: listed as д.м. it never matched. Two letters with stops are paired initials (rules/C5), which no shape reads as a credential, so only the listing does; behind one word ending a name it takes the trailing slot as md does (Иванов Д.М.), and Дм., Дмитрий written short, folds to дм too (Петров Дм. loses its family under every order), so it is read only under a Bulgarian choice (decisions/H5, 2026-11-21 #1128; config_diff.py, 2026-11-21: 1 of 29,666 local names holding the letters moved, this one). к.м.н. and д.м.н. need no entry, rules/S3 reading three dotted chunks" } [[word]] text = "и" diff --git a/tests/v2/test_parser.py b/tests/v2/test_parser.py index cb5f5f907..ba01baef0 100644 --- a/tests/v2/test_parser.py +++ b/tests/v2/test_parser.py @@ -2834,10 +2834,23 @@ def test_only_a_bulgarian_choice_reads_the_medical_degree(strict: bool) -> None: bg = parser_for(_choosing("bg"), strict=strict).parse(name) assert (bg.title, bg.given, bg.family, bg.suffix) == ( "доц. д-р", "Мария", "Петрова", "д.м.") + # under the choice, the degree behind one word and initials ending a + # name read as md's do; in capitals behind one word and a comma, + # initials stay the given name (rules/C16) + one = parser_for(_choosing("bg"), strict=strict).parse("Петрова, д.м.") + assert (one.family, one.suffix) == ("Петрова", "д.м.") + pair = parser_for(_choosing("bg"), strict=strict).parse("Иванов Д.М.") + assert (pair.given, pair.suffix) == ("Иванов", "Д.М.") + assert parser_for(_choosing("bg"), strict=strict).parse( + "Петрова, Д.М.").given == "Д." for parser in (Parser(), parser_for(_choosing("ru"), strict=strict), + parser_for(_choosing("en"), strict=strict), parser_for(locales.RU)): assert parser.parse(name).given == "д.м." assert parser.parse("Петров Дм.").family == "Дм." + # the default family-first order keeps the initials, as master read + ff = Parser(policy=Policy(name_order=FAMILY_FIRST)).parse("Иванов Д.М.") + assert (ff.family, ff.given, ff.middle) == ("Иванов", "Д.", "М.") def test_a_pack_choosing_no_language_leaves_the_vocabulary_as_it_is() -> None: