[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 import example

FoxxMD (Apr 4, 2023, 1:56 PM EDT) 44449e27 40068eef

+5 -5
+5 -5
README.md
··· 20 20 ``` 21 21 22 22 ```js 23 - import compare from '@foxxmd/string-sameness'; 23 + import {stringSameness} from '@foxxmd/string-sameness'; 24 24 25 - const result = compare('This is one sentence', 'This is another sentence'); 25 + const result = stringSameness('This is one sentence', 'This is another sentence'); 26 26 console.log(result); 27 27 // { 28 28 // "scores": { ··· 37 37 38 38 ### Normalization 39 39 40 - A third argument may be passed to `compare` to provide a list of functions to apply to the strings to compare. When not explicitly provided a default set of functions is applied to normalize the strings (to remove trivial differences): 40 + A third argument may be passed to `stringSameness` to provide a list of functions to apply to the strings to compare. When not explicitly provided a default set of functions is applied to normalize the strings (to remove trivial differences): 41 41 42 42 * convert to lowercase 43 43 * trim (remove whitespace at beginning/end) ··· 49 49 Example of supplying your own transform functions: 50 50 51 51 ```js 52 - import compare, {defaultStrCompareTransformFuncs} from '@foxxmd/string-sameness'; 52 + import {stringSameness, defaultStrCompareTransformFuncs} from '@foxxmd/string-sameness'; 53 53 54 54 const myFuncs = [ 55 55 ...defaultStrCompareTransformFuncs, ··· 57 57 (str) => str.replace(/[aeiou]/ig, 'e') 58 58 ] 59 59 60 - const result = compare('This is one sentence', 'This is another sentence', myFuncs); 60 + const result = stringSameness('This is one sentence', 'This is another sentence', myFuncs); 61 61 ```