def is_eq_preds(p1, p2):
"""
Return whether these two predicates are equal, with fuzzy string matching.
:param x: the first predicate
:param y: the second predicate
:return: Whether they are equal
"""
global nlp
# Levenshtein distance mostly
if fuzz.ratio(p1, p2) >= 90:
return True
# Same verb
if p1.replace('{a0} ', '{a0} be ') == p2 or p1.replace('{a0} ', '{a0} have ') == p2 or \
p2.replace('{a0} ', '{a0} be ') == p1 or p2.replace('{a0} ', '{a0} have ') == p1:
return True
return False
评论列表
文章目录