def fuzzy_match_strings(ref, val):
"""
Returns the matching score of two values.
"""
if not ref or not val:
return 0
ref_q = to_q(ref)
val_q = to_q(val)
if ref_q or val_q:
return 100 if ref_q == val_q else 0
simplified_val = unidecode(val).lower()
simplified_ref = unidecode(ref).lower()
# Return symmetric score
r1 = fuzz.token_sort_ratio(simplified_val, simplified_ref)
r2 = fuzz.token_sort_ratio(simplified_ref, simplified_val)
r2 = r1
return int(0.5*(r1+r2))
评论列表
文章目录