more heuristics for splitting street/house and first/last name
This commit is contained in:
parent
fbaa84399d
commit
c7eb19fa57
|
@ -15,11 +15,22 @@ def get_alpha3_country_from_alpha2(twodigit):
|
||||||
|
|
||||||
# split the last word of a string containing stree name + house number
|
# split the last word of a string containing stree name + house number
|
||||||
def split_street_house(streethouse):
|
def split_street_house(streethouse):
|
||||||
|
# first try to split at last space
|
||||||
r = streethouse.rsplit(' ', 1)
|
r = streethouse.rsplit(' ', 1)
|
||||||
|
# if that fails, try to split at last dot
|
||||||
|
if len(r) < 2:
|
||||||
|
r = streethouse.rsplit('.', 1)
|
||||||
|
# if that also fails, return empty house number
|
||||||
|
if len(r) < 2:
|
||||||
|
return (streethouse, '')
|
||||||
return (r[0], r[1])
|
return (r[0], r[1])
|
||||||
|
|
||||||
def split_first_lastname(name):
|
def split_first_lastname(name):
|
||||||
|
# try to split at last space
|
||||||
r = name.rsplit(' ', 1)
|
r = name.rsplit(' ', 1)
|
||||||
|
# if this fails, simply claim everything is the last name
|
||||||
|
if len(r) < 2:
|
||||||
|
return ("", name)
|
||||||
return (r[0], r[1])
|
return (r[0], r[1])
|
||||||
|
|
||||||
class DPDeliveryCarrier(models.Model):
|
class DPDeliveryCarrier(models.Model):
|
||||||
|
|
Loading…
Reference in New Issue