fast-levenshtein icon indicating copy to clipboard operation
fast-levenshtein copied to clipboard

returning the wrong distance

Open zdrd opened this issue 7 years ago • 2 comments

I came across an instance of this returning the incorrect distance, here is a full code snippet to reproduce:

  var levenshtein  = require('fast-levenshtein');
  var a = 'A Microbial communities are very vital in the function of all ecosystems';
  var b1 = 'Microbial communities are vital in the functioning of all ecosystems;';
  var b2 = 't\nMicrobial communities are vital in the functioning of all ecosystems;';

  var leven1 = levenshtein.get(a, b1);
  console.log(leven1); // returns 11 correctly

  var leven2 = levenshtein.get(a, b2);
  console.log(leven2); // should return 12, but returns 11 which is incorrect

zdrd avatar Mar 18 '17 15:03 zdrd

I guess it's the character code (\n) which trips it up?

hiddentao avatar Mar 22 '17 15:03 hiddentao

It is actually correct with 11, \n is only one character, i.e the newline character.

I guess thats what you also say @hiddentao, but just to clarify :)

gustf avatar May 26 '17 19:05 gustf