text-similarity-scorer is your goto similarity score between two strings
For more informatiom about the future of the package, check out the discussion here.
npm i --save text-similarity-scorer
const similarity = require("text-similarity-scorer");
const score = similarity(
"I HAVE A DREAM", //first sentence
"I HAD A NAP" //second sentence
);
// NOTE : Order matters
console.log(score);
/*
{
matched: [ 0, -1, 2, -1 ],
matchScore: [ 1, 0, 1, 0 ],
exact: 2,
literal: 0,
score: 2,
score_pct: 0.5,
order: 1,
size: 0.25
}
*/
- Adding ability to choose similarity algorithm
MIT