webkal / utils /matcher.py
Clemenz88's picture
Upload 2 files
99812b0 verified
from difflib import get_close_matches
# Simple mapping from English label to Danish synonym
mapping = {
"french_fries": "pommes frites",
"pizza": "pizza",
"ice_cream": "is",
"apple_pie": "æbletærte",
"grilled_salmon": "grillet laks"
# ... tilføj flere som ønsket
}
def oversæt_fuzzy(label):
match = get_close_matches(label, mapping.keys(), n=1, cutoff=0.5)
return mapping[match[0]] if match else label