Improved the handling of surname particles, (prompted by failure to handle the name of Niels ten Oever correctly)
- Legacy-Id: 13663
This commit is contained in:
parent
1905d25aee
commit
bb089c182d
|
@ -1,5 +1,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import debug # pyflakes:ignore
|
||||||
|
|
||||||
def name_parts(name):
|
def name_parts(name):
|
||||||
prefix, first, middle, last, suffix = u"", u"", u"", u"", u""
|
prefix, first, middle, last, suffix = u"", u"", u"", u"", u""
|
||||||
|
|
||||||
|
@ -28,11 +30,16 @@ def name_parts(name):
|
||||||
suffix = parts[-1]
|
suffix = parts[-1]
|
||||||
parts = parts[:-1]
|
parts = parts[:-1]
|
||||||
if len(parts) > 2:
|
if len(parts) > 2:
|
||||||
name = u" ".join(parts)
|
# Check if we have a surname with nobiliary particle
|
||||||
compound = re.search(r" (de|hadi|van|ver|von|el|le|st\.?) ", name.lower())
|
full = u" ".join(parts)
|
||||||
if compound:
|
if full.upper() == full:
|
||||||
pos = compound.start()
|
full = full.lower() # adjust case for all-uppercase input
|
||||||
parts = name[:pos].split() + [name[pos+1:]]
|
# This is an incomplete list. Adjust as needed to handle known ietf
|
||||||
|
# participant names correctly:
|
||||||
|
particle = re.search(r" (af|de|der|di|Di|du|el|hadi|st\.?|ten|ter|van|van der|Van|von|von der|Von|zu) ", full)
|
||||||
|
if particle:
|
||||||
|
pos = particle.start()
|
||||||
|
parts = full[:pos].split() + [full[pos+1:]]
|
||||||
if len(parts) > 2:
|
if len(parts) > 2:
|
||||||
first = parts[0]
|
first = parts[0]
|
||||||
last = parts[-1]
|
last = parts[-1]
|
||||||
|
|
Loading…
Reference in a new issue