[fix] only replace whitespace between words, not for instance whitespace around an existing hyphen, and reducing to one space for spaced hyphens

This commit is contained in:
Al
2016-10-19 01:23:58 -04:00
parent 78f341f4f1
commit 51afc2619b

View File

@@ -1224,8 +1224,8 @@ class AddressComponents(object):
address_components.pop(AddressFormatter.HOUSE_NUMBER, None)
name_regex = re.compile('^[\s\-]*(.*?)[\s\-]*$')
whitespace_regex = re.compile('[\s]+')
hyphen_regex = re.compile('[\-]+')
whitespace_regex = re.compile('(?<=[\w])[\s]+(?=[\w])')
hyphen_regex = re.compile('[\s]*[\-]+[\s]*')
def dehyphenate_multiword_name(self, name):
return self.hyphen_regex.sub(six.u(' '), name)