From 3a7ba0288fb028b3222e610b3e6cd719154632c7 Mon Sep 17 00:00:00 2001 From: Al Date: Sat, 5 Dec 2015 16:13:15 -0500 Subject: [PATCH] [fix] .get --- scripts/geodata/osm/osm_address_training_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/geodata/osm/osm_address_training_data.py b/scripts/geodata/osm/osm_address_training_data.py index b8cef9d9..b221fb2e 100644 --- a/scripts/geodata/osm/osm_address_training_data.py +++ b/scripts/geodata/osm/osm_address_training_data.py @@ -726,7 +726,9 @@ def build_address_format_training_data(admin_rtree, language_rtree, neighborhood Probabilistically strip standard prefixes/suffixes e.g. "London Borough of" ''' for component in REPLACE_COMPONENTS: - name = address_components[component] + name = address_components.get(component) + if not name: + continue replacement = replace_name_prefixes(replace_name_suffixes(name)) if replacement != name and random.random() < 0.6: address_components[component] = replacement