MCPcopy Create free account
hub / github.com/caesarHQ/textSQL / replace_unsupported_localities

Function replace_unsupported_localities

api/app/api/routes.py:20–37  ·  view source on GitHub ↗
(original_string, scope="USA")

Source from the content-addressed store, hash-verified

18from .utils.logging.sentry import capture_exception
19
20def replace_unsupported_localities(original_string, scope="USA"):
21 if scope == "USA":
22 new_string = re.sub(r'\bneighborhood\b', 'zipcode', original_string, flags=re.IGNORECASE)
23 new_string = re.sub(r'\bneighborhoods\b', 'zipcodes', new_string, flags=re.IGNORECASE)
24 new_string = re.sub(r'\barea\b', 'zipcode', new_string, flags=re.IGNORECASE)
25 new_string = re.sub(r'\bareas\b', 'zipcodes', new_string, flags=re.IGNORECASE)
26 new_string = re.sub(r'\bplace\b', 'zipcode', new_string, flags=re.IGNORECASE)
27 new_string = re.sub(r'\bplaces\b', 'zipcodes', new_string, flags=re.IGNORECASE)
28 new_string = re.sub(r'\bpart\b', 'zipcode', new_string, flags=re.IGNORECASE)
29 new_string = re.sub(r'\bparts\b', 'zipcodes', new_string, flags=re.IGNORECASE)
30 elif scope == "SF":
31 new_string = re.sub(r'\barea\b', 'neighborhood', original_string, flags=re.IGNORECASE)
32 new_string = re.sub(r'\bareas\b', 'neighborhoods', new_string, flags=re.IGNORECASE)
33 new_string = re.sub(r'\bplace\b', 'neighborhood', new_string, flags=re.IGNORECASE)
34 new_string = re.sub(r'\bplaces\b', 'neighborhoods', new_string, flags=re.IGNORECASE)
35 new_string = re.sub(r'\bpart\b', 'neighborhood', new_string, flags=re.IGNORECASE)
36 new_string = re.sub(r'\bparts\b', 'neighborhoods', new_string, flags=re.IGNORECASE)
37 return new_string
38
39
40bp = Blueprint('api_bp', __name__)

Callers 2

get_tablesFunction · 0.85
text_to_sqlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected