6 Commits

Author SHA1 Message Date
d5e3d8e2a0 Merge pull request 'corporate name improvements.' (#16) from biz-name-jb-8 into main
Reviewed-on: #16
Reviewed-by: linnealovespie <linnealovespie@noreply.git.coopcloud.tech>
2026-02-14 01:47:38 +00:00
c4c766380f Merge branch 'main' into biz-name-jb-8
# Conflicts:
#	processors/corp_owners.py
2026-01-21 19:01:25 -08:00
5a37d38130 Merge pull request 'CCFS Database' (#18) from linnealovespie/database into main
Reviewed-on: #18
Reviewed-by: jessib <jessib@noreply.git.coopcloud.tech>
2026-01-22 00:14:57 +00:00
2a97e1ccb7 escape regexp pattern 2026-01-06 16:34:54 -08:00
900c051800 typo 2026-01-05 21:19:38 -08:00
672c474fb8 draft corporate name improvements. 2025-12-29 20:18:53 -08:00

View File

@ -106,33 +106,52 @@ class LookupCompaniesHelper:
- Partnership
- etc.
"""
def normalize_name(term):
# add space at at end of beginning to simplify matching words without using regexp (and then will remove)
term = " " + term.upper() + " "
term = re.sub(r"\s+", " ", term)
# examples: LLC, LLP, L L C, L.L.C., L.L.C. L.L.P., L.L.P, LLC.
# This requires space before and after
p = re.compile(r" L[\s.]?L[\s,.]?[PC][.]? ")
term = re.sub(p, "LLC", term)
term = term.replace(",", "")
word_replace_map = {
"LIMITED LIABILITY COMPANY": "LLC",
"LIMITED PARTNERSHIP": "LLC",
"APARTMENTS": "APTS",
"LTD PS": "LLC",
"LTD PARTNERSHIP": "LLC",
"ST": "STREET",
"AVE": "AVENUE",
"BLVD": "BOULEVARD",
"PRPTS": "PROPERTIES",
"PPTY": "PROPERTY",
"BLDG": "BUILDING",
"HLDGS": "HOLDINGS",
"GRP": "GROUP",
"INVSTMNTS": "INVESTMENTS",
"FMLY": "FAMILY",
"CO": "COMPANY",
"CORP": "CORPORATION",
"&": "AND",
"APT": "APARTMENT",
"APTS": "APARTMENTS",
}
for k,v in word_replace_map.items():
term = term.replace(" " + k + " ", " " + v + " ")
return term.strip()
def is_exact_match(row, searchTerm):
""" Extract exact matches, including some regex magic. """
search = searchTerm
result = row["BusinessName"]
# examples: LLC, LLP, L L C, L.L.C., L.L.C. L.L.P., L.L.P, LLC.
# Limited Partnership, Limited liability company
p = re.compile("L[\s.]?L[\s,.]?[PC][.]" ,flags=re.IGNORECASE)
replace_map = {
",": "",
"LIMITED LIABILITY COMPANY":"LLC",
"LIMITED PARTNERSHIP": "LLC",
"APARTMENTS": "APTS",
"LTD PS": "LLC",
"LTD PARTNERSHIP": "LLC",
}
result= re.sub(p, "LLC", result)
search=re.sub(p, "LLC", search)
return normalize_name(search) == normalize_name(result)
for k,v in replace_map.items():
result = result.replace(k, v)
search = search.replace(k, v)
return search == result
exact_matches = self._get_empty_df()
potential_matches = self._get_empty_df()