JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 56817
  • Score
    100M100P100Q154648F
  • License MIT

Calculates similarity between two strings

Package Exports

  • string-similarity-js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (string-similarity-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status codecov Wallaby.js

String Similarity

A simple, lightweight string similarity function based on comparing the number of substrings (typically letter pairs) in common between any two strings. Returns a score between 0 and 1 indicated the strength of the match.

~500 bytes minified

This algorithm is most effective at detecting rearranged words or misspellings. It tends to be less effective with very short strings. Always returns 0 for strings <= 2 characters in length. Does not ignore punctuation or spaces.

Usage

import {getStringSimilarity} from "string-similarity";

// Rearranged words
getStringSimilarity("Lorem ipsum", "Ipsum lorem") // Returns a score of 0.9

// Typos
getStringSimilarity("The quick brown fox jumps over the lazy dog", "The quck brwn fox jumps over the lazy dog") // Returns ~0.92

License

This project is licensed under the MIT License - see the LICENSE.md file for details