[fix] convert newlines
This commit is contained in:
@@ -1223,6 +1223,7 @@ class AddressComponents(object):
|
|||||||
else:
|
else:
|
||||||
address_components.pop(AddressFormatter.HOUSE_NUMBER, None)
|
address_components.pop(AddressFormatter.HOUSE_NUMBER, None)
|
||||||
|
|
||||||
|
newline_regex = re.compile('[\n]+')
|
||||||
name_regex = re.compile('^[\s\-]*(.*?)[\s\-]*$')
|
name_regex = re.compile('^[\s\-]*(.*?)[\s\-]*$')
|
||||||
whitespace_regex = re.compile('(?<=[\w])[\s]+(?=[\w])')
|
whitespace_regex = re.compile('(?<=[\w])[\s]+(?=[\w])')
|
||||||
hyphen_regex = re.compile('[\s]*[\-]+[\s]*')
|
hyphen_regex = re.compile('[\s]*[\-]+[\s]*')
|
||||||
@@ -1237,6 +1238,7 @@ class AddressComponents(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def strip_whitespace_and_hyphens(cls, name):
|
def strip_whitespace_and_hyphens(cls, name):
|
||||||
|
name = cls.newline_regex.sub(six.u(' '), name)
|
||||||
return cls.name_regex.match(name).group(1)
|
return cls.name_regex.match(name).group(1)
|
||||||
|
|
||||||
def name_hyphens(self, name, hyphenate_multiword_probability=None, remove_hyphen_probability=None):
|
def name_hyphens(self, name, hyphenate_multiword_probability=None, remove_hyphen_probability=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user