diff --git a/geoconvert/convert.py b/geoconvert/convert.py index 864ef2b..09423f0 100644 --- a/geoconvert/convert.py +++ b/geoconvert/convert.py @@ -9,7 +9,7 @@ DE_POSTCODE_RANGE, NUTS_CODES_BY_COUNTRY, all_nuts_regex, - ambiguous_countries, + ambiguous_country_names, br_postcode_regex, br_state_code_regex, br_state_name_regex, @@ -415,13 +415,11 @@ def _full_name_to_country_code(text, lang, language_to_full_names): language_to_full_names = {} for language, full_names in language_to_full_names.items(): - # When language is not set, we remove ambiguous countries names from the countries list + # When no language is set, remove ambiguous country names from the countries list. if not lang: - full_names = { - name: code - for name, code in full_names.items() - if name not in ambiguous_countries - } + full_names = full_names.copy() + for name in ambiguous_country_names: + full_names.pop(name, None) country_code = _full_name_to_country_code_for_lang(text, language, full_names) if country_code: return country_code diff --git a/geoconvert/data/__init__.py b/geoconvert/data/__init__.py index 841d785..287c74f 100644 --- a/geoconvert/data/__init__.py +++ b/geoconvert/data/__init__.py @@ -1,6 +1,6 @@ from .capitals import capitals_de, capitals_en, capitals_fr, language_to_capital_names from .countries import ( - ambiguous_countries, + ambiguous_country_names, countries_de, countries_en, countries_fr, diff --git a/geoconvert/data/countries.py b/geoconvert/data/countries.py index 437b45e..ec4b7b6 100644 --- a/geoconvert/data/countries.py +++ b/geoconvert/data/countries.py @@ -57,7 +57,7 @@ # We register here names matching common words in other languages to prevent # matching them when language is not defined -ambiguous_countries = ["island"] +ambiguous_country_names = ["island"] countries_fr = {