From 399ca544904f873e8477a9da98b2f035b1242e04 Mon Sep 17 00:00:00 2001 From: MayBaMay <49728619+MayBaMay@users.noreply.github.com> Date: Mon, 9 Aug 2021 12:04:06 +0200 Subject: [PATCH] New Jersey in special countries (#18) * New Jersey in special countries (US not JE) * add Jersey examples Co-authored-by: maylis baschet --- README.md | 6 ++++++ geoconvert/data/countries.py | 4 +++- test_geoconvert.py | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 70e8c90..befb8fc 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ pip install https://github.com/jurismarches/geoconvert/archive/master.zip 'AF' >>> address_to_country_code("Bienvenidos a Nueva Zelanda") # ES 'NZ' +>>> address_to_country_code("659 Ocean Ave, Lakewood, New Jersey 08701") +'US' +>>> address_to_country_code("Le Chemin des Garennes, Jersey JE3 2FE, Jersey") +'JE' >>> address_to_subdivision_code("2 pl. Saint-Pierre, 44000 Nantes, France") # FR '44' >>> address_to_subdivision_code("2 pl. Saint-Pierre, 44000 Nantes", country="FR") @@ -50,6 +54,8 @@ pip install https://github.com/jurismarches/geoconvert/archive/master.zip >>> address_to_subdivision_code("1800 W Erie Ave, Lorain, OH 44052", country="FR") >>> address_to_subdivision_code("196 Voie Camillien-Houde, Montréal, QC H3H 1A1") # CA 'QC' +>>> address_to_country_and_subdivision_codes("1170 Cattus Island Blvd, Toms River, New Jersey") # US +('US', 'NJ') >>> address_to_country_and_subdivision_codes("Montréal, Québec") # CA ('CA', 'QC') >>> address_to_country_and_subdivision_codes("1800 W Erie Ave, Lorain, OH 44052") # US diff --git a/geoconvert/data/countries.py b/geoconvert/data/countries.py index 92ae026..339f64e 100644 --- a/geoconvert/data/countries.py +++ b/geoconvert/data/countries.py @@ -17,10 +17,12 @@ "republik kongo": "CG", # de "republica do congo": "CG", # pt "congo": "CG", # en, fr - # make sure we never mistake it for SD + # Make sure we never mistake it for SD "south sudan": "SS", # en "sudsudan": "SS", # de "sudan del sur": "SS", # es + # Make sure we never mistake it for JE + "new jersey": "US", } diff --git a/test_geoconvert.py b/test_geoconvert.py index 033627d..1ed875b 100644 --- a/test_geoconvert.py +++ b/test_geoconvert.py @@ -109,6 +109,7 @@ def test_ca_province_name_to_province_code(self, input_data, expected): ("Washington DC", "DC"), ("Richmond, Virginia", "VA"), ("Charleston, West Virginia", "WV"), + ("650 Great Rd, Princeton, New Jersey", "NJ"), # Should be case-sensitive when detecting state code directly. # "de" is not mistaken for "DE", but "DE" gives "DE" ( @@ -775,6 +776,8 @@ def test_address_to_subdivision_code(self, input_data, kwargs, expected): ("Los Angeles, CA\nUnited States", "US"), ("Cabul, Afeganistão", "AF"), ("Try to find South Sudan in an address", "SS"), + ("650 Great Rd, Princeton, New Jersey", "US"), + ("St Peter, Jersey JE1 1BY, Jersey", "JE"), # The country code can be found using the capital name in any available language ("Kairo", "EG"), ("Paris", "FR"),