Skip to content

Read two capitals alone in a comma part as a credential before a later listed credential (Jane Mary Doe, MH, PhD) - #1407

Merged
derek73 merged 10 commits into
masterfrom
fix/issue-1392-two-capitals-before-later-credential
Nov 16, 2026
Merged

derek73 merged 10 commits into
masterfrom
fix/issue-1392-two-capitals-before-later-credential

Conversation

@derek73

@derek73 derek73 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Closes #1392

What changes

Two capitals alone in a comma part, behind a full name, are read as a credential where a later comma part is a listed credential, dotted or not. Before, the comma decision read the part after the first comma alone (rules/C1), and #1323's clause looked for the credential inside the pair's own part.

Input 1.4.0 through 3.0.1, and master this PR
Jane Mary Doe, MH, PhD given 'MH', family 'Jane Mary Doe', suffix 'PhD' given 'Jane', middle 'Mary', family 'Doe', suffix 'MH, PhD'
Jane Mary Doe, M.H., PhD given 'M.H.', family 'Jane Mary Doe' (master: given 'M.', middle 'H.') given 'Jane', middle 'Mary', family 'Doe', suffix 'M.H., PhD'
Jane Doe, BM, BCh, PhD given 'BM', family 'Jane Doe' suffix 'BM, BCh, PhD' (any later part answers)
Smith, JO, MD, Doe, M.H., PhD given 'JO' / 'M.H.' unchanged: one name word before the comma
Jane Doe, MH, Jane Doe, MH, Jr. given 'MH' unchanged: no later listed credential
Jane Doe, MH Jr., PhD, Jane Doe, M.H. PhD given 'MH' / 'M.H.' unchanged: not alone in its part
JANE DOE, MH, PHD given 'MH' unchanged: no case contrast (rules/C6)

The pair needs what #1323's needs (two name words, the case contrast), and each shape keeps its own switch: unlisted_caps_suffixes=OFF keeps the undotted pair a name and leaves the dotted one a credential; unlisted_dotted_suffixes=False the reverse; AFTER_COMMA and EVERYWHERE read both. A later part is a listed credential where every word is one the pair's own part would take as company and the vocabulary lists: no generation, particle, gated word, Title-case member, or word read by shape; a joined word is asked chunk by chunk and a delimiter standing alone is skipped. The flip reports suffix-or-name, as the three-capital flip does.

Measurements (2026-11-15; head = this branch, which merges master dfd9b77; the corpus moves re-taken against dfd9b77, whose nameparser/ is 92f4a55's)

Census, every local corpus and the committed ones (script below). The shape (a part of one or two unlisted two-letter words, another part wholly listed suffix words) is written by ClinicalTrials.gov officials 430 of 352,104 names, FEC 26 of 1,893,964, ORCID 22 of 1,871,547, and no other corpus. Read by hand, every name with the pair before a listed credential behind two or more words: two capitals 142 of 142 a credential, office or title, 0 initials; dotted pairs 19 of 19 a credential, 0 initials. Master misread 59 of the two-capital names and 20 of 21 dotted ones. Initials alone between a one-word surname and a listed credential (Smith, JO, MD) are written by no corpus.

Moves at the head, snapshot.py --local <corpus> --base <dfd9b777>:

corpus moved undotted dotted
ctgov-officials 62 53 9
orcid-researchers 9 1 8
fec-individuals, govuk-people, nepal-candidates, cz-candidates, psc-individuals, patentsview-inventors, dof-signatures, tse-donors, opensanctions-parliaments, jrc-names, tw-donors 0
committed snapshot 0 moved; gains the rule examples added here

All 71 read one by one: 69 to the whole name right, 2 better and still not right for another reason (a head written family first; a compound surname), none wrong.

  • local_agreement.py: psc, PatentsView and cz match the base; ORCID changes 4 records whose filed boxes hold the credentials themselves.
  • cldr_agreement.py: matches the record.
  • match_diff.py --base: 117 pairs move under each of the 22 settings, every one a pair holding a name this PR's own matching test adds (Ji Eun Lee, MH, PhD, Ji Eun Lee, M.H., PhD, the issue's example); no pair drawn from the corpora moves, the draw holding none of the shape. The key guarantee holds. The matching gain is pinned by test_two_capitals_before_a_later_credential_match_the_name_without_them: consistent with the name written without the pair and sharing its key, where master read a conflict and no shared key.
  • Frames (py3.11, _frames_for / _calls_per_parse, one fresh process per tree): reference row 285.80 → 285.80, Smith, John 136 → 136, Jane Mary Doe, MH 288 → 288; Jane Mary Doe, M.H. 388 → 388; a later part read and declined, Jane Mary Doe, MH, Jr. 343 → 348 and Jane Mary Doe, M.H., Jr. 434 → 439; Jane Mary Doe, MH, PhD 349 → 389; Jane Mary Doe, M.H., PhD 438 → 402.
  • Sweep, 103 names × 3 orders × 8 settings (script and names below): 38 names move, the 34 undotted under every order and setting but CapsSuffixes.OFF, the 4 dotted under every one but unlisted_dotted_suffixes=False.

