mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
perf: use score_cutoff for fuzzy string matching (#2553)
This commit is contained in:
parent
9a04b11ee5
commit
15c6df88ab
@ -96,15 +96,13 @@ class ABCIngredientParser(ABC):
|
||||
return store_map[match_value]
|
||||
|
||||
# fuzzy match against food store
|
||||
fuzz_result = process.extractOne(match_value, store_map.keys(), scorer=fuzz.ratio)
|
||||
fuzz_result = process.extractOne(
|
||||
match_value, store_map.keys(), scorer=fuzz.ratio, score_cutoff=fuzzy_match_threshold
|
||||
)
|
||||
if fuzz_result is None:
|
||||
return None
|
||||
|
||||
choice, score, _ = fuzz_result
|
||||
if score < fuzzy_match_threshold:
|
||||
return None
|
||||
else:
|
||||
return store_map[choice]
|
||||
return store_map[fuzz_result[0]]
|
||||
|
||||
def find_food_match(self, food: IngredientFood | CreateIngredientFood) -> IngredientFood | None:
|
||||
if isinstance(food, IngredientFood):
|
||||
|
Loading…
x
Reference in New Issue
Block a user