dice-similarity-coeff
v1.1.1
Published
Find similarity between two strings, based on Dice Similarity Coefficient DSC
Downloads
162
Maintainers
Readme
dice-similarity-coeff
The Dice Similarity Coefficient is a simple and elegant way to calculate a measure of the similarity of two strings. The values produces are bounded between zero and one.
The algorithm works by comparing the number of identical character pairs between the two strings.
Install
npm install dice-similarity-coeff --save
or
yarn install dice-similarity-coeff
Running the tests
you need to install jest
npm test
or
yarn test
Usage
import dsc from 'dice-similarity-coeff';
let result = dsc.twoStrings('Hello World', 'Hello es6');
Examples
import dsc from 'dice-similarity-coeff';
dsc.twoStrings('hello world','hello es6')
// 0.5
dsc.twoStrings('hello world','hello world!')
// 0.9473684210526315
dsc.twoStrings('google','facebook')
// 0.16666666666666666
dsc.twoStrings('github','microsoft')
// 1 (it is just joke result = 0)
dsc.simSort('hello',['hella','world','helloo','hel'])
// ["helloo","hella","hel","world"]
Author
kerim selmi karimation
License
This project is licensed under the MIT License