fix: check for suite
parent
4726764482
commit
086bcfd224
|
@ -6,18 +6,18 @@ def parse_address_two(street_address: str) -> tuple:
|
||||||
return street_address, None
|
return street_address, None
|
||||||
|
|
||||||
apt_match = re.search(
|
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,
|
street_address,
|
||||||
re.I,
|
re.I,
|
||||||
)
|
)
|
||||||
|
|
||||||
if apt_match:
|
if apt_match:
|
||||||
apt_str = apt_match.group().strip()
|
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(
|
main_address = street_address.replace(apt_str, "").strip()
|
||||||
apt_str, ""
|
|
||||||
).strip() # Remove the matched part from the original address
|
|
||||||
return main_address, cleaned_apt_str
|
return main_address, cleaned_apt_str
|
||||||
else:
|
else:
|
||||||
return street_address, None
|
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 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 unit 3A"))
|
print(parse_address_two("1234 Elm Street unit 3A"))
|
||||||
|
print(parse_address_two("1234 Elm Street SuIte 3A"))
|
||||||
|
|
Loading…
Reference in New Issue