Skip to content

feat: add patronymic_name_order for Russian formal name order (#85)#184

Merged
derek73 merged 12 commits into
masterfrom
feat/patronymic-name-order
Jun 30, 2026
Merged

feat: add patronymic_name_order for Russian formal name order (#85)#184
derek73 merged 12 commits into
masterfrom
feat/patronymic-name-order

Conversation

@derek73

@derek73 derek73 commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add opt-in patronymic_name_order flag to Constants that detects Russian formal-order names (Surname GivenName Patronymic) by anchoring on a trailing East-Slavic patronymic suffix and rotates to Western order (first=GivenName, middle=Patronymic, last=Surname)
  • Add patronymic (Latin) and patronymic_cyrillic regex patterns to REGEXES
  • Add is_patronymic() helper and handle_patronymic_name_order() to HumanName; wired into post_process() after handle_firstnames() and before handle_capitalization()
  • Feature is purely additive and opt-in — default patronymic_name_order = False leaves all existing parses byte-for-byte unchanged

Guards (reordering only fires when all hold)

  • No-comma input (comma = explicit field order, skip)
  • Exactly one token in each of first_list, middle_list, last_list
  • last token matches a patronymic suffix
  • middle token does NOT match a patronymic suffix (already Western order → skip)

Test Plan

  • uv run pytest — 942 passed, 22 xfailed, 0 failures
  • uv run mypy nameparser/ — no issues
  • uv run ruff check nameparser/ tests/ — all checks passed
  • tests/test_patronymic_order.py covers: 7 reorder cases (Latin, Cyrillic, hyphenated surname, title/suffix preserved), 8 guard cases (comma guard, 2-token, no patronymic, middle-is-patronymic, documented tradeoff), and flag-off baseline
  • Doctest in Constants.patronymic_name_order docstring runs live and passes

Closes #85

🤖 Generated with Claude Code

derek73 and others added 9 commits June 29, 2026 21:28
Add two precompiled regex patterns to detect Russian patronymic suffixes:
- patronymic: Detects Latin-character patronymic endings (ovich, ovna, evich, etc.)
- patronymic_cyrillic: Detects Cyrillic patronymic endings (ович, овна, евич, etc.)

Both patterns are end-anchored ($) to match complete patronymic suffixes,
supporting case-insensitive Latin matching and case-sensitive Cyrillic matching.

These patterns will be used by Tasks 2-3 to implement Russian formal name
order detection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add documentation for the new patronymic_name_order feature:
- Add bullet to "Other editable attributes" list in customize.rst
- Add new "Russian Formal Name Order" subsection with code example
- Add release log entry for the feature
- Fix pre-existing doctest output formatting in prefix example

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 derek73 merged commit 2a0c11b into master Jun 30, 2026
8 checks passed
@derek73 derek73 deleted the feat/patronymic-name-order branch June 30, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

last name + first name + optional patronymic, Russian name order

1 participant