Skip to content

Fix a lone numeral behind a particle before a family comma - #1086

Closed
Omair-Asdaq wants to merge 3 commits into
derek73:masterfrom
Omair-Asdaq:fix/1080-particle-numeral
Closed

Omair-Asdaq wants to merge 3 commits into
derek73:masterfrom
Omair-Asdaq:fix/1080-particle-numeral

Conversation

@Omair-Asdaq

@Omair-Asdaq Omair-Asdaq commented Nov 5, 2026 •

Copy link
Copy Markdown

Problem

rules/P9 says a lone letter behind a particle before a family comma reads as it does in the same part without the particle, so SMITH VD V, JOHN should read as SMITH V, JOHN does. Since 2.7.0 it does not:

>>> parse("SMITH V, JOHN").family
'SMITH V'
>>> parse("SMITH VD V, JOHN").family
'SMITH VD'
>>> parse("SMITH VD V, JOHN").suffix
'V'

The same holds for SMITH VAN V, JOHN and Smith van der V, John. It came from 1f0b07c (#886), which added the family-part numeral reading and handed _family_part_numeral the piece count k - lead: the particle counted as one of the name words rules/S10 requires in front of a one-letter numeral. 2.6.0 read family SMITH VD V, and no decisions entry (P9, S10, C3, P2) records or accepts the move. #1080 has the bisect and the table.

Change

nameparser/_pipeline/_assign.py: the family-part numeral is now given the count of the name words in front of it, leaving out particle pieces, instead of the piece count. One call site, and _family_part_numeral has one caller.

1 + sum(1 for j in range(lead + 1, k)
        if "particle" not in tokens[fam_pieces[j][0]].tags)

The same diff carries the documents and tests AGENTS.md asks for: the two deviates: #1080 markers are gone from P9's fenced examples (so they now assert the rule), a release-log bullet is added under 3.0.0's Behavior Changes, three case rows pin the vd, plain-particle and particle-run readings, and the differential snapshot records the two corpus names that move.

Test evidence

  • P9's two fenced examples fail on the pre-fix expression and pass here (tests/v2/test_rules_doc.py::test_example[P9-1] and [P9-2]: 2 failed on the baseline expression, 1954 passed).
  • The three new rows fail on the pre-fix expression (3 failed) and pass here. A mutant that leaves out only the words that are suffix vocabulary too (vd, mc) fails the plain-particle and run rows (2 failed), so the rows are not one-member duplicates.
  • Full suite, before and after merging current master (5138879b): the merged tree is 36 failed, 29578 passed, 7 skipped, 3 xfailed, 72 errors; master itself is 36 failed, 29546 passed, 8 skipped, 3 xfailed, 72 errors. The failing and erroring test names are identical in both directions. (The one extra master skip is a test that skips outside a git checkout, which the archive copy used for the baseline is.) Those failures are this machine's cp1252 fixture decoding, \-vs-/ anywhere the suite reads a path, and the network-only local-corpora tests, not the parser.
  • ruff check and mypy are clean.

Boundary shapes

Unchanged, executed before and after: SMITH VD, JOHN suffix VD; SMITH VD JR, JOHN suffix VD JR; SMITH VD MA, JOHN family SMITH VD MA; SMITH VD VI, JOHN suffix VI; SMITH V, JOHN family SMITH V; JOHN SMITH VD V, AD family JOHN SMITH VD, suffix V; DOE, JANE PHD VD MA suffix PHD VD MA; Smith vd v, John (lowercase letter in a mixed-case name) family Smith, suffix vd v; the comma-less path and the part after a comma are untouched. Re-recording the differential snapshot moves 2 of 6,938 corpus readings, both of them the two P9 examples.

Known limitations

  • The count leaves out every particle, which is what Why does "SMITH VD V, JOHN" lose the V from the family name when "SMITH V, JOHN" keeps it? #1080 asks for. That also moves a multi-particle surname before a one-letter numeral: van der Berg V, John now gives family van der Berg V where it gave family van der Berg, suffix V. P9's "as the same part without the particle" (Berg V, John gives family Berg V) and C3's one-word particle run both require it, but it is a real reading change for Dutch and Spanish names, so it is called out here rather than buried: no committed case row or corpus name covered that shape before.
  • Only the part before a family comma changes. The comma-less reading and the given part after a comma are out of scope.

Fixes #1080.

…ek73#1080)

The family part's numeral predicate was handed the piece count, so the
particle in "SMITH VD V, JOHN" was a word to spare and the lone V read
as a suffix. Count the name words in front of the numeral instead, as
the same part without the particle reads it.
The count drops every particle, not only the word that is suffix
vocabulary too, so record a plain particle and a run of two as well:
a mutant that subtracts one particle, or only the dual-vocabulary
word, would pass the VD row alone. Correct the predicate's docstring,
which still called the count a count of pieces.

Refs derek73#1080
@derek73

derek73 commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thank you for this. The analysis is right, the bisect to #886 matches what we found, and calling out van der Berg V, John in Known limitations was exactly the kind of note that helps.

This is fixed on master by #1091 (merged as 4109b02), which was in progress when this PR was opened, so I'm closing this one as a duplicate. The two fixes differ in two shapes, both found in review of #1091:

  • A particle chain joined to a name word. In Smith van der Berg V, John the joined piece van der Berg opens with a particle, so testing a piece's first token leaves it out of the count and reads family Smith van der Berg V. Count a family part's particles out of its numeral count (#1080) #1091 counts a piece unless it is wholly particles, so van der Berg counts as a name word, two stand in front, and V stays the suffix, as in Smith Jones V, John.
  • A particle opening the part. The 1 + always counts the first piece, so de Mesnil V, Jean still counts two words (de, Mesnil) and reads suffix V. Count a family part's particles out of its numeral count (#1080) #1091 leaves a leading particle out too, and reads family de Mesnil V, as 2.6.0 did.

#1091 also amends rules/S10 and rules/C1, since the count is S10's and C1's sentence about the comma-less reading needed an exception. decisions/P9 and decisions/S10 record the release history and the cost.

One more thing, about how to contribute here. CONTRIBUTING.md was updated today (#1092) and now opens with "Ask before you open a pull request": please open an issue, or comment on an existing one, and wait for agreement before starting work. Every issue is assigned to the maintainer and most are already in progress, as #1080 was, so an unrequested PR usually duplicates work. Changes here also move rules, design records and a snapshot of real names that aren't in the repository. Working with an AI agent is fine, and the guide asks you to say so in a Co-Authored-By: line. If you have an idea for something else, an issue is the best place to start.

@derek73 derek73 closed this Nov 5, 2026
@Omair-Asdaq

Copy link
Copy Markdown
Author

AH ok no problem i will keep that in mind from now on

@Omair-Asdaq
Omair-Asdaq deleted the fix/1080-particle-numeral branch November 6, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why does "SMITH VD V, JOHN" lose the V from the family name when "SMITH V, JOHN" keeps it?

2 participants