Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pleplenier committed Nov 5, 2024
1 parent 0e2236c commit b6d5b08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions geoconvert/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion geoconvert/data/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion geoconvert/data/countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit b6d5b08

Please sign in to comment.