Skip to content

Commit d6517ec

Browse files
committed
v0.3.2, Fix #19, single comma name format may have trailing suffix
1 parent 2db6bb3 commit d6517ec

4 files changed

Lines changed: 53 additions & 37 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# The short X.Y version.
5959
version = nameparser.__version__
6060
# The full version, including alpha/beta/rc tags.
61-
release = '0.3.1'
61+
release = '0.3.2'
6262

6363
# The language for content autogenerated by Sphinx. Refer to documentation
6464
# for a list of supported languages.

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, 1)
1+
VERSION = (0, 3, 2)
22
__version__ = '.'.join(map(str, VERSION))
33
__author__ = "Derek Gulbranson"
44
__author_email__ = 'derek73@gmail.com'

nameparser/parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ def parse_full_name(self):
413413
if not self.first:
414414
self.first_list.append(piece)
415415
continue
416+
if (i == len(pieces) - 2) and self.is_suffix(nxt):
417+
self.last_list.append(piece)
418+
self.suffix_list.insert(0,nxt)
419+
break
416420
if not nxt:
417421
self.last_list.append(piece)
418422
continue

tests.py

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -982,40 +982,6 @@ def test119(self):
982982
self.m(hn.first, "God", hn)
983983
self.m(hn.last, "Almighty", hn)
984984

985-
def test_last_name_is_also_title(self):
986-
hn = HumanName("Amy E Maid")
987-
self.m(hn.first, "Amy", hn)
988-
self.m(hn.middle, "E", hn)
989-
self.m(hn.last, "Maid", hn)
990-
991-
def test_last_name_is_also_title2(self):
992-
hn = HumanName("Duke Martin Luther King, Jr.")
993-
self.m(hn.title, "Duke", hn)
994-
self.m(hn.first, "Martin", hn)
995-
self.m(hn.middle, "Luther", hn)
996-
self.m(hn.last, "King", hn)
997-
self.m(hn.suffix, "Jr.", hn)
998-
999-
def test_last_name_is_also_title3(self):
1000-
hn = HumanName("John King")
1001-
self.m(hn.first, "John", hn)
1002-
self.m(hn.last, "King", hn)
1003-
1004-
def test_title_with_conjunction(self):
1005-
hn = HumanName("Secretary of State Hillary Clinton")
1006-
self.m(hn.title, "Secretary of State", hn)
1007-
self.m(hn.first, "Hillary", hn)
1008-
self.m(hn.last, "Clinton", hn)
1009-
1010-
def test_compound_title_with_conjunction(self):
1011-
hn = HumanName("Cardinal Secretary of State Hillary Clinton")
1012-
self.m(hn.title, "Cardinal Secretary of State", hn)
1013-
self.m(hn.first, "Hillary", hn)
1014-
self.m(hn.last, "Clinton", hn)
1015-
1016-
def test_title_is_title(self):
1017-
hn = HumanName("Coach")
1018-
self.m(hn.title, "Coach", hn)
1019985

1020986

1021987
class HumanNameConjunctionTestCase(HumanNameTestBase):
@@ -1299,7 +1265,53 @@ def test_parenthesis_are_removed2(self):
12991265

13001266

13011267
class HumanNameTitleTestCase(HumanNameTestBase):
1302-
1268+
def test_last_name_is_also_title(self):
1269+
hn = HumanName("Amy E Maid")
1270+
self.m(hn.first, "Amy", hn)
1271+
self.m(hn.middle, "E", hn)
1272+
self.m(hn.last, "Maid", hn)
1273+
1274+
def test_last_name_is_also_title2(self):
1275+
hn = HumanName("Duke Martin Luther King, Jr.")
1276+
self.m(hn.title, "Duke", hn)
1277+
self.m(hn.first, "Martin", hn)
1278+
self.m(hn.middle, "Luther", hn)
1279+
self.m(hn.last, "King", hn)
1280+
self.m(hn.suffix, "Jr.", hn)
1281+
1282+
def test_last_name_is_also_title3(self):
1283+
hn = HumanName("John King")
1284+
self.m(hn.first, "John", hn)
1285+
self.m(hn.last, "King", hn)
1286+
1287+
def test_title_with_conjunction(self):
1288+
hn = HumanName("Secretary of State Hillary Clinton")
1289+
self.m(hn.title, "Secretary of State", hn)
1290+
self.m(hn.first, "Hillary", hn)
1291+
self.m(hn.last, "Clinton", hn)
1292+
1293+
def test_compound_title_with_conjunction(self):
1294+
hn = HumanName("Cardinal Secretary of State Hillary Clinton")
1295+
self.m(hn.title, "Cardinal Secretary of State", hn)
1296+
self.m(hn.first, "Hillary", hn)
1297+
self.m(hn.last, "Clinton", hn)
1298+
1299+
def test_title_is_title(self):
1300+
hn = HumanName("Coach")
1301+
self.m(hn.title, "Coach", hn)
1302+
1303+
def test_suffix_with_single_comma_format(self):
1304+
hn = HumanName("John Doe jr., MD")
1305+
self.m(hn.first, "John", hn)
1306+
self.m(hn.last, "Doe", hn)
1307+
self.m(hn.suffix, "jr., MD", hn)
1308+
1309+
def test_suffix_with_double_comma_format(self):
1310+
hn = HumanName("Doe, John jr., MD")
1311+
self.m(hn.first, "John", hn)
1312+
self.m(hn.last, "Doe", hn)
1313+
self.m(hn.suffix, "jr., MD", hn)
1314+
13031315
# TODO: fix handling of U.S.
13041316
@unittest.expectedFailure
13051317
def test_chained_title_first_name_initial(self):

0 commit comments

Comments
 (0)