我正在使用fuzzywuzzy和rapidfuzz来查找评论中提到的名字。我通读了"token_set_ratio“函数的文档,但我仍然不理解以下内容:
# I preprocessed the comments to remove stop words and commonly mentioned other words
fuzz.token_set_ratio("reporting michael anders sven straumann guy called jonatjan smith partners","jonathan smith")
# returns 52.6乔纳森·史密斯只有一个拼写错误,为什么这个比例这么低?
此外,有没有办法克服这个问题,让乔纳森得到更高的分数?
谢谢你的帮助,迈克尔
发布于 2020-10-09 15:36:59
对于您的问题,Fuzz.token_set_ratio并不是真正合适的比例,因为它会对单词进行排序,而您希望保留名字和第二个名字的配对。您可以使用fuzz.partial_ratio将较长字符串的最佳匹配子字符串与较短字符串进行比较。
fuzz.partial_ratio(
"reporting michael anders sven straumann guy called jonatjan smith partners",
"jonathan smith")
# returns 92.85714285714286https://stackoverflow.com/questions/64259997
复制相似问题