string-similarity icon indicating copy to clipboard operation
string-similarity copied to clipboard

compareTwoStrings with arguments length lower than 3 since

Open Flo0806 opened this issue 3 years ago • 1 comments

Hello!

If I try to compare two strings like compareTwoStrings("set", "st"); the result is always 0. Strings with length lower than 3 cannot be compared.

Is this normal?

Greatings!

Flo0806 avatar Jul 01 '22 18:07 Flo0806

In your example, 0 is the correct value of the Dice coefficient. The two string do not have any bigrams in common.

It can give non-zero results for strings of length two and three:

compareTwoStrings("abc", "abc") === 1
compareTwoStrings("abc", "ab") === compareTwoStrings("abc", "bc") === 2/3

dlnnlsn avatar Nov 02 '22 14:11 dlnnlsn