Accepted costs (rules/C5 Accepted, each a case row)

  • García Márquez, MJ, PhD, García Márquez, M.J., PhD, Ortega y Gasset, MJ, PhD: a surname of two words reads as a full name, the cost Should Jane Doe, BM PhD read BM as a credential, not the given name? #1323 took for MJ PhD. No corpus holds one.
  • Ana Ruiz, JO, MD reads suffix 'JO, MD' (a given name in two capitals; one that is also a particle, AL, stays a name).
  • Ram Bahadur, BK, MD and Ram Bahadur, B.K., MD flip, under locales.NE too.
  • Jane Doe, MH, John, PhD reads suffix 'MH, John, PhD', flagged comma-structure before and after: an unwritten shape, and a guard would keep the 5 ctgov BM, BCh, PhD names wrong.
  • What "any later part" also gives, each a row: Jane Doe, MH, Mc, PhD, MH, de, PhD, MH, PhD, Smith, MH, Dr., PhD (title 'Dr.', suffix 'MH, PhD').
  • Left as it was: Bin Zhang, MH, PhD and Freiherr von Berg, MH, PhD (rules/C3 counts one name word); the dotted pair beside credentials in its own part (Jane Doe, M.H. PhD); the Title-case pair (Mh, Ph), not taken.

Decided the same day after being held open, each as it ships (rules/C5 Accepted, a case row each):

  • Jane Doe, MH, Md reads suffix 'MH, Md' (master: given 'MH', suffix 'Md'): a later part that is an unambiguous credential a given name written short also spells speaks for the pair in any case (Ma, a member of the ambiguous class, only in capitals), as in the pair's own part. No corpus holds a pair before a later part written Md, so a guard would cost and save no measured name.
  • Jane Doe, A.L., PhD reads suffix 'A.L., PhD' (master: given 'A.', middle 'L.'), where undotted AL stays a name (undotted MC, VD, DO are listed credentials and ST a title). A guard would leave 5 of the 17 dotted corpus names wrong (S.T. four times, D.A. once, all degrees read right) and save none known.
  • Jane Doe, VI, PhD reads suffix 'VI, PhD' and reports suffix-or-name (master: given 'VI'), where Jane Doe, II, PhD reads suffix unreported; that unevenness is accepted as it is. VI and IX fill the generation view as II does; XI lands in credentials. No corpus writes VI, IX or XI there, and a guard would return VI to the given name.

Limits and recorded gaps (decisions/C5)

  • A particle head keeps the given name under the default; it moves under any choice of languages that drops the head's particle reading: locales.VI (de la Vega, MH, PhD), CS/HR/SK/SL (st John, MH, PhD), and strict choices lacking the particle's file. The same-part twin read so on master already.
  • Fullwidth: Jane Doe, M.H., PhD is no pair on either tree; a later part MD does not speak one comma along.
  • Gaps of the shared per-word tests on both sides of the comma: a particle or Title-case dual as a chunk of a joined word (MD/Mc), a word joined by a full stop (MD.Jr), and a particle or generation with a delimiter glued (MH, Mc;, MH, Jr.;;). The last is new in the later part with this PR and has a row.

Declined (decisions/C5), measured as spikes on 92f4a55

wide rule: every part a credential where the last part is listed vocabulary only: bm nc mn sm rm ca dn cs mh
committed snapshot 3 (2 CLDR renderings wrong) 5 (2 break rules/C5 boundary examples)
ctgov-officials 991 (513 a given name; sample of 50: 48 right, 0 wrong) 277 (sample of 50: 26 right, 5 wrong)
orcid-researchers 29 199 (sample: 37 of 50 wrong)
fec-individuals 7, all wrong 78 (sample: 38 of 50 wrong)
tse-donors 0 64 (sample: 50 of 50 wrong)
cz / govuk / nepal 28 / 4 / 0 1 / 3 / 7 (7 wrong)
psc, patentsview, jrc, parliaments 0 3, 7, 3, 3
cldr_agreement 5 regressions matches

The wide rule shows the defect is wider than two capitals (ctgov: inner-capital AuD / DNSc 191, Title-case words 172); a follow-up issue is drafted, not filed.

