Skip to content

Commit

Permalink
Do not mistake subdivisions with "Island" in their name with Iceland.
Browse files Browse the repository at this point in the history
This is because Iceland spells Island in German, and this has precedence
over subdivision detection.
  • Loading branch information
mmoriniere committed Mar 15, 2023
1 parent 0be2010 commit abdf440
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- All tests pass, no warning
- Detection for "Congo Democratic Republic" as CG (without "of" in the end)
- Do not mistake "Haute-Vienne" French department with the Austrian capital name "Vienne" (in French)
- Do not mistake "Prince Edward Island" (Canadian province) and "Rhode Island" (US state)
with Iceland (which spells Island in German).

### Upgrade

Expand Down
4 changes: 3 additions & 1 deletion geoconvert/data/countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
"south sudan": "SS", # en
"sudsudan": "SS", # de
"sudan del sur": "SS", # es
# Make sure we never mistake some countries for IS (Iceland)
# Make sure we never mistake some countries or subdivisions for IS (Iceland)
# We would mistake them because Iceland spells Island in German.
"prince edward island": "CA", # en
"rhode island": "US", # en
"bouvet island": "BV", # en
"christmas island": "CX", # en
"heard island": "HM", # en
Expand Down
2 changes: 2 additions & 0 deletions tests/test_countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class TestCountries:
("Heard Island", {}, "HM"), # en
("Norfolk Island", {}, "NF"), # en
("Solomon Islands", {}, "SB"), # en
("Prince Edward Island", {}, "CA"), # en
("Rhode Island", {}, "US"), # en
# However, in cases where island is singular instead of plural,
# there can be confusion.
("Solomon Island Nationals", {}, "IS"), # en
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class TestNoCountryProvided:
("2 pl. Saint-Pierre, 44000 Nantes", {"country": "FR"}, "44"),
("2 pl. Saint-Pierre, 44000 Nantes, France", {}, "44"),
("2 pl. Saint-Pierre, 44000 Nantes, France", {"country": "FR"}, "44"),
# No mistakes with Iceland (IS)
("Prince Edward Island", {}, "PE"),
("Rhode Island", {}, "RI"),
],
)
def test_address_to_subdivision_code(self, input_data, kwargs, expected):
Expand Down Expand Up @@ -95,6 +98,9 @@ def test_address_to_subdivision_code(self, input_data, kwargs, expected):
{},
("AT", None), # Precedence goes to the French capital name for Austria
),
# No mistakes with Iceland (IS)
("Prince Edward Island", {}, ("CA", "PE")),
("Rhode Island", {}, ("US", "RI")),
],
)
def test_address_to_country_and_subdivision_code(
Expand Down

0 comments on commit abdf440

Please sign in to comment.