Skip to content

Commit b4c672a

Browse files
committed
docs: document leading period-abbreviation title inference (#109)
1 parent 0015a93 commit b4c672a

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/release_log.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Release Log
3030
``CONSTANTS.first_name_prefixes.clear()``. **Default-on: changes parsing
3131
output for names with these prefixes.** (#150)
3232
- Add ``middle_name_as_last`` flag to ``Constants`` and ``HumanName`` for opt-in folding of middle names into the last name, for naming systems with no middle-name concept (e.g. Arabic patronymic chaining) (#133)
33+
- Treat an unrecognized, multi-letter token ending in a period at the start of a name (e.g. ``"Major."``) as a ``title`` instead of a ``first`` name; internal-period abbreviations (``"E.T."``) and single-letter initials (``"J."``) are unaffected. **Default-on: changes parsing of names with a leading unknown period-abbreviation** (closes #109)
3334
* 1.2.1 - June 19, 2026
3435
- Fix ``initials()`` interpolating the literal ``None`` for empty name parts when ``empty_attribute_default = None`` (e.g. ``"J. None D."``); empty parts now render as an empty string and a fully-empty result returns ``empty_attribute_default``
3536
- Add ``python -m nameparser "Name String"`` command-line helper that prints a parsed name

docs/usage.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,35 @@ reading in that ambiguous context:
188188
nickname: 'JD'
189189
]>
190190

191+
Leading Period-Abbreviation Titles
192+
-----------------------------------
193+
194+
An unrecognized, multi-letter word ending in a period, appearing before the
195+
first name, is treated as a title -- this covers military ranks and other
196+
abbreviations that aren't in the built-in titles list. Single-letter
197+
initials (``"J."``) and internal-period abbreviations (``"E.T."``) are not
198+
affected, and the same word appearing after the first name is left as a
199+
middle name.
200+
201+
.. doctest:: leading_period_titles
202+
:options: +NORMALIZE_WHITESPACE
203+
204+
>>> name = HumanName("Major. Dona Smith")
205+
>>> name
206+
<HumanName : [
207+
title: 'Major.'
208+
first: 'Dona'
209+
middle: ''
210+
last: 'Smith'
211+
suffix: ''
212+
nickname: ''
213+
]>
214+
>>> name = HumanName("J. Smith")
215+
>>> name.first
216+
'J.'
217+
>>> name.title
218+
''
219+
191220
Change the output string with string formatting
192221
-----------------------------------------------
193222

0 commit comments

Comments
 (0)