如何在另一个句子中找到最匹配的句子
matchSentence = ["weather in", "weather at", "weather on"]
sentence = "weather on monday"
for item in matchSentence:
''' here get the index of the `item`
if all the words are in the `item` is in the `sentence`
'''
我正在寻找一个函数,它将检查sentence
中是否存在所有单词
Desired result is: 2
找到最相似句子的一种方法是计算每个单词在目标句子中出现的次数
您可以使用
in
运算符:输出:
但它在很多情况下都不起作用,比如
您可以将模块^{} 用于以下情况:
第一轮:
输出:
第二轮:
输出:
如您所见,
1
表示尽可能多的相似性(相同),而0
表示最少的相似性(完全没有公共字符)相关问题 更多 >
编程相关推荐