Skip to content

Commit 794bbad

Browse files
committed
Refine the splitting of flat names into constituent parts. Fixes ietf-tools#769.
- Legacy-Id: 4065
1 parent e9864d7 commit 794bbad

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

ietf/person/name.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@ def name_parts(name):
1010
name = name_with_paren_match.group(1)
1111

1212
parts = name.split()
13-
if parts[0] in ["Mr", "Mr.", "Mrs", "Mrs.", "Ms", "Ms.", "Miss", "Dr.", "Doctor", "Prof", "Prof.", "Professor", "Sir", "Lady", "Dame"]:
13+
if len(parts) > 2 and parts[0] in ["M", "M.", "Sri", ] and "." not in parts[1]:
14+
prefix = parts[0];
15+
parts = parts[1:]
16+
if parts[0] in ["Mr", "Mr.", "Mrs", "Mrs.", "Ms", "Ms.", "Miss", "Dr.", "Doctor", "Prof", "Prof.", "Professor", "Sir", "Lady", "Dame", ]:
1417
prefix = parts[0];
1518
parts = parts[1:]
1619
if len(parts) > 2:
1720
if parts[-1] in ["Jr", "Jr.", "II", "2nd", "III", "3rd", "Ph.D."]:
1821
suffix = parts[-1]
1922
parts = parts[:-1]
23+
if len(parts) > 2:
24+
name = " ".join(parts)
25+
compound = re.search(" (de|hadi|van|ver|von|el|le|st\.?) ", name.lower())
26+
if compound:
27+
pos = compound.start()
28+
parts = name[:pos].split() + [name[pos+1:]]
2029
if len(parts) > 2:
2130
first = parts[0]
2231
last = parts[-1]

0 commit comments

Comments
 (0)