feat: add suffix_delimiter for parsing suffixes separated by arbitrary delimiters (#156)#172
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add the suffix_delimiter class attribute to the Constants class with a default value of None. This attribute will be used by HumanName to split suffix groups after comma-splitting. The attribute follows the existing pattern of scalar class attributes (string_format, initials_delimiter, initials_separator). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When parsing names with suffixes separated by a custom delimiter (e.g. "Steven Hardman, RN - CRNA" with suffix_delimiter=" - "), the parser now re-splits post-comma parts on the suffix_delimiter and flattens them before processing. This transforms ["Steven Hardman", "RN - CRNA"] into ["Steven Hardman", "RN", "CRNA"], making downstream suffix detection work correctly instead of treating the delimiter as an invalid suffix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…clarify known-limitation test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Filter empty tokens from trailing/leading delimiters to prevent silent parse corruption (e.g. "MD-PhD-" with suffix_delimiter="-") - Clarify no-op note in Constants docstring: both the comma split and subsequent strip() make ", " a no-op, not just the comma split - Correct param docstring: expansion applies to all post-comma parts, not just identified suffix groups - Tighten known-limitation test with concrete field assertions instead of a fragile assertNotEqual - Add tests: trailing delimiter, comma-space no-op, inverted-format limitation Co-Authored-By: Claude Sonnet 4.6 <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
suffix_delimitertoConstants(defaultNone) and as aHumanNamekwarg, following the same pattern asinitials_separatorparts[1:]onsuffix_delimiterand flattens — turning"RN - CRNA"into two separate suffix tokens with no changes to downstream parse logic"Steven Hardman, RN - CRNA"now parse correctly whensuffix_delimiter=" - "is setUsage
Test Plan
HumanName("Steven Hardman, RN - CRNA", suffix_delimiter=" - ")→first="Steven",last="Hardman",suffix="RN, CRNA""John Doe, MD - PhD - FACS"→suffix="MD, PhD, FACS"CONSTANTS.suffix_delimiterapplies globally to new instancesuv run pytest— 748 passed, 20 xfailedCloses #156
🤖 Generated with Claude Code