From 779298360cb6a592fdbcf4bec2d0ecd904c5d128 Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 9 Dec 2015 01:00:59 -0500 Subject: [PATCH] [osm] In cases with more than one official language and where the address language can be determined, use it for looking up language-specific OSM polygons --- scripts/geodata/osm/osm_address_training_data.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/geodata/osm/osm_address_training_data.py b/scripts/geodata/osm/osm_address_training_data.py index 88dac22a..02c2a985 100644 --- a/scripts/geodata/osm/osm_address_training_data.py +++ b/scripts/geodata/osm/osm_address_training_data.py @@ -453,6 +453,9 @@ def build_address_format_training_data(admin_rtree, language_rtree, neighborhood _ = value.pop(key, None) language = None + + more_than_one_official_language = len(candidate_languages) > 1 + if tag_components: if len(candidate_languages) == 1: language = candidate_languages[0]['lang'] @@ -584,6 +587,8 @@ def build_address_format_training_data(admin_rtree, language_rtree, neighborhood if non_local_language is not None: osm_suffix = ':{}'.format(non_local_language) + elif more_than_one_official_language and language not in (AMBIGUOUS_LANGUAGE, UNKNOWN_LANGUAGE): + osm_suffix = ':{}'.format(language) else: osm_suffix = ''