You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't extract suffix-shaped parenthesized/quoted content as nicknames (#189)
- `parse_nicknames()` used to extract everything inside parens/quotes as a nickname unconditionally, so suffix-like content such as `(Ret)`, `(Jr.)`, `(MBA)`, `(M.D)` was wrongly classified as a nickname instead of a suffix (closes#111).
- Added `SUFFIX_ACRONYMS_AMBIGUOUS` (`ed`, `jd`) as a small standalone exception list for acronym suffixes that also plausibly collide with a common given-name nickname, wired into `Constants` as a plain `SetManager` attribute. Existing `SUFFIX_ACRONYMS`/`suffix_acronyms` are otherwise unchanged (no API break).
- Moved `'(ret)'`/`'(vet)'` out of `SUFFIX_ACRONYMS` into `SUFFIX_NOT_ACRONYMS` as bare `'ret'`/`'vet'`.
- Rewrote `parse_nicknames()` to use a per-match callback: suffix-shaped or period-terminated content is left in place (undelimited) for normal downstream parsing instead of being routed to `nickname_list`. Correctly strips internal periods (e.g. `"M.D"`) before the acronym-suffix check, matching `is_suffix()`'s existing behavior. `JEFFREY (JD) BRICKEN` still parses `JD` as a nickname by default (regression guard).
- Fixed an unrelated, pre-existing bug: a missing comma between `'msc'` and `'mscmsm'` in `SUFFIX_ACRONYMS` caused Python's implicit string-literal concatenation to silently merge them into a bogus `'mscmscmsm'` entry.
- Updated `docs/usage.rst` and `docs/customize.rst` to document the new behavior and the `SUFFIX_ACRONYMS_AMBIGUOUS`/`suffix_acronyms_ambiguous` constant.
Known, documented limitation (not fixed, out of scope): `parse_full_name`'s no-comma suffix detection only recognizes a trailing run of suffix-shaped pieces, so a freed suffix-shaped word only lands in `suffix` when already in a trailing/comma position in the source string — this predates the PR and is unrelated to it.
Test plan: `pytest -q` — 980 passed, 4 skipped, 22 xfailed, no failures.
Copy file name to clipboardExpand all lines: docs/customize.rst
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,7 @@ Editable attributes of nameparser.config.CONSTANTS
43
43
* :py:data:`~nameparser.config.FIRST_NAME_TITLES` - Titles that, when followed by a single name, that name is a first name, e.g. "King David".
44
44
* :py:data:`~nameparser.config.SUFFIX_ACRONYMS` - Pieces that come at the end of the name that may or may not have periods separating the letters, e.g. "m.d.".
45
45
* :py:data:`~nameparser.config.SUFFIX_NOT_ACRONYMS` - Pieces that come at the end of the name that never have periods separating the letters, e.g. "Jr.".
46
+
* :py:data:`~nameparser.config.SUFFIX_ACRONYMS_AMBIGUOUS` - Acronym suffixes from ``SUFFIX_ACRONYMS`` that also plausibly work as a given-name nickname on their own, e.g. "JD", "Ed". When one of these appears alone in parenthesis or quotes (e.g. ``'JEFFREY (JD) BRICKEN'``), it's kept as a nickname rather than reclassified as a suffix, since that's the more common reading in ambiguous, delimiter-only context (see the "Nickname Handling" section in the usage guide).
46
47
* :py:data:`~nameparser.config.conjunctions.CONJUNCTIONS` - Connectors like "and" that join the preceding piece to the following piece.
47
48
* :py:data:`~nameparser.config.prefixes.PREFIXES` - Connectors like "del" and "bin" that join to the following piece but not the preceding, similar to titles but can appear anywhere in the name.
48
49
* :py:data:`~nameparser.config.CAPITALIZATION_EXCEPTIONS` - Dictionary of pieces that do not capitalize the first letter, e.g. "Ph.D".
Copy file name to clipboardExpand all lines: docs/release_log.rst
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@ Release Log
7
7
to 1.2.1 first (which includes a one-version compatibility shim), load and
8
8
re-pickle under 1.2.1, then upgrade to 1.3.0.
9
9
10
+
- Fix suffix-shaped parenthesized/quoted content (e.g. ``"(Ret)"``, ``"(MBA)"``) being misclassified as a nickname instead of a suffix (closes #111)
11
+
- 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)
12
+
- Fix missing comma between ``'msc'`` and ``'mscmsm'`` in ``suffix_acronyms``, which silently concatenated them into a bogus ``'mscmscmsm'`` entry (#111)
10
13
- Add ``given_names`` (and ``given_names_list``) attribute as aggregate of first and middle names, mirroring ``surnames`` (closes #157)
11
14
- Add ``suffix_delimiter`` to ``Constants`` and ``HumanName`` for parsing suffixes separated by arbitrary delimiters, e.g. ``"RN - CRNA"`` (#156)
12
15
- Add ``initials_separator`` to ``Constants`` and ``HumanName`` to control spacing between consecutive initials within a name group (#171)
0 commit comments