-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixup for common address parsing problems
- Loading branch information
1 parent
bf77982
commit 65d125d
Showing
3 changed files
with
145 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/meshdb/utils/spreadsheet_import/tests/test_fixup_bad_address.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from meshdb.utils.spreadsheet_import.building.resolve_address import call_pelias_parser, fixup_bad_address | ||
|
||
|
||
def test_fixup(): | ||
assert fixup_bad_address("244 E 45st New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 E 45St New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 E 45ST New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 E 45 St New York") == "244 E 45 St New York" | ||
|
||
assert fixup_bad_address("244 5Ave New York") == "244 5 Ave New York" | ||
assert fixup_bad_address("244 5AVE New York") == "244 5 Ave New York" | ||
assert fixup_bad_address("244 5 Ave New York") == "244 5 Ave New York" | ||
|
||
assert fixup_bad_address("357 13th Steet Apt #2") == "357 13th Street Apt #2" | ||
assert fixup_bad_address("357 13th STEET Apt #2") == "357 13th Street Apt #2" | ||
assert fixup_bad_address("357 13th steet Apt #2") == "357 13th Street Apt #2" | ||
|
||
assert fixup_bad_address("357 6th Avue") == "357 6th Avenue" | ||
assert fixup_bad_address("357 6th steet") == "357 6th Street" | ||
assert fixup_bad_address("357 Grand concoourse") == "357 Grand Concourse" | ||
|
||
assert fixup_bad_address("244 E45 St New York") == "244 E 45 St New York" | ||
assert fixup_bad_address("244 e45St New York") == "244 e 45 St New York" | ||
assert fixup_bad_address("244 W45St New York") == "244 W 45 St New York" | ||
|
||
assert fixup_bad_address("244 Abc nlvd New York") == "244 Abc Boulevard New York" | ||
|
||
assert fixup_bad_address("244 W 45St New York") == "244 W 45 St New York" | ||
assert fixup_bad_address("244 W 45St New York; 10023") == "244 W 45 St New York, 10023" | ||
|
||
|
||
def test_pelias_bowery(): | ||
# If this is failing, it's probably because you don't have connectivity | ||
# to a pelias parser, maybe you need to run it with Docker? | ||
|
||
result = call_pelias_parser("123 Bowery, New York, NY") | ||
assert result[0][1] == {"housenumber": "123", "locality": "New York", "region": "NY", "street": "Bowery"} | ||
assert result[0][2] == {"housenumber": (0, 3), "locality": (12, 20), "region": (22, 24), "street": (4, 10)} | ||
|
||
result = call_pelias_parser("123 Bowery") | ||
assert result[0][1] == {"housenumber": "123", "street": "Bowery"} | ||
assert result[0][2] == {"housenumber": (0, 3), "street": (4, 10)} |