Skip to content

Commit 71d91a2

Browse files
committed
feat: infer leading period-abbreviations as titles in suffix-comma path (#109)
1 parent d4f7dcd commit 71d91a2

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

nameparser/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ def parse_full_name(self) -> None:
992992

993993
if not self.first \
994994
and (nxt or len(pieces) == 1) \
995-
and self.is_title(piece):
995+
and self.is_leading_title(piece):
996996
self.title_list.append(piece)
997997
continue
998998
if not self.first:

tests/test_titles.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,10 @@ def test_herr_title_with_first_name(self) -> None:
278278
self.m(hn.title, "Herr", hn)
279279
self.m(hn.first, "Klaus", hn)
280280
self.m(hn.last, "Schmidt", hn)
281+
282+
def test_leading_period_abbreviation_suffix_comma(self) -> None:
283+
hn = HumanName("Major. John Smith, Jr.")
284+
self.m(hn.title, "Major.", hn)
285+
self.m(hn.first, "John", hn)
286+
self.m(hn.last, "Smith", hn)
287+
self.m(hn.suffix, "Jr.", hn)

0 commit comments

Comments
 (0)