7476: Given Name Cloud Gramplet splits up given names into words

This commit is contained in:
Paul Franklin 2014-03-23 18:43:01 -07:00
parent a5a7126dc4
commit 0edd609b92
2 changed files with 13 additions and 0 deletions

View File

@ -68,6 +68,12 @@ class GivenNameCloudGramplet(Gramplet):
allnames = [person.get_primary_name()] + person.get_alternate_names()
allnames = set(name.get_first_name().strip() for name in allnames)
for givenname in allnames:
anyNBSP = givenname.split(u'\u00A0')
if len(anyNBSP) > 1: # there was an NBSP, a non-breaking space
first_two = anyNBSP[0] + u'\u00A0' + anyNBSP[1].split()[0]
givensubnames[first_two] += 1
representative_handle[first_two] = person.handle
givenname = ' '.join(anyNBSP[1].split()[1:])
for givensubname in givenname.split():
givensubnames[givensubname] += 1
representative_handle[givensubname] = person.handle

View File

@ -69,6 +69,13 @@ class SameGiven(Rule):
src = self.list[0].upper()
for name in [person.get_primary_name()] + person.get_alternate_names():
if name.first_name:
anyNBSP = name.first_name.split(u'\u00A0')
if len(anyNBSP) > 1: # there was an NBSP, a non-breaking space
first_two = anyNBSP[0] + u'\u00A0' + anyNBSP[1].split()[0]
if first_two.upper() == src:
return True
else:
name.first_name = ' '.join(anyNBSP[1].split()[1:])
if " " in name.first_name.strip():
for name in name.first_name.upper().strip().split():
if name == src.upper():