Spaces:
Sleeping
Sleeping
Update retriever.py
Browse files- retriever.py +0 -13
retriever.py
CHANGED
|
@@ -34,12 +34,6 @@ class HybridRetriever:
|
|
| 34 |
self.vectorizer = TfidfVectorizer(stop_words=None)
|
| 35 |
self.sparse_matrix = self.vectorizer.fit_transform(self.texts)
|
| 36 |
|
| 37 |
-
# this is just a temporary hard-coded fix for correctly matching this municipality in the UI retrieval,
|
| 38 |
-
# since ' is still not recognized in municipality extraction
|
| 39 |
-
self._overrides = {
|
| 40 |
-
"capo d orlando": "capo d"
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
def fuzzy_match(self, municipality_ref, user_input, threshold=80):
|
| 44 |
"""
|
| 45 |
Fuzzy-matches stored municipality against user input.
|
|
@@ -59,13 +53,6 @@ class HybridRetriever:
|
|
| 59 |
ref = normalize(municipality_ref)
|
| 60 |
inp = normalize(user_input)
|
| 61 |
|
| 62 |
-
# override check: if the normalized input matches a key, force match
|
| 63 |
-
if inp in self._overrides:
|
| 64 |
-
# normalize the override target and compare to this ref
|
| 65 |
-
override_target = normalize(self._overrides[inp])
|
| 66 |
-
if ref == override_target:
|
| 67 |
-
return True
|
| 68 |
-
|
| 69 |
# Compute fuzzy match score
|
| 70 |
score = fuzz.ratio(ref, inp)
|
| 71 |
|
|
|
|
| 34 |
self.vectorizer = TfidfVectorizer(stop_words=None)
|
| 35 |
self.sparse_matrix = self.vectorizer.fit_transform(self.texts)
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
def fuzzy_match(self, municipality_ref, user_input, threshold=80):
|
| 38 |
"""
|
| 39 |
Fuzzy-matches stored municipality against user input.
|
|
|
|
| 53 |
ref = normalize(municipality_ref)
|
| 54 |
inp = normalize(user_input)
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# Compute fuzzy match score
|
| 57 |
score = fuzz.ratio(ref, inp)
|
| 58 |
|