Country lookup: every ISO country, the widest unit wins, several European countries are EU

country_of folds with _place_fold (ł, đ, ø, æ map to ASCII; _fold keeps building
company_key unchanged), knows every ISO country by English name and European
ones by their own, and the cities among the 150 most frequent unresolved
places on the live data. Within one location a country beats a US state or
Canadian province, which beats a city. A state code that is also an ISO code
counts as the state only when the line names a US place. Several countries,
all European, are EU; otherwise ''. A code in parentheses is read when no
name matched.

Migration 12 recomputes country from place for roles extract has not read
and whose board sent no country in raw. On the live data: open roles with no
country 2,827 -> 1,183 of 16,841; 1,705 open roles change, 48 from a code.

Co-Authored-By: Claude Opus <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus committed 2026-09-29 15:06:15 +02:00
1 parent 706b127bc0
commit 2c4b992c50
6 files changed
+611 -109

No files matched your search

+27
View File
@@ -50,6 +50,33 @@ def store(tmp_path: Path) -> Store:
("London or New York", ""),
("Remote", ""),
("", ""),
("Wrocław", "PL"), # ł and đ do not decompose under NFKD
("Łódź, Poland", "PL"),
("Bogota, CO", "CO"), # a state code that is a country's too
("Paderborn, DE", ""), # ... is no US state without a US place
("Sliema, MT", ""),
("Casablanca, MA", "MA"),
("Cambridge, MA", "US"),
("Chicago, IL", "US"),
("Madrid, MD, Spain", "ES"),
("Dublin, London", "EU"), # several European countries
("Anywhere in France, Belgium, Spain", "EU"),
("Amsterdam, Netherlands; London, United Kingdom; Remote - Europe", "EU"),
("Remote, EU or US", ""), # a region and a country outside it
("London, Ontario", "CA"), # a province beats the city before it
("Bellevue, Washington", "US"),
("Tilburg, NB, Netherlands", "NL"), # a country beats a province code
("Atlanta, Georgia", "US"),
("Tbilisi, Georgia", "GE"),
("Malaysia", "MY"),
("Belgrade, Serbia", "RS"),
("Dubai", "AE"),
("United Arab Emirates", "AE"),
("Buenos Aires, , Argentina", "AR"),
("Leicester (GB)", "GB"), # a code in parentheses when nothing else
("Cagliari (CA)", "IT"), # ... and not over a name
("Hybrid", ""),
("Distributed", ""),
])
def test_country_of(place: str, code: str) -> None:
assert country_of(place) == code