mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-04 21:15:22 +02:00
perf: use score_cutoff for fuzzy string matching (#2553)
This commit is contained in:
parent
9a04b11ee5
commit
15c6df88ab
1 changed files with 4 additions and 6 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue