tad-lispy / node-damerau-levenshtein

Damerau - Levenstein distance function for node
BSD 2-Clause "Simplified" License
46 stars 10 forks source link

Incorrect answer for specific strings #21

Open TTPO100AJIEX opened 2 years ago

TTPO100AJIEX commented 2 years ago

Hello! I have been trying to incorporate Damerau-Levenshtein distance into my project, and this library seems to be the best option for me. However, after some testing I found that it does not really count transpositions correctly. Suppose I want to get the distance from CA to ABC. Clearly, the answer is 2: CA -> (transposition) AC -> (insert) ABC. But the package says it was 3 steps: { steps: 3, relative: 1, similarity: 0 } The code to reproduce:

import levenshtein from 'damerau-levenshtein';
const lev = levenshtein('CA', 'ABC');
console.log(lev);

Feel free to correct me, but seems like this is clearly an incorrect answer. I am not exactly sure what the issue is and how to fix, so I would want some assistance here.