Skip to content

Commit

Permalink
Merge pull request #41 from argyle-engineering/fix-bo-box
Browse files Browse the repository at this point in the history
Support PO Drawer
  • Loading branch information
lmelninkas authored Mar 12, 2024
2 parents 17e4b27 + e96ffa2 commit ec79a31
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
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

0 comments on commit ec79a31

Please sign in to comment.