本文介绍了在模糊模糊中使用 Process.extract 和所有最大相似选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下输入-
query = 'Total replenishment lead time (in workdays)'
choices = ['PLANNING_TIME_FENCE_CODE', 'BUILD_IN_WIP_FLAG','Lead_time_planning', 'Total replenishment lead time 1', 'Total replenishment lead time 2']
print(process.extract(query, choices))
我得到以下输出-
[('Total replenishment lead time 1', 92), ('Total replenishment lead time 2', 92), ('Lead_time_planning', 50), ('PLANNING_TIME_FENCE_CODE', 36), ('BUILD_IN_WIP_FLAG', 26)]
但我只想要所有具有最大相似率的最佳选择,即使两个选择的比率相似.
But I just want all the best choices with a maximum similarity ratio even if the ratio is similar for two choices.
请帮忙.
推荐答案
如果我理解您的问题是正确的,您希望收到以下输出:
If I understand your question correct you would like to receive the following output:
[('Total replenishment lead time 1', 92), ('Total replenishment lead time 2', 92)]
您可以通过过滤 process.extract
matches = process.extract(query, choices, limit=None)
max_ratio = matches[0][1]
best_matches = []
for match in matches:
if match[1] != max_ratio:
break
best_matches.append(match)
这篇关于在模糊模糊中使用 Process.extract 和所有最大相似选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!