Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dice-similarity-coeff

selmi-karim77MIT1.1.1

Find similarity between two strings, based on Dice Similarity Coefficient DSC

string, string-matching, similarity, string-similarity, string-compare, dice, dice-similarity, javascript, rn-strings-filter, rn-string-matching, rn-strig-compare, react-native

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

changelog