Skip to content

feat: add last_base / last_prefixes derived properties (#130, #132)#182

Merged
derek73 merged 9 commits into
masterfrom
feat/last-name-prefix-split
Jun 30, 2026
Merged

feat: add last_base / last_prefixes derived properties (#130, #132)#182
derek73 merged 9 commits into
masterfrom
feat/last-name-prefix-split

Conversation

@derek73

@derek73 derek73 commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add last_base / last_base_list — the last name with leading prefix particles stripped (e.g. "van Gogh""Gogh")
  • Add last_prefixes / last_prefixes_list — the leading prefix particle(s) (e.g. "van", "de la")
  • Add family and family_prefixes string aliases for the above
  • All six are derived read-only properties computed from last_list at access time; last and last_list are unchanged

Design

Uses a single _split_last() helper that consumes leading PREFIXES words. Includes an all-particles guard so surnames that collide with the prefix set (e.g. "Do") are never stripped. Purely additive — no changes to _members, parse flow, or existing attributes.

Test Plan

  • uv run pytest — 864 passed, 22 xfailed
  • uv run pytest --doctest-modules nameparser/parser.py — 9 passed
  • uv run mypy nameparser/ — clean
  • uv run ruff check nameparser/ tests/ — clean
  • Edge cases covered: van Gogh, de la Vega, von bergen wessels, John Smith (no prefix), Anh Do (surname == prefix word guard), all-particles guard, empty name, alias parity, title+prefix (Dra. da Silva)

Closes #130, #132

derek73 and others added 7 commits June 29, 2026 15:41
Adds _split_last(), last_base, last_prefixes, last_base_list,
last_prefixes_list, family, and family_prefixes to HumanName.
The guard prevents stripping when every last-name token is a prefix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add list-form assertions to test_von_bergen_wessels (multi-word base)
- Add test_case_insensitive_prefix_detection to pin is_prefix lowercasing
- Clarify _split_last docstring: document the all-particles guard invariant,
  add Anh Do doctest, soften inline comment to heuristic framing
- Add guard-behavior notes to last_base_list, last_prefixes_list, last_base,
  and last_prefixes docstrings so the non-obvious empty-prefix case is surfaced

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@derek73 derek73 self-assigned this Jun 30, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jun 30, 2026
derek73 and others added 2 commits June 29, 2026 19:14
Adds 'af', 'av', 'bar', 'bat', 'bint', 'den', 'ter', 'zu', and "'t"
sourced from https://en.wikipedia.org/wiki/List_of_family_name_affixes
(also referenced in PR #132). Excludes 'ben' due to ambiguity with the
common English given name; excludes single-letter particles and fused
prefixes (mc, fitz) as too ambiguous for general use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace 'ter' (now in PREFIXES) with 'op' as the custom-particle example;
also demonstrates chaining with the newly added 'den' prefix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@derek73 derek73 merged commit fbc1283 into master Jun 30, 2026
8 checks passed
@derek73 derek73 deleted the feat/last-name-prefix-split branch June 30, 2026 02:59
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.

Tussenvoegsels / family name prefixes

1 participant