diff --git a/pyap/source_US/data.py b/pyap/source_US/data.py index f2ecef3..516f1d0 100644 --- a/pyap/source_US/data.py +++ b/pyap/source_US/data.py @@ -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 - (?: - (?:[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 = ( diff --git a/tests/test_parser_us.py b/tests/test_parser_us.py index cb0012f..f4a8dd4 100644 --- a/tests/test_parser_us.py +++ b/tests/test_parser_us.py @@ -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), @@ -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),