Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PO Drawer #41

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pyap/source_US/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,18 +907,22 @@ def street_type_list_to_regex(street_type_list):
"""

po_box = r"""
(?:
[Pp]\.?\ ?[Oo]\.?\ ?
|
[Pp][Oo][Ss][Tt]\ [Oo][Ff][Ff][Ii][Cc][Ee]\ ?
)?
(?:
(?:
(?:
[Pp]\.?\ ?[Oo]\.?\ ?
[Bb][Oo][Xx]
|
[Pp][Oo][Ss][Tt]\ [Oo][Ff][Ff][Ii][Cc][Ee]\ ?
)?
[Bb][Oo][Xx]
|
[Pp][Mm][Bb]
[Pp][Mm][Bb]
)
\ \#?\ ?A?\d+
)
\ \#?\ ?A?\d+
|
(?:[Dd][Rr][Aa][Ww][Ee][Rr]\ +[A-Z]\b)
)
"""

Expand Down
13 changes: 13 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ def test_combine_results():
"postal_code": "94583-2176",
},
),
(
"2006 Broadway Ave Suite 2A, PO Drawer J, Great Bend, KS 67530",
{
"street_number": "2006",
"street_type": "Ave",
"street_name": "Broadway",
"occupancy": "Suite 2A",
"city": "Great Bend",
"region1": "KS",
"po_box": "PO Drawer J",
"postal_code": "67530",
},
),
],
)
def test_parse_address(input: str, expected):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_parser_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def test_occupancy(input, expected):
("PMB 29700", True),
("pmb #29700", True),
("PO Box # A3656", True),
("PO Drawer J", True),
# negative assertions
("po box108 ", False),
("PoBox53485 ", False),
Expand Down Expand Up @@ -561,6 +562,7 @@ def test_full_street_positive(input, expected):
("1 MEGA CENTER, MegaCity, MICH.49423-9576", True),
("1300 E MOUNT GARFIELD ROAD, NORTON SHORES 49441", True),
("PO Box # A3656\nChicago, IL 60690", True),
("2006 Broadway Ave Suite 2A, PO Drawer J, Great Bend, KS 67530", True),
# negative assertions
("ONE HEALING CENTER LLC, 16444", False),
("85 STEEL REGULAR SHAFT - NE", False),
Expand Down
Loading