Calculating string similarity as a percentage

后端 未结 3 739
有刺的猬
有刺的猬 2021-01-21 01:02

The given function uses \"stringdist\" package in R and tells the minimum changes needed to change one string to another. I wish to find out how much similar is one string to an

3条回答
  •  遇见更好的自我
    2021-01-21 01:32

    You can use RecordLinkage package and use the function levenshteinSim, i.e.

    #This gives the similarity
    RecordLinkage::levenshteinSim('abc', 'abcd')
    #[1] 0.75
    
    #so to get the distance just subtract from 1, 
    1 - RecordLinkage::levenshteinSim('abc', 'abcd')
    #[1] 0.25
    

提交回复
热议问题