var didyoumean = require("didyoumean")
didyoumean.threshold = null;
var input = 'follower';
var list = ['follow', 'justsomethingrandom'];
let result = didyoumean(input, list);
console.log(result);
// > "justsomethingrandom"
However, the distance from follower to follow is 2 and from follower to justsomethingrandom 16. This obviously should return follow instead of justsomethingrandom.
General it seems that strings, which have a distance that includes more than 1 deletion are not matched at all.
Edit:
After some debugging I think the problem is due to line 239 and 240 in didYouMean-1.2.1.js:
maxJ = lenb + 1;
if (maxJ > max + i) maxJ = max + i;
I don't see why maxJ is restricted to length + 1, to my mind maxJ should be lenb + max.
Anyway, replacing that two lines with
maxJ = lenb + max;
seems to work fine, but maybe I'm missing something.
There seems to be a bug if an input string is more than one character longer then an correlating string from the list.
Code for reproduction (runkit):
However, the distance from follower to follow is 2 and from follower to justsomethingrandom 16. This obviously should return follow instead of justsomethingrandom.
General it seems that strings, which have a distance that includes more than 1 deletion are not matched at all.
Edit:
After some debugging I think the problem is due to line 239 and 240 in didYouMean-1.2.1.js:
I don't see why maxJ is restricted to length + 1, to my mind
maxJ
should belenb + max
.Anyway, replacing that two lines with
seems to work fine, but maybe I'm missing something.