[READ-ONLY] Mirror of https://github.com/FoxxMD/string-sameness. Compare the sameness of two strings foxxmd.github.io/string-sameness/
compare cosine-similarity dice-coefficient levenshtein-distance sameness string text typescript
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(leven): Use shorter length for score generation

FoxxMD (Oct 26, 2023, 1:16 PM EDT) e12a662d f5819da3

+5 -1
+5 -1
src/matchingStrategies/levenSimilarity.ts
··· 13 13 } 14 14 15 15 const distance = leven(longer, shorter); 16 - const diff = (distance / longer.length) * 100; 16 + // use the shorter length 17 + // because if we have more move/change operations than the length of the shortest string than we have two unique strings 18 + // and if we use the longer length the score actually gets *better* as the length gap gets larger (not what we want) 19 + // -- cap at 100% diff 20 + const diff = Math.min((distance / shorter.length) * 100, 100); 17 21 return [distance, 100 - diff]; 18 22 } 19 23