Skip to content

Commit 64faab7

Browse files
committed
Document non_first_name_prefixes and log 1.3.0 entry (#121)
1 parent cc92d35 commit 64faab7

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

docs/customize.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,33 @@ You can also pass a custom set per ``Constants`` instance::
295295
>>> hn2.first, hn2.last
296296
('abu bakr', 'al saud')
297297

298+
Non-First-Name Prefixes
299+
-----------------------
300+
301+
``CONSTANTS.non_first_name_prefixes`` is the subset of prefixes that are *never*
302+
a standalone first name (``de``, ``dos``, ``ibn``, ...). When a name **starts**
303+
with one of these, there is no first name -- the whole thing is a surname.
304+
305+
Example::
306+
307+
>>> from nameparser import HumanName
308+
>>> hn = HumanName("de Mesnil")
309+
>>> hn.first, hn.last
310+
('', 'de Mesnil')
311+
312+
A member must be a prefix that is never a given name in any culture, and the set
313+
must stay **disjoint** from ``first_name_prefixes`` (a word cannot both join to
314+
the first name and never be a first name). Ambiguous particles that *can* be
315+
given names (``van``, ``von``, ``della``, ``di``, ``del``, ...) are intentionally
316+
excluded; add them yourself if your data warrants it::
317+
318+
>>> from nameparser.config import CONSTANTS
319+
>>> CONSTANTS.non_first_name_prefixes.add('von') # doctest: +SKIP
320+
321+
To **disable** the feature entirely::
322+
323+
>>> CONSTANTS.non_first_name_prefixes.clear() # doctest: +SKIP
324+
298325
Parser Customization Examples
299326
-----------------------------
300327

docs/release_log.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Release Log
77
to 1.2.1 first (which includes a one-version compatibility shim), load and
88
re-pickle under 1.2.1, then upgrade to 1.3.0.
99

10+
- Add ``non_first_name_prefixes`` to ``Constants``: a leading particle that is never a first name (e.g. ``"de Mesnil"``, ``"dos Santos"``) now parses as a surname with an empty first name, instead of treating the particle as the first name (closes #121)
1011
- Add a first-class ``maiden`` field and ``maiden_delimiters`` to ``Constants``, so a delimiter (e.g. parenthesis) can be routed to ``maiden`` instead of ``nickname`` for alternate/maiden surnames, e.g. ``"Baker (Johnson), Jenny"`` (closes #22)
1112
- Fix suffix-shaped parenthesized/quoted content (e.g. ``"(Ret)"``, ``"(MBA)"``) being misclassified as a nickname instead of a suffix (closes #111)
1213
- Add ``suffix_acronyms_ambiguous`` to ``Constants`` for acronym suffixes that also read as given-name nicknames (e.g. ``"JD"``, ``"Ed"``), used when disambiguating parenthesized/quoted content (#111)

0 commit comments

Comments
 (0)