可以使用word2vec预训练模型(GoogleNews-vectors-negative300)或wordnet获得两个单词列表之间的相似度平均值:
dic_email=['email','e-mail','address'] # dictionary of email contain word similar to email
dic_identity=['name','first','last','identity','forename']
lista = ['fullname','user'] # fullname is similar to name
listb = ['phone','number']
resa=lista.compare(dic_email,dic_identity) #just an example of my function compare
restb=listb.compare(dic_email,dic_identity)
print('the percent of similarity is :'+resa)
print('the percent of similarity is :'+resb)
结果应为:
the percent of similarity is : [('dic_identity',0.8),('dic_email',0.0)] # i just gives a rondom percent to explain lista is similar to dic_identity beacause fullname is similar to the item in dic_identity
the percent of similarity is : [('dic_identity',0.0),('dic_email',0.0)]