Skip to content

Commit

Permalink
Update address_parser.py
Browse files Browse the repository at this point in the history
  • Loading branch information
michplunkett committed Feb 17, 2024
1 parent 1bc08c4 commit 3cbdc6b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions incident_scraper/models/address_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AddressParser:
"""

_instance = None
ORDINALS_REGEX = r"E\. (\d{2})[a-z]{2} \w+"

def __new__(cls):
if cls._instance is None:
Expand Down Expand Up @@ -189,9 +190,7 @@ def _correct_replacements(address: str) -> str:
return address

def process_at_and_streets(self, address: str) -> str:
ordinals = list(
map(int, re.findall(r"E\. (\d{2})[a-z]{2} \w+", address))
)
ordinals = list(map(int, re.findall(self.ORDINALS_REGEX, address)))
non_ordinal_streets = [
s for s in self.street_corrections_final if s in address
]
Expand All @@ -205,9 +204,7 @@ def process_at_and_streets(self, address: str) -> str:

def process_between_streets(self, address) -> [str]:
and_cnt = len([s for s in address.split() if s == "and"])
ordinals = list(
map(int, re.findall(r"E\. (\d{2})[a-z]{2} \w+", address))
)
ordinals = list(map(int, re.findall(self.ORDINALS_REGEX, address)))
ordinals.sort()
non_ordinal_streets = [
s for s in self.street_corrections_final if s in address
Expand Down

0 comments on commit 3cbdc6b

Please sign in to comment.