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
43 changes: 26 additions & 17 deletions pyap/source_US/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,37 +879,46 @@ def street_type_list_to_regex(street_type_list: list[str]) -> str:
floor_indic=floor_indic
)

tower = r"(?:{re_post_direction}\ [Tt][Oo][Ww][Ee][Rr])".format(
re_post_direction=post_direction_re
)

building = r"""
(?P<building_id>
(?:
(?:[Bb][Uu][Ii][Ll][Dd][Ii][Nn][Gg])\.?
|
(?:[Bb][Ll][Dd][Gg])\.?
|
(?:[Bb][Ll][Vv])\.?
)
\
(?:
(?:
[Aa][Nn][Dd]\
(?:[Bb][Uu][Ii][Ll][Dd][Ii][Nn][Gg])\.?
|
{thousand}
(?:[Bb][Ll][Dd][Gg])\.?
|
{hundred}
|
{zero_to_nine}
(?:[Bb][Ll][Vv])\.?
)
\
(?:
(?:
[Aa][Nn][Dd]\
|
{thousand}
|
{hundred}
|
{zero_to_nine}
|
{ten_to_ninety}
){{1,5}}
|
{ten_to_ninety}
){{1,5}}
\d{{0,4}}(?:\.\d)?[A-Za-z]?[XxVvIi]{{0,4}}
)
|
\d{{0,4}}(?:\.\d)?[A-Za-z]?[XxVvIi]{{0,4}}
)
{tower}
)
)
""".format(
thousand=thousand,
hundred=hundred,
zero_to_nine=zero_to_nine,
ten_to_ninety=ten_to_ninety,
tower=tower,
)

occupancy_details = (
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 @@ -304,6 +304,7 @@ def test_floor(input, expected):
("Building ", True),
("building one ", True),
("Building three ", True),
("South Tower", True),
# negative assertions
("bldg", False),
("bldgm", False),
Expand Down Expand Up @@ -521,6 +522,7 @@ def test_po_box_positive(input, expected):
("123 Chase Wimbledom St.", True),
("82 ALBRO TRACT", True),
("6123 SHEFFIELD HOUSE", True),
("99 Valley Greens Dr\nSouth Tower", True),
# negative assertions
("6 95 34 75 COMPANY PHONE IS", False),
(", 666 Hell ST PMB 29700", False),
Expand Down