不基于语义的基于字符串交集的字符串相似度比较

def strIntersection(s0, s1, margin=0.2):
set0, set1 = set([i for i in s0]), set([i for i in s1])
I = set0 & set1
return len(I) / len(set0) >= margin or len(I) / len(set1) >= margin


def diffStr(str_, list_, margin_=0.4):
b = False
for i in list_:
b = strIntersection(str_, i, margin_)
if b:
print(str_, i)
return True
return b



原文地址:https://www.cnblogs.com/rsapaper/p/9999046.html