Skip to content

Commit 8e544d8

Browse files
authored
Merge pull request #83 from argyle-engineering/match-lot-occupancy-type
match lot and block occupancy type
2 parents 91f4186 + a5e5e98 commit 8e544d8

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎pyap/source_US/data.py‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -902,10 +902,11 @@ def street_type_list_to_regex(street_type_list: list[str]) -> str:
902902
ten_to_ninety=ten_to_ninety,
903903
)
904904

905-
occupancy_details = r"(?:[A-Za-z\#\&\-\d]{{1,7}}(?:\s?{post_direction_re})?)".format(
906-
post_direction_re=post_direction_re
905+
occupancy_details = (
906+
r"(?:(?:\#\ )?[A-Za-z\#\&\-\d]{{1,7}}(?:\s?{post_direction_re})?)".format(
907+
post_direction_re=post_direction_re
908+
)
907909
)
908-
909910
occupancy = r"""
910911
(?P<occupancy>
911912
(?:
@@ -934,7 +935,10 @@ def street_type_list_to_regex(street_type_list: list[str]) -> str:
934935
|
935936
# Space
936937
[Ss][Pp][Cc]|[Ss][Pp][Aa][Cc][Ee]
937-
)\b[\ \,\.]+
938+
|
939+
# Lot
940+
[Ll][Oo][Tt]
941+
)\b[\ \,\.]*
938942
{occupancy_details}?
939943
|
940944
\d{{2,4}}\ [Ss][Tt][Ee](?:\ \*)?
@@ -957,6 +961,11 @@ def street_type_list_to_regex(street_type_list: list[str]) -> str:
957961
# the `ST.` in `ST. LOUIS`
958962
[Ss][Tt][Ee]?\b[\ \,\.]+{occupancy_details}
959963
)
964+
|
965+
(?:
966+
#Block abbreviated as B
967+
[Bb]\d{{1,4}}
968+
)
960969
)
961970
)
962971
""".format(
@@ -1267,7 +1276,6 @@ def make_full_address(
12671276
country: Optional[str] = None,
12681277
phone_number: str = phone_number,
12691278
) -> str:
1270-
12711279
return r"""
12721280
(?P<full_address>
12731281
{full_street}

‎tests/test_parser_us.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,11 @@ def test_building(input, expected):
363363
("Suite 3 South", True),
364364
("Suite 3 North", True),
365365
("Suite 4 Northeast", True),
366+
("Lot#18", True),
367+
("B2", True),
368+
("apt # 2d", True),
366369
# negative assertions
367370
("suite900 ", False),
368-
("Suite#2", False),
369371
("suite218 ", False),
370372
],
371373
)
@@ -648,6 +650,8 @@ def test_full_street_positive(input, expected):
648650
("1234 WOODMONT DRIVE NORTHWEST APT# APT F-15 LENOIR NC 28645", True),
649651
("1234 N Front Street\nSuite 3 South\nHarrisburg, PA 17102", True),
650652
("206 La Rue France, Lafayette, LA, 70508", True),
653+
("1234 Fowlstown Rd Lot#18 \nBainbridge, GA 39817", True),
654+
("1234 LONG LANE\nB2 \nUPPER DARBY PA 19082", True),
651655
# negative assertions
652656
("ONE HEALING CENTER LLC, 16444", False),
653657
("85 STEEL REGULAR SHAFT - NE", False),

0 commit comments

Comments
 (0)