Skip to content

Commit fcd7652

Browse files
committed
fix #42 clash when potential first names are suffixes
1 parent 4b32019 commit fcd7652

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

docs/release_log.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Release Log
22
===========
3+
* 0.3.12 - October 17, 2015
4+
- Fix first name clash with suffixes (#42)
5+
- Fix encoding of constants added via the python shell
36
* 0.3.11 - October 17, 2015
47
- Fix bug capitalization exceptions (#39)
58
* 0.3.10 - September 19, 2015

nameparser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (0, 3, 11)
1+
VERSION = (0, 3, 12)
22
__version__ = '.'.join(map(str, VERSION))
33
__author__ = "Derek Gulbranson"
44
__author_email__ = '[email protected]'

nameparser/parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,14 @@ def parse_full_name(self):
439439

440440
self.middle_list.append(piece)
441441
else:
442-
if self.are_suffixes(parts[1].split(' ')):
442+
# if all the end parts are suffixes and there is more than one piece in
443+
# the first part. (Suffixes will never appear after last names only, and
444+
# allows potential first names to be in suffixes, e.g. "Johnson, Bart"
445+
if self.are_suffixes(parts[1].split(' ')) and len(parts[0].split(' ')) > 1:
443446

444447
# suffix comma: title first middle last [suffix], suffix [suffix] [, suffix]
445448
# parts[0], parts[1:...]
449+
446450

447451
self.suffix_list += parts[1:]
448452
pieces = self.parse_pieces(parts[0].split(' '))

tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,18 @@ def test_potential_suffix_that_is_also_last_name_comma(self):
14441444
self.m(hn.first, "Jack", hn)
14451445
self.m(hn.last, "Ma", hn)
14461446

1447+
def test_potential_suffix_that_is_also_first_name_comma(self):
1448+
hn = HumanName("Johnson, Bart")
1449+
self.m(hn.first, "Bart", hn)
1450+
self.m(hn.last, "Johnson", hn)
1451+
1452+
# TODO: handle conjunctions in last names followed by first names clashing with suffixes
1453+
@unittest.expectedFailure
1454+
def test_potential_suffix_that_is_also_first_name_comma_with_conjunction(self):
1455+
hn = HumanName("De la Vina, Bart")
1456+
self.m(hn.first, "Bart", hn)
1457+
self.m(hn.last, "De la Vina", hn)
1458+
14471459
def test_potential_suffix_that_is_also_last_name_with_suffix(self):
14481460
hn = HumanName("Jack Ma Jr")
14491461
self.m(hn.first, "Jack", hn)

0 commit comments

Comments
 (0)