python之計算文本相似度

1.安裝包

pip install python-Levenshtein

2.demo

import Levenshtein
a='abc'
b='abcd'
wer=Levenshtein.distance(a,b)/len(a)
corr=(1-wer)
print(corr)

result:

0.6666666666666667

Process finished with exit code 0
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章