From f8a3081d0fe585d25833d64e63972ed824d00ae2 Mon Sep 17 00:00:00 2001 From: Al Date: Mon, 7 Dec 2015 02:33:12 -0500 Subject: [PATCH] [fix] city name in OSM formatting --- scripts/geodata/osm/osm_address_training_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/geodata/osm/osm_address_training_data.py b/scripts/geodata/osm/osm_address_training_data.py index 6c21fbaa..3972bdec 100644 --- a/scripts/geodata/osm/osm_address_training_data.py +++ b/scripts/geodata/osm/osm_address_training_data.py @@ -589,6 +589,8 @@ def build_address_format_training_data(admin_rtree, language_rtree, neighborhood if osm_components: poly_components = defaultdict(list) + existing_city_name = address_components.get(AddressFormatter.CITY) + for component, components_values in osm_components.iteritems(): seen = set() @@ -610,12 +612,9 @@ def build_address_format_training_data(admin_rtree, language_rtree, neighborhood name = component_value[simple_name_key] elif international_name_key in component_value: name = component_value[international_name_key] - if not name: name = component_value.get(key, component_value.get(raw_key)) - existing_city_name = address_components.get(AddressFormatter.CITY) - if not name or (component != AddressFormatter.CITY and name == existing_city_name): name = component_value.get(name_key, component_value.get(raw_name_key)) @@ -654,6 +653,7 @@ def build_address_format_training_data(admin_rtree, language_rtree, neighborhood if not names or lang not in names: continue + city = None if 'abbr' not in names or non_local_language: # Use the common city name in the target language city = names[lang][0][0]