Checks

  • At e346e68: uv run pytest on 3.11 and on 3.15 in its own environment: 49,766 passed each (the commit after it is docs and rows only, checked by the doc tests and the case table); -n0 -m serial: 38 passed; mypy, ruff, sphinx-build -E (-b doctest and -b html), python -m doctest README.rst and tools/vocab/build.py --check clean; tools/docs_scan.py reports nothing for policy.rst and only master's own three for migrate.rst.
  • Parity labels run against the 1.4.0, 2.8.2 and 3.0.1 wheels outside the tree.
  • Each clause of the new code mutated: every one fails a row, and the redundant clauses found that way were removed.

Reviews

First commit: pr-review-toolkit:code-reviewer, pr-review-toolkit:pr-test-analyzer and design-docs-reviewer, each given the diff and not its author's reading. They found the later part read more loosely than the pair's own part (a joined word asked whole, a particle counted, a spaced delimiter refusing a listed part, EVERYWHERE flipping a name with no contrast), a mutant surviving on "any later part", untested family-first readings, an unstated condition in the new rule bullet, frame figures taken with another counter and a census recipe too loose to re-run. The second commit fixes each and adds the dotted pair.

Second commit, reviewed in turn (pr-review-toolkit:code-reviewer for code and tests, design-docs-reviewer). Both reproduced the corpus moves, the frames and the wheel claims from the trees. They found: a later part's word read with a delimiter glued to it, so MH, MD/Jr.; flipped where MH, MD/Jr. did not (fixed, fourth commit, with the contrast now asked after the later part has answered); rules/C11, S3 and S9 and decisions/S9's Standing lines still stating the older limits, C11 calling the dotted flip silent when it is reported; the particle hold-back claimed for the dotted pair, which is read by shape whatever its letters spell (A.L.: prose corrected, behaviour kept, one of the nine dotted ctgov names being such a degree); the census recipe missing two details; and M. A. refused for the wrong stated reason (third commit, prose only). Extracting the shared predicate moved none of 100,485 same-part parses.

Recorded as open, not this PR's: a particle or a Title-case dual as a chunk of a joined word (MD/Mc) and a word joined by a full stop (MD.Jr) pass as credentials on both sides of the comma, on master too for the pair's own part; DO, a credential that is also a particle, speaks for no pair on either side. rules/C5 now carries a third signal and is recorded as a candidate for a split (decisions/C5, Open).

Coordinator review at 41970ce (two reviewers), then a third design-docs-reviewer round over the fix commits: three more Standing lines and two "Elsewhere" lines qualified (decisions/C1, C12, S9, C16, C6); what undotted capitals that spell a particle read as stated exactly (MC, VD, DO credentials, ST a title, the other 14 and both connectives a name); the entry now separates the decision from the implementation choices and lists the three open readings; an error of mine corrected (VI and IX do fill the generation view); counts corrected (IV 8, three of nine dotted ctgov pairs); rows added for every shape the entry names. The third round re-took the frames, the 71 corpus moves and the census (430 / 26 / 22) from the trees and they reproduce. Asking the contrast last moved none of 302,400 parses against 99699e7 beyond the glued-delimiter rows it was for.

Census script (reads each cached corpus.jsonl; fetches nothing)
"""Census for #1392: names '<head>, <part>, ...' where a part is 1-2 unlisted two-letter words
and another part is a listed credential. Reads corpora read-only."""
import json, re, sys, collections, random, os
from pathlib import Path
from nameparser import Lexicon
L = Lexicon.default()._sets
SUF = set(L.suffix_acronyms) | set(L.suffix_words) | set(L.suffix_acronyms_ambiguous) | set(L.suffix_words_ambiguous)
GEN = set(L.generation_words)
def norm(w): return w.lower().replace('.', '').strip(';')
def kind2(w):
    if norm(w) in SUF: return None
    if len(w) == 2 and w.isalpha():
        if w.isupper(): return 'caps'
        if w[0].isupper() and w[1].islower(): return 'mixed'
    if re.fullmatch(r'[^\W\d_]\.[^\W\d_]\.?', w) and w.replace('.', '').isupper(): return 'dotted'
    return None
def part_kind(p):
    ws = p.split()
    if not ws: return 'empty', None
    if all(norm(w) in SUF for w in ws):
        return ('gen' if all(norm(w) in GEN or re.fullmatch(r'[IVX]+', w.rstrip('.')) for w in ws) else 'cred'), None
    if len(ws) <= 2:
        ks = [kind2(w) for w in ws]
        if all(ks): return 'two', (ks[0] if len(set(ks)) == 1 else 'mix') + ('x2' if len(ws) == 2 else '')
    return 'other', None
def scan(names, label, out):
    cells = collections.Counter(); words = collections.Counter(); samples = collections.defaultdict(list)
    n = commas2 = 0
    for name in names:
        n += 1
        if name.count(',') < 2: continue
        commas2 += 1
        parts = [p.strip() for p in name.split(',')]
        if not parts[0]: head_n = 0
        else: head_n = len(parts[0].split())
        kinds = [part_kind(p) for p in parts[1:]]
        cred_idx = [i for i, (k, _) in enumerate(kinds) if k == 'cred']
        if not cred_idx: continue
        for i, (k, form) in enumerate(kinds):
            if k != 'two': continue
            pos = ('before' if i < cred_idx[0] else 'after' if i > cred_idx[-1] else 'between')
            hw = '0' if head_n == 0 else '1' if head_n == 1 else '2' if head_n == 2 else '3+'
            hl = [c for c in parts[0] if c.isalpha()]
            case = 'CAPS' if hl and all(c.isupper() for c in hl) else 'mixed'
            cell = (form, hw, pos, case)
            cells[cell] += 1
            for w in parts[1 + i].split(): words[(form.replace('x2',''), w if form.startswith('mixed') or form.startswith('caps') else w.upper())] += 1
            samples[cell].append((name, parts[1 + i]))
    out[label] = dict(n=n, commas2=commas2, cells=cells, words=words, samples=samples)
def lines(path):
    with open(path, encoding='utf-8') as f:
        for line in f:
            if not line.strip(): continue
            v = json.loads(line)
            yield v if isinstance(v, str) else v['name']
out = {}
cache = Path.home() / '.cache/nameparser-tools/local'
for d in sorted(cache.iterdir()):
    c = d / 'corpus.jsonl'
    if c.exists(): scan(lines(c), d.name, out)
comm = []
for p in sorted(Path('tools/differential').glob('corpus*.jsonl')): comm.extend(lines(p))
scan(comm, 'committed', out)
S = Path(sys.argv[1])
random.seed(1392)
with open(S / 'cells.tsv', 'w') as f, open(S / 'samples.txt', 'w') as g, open(S/'words.tsv','w') as h:
    f.write('corpus\tnames\t2+commas\tform\thead_words\tposition\thead_case\tcount\n')
    for lab, o in out.items():
        print(lab, o['n'], o['commas2'], sum(o['cells'].values()))
        if not o['cells']: f.write(f"{lab}\t{o['n']}\t{o['commas2']}\t-\t-\t-\t-\t0\n")
        for cell, cnt in sorted(o['cells'].items()):
            f.write(f"{lab}\t{o['n']}\t{o['commas2']}\t" + '\t'.join(cell) + f"\t{cnt}\n")
            ss = o['samples'][cell]; ss = random.sample(ss, min(30, len(ss)))
            g.write(f"## {lab} {cell} n={cnt}\n" + ''.join(f"  {w!r}\t{nm!r}\n" for nm, w in ss))
        for (form, w), cnt in o['words'].most_common():
            h.write(f"{lab}\t{form}\t{w}\t{cnt}\n")
Sweep script and its 103 names
"""Sweep for #1392: names x orders x switches; run inside a tree; writes JSON."""
import sys, json, unicodedata
import nameparser
from nameparser import (Parser, Policy, CapsSuffixes, GIVEN_FIRST, FAMILY_FIRST,
                        FAMILY_FIRST_GIVEN_LAST, parser_for, locales)
