ksdc
Measure how similar two strings are using the Sørensen–Dice Coefficient
Install
$ npm install ksdc
Or if you prefer using Yarn:
$ yarn add ksdc
Usage
// => 0.25 const compareNightWith = // => {// => bestMatch: { score: 0.5714285714285714, index: 0, reference: 'heal' },// => matches: [// => { score: 0.5714285714285714, reference: 'heal' },// => { score: 0, reference: 'thing' }// => ]// => } const findMatchFromList =
API
compareStrings(reference, input)
Compare input
with reference
, returns the Sørensen–Dice coefficient between the two strings.
This is a curried function. If input
is not provided a function that accepts input
as an argument is returned.
reference
Type: string
input
Type: string
findMatch(references, input)
Compare input
with a list of strings, references
, and finds the best match for it, returns an object that has the following properties:
This is a curried function. If input
is not provided a function that accepts input
as an argument is returned.
references
Type: string[]
input
Type: string
Browser support
The latest version of Chrome, Firefox, Safari, and Edge.
Node.js support
Node.js 12 or later.