[fix] moving checks inside the add_locatives function, fixing float cast

This commit is contained in:
Al
2016-12-28 04:59:27 -05:00
parent 6f009fb8a6
commit 91013fe296

View File

@@ -876,9 +876,10 @@ class AddressComponents(object):
return six.u(' ').join(norm)
def add_locatives(self, address_components, language):
if language in self.slavic_morphology_analyzers and AddressFormatter.CITY in address_components:
for component in address_components:
locative_probability = float(nested_get(self.config, ('slavic_names', component, 'locative_probability')))
if locative_probability is not None and random.random() < locative_probability:
locative_probability = nested_get(self.config, ('slavic_names', component, 'locative_probability'))
if locative_probability is not None and random.random() < float(locative_probability):
address_components[component] = self.locative_name(address_components[component], language)
def abbreviated_state(self, state, country, language):
@@ -1713,7 +1714,6 @@ class AddressComponents(object):
self.drop_invalid_components(address_components, country)
if language in self.slavic_morphology_analyzers and AddressFormatter.CITY in address_components:
self.add_locatives(address_components, language)
if language_suffix and not non_local_language and not language_altered: