python单词相似度计算_计算单词表之间的相似度

该博客展示了如何使用Python计算两个单词列表的余弦相似度,具体包括逐个单词的余弦相似度计算,并给出了使用Counter计算整个列表相似度的方法。
摘要由CSDN通过智能技术生成

既然你还没能真正演示出晶体输出,那么我最好的办法是:list_A = ['email','user','this','email','address','customer']

list_B = ['email','mail','address','netmail']

在上面两个列表中,我们将找到列表中每个元素与其余元素之间的余弦相似性。i、 e.email来自list_B,其中list_A中的每个元素:

^{pr2}$

输出:The cosine similarity between : email and : email is: 100.0

The cosine similarity between : mail and : email is: 89.44271909999159

The cosine similarity between : address and : email is: 26.967994498529684

The cosine similarity between : netmail and : email is: 84.51542547285166

The cosine similarity between : email and : user is: 22.360679774997898

The cosine similarity between : mail and : user is: 0.0

The cosine similarity between : address and : user is: 60.30226891555272

The cosine similarity between : netmail

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值