def is_eq_arg(x, y):
"""
Return whether these two words are equal, with fuzzy string matching.
:param x: the first argument
:param y: the second argument
:return: Whether they are equal
"""
if fuzz.ratio(x, y) >= 90:
return True
# Convert numbers to words
x_words = [num2words(int(w)).replace('-', ' ') if w.isdigit() else w for w in x.split()]
y_words = [num2words(int(w)).replace('-', ' ') if w.isdigit() else w for w in y.split()]
# Partial entailment with equivalence, e.g. 'two girls' -> 'two kids':
return fuzz.ratio(' '.join(x_words), ' '.join(y_words)) >= 85
评论列表
文章目录