Percentage rank of matches using Levenshtein Distance matching

后端 未结 6 1848
既然无缘
既然无缘 2020-12-14 02:19

I am trying to match a single search term against a dictionary of possible matches using a Levenshtein distance algorithm. The algorithm returns a distance expressed as numb

6条回答
  •  臣服心动
    2020-12-14 02:25

    I had a similar problem and this thread helped me to figure out a solution. Hope it can help others too.

    int levDis = Lev_distance(Q, Mi)
    int bigger = max(strlen(Q), strlen(Mi))
    double pct = (bigger - levDis) / bigger
    

    It should return 100% if both strings are exactly the same and 0% if they are totaly different.

    (sorry if my english isn't that good)

提交回复
热议问题