From 086bcfd224eeef9fd29f480fc2418e360f118361 Mon Sep 17 00:00:00 2001 From: Cullen Watson Date: Mon, 18 Sep 2023 17:57:15 -0500 Subject: [PATCH] fix: check for suite --- homeharvest/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeharvest/utils.py b/homeharvest/utils.py index dea27d5..4b68913 100644 --- a/homeharvest/utils.py +++ b/homeharvest/utils.py @@ -6,18 +6,18 @@ def parse_address_two(street_address: str) -> tuple: return street_address, None apt_match = re.search( - r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$", + r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+|SUITE\s*[\dA-Z]+)$", street_address, re.I, ) if apt_match: apt_str = apt_match.group().strip() - cleaned_apt_str = re.sub(r"(APT\s*|UNIT\s*|LOT\s*)", "#", apt_str, flags=re.I) + cleaned_apt_str = re.sub( + r"(APT\s*|UNIT\s*|LOT\s*|SUITE\s*)", "#", apt_str, flags=re.I + ) - main_address = street_address.replace( - apt_str, "" - ).strip() # Remove the matched part from the original address + main_address = street_address.replace(apt_str, "").strip() return main_address, cleaned_apt_str else: return street_address, None @@ -45,3 +45,4 @@ if __name__ == "__main__": print(parse_address_two("1234 Elm Street apt 2B")) print(parse_address_two("1234 Elm Street UNIT 3A")) print(parse_address_two("1234 Elm Street unit 3A")) + print(parse_address_two("1234 Elm Street SuIte 3A"))