Skip to content

Commit a017a60

Browse files
committed
fix handling of prefixes with periods in them, fix #50
1 parent 95975f2 commit a017a60

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/release_log.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Release Log
22
===========
33
* 0.4.1 - July 25, 2016
44
- Remove "bishop" from titles because it also could be a first name
5+
- Fix handling of lastname prefixes with periods, e.g. "Jane St. John" (#50)
56
* 0.4.0 - June 2, 2016
67
- Remove "CONSTANTS.suffixes", replaced by "suffix_acronyms" and "suffix_not_acronyms" (#49)
78
- Add "du" to prefixes

nameparser/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ def is_conjunction(self, piece):
274274
return piece.lower() in self.C.conjunctions and not self.is_an_initial(piece)
275275

276276
def is_prefix(self, piece):
277-
"""Is in the prefixes set and not :py:func:`is_an_initial()`."""
278-
return piece.lower() in self.C.prefixes and not self.is_an_initial(piece)
277+
"""Lowercase and no periods version of piece is in the `~nameparser.config.titles.PREFIXES` set."""
278+
return lc(piece) in self.C.prefixes
279279

280280
def is_roman_numeral(self, value):
281281
"""

tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,11 @@ def test_prefix(self):
13781378
self.m(hn.first, "Juan", hn)
13791379
self.m(hn.last, "del Sur", hn)
13801380

1381+
def test_prefix_with_period(self):
1382+
hn = HumanName("Jill St. John")
1383+
self.m(hn.first, "Jill", hn)
1384+
self.m(hn.last, "St. John", hn)
1385+
13811386
def test_prefix_before_two_part_last_name(self):
13821387
hn = HumanName("pennie von bergen wessels")
13831388
self.m(hn.first, "pennie", hn)

0 commit comments

Comments
 (0)