Optimizing Jaro-Winkler algorithm

前端 未结 6 2024
孤独总比滥情好
孤独总比滥情好 2021-02-05 13:45

I have this code for Jaro-Winkler algorithm taken from this website. I need to run 150,000 times to get distance between differences. It takes a long time, as I run on an Androi

6条回答
  •  时光取名叫无心
    2021-02-05 14:27

    I know this question has probably been solved for some time, but I would like to comment on the algorithm itself. When comparing a string against itself, the answer turns out to be 1/|string| off. When comparing slightly different values, the values also turn out to be lower.

    The solution to this is to adjust 'm-1' to 'm' in the inner for-statement within the getCommonCharacters method. The code then works like a charm :)

    See http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance as well for some examples.

提交回复
热议问题