Skip to content

Commit

Permalink
New Jersey in special countries (#18)
Browse files Browse the repository at this point in the history
* New Jersey in special countries (US not JE)

* add Jersey examples

Co-authored-by: maylis baschet <[email protected]>
  • Loading branch information
MayBaMay and maylis baschet authored Aug 9, 2021
1 parent c7b5ceb commit 399ca54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion geoconvert/data/countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}


Expand Down
3 changes: 3 additions & 0 deletions test_geoconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
(
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 399ca54

Please sign in to comment.