给定两个句子串计算余弦相似度从…Python:tf-idf-cosine:查找文档相似性,利用TF-下手余弦计算文档相似度是可能的.在不导入外部库的情况下,这是计算两个字符串之间余弦相似性的任何方法吗?s1 = "This is a foo bar sentence ."s2 = "This sentence is similar to a foo bar sentence ."s3 = "What is this string ? Totally not related to the other two lines ."cosine_sim(s1, s2) # Should give high cosine similaritycosine_sim(s1, s3) # Shouldn't give high cosine similarity valuecosine_sim(s2, s3) # Shouldn't give high cosine similarity value
添加回答
举报
0/150
提交
取消