tree, out = sys.argv[1], sys.argv[2]
import os; assert os.path.realpath(nameparser.__file__).startswith(os.path.realpath(tree)), nameparser.__file__
NAMES = """Smith, JO, MD
Lee, MH, PhD
Ji Eun Lee, MH, PhD
de la Vega, JO, MD
van der Berg, Jan, MD
Ji Eun Lee, MH
Ji Eun Lee, MH, Jr.
Ji Eun Lee, Jr., MH, PhD
Dr. Ji Eun Lee, MH, PhD
LEE JI EUN, MH, PHD
ji eun lee, mh, phd
Ji Eun Lee, M.H., PhD
Ji Eun Lee, M.H, PhD
Ji Eun Lee, Mh, PhD
Ji Eun Lee, MH PhD
Ji Eun Lee, PhD, MH
Lee Ji Eun, MH, PhD
John Smith Jr., MH, PhD
John Smith III, MH, PhD
John Smith VI, MH, PhD
Ana Ruiz MD, MH, PhD
Freiherr von Berg, MH, PhD
St John, MH, PhD
St. de Mesnil, MH, PhD
Freiherr St van Berg, MH, PhD
Ana Ruiz, AL, MD
Ana Ruiz, ED, MD
Ana Ruiz, JO, MD
Ana Ruiz, MA, MD
Ana Ruiz, Jo, MD
Ji Eun Lee MH PhD
Ji Eun Lee MH, PhD
, MH, PhD
(Bob), MH, PhD
, Ma Dr., MH, PhD
García Márquez, MJ, PhD
García Márquez, M.J., PhD
García Márquez, MJ, Jr.
de Mesnil, MJ, PhD
Ortega y Gasset, MJ, PhD
Vega y Lopez Jr., MJ, PhD
Bin Zhang, MH, PhD
Ashley Knight, MH, PhD
de Waart, MH, PhD
JP Clancy, MH, MD
Md Rahman, MH, PhD
Sr. Ana Ruiz, MH, PhD
Rev. Sr. Ruiz, MH, PhD
Ana Ruiz, MH, PhD, Jr.
Ana Ruiz, MH,, PhD
Ana Ruiz,MH,PhD
Ana Ruiz , MH , PhD
Ana Ruiz, MH; PhD
Ana Ruiz, MH, Ma
Ana Ruiz, MH, MA
Ana Ruiz, MH, Ed
Ana Ruiz, MH, Prof.
Ana Ruiz, MH, Ms
Ana Ruiz, MH, MS
Ana Ruiz, MH, Jones
Ana Ruiz, MH, XYZ
Ana Ruiz, MH, X.Y.Z.
Ana Ruiz, MH, KC
Ana Ruiz, MH, Junior
Ana Ruiz, MH, V
Ana Ruiz, MH, MD/PhD
Ana Ruiz, MH, Ph. D.
Ana Ruiz, MH, PhD Jones
Ana Ruiz, MH, John, PhD
Ana Ruiz, MH RN, PhD
Ana Ruiz, MH JK, PhD
Ana Ruiz, MH JK
Ana Ruiz, Ms MH, PhD
Ana Ruiz, MH Jr., PhD
Ana Ruiz, John, PhD
Ruiz Soto, Ana, MD
Ruiz Soto, Ana María, MD
Ana Ruiz, Professor, MD
Ana Ruiz, V, MD
Ana Ruiz, MÁ, PhD
Ana Ruiz, BM, BCh
Ana Ruiz, BM, BCh, PhD
Ana Ruiz, Dr, MD
Ana Ruiz, Pr, MD
Ana Ruiz, XYZ, MD
Ana Ruiz, PU-PH, MD
Ana Ruiz, M-H, MD
Ana Ruiz, MH (Annie), PhD
Ana Ruiz (Annie), MH, PhD
Ana Ruiz, MH, PhD (Annie)
Ana Ruiz née Soto, MH, PhD
Ram Bahadur, BK, MD
Ram Bahadur, B.K., MD
Ram Bahadur B.K., MH, MD
Ram B K, MH, MD
Mamedov Ali, MH, PhD
Ana Ruiz, MH
Ruiz, MH
Ana Ruiz MH
, MH
Ana Ruiz, M.H.
Ana Ruiz, PhD MH""".split("\n")
NAMES += [unicodedata.normalize("NFD", "Ana Ruiz, MÁ, PhD")]
ORDERS = {"GF": GIVEN_FIRST, "FF": FAMILY_FIRST, "FFGL": FAMILY_FIRST_GIVEN_LAST}
def cfgs():
    for on, o in ORDERS.items():
        yield f"{on}", Parser(policy=Policy(name_order=o))
        yield f"{on}+strict-comma", Parser(policy=Policy(name_order=o, lenient_comma_suffixes=False))
        yield f"{on}+caps-off", Parser(policy=Policy(name_order=o, unlisted_caps_suffixes=CapsSuffixes.OFF))
        yield f"{on}+caps-everywhere", Parser(policy=Policy(name_order=o, unlisted_caps_suffixes=CapsSuffixes.EVERYWHERE))
        yield f"{on}+dotted-off", Parser(policy=Policy(name_order=o, unlisted_dotted_suffixes=False))
        yield f"{on}+capitals_as_family", Parser(policy=Policy(name_order=o, capitals_as_family=True))
        yield f"{on}+initials_as_family", Parser(policy=Policy(name_order=o, initials_as_family=True))
        yield f"{on}+NE", parser_for(locales.NE, base=Parser(policy=Policy(name_order=o)))
res = {}
for cn, p in cfgs():
    for n in NAMES:
        r = p.parse(n)
        d = {k: v for k, v in r.as_dict().items() if v}
        d["amb"] = [f"{a.kind.value}: {a.detail}" for a in r.ambiguities]
        res[f"{cn}\t{n}"] = d
json.dump(res, open(out, "w"), ensure_ascii=False, indent=0)
print(len(res))
Declined spike: the wide rule
diff --git a/nameparser/_pipeline/_comma.py b/nameparser/_pipeline/_comma.py
index a59525cc..2785e706 100644
--- a/nameparser/_pipeline/_comma.py
+++ b/nameparser/_pipeline/_comma.py
@@ -471,6 +471,33 @@ def _credentials_beside(state: ParseState, seg0: Sequence[int],
     return contrast[0]
 
 
+def _later_credential(state: ParseState) -> bool:
+    """SPIKE #1392: whether a part past the second comma is nothing but
+    listed credentials (no generation, a title/suffix dual only in
+    capitals, a member of the ambiguous class only where its capitals
+    settle it)."""
+    tokens = state.tokens
+    for seg in state.segments[2:]:
+        if not seg:
+            continue
+        for i in seg:
+            token = tokens[i]
+            tags = token.tags
+            if (GENERATION_WORD_TAG in tags
+                    or ROMAN.match(token.text.rstrip(".")) is not None):
+                break
+            if "vocab:suffix" in tags:
+                if "vocab:title" in tags and not token.text.isupper():
+                    break
+            elif not (AMBIGUOUS_ACRONYM_TAG in tags
+                      and SHAPE_ACRONYM_TAG not in tags
+                      and settled_by_case(token, state.one_case)):
+                break
+        else:
+            return True
+    return False
+
+
 def _run_read_as_initials(state: ParseState, i: int) -> ParseState:
     """The listing form, with the run of initials at `i` that made the
     part the given part (rules/C16, #1238) tagged an initial, as a run
@@ -630,6 +657,25 @@ def decide(state: ParseState, splits: bool | None = True) -> ParseState:
                 tokens[i] = copy_with(
                     tokens[i], tags=tags | {AMBIGUOUS_ACRONYM_TAG})
     p1, pt1 = _reading_pieces(part, tokens, splits is not False)
+    # SPIKE #1392 (A): two or more name words before the comma and the
+    # LAST part a listed credential: every part is the credential run
+    if len(state.segments) > 2 and seg0 and _later_credential(
+            copy_with(state, segments=state.segments[:2] + tuple(
+                s for s in state.segments[2:] if s)[-1:])):
+        if name_word_count([tokens[i].text for i in seg0], lex, pol,
+                           letters_one_case=state.one_case,
+                           members=set()) >= 2:
+            for k, piece in enumerate(p1):
+                role = (Role.TITLE if not is_suffix_piece(piece, pt1[k], tokens)
+                        and is_title_piece(piece, pt1[k], tokens)
+                        else Role.SUFFIX)
+                for i in piece:
+                    tokens[i] = copy_with(tokens[i], role=role)
+            return copy_with(state, tokens=tuple(tokens),
+                             segments=state.segments[:1] + ((),)
+                             + state.segments[2:],
+                             structure=Structure.SUFFIX_COMMA,
+                             dropped=tuple(state.dropped) + tuple(core_idx))
     anchored: list[int] = []
     absorbed: list[int] = []
     # A core in the part, standing alone or glued to a word or inside
Declined spike: vocabulary only
diff --git a/nameparser/vocab/mul.toml b/nameparser/vocab/mul.toml
index 80aac8fa..ab46f499 100644
--- a/nameparser/vocab/mul.toml
+++ b/nameparser/vocab/mul.toml
@@ -102,10 +102,26 @@ family = { us_census_2010 = 2146, wikidata = 68, as_of = 2026-11-03 }
 text = "v"
 generation = {}
 
+[[word]]
+text = "bm"
+credential = { note = "SPIKE 1392" }
+
 [[word]]
 text = "bsc"
 credential = { cased = "BSc", note = "written after names in every country's data (ClinicalTrials.gov, ORCID; decisions/vocabulary-model, 2026-11-02 #1005), so shared rather than copied into each language's file", issue = 1005 }
 
+[[word]]
+text = "ca"
+credential = { note = "SPIKE 1392" }
+
+[[word]]
+text = "cs"
+credential = { note = "SPIKE 1392" }
+
+[[word]]
+text = "dn"
+credential = { note = "SPIKE 1392" }
+
 [[word]]
 text = "ing"
 family = { us_census_2010 = 1814, wikidata = 13, as_of = 2026-10-23 }
@@ -123,6 +139,14 @@ text = "md"
 credential = { note = "the medical degree, written after names in every country's data (ClinicalTrials.gov officials, ORCID), so shared with its given reading here: a strict choice of a language other than English kept the given reading and dropped the credential, reading 'John Smith, MD' as given 'MD' (2026-11-14, #1383's review)", issue = 1383 }
 given = { us_ssa = 524, as_of = 2026-11-13, same_as = ["muhammad", "mohammad", "mohammed", "muhammed", "mohamed"], note = "Muhammad written short, in Bangladesh, Nepal and India: the first word of 13,734 ORCID given boxes in Bangladesh, where the long spellings written first are mohammad 1,787, muhammad 429, mohammed 272, muhammed 35, mohamed 6 and mohamad 1, the five it lists those above mohamad's 1 (the first word of each ORCID given box by the record's country, 2026-11-14 (decisions/vocabulary-model, 2026-11-14 #1383)); UK PSC filers write Md 1,358 times, Nepal's 2022 local candidates 318 (2026-11-13); US SSA male births. Its credential reading (the medical degree, above) stays unambiguous, a name written short marking no clash with it (#1383); written with its period at the head of a name (Md. Rahman), it read as a title by the leading-abbreviation shape until #1383" }
 
+[[word]]
+text = "mh"
+credential = { note = "SPIKE 1392" }
+
+[[word]]
+text = "mn"
+credential = { note = "SPIKE 1392" }
+
 [[word]]
 text = "mph"
 credential = { note = "written after names in every country's data (ClinicalTrials.gov, ORCID; decisions/vocabulary-model, 2026-11-02 #1005), so shared rather than copied into each language's file", issue = 1005 }
@@ -135,10 +159,22 @@ credential = { cased = "MSc", note = "written after names in every country's dat
 text = "mst"
 credential = { expands = "Master of Science in Teaching, and Oxford's Master of Studies (MSt)", note = "written after the name: NPPES 113 US healthcare providers (MST 101, M.S.T. 6), ClinicalTrials.gov officials after a comma (rauena Lopes, Mst; data 2026-10-21, counted 2026-11-06); no name reading, and a leading Mst stays the given name its filers type it as (bn.toml's exclusion); in mul.toml so a strict choice keeps it, as msc", issue = 1130 }
 
+[[word]]
+text = "nc"
+credential = { note = "SPIKE 1392" }
+
 [[word]]
 text = "phd"
 credential = { expands = "Doctor of Philosophy", cased = "PhD", note = "written after names in every country's data (ClinicalTrials.gov, ORCID; decisions/vocabulary-model, 2026-11-02 #1005), so shared rather than copied into each language's file", issue = 1005 }
 
+[[word]]
+text = "rm"
+credential = { note = "SPIKE 1392" }
+
+[[word]]
+text = "sm"
+credential = { note = "SPIKE 1392" }
+
 [[word]]
 text = "&"
 conjunction = {}

🤖 Generated with Claude Code

derek73 and others added 2 commits November 15, 2026 19:53
…r listed credential (Jane Mary Doe, MH, PhD)

`Jane Mary Doe, MH, PhD` read given 'MH', family 'Jane Mary Doe' from
1.4.0 through 3.0.1: the comma decision reads the part after the first
comma alone, and rules/C5's clause for two capitals before credentials
(#1323) looked for the credential inside the pair's own part. A pair
that is the whole part is now kept in the credential run where any
later comma part is nothing but listed credentials; the head still
needs two name words and the case contrast, and CapsSuffixes.OFF keeps
the given name.

Unchanged: a one-word head (`Smith, JO, MD`), a pair with no later
listed credential (`Jane Doe, MH, Jr.`), a pair with company in its own
part, and the dotted pair, which is left as an open question in
decisions/C5 with its census.

rules/C5 and C1, decisions/C5 (census, measurements, the two declined
alternatives) and C1, the sweep note in nameparser/AGENTS.md, the
release log, migrate.rst and policy.rst are amended with it.

Closes #1392

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ir's own part asks (Jane Mary Doe, M.H., PhD)

The dotted pair joins #1392's rule: two capitals with full stops, alone
in their comma part behind two or more name words carrying the case
contrast, are a credential where a later comma part is a listed
credential. `unlisted_dotted_suffixes=False` keeps the dotted pair a
name and `CapsSuffixes.OFF` the undotted one. Beside credentials in its
own part the dotted pair still keeps the given name.

Review of the first commit found the later part read more loosely than
the pair's own part. It now asks the same predicates: a joined word is
asked chunk by chunk (`MH, MD/Jr.` keeps the name), a particle that is
also an acronym is a name's word (`MH, Mc`), a delimiter standing alone
is no word of the part (`MH, MD - PhD` is a credential run), and the
case contrast is asked again, since CapsSuffixes.EVERYWHERE tags the
pair without it (`JANE DOE, MH, PhD` keeps the name).

Rows for each, for both family-first orders and for a credential that
is not the last part; rules/C5, C1 and C12, decisions/C5 and C1, the
sweep note in nameparser/AGENTS.md and the user docs follow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@derek73 derek73 added this to the 3.1 milestone Nov 16, 2026
@derek73 derek73 added bug suffixes Generational suffixes and credentials (rules/S) commas Commas and name structure (rules/C) labels Nov 16, 2026
@derek73 derek73 self-assigned this Nov 16, 2026
derek73 and others added 8 commits November 15, 2026 20:40
… not ask, where each rule says otherwise

Second review of #1392's fix commit, prose only (no reading moves):
rules/C11 called every flip with no listed member silent, and the
dotted pair's flip before a later credential is reported; rules/S3 and
S9 and decisions/S9's Standing lines restated the older limits; the
particle hold-back was claimed for the dotted pair, which is read by
its shape whatever its letters spell; the census recipe lacked two
details needed to recount it and now names PR #1407 for its script; two
single letters written apart are refused as no split credential, not as
ambiguous; and the joined-word gaps the shared predicate does not ask
are recorded as open on both sides of the comma.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…contrast after the later part has answered

Second code review of #1392's fix commit. The later part's words were
read with a delimiter glued to them, where the comma decision reads
the pair's own part without it, so `Jane Doe, MH, MD/Jr.;` flipped
where `MH, MD/Jr.` and `BM MD/Jr.;` did not; the later part reads the
stem now. The contrast is asked only once a later part has answered,
so a dotted pair no later part speaks for pays 5 frames, not 29. A row
for each, and for `DO`, a credential that is also a particle, which
speaks for no pair on either side of the comma.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…a particle spells read as, and separate what was decided from the choices made

Coordinator review of #1392's PR, prose and rows only (no reading
moves). decisions/C1, C12 and S9 each kept a Standing line stating a
limit the later credential now lifts; rules/C5 said undotted capitals
that spell a particle stay a name, which is false of the three the
vocabulary also lists as a credential (`MC`, `VD`, `DO`) and of `ST`,
a title; decisions/C5 now sets the decision apart from the
implementation choices, lists three readings as open rather than
accepted (`MH, Md`; a dotted pair spelling a particle; `VI, PhD`),
records the `locales.VI` particle-head limit and the fullwidth shapes
with a row each, names the other shapes "any later part" takes with
`MH, John, PhD`, accounts for the seventeenth dotted name, and marks
the rule a candidate for a split. The pointer in policy.rst now points
up, where its text is.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
tools/docs_scan.py, new on master, flagged each past its paragraph
length; policy.rst now reports none and migrate.rst only master's own.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…give each shape it names a row

Third review of the PR's fix commits, prose and rows only (no reading
moves). `VI` and `IX` before a later credential land in the generation
view as `II` does and differ only by the report; the particle-head
limit belongs to any choice of languages that drops the particle's
reading, not to `vi` alone; a particle with a delimiter glued to it
still speaks (`MH, Mc;`), a gap of the shared tests recorded with a
row; two counts are corrected (`IV` 8 times, three of the nine dotted
ctgov pairs spell a particle); decisions/C16 and C6 restated the older
limit; the `Md` row's note calls it open as the entry does; and
`MH, de, PhD`, `MH, PhD, Smith` and `MH, Dr., PhD` get the rows the
entry said they had. policy.rst's two sentences say which pairs and
which later parts they mean.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e rule's words

Docs and rows only, no reading moves. Decided 2026-11-15: a later part
that is a credential a given name written short also spells speaks for
the pair (`Jane Doe, MH, Md`); a dotted pair whose letters spell a
particle reads as a credential (`Jane Doe, A.L., PhD`), the undotted
letters staying a name; and two capitals that spell an unlisted numeral
read through the pair and are reported (`Jane Doe, VI, PhD`), the
report's unevenness with the listed `II` accepted as it is. rules/C5
carries an Accepted bullet for each, decisions/C5 quotes the same
sentences with the measured reason, and each has a case row.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…d sentences mean

Review of the accepted-costs commit: undotted letters that spell a
particle stay a name unless the vocabulary also lists them as a
credential or a title (MC, VD, DO, ST), and only an unambiguous
credential a given name written short spells (Md) speaks in any case;
Ma, a member of the ambiguous class, speaks only in capitals. The rule
and the entry agree word for word.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@derek73
derek73 merged commit 5e4f5fa into master Nov 16, 2026
14 checks passed
@derek73
derek73 deleted the fix/issue-1392-two-capitals-before-later-credential branch November 16, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug commas Commas and name structure (rules/C) suffixes Generational suffixes and credentials (rules/S)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two unlisted capitals between a name and a credential read as the given name (Ji Eun Lee, MH, PhD gives given 'MH', family 'Ji Eun Lee')

1 participant