Skip to content
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
29 changes: 18 additions & 11 deletions pyap/source_US/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ def str_list_to_upper_lower_regex(str_list: List[str]) -> str:
[Ww][Ee][Ss][Tt]
)
|
\b(?:NW|NE|SW|SE)\b
\b(?:[Nn][Ww]|[Nn][Ee]|[Ss][Ww]|[Ss][Ee])\b
|
\b(?:N\.W\.|N\.E\.|S\.W\.|S\.E\.)
\b(?:[Nn]\.[Ww]\.|[Nn]\.[Ee]\.|[Ss]\.[Ww]\.|[Ss]\.[Ee]\.)
|
\b(?:N|S|E|W)\b\.?
\b(?:[Nn]|[Ss]|[Ee]|[Ww])\b\.?
)
"""

Expand Down Expand Up @@ -1000,18 +1000,25 @@ def street_type_list_to_regex(street_type_list: list[str]) -> str:
(?:
(?P<line1>
(?:(?P<po_box_b>{po_box}){part_div})?
{street_number}{space_div}?
(?:
(?:{numbered_or_typeless_street_name})
|
(?:{typed_street_name}(?![A-Za-z\d\.]))
|
{street_number}{space_div}?
(?:
{post_direction_re}\
\d{{,3}}[A-Za-z\-]{{1,31}}
(?:{numbered_or_typeless_street_name})
|
(?:{typed_street_name}(?![A-Za-z\d\.]))
|
(?:
{post_direction_re}\
\d{{,3}}[A-Za-z\-]{{1,31}}
)
)
(?:{space_div}{post_direction})?
)
|
(?:
\d{{1,4}}{space_div}{post_direction_re}{space_div}
\d{{1,4}}{space_div}{post_direction_re}
)
(?:{space_div}{post_direction})?
)
(?P<line2>
(?:{part_div}{floor})?
Expand Down
13 changes: 8 additions & 5 deletions tests/test_parser_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ def test_po_box_positive(input, expected):
("2817 PETERS ROAD BAY 52", True),
("1234 Big Avenue 3B", True),
("15 ROUTE 9H", True),
("123 w 456 s", True),
("123 SE 4 NE", True),
# negative assertions
("6 95 34 75 COMPANY PHONE IS", False),
(", 666 Hell ST PMB 29700", False),
Expand Down Expand Up @@ -627,6 +629,12 @@ def test_full_street_positive(input, expected):
("1800 M STREET NW SUITE 375 N, WASHINGTON, DC 20036", True),
("10 INDIAN BAY, ALAMEDA CA 94502", True),
("1234 THE BENT TWIG JOHNS ISLAND, KY 40207", True),
("400 blvd of the americas\nste 401\nlakewood nj 08701", True),
("400 ave of the stars\nlakewood nj 08701", True),
("930 laurel breeze dr\napt# apt 308\nknightdale nc 27545", True),
("1234 PEDDY RD SPC 42,RIVERSIDE,CA,92509", True),
("123 Blackwood street Ap B5 Philadelphia, PA 19116", True),
("123 w 456 s mighey, IN 46953", True),
# negative assertions
("ONE HEALING CENTER LLC, 16444", False),
("85 STEEL REGULAR SHAFT - NE", False),
Expand All @@ -648,11 +656,6 @@ def test_full_street_positive(input, expected):
("2 TRACTOR HEAD Actros MP", False),
("00 Straight Fit Jean, USA", False),
("123 Curvy Way, Littleville, USA", False),
("400 blvd of the americas\nste 401\nlakewood nj 08701", True),
("400 ave of the stars\nlakewood nj 08701", True),
("930 laurel breeze dr\napt# apt 308\nknightdale nc 27545", True),
("1234 PEDDY RD SPC 42,RIVERSIDE,CA,92509", True),
("123 Blackwood street Ap B5 Philadelphia, PA 19116", True),
],
)
def test_full_address(input, expected):
Expand Down