Fix missing bound-first-name join in suffix-comma branch#205
Merged
Conversation
parse_full_name() called _join_bound_first_name() in the no-comma and
lastname-comma branches but not in the suffix-comma branch, so
HumanName("Abdul Salam Hassan, MD") split the bound first name across
first/middle while the equivalent no-comma and lastname-comma forms of
the same name did not. Add the missing call and regression tests.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Reviewer follow-ups on PR #205: add regression tests for title and last-name-prefix interaction in the suffix-comma branch, mirroring existing coverage for the no-comma branch, and split a run-on sentence in AGENTS.md's parse-flow notes for readability. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parse_full_name()calls_join_bound_first_name()in the no-comma branch (reserve_last=True) and the lastname-comma branch (reserve_last=False), but was missing the call in the suffix-comma branch (theparts[0]path taken whenare_suffixes_after_commais true).HumanName("Abdul Salam Hassan, MD")split the bound first name intofirst='Abdul', middle='Salam', while the equivalent no-comma ("Abdul Salam Hassan MD") and lastname-comma ("Hassan, Abdul Salam, MD") forms correctly producedfirst='Abdul Salam'._join_bound_first_name(pieces, reserve_last=True)call at the suffix-comma call site, matching the no-comma branch's treatment of the same "title first middle last" token sequence.Why not centralize the join inside
parse_pieces()?Considered moving the join into
parse_pieces()itself, keyed offadditional_parts_count, so callers wouldn't each need to remember to call it. Rejected:parse_pieces()is called with the sameadditional_parts_countvalue both for the post-comma given-names portion (which should get the join) and for the lastname portion in the lastname-comma branch (which must never get it, since it's surname text, not first-name text). Since the same parameter value means different things depending on which slice of the name is being parsed, doing this centrally would need extra context to disambiguate — no simpler than the current explicit per-call-site design, and riskier to get right. Documented this reasoning inAGENTS.md.Changes
nameparser/parser.py: added the missing call in the suffix-comma branch.tests/test_bound_first_names.py: added regression tests for the suffix-comma form (basic join, join-with-middle, two-token no-join guard).AGENTS.md: updated the parse-flow notes to describe all three call sites and why the join isn't centralized.Test plan
python -m pytest tests/test_bound_first_names.py -v— all pass, including new suffix-comma testspython -m pytest -q— full suite passes (1238 passed, 4 skipped, 22 xfailed), no regressions"Abdul Salam Hassan, MD","Abdul Salam Hassan MD","Hassan, Abdul Salam, MD"→first='Abdul Salam'🤖 Generated with Claude Code