Skip to content

Commit e83ee31

Browse files
committed
run the parsing of pieces for post-comma parts prior to checking if all post-comma elements are suffixes. this ensures that suffixes are properly captured in the constants prior to the all-suffix check
1 parent ce92f37 commit e83ee31

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nameparser/parser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ def parse_full_name(self):
528528
# in the first part. (Suffixes will never appear after last names
529529
# only, and allows potential first names to be in suffixes, e.g.
530530
# "Johnson, Bart"
531+
532+
post_comma_pieces = self.parse_pieces(parts[1].split(' '), 1)
533+
531534
if self.are_suffixes(parts[1].split(' ')) \
532535
and len(parts[0].split(' ')) > 1:
533536

@@ -566,9 +569,8 @@ def parse_full_name(self):
566569
# lastname comma:
567570
# last [suffix], title first middles[,] suffix [,suffix]
568571
# parts[0], parts[1], parts[2:...]
569-
pieces = self.parse_pieces(parts[1].split(' '), 1)
570572

571-
log.debug("pieces: %s", u(pieces))
573+
log.debug("post-comma pieces: %s", u(post_comma_pieces))
572574

573575
# lastname part may have suffixes in it
574576
lastname_pieces = self.parse_pieces(parts[0].split(' '), 1)
@@ -580,14 +582,14 @@ def parse_full_name(self):
580582
else:
581583
self.last_list.append(piece)
582584

583-
for i, piece in enumerate(pieces):
585+
for i, piece in enumerate(post_comma_pieces):
584586
try:
585-
nxt = pieces[i + 1]
587+
nxt = post_comma_pieces[i + 1]
586588
except IndexError:
587589
nxt = None
588590

589591
if self.is_title(piece) \
590-
and (nxt or len(pieces) == 1) \
592+
and (nxt or len(post_comma_pieces) == 1) \
591593
and not self.first:
592594
self.title_list.append(piece)
593595
continue

0 commit comments

Comments
 (0)