[READ-ONLY] Mirror of https://github.com/FoxxMD/string-sameness. Compare the sameness of two strings foxxmd.github.io/string-sameness
README.md
# string-sameness Generate scores that represents how similar two strings are based on different string comparison algorithms. Scores from all used algorithms are averaged and then weighted by the length of the content being compared (more weight for longer content). The sameness is then given a **score of 0 to 100.** * 0 => Totally unique pieces of content * 100 => Identical content # Install/Usage ``` npm install @foxxmd/string-sameness ``` ```js import {stringSameness} from '@foxxmd/string-sameness'; const result = stringSameness('This is one sentence', 'This is another sentence'); console.log(result); // { // "strategies": { // "dice": { // "rawScore": 0.6666, // "score": 66.66 // }, // "leven": { // "rawScore": 5, // "distance": 5, // "score": 79.16 // }, // "cosine": { // "rawScore": 0.75, // "score": 75 // } // }, // "highScore": 73.61, // "highScoreWeighted": 83.58 // } ``` # Options An optional third argument can be provided to `stringSameness` to customize how strings are normalized before comparison and what strategies are used for comparison. ## Strategies Pass a list of `ComparisonStrategy` objects using `{strategies: []}` to define which string comparisons should be performed on the given strings. The average of the scores from all passed strategies is returned as `highScore` (and `highScoreWeighted`) from `stringSameness()` When no strategies are explicitly passed a default set of strategies is used, found in `import {defaultStrategies} from @foxxmd/string-sameness;`: * [Dice's Coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient) in [`diceSimilarities.ts`](/src/matchingStrategies/diceSimilarity.ts) * [Cosine Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) in [`cosineSimilarities.ts`](/src/matchingStrategies/cosineSimilarity.ts) * [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_d…