我正在使用 Pythonfuzzywuzzy
在句子列表中查找匹配项:
def getMatches(needle):
return process.extract(needle, bookSentences, scorer=fuzz.token_sort_ratio, limit=3)
我正在尝试打印匹配以及它周围的句子:
for match in matches:
matchIndex = bookSentences.index(match)
sentenceIndices = range(matchIndex-2,matchIndex+2)
for index in sentenceIndices:
print bookSentences[index],
print '\n\n'
不幸的是,脚本无法在原始列表中找到匹配项:
ValueError: (u'因此,除了上面提到的双重目的,这本书至少是为两个群体写的:1.', 59) 不在列表中
有没有更好的方法在原始列表中找到匹配的索引?有的可以fuzzywuzzy
给我吗?自述文件中似乎没有任何关于它的内容。
如何获取由返回的匹配项的原始列表中的索引fuzzywuzzy
?