From 57f17a5d380ae441d4902b1f70548efa6ec043d3 Mon Sep 17 00:00:00 2001 From: Al Date: Sun, 25 Dec 2016 00:44:48 -0500 Subject: [PATCH] [addresses] remove generated components in combined house numbers if the other components were not numeric. Add house number phrase after the units, etc. are generated so it may be applied to a combined house number as well --- scripts/geodata/addresses/components.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/geodata/addresses/components.py b/scripts/geodata/addresses/components.py index d94c0ac3..902523f9 100644 --- a/scripts/geodata/addresses/components.py +++ b/scripts/geodata/addresses/components.py @@ -495,7 +495,12 @@ class AddressComponents(object): for combo in combo_config: components = OrderedDict.fromkeys(combo['components']).keys() + if not all((is_numeric(address_components.get(c, generated.get(c))) for c in components)): + if combo['probability'] == 1.0: + for c in components: + if c in address_components and c in generated: + address_components.pop(c, None) continue combos.append((len(components), combo)) @@ -1613,7 +1618,6 @@ class AddressComponents(object): self.remove_numeric_boundary_names(address_components) - self.add_house_number_phrase(address_components, language, country=country) self.add_postcode_phrase(address_components, language, country=country) self.add_metro_station_phrase(address_components, language, country=country) @@ -1623,6 +1627,8 @@ class AddressComponents(object): self.add_sub_building_components(address_components, language, country=country, num_floors=num_floors, num_basements=num_basements, zone=zone) + self.add_house_number_phrase(address_components, language, country=country) + if dropout_places: # Population of the city helps us determine if the city can be used # on its own like "Seattle" or "New York" vs. smaller cities like