从 Fuzzywuzzy 获取匹配的 token 列表

Get the list of matching token from Fuzzywuzzy

我正在使用 fuzzywuzzy token_set_ratio 来匹配 2 强。我想知道匹配的标记。 fuzzywuzzy 中有这样做的功能吗?

字符串 1="this is a banana tree" String2="there is banana tree next to my house"

在这种情况下 token_set_ratio 是:85

匹配的标记将是 banana,tree,is 我想把它作为列表

我希望输出为 [banana,tree,is]

代码:

import fuzzywuzzy
from fuzzywuzzy import process

s1 = "this is a banana tree" 
s2 = "there is banana tree next to my house"

onegram1 = s1.split()
onegram2 = s2.split()

dummy_list = []
for i in onegram1:  
    matches = fuzzywuzzy.process.extract(i,onegram2,scorer=fuzzywuzzy.fuzz.token_sort_ratio)
    for i,j in matches:
        if j > 85:
            dummy_list.append(i)

输出:

dummy_list   
Out[24]: ['is', 'banana', 'tree']