fast-dice-coefficient

1.0.3 • Public • Published

fast-dice-coefficient

Fastest implementation of Sørensen–Dice coefficient. This implementation has linear time complexity O(n), as opposed to other solutions: string-similarity, dice-coefficient, etc., running in quadratic time O(n2).

This algorithm can be used to compute the similarity between strings. It return a fraction between 0 and 1, where 0 indicates no match and 1 indicates full match.

Install

$ npm install fast-dice-coefficient --save

Usage

var dice = require('fast-dice-coefficient');
 
console.log(dice('javascript', 'coffeescript'));
//=> 0.5

Benchmark

200 samples on i7-3667u with 8GB RAM.

Using two test-strings with 100 characters each.

First 4 packages uses dice-coefficient and last uses levenshtein.

Package ops/sec
stringSimilarity 7,590
natural.DiceCoefficient 11,117
dice-coefficient 14,732
fast-dice-coefficient 44,067
fast-levenshtein 4,495

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    369
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    369
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i fast-dice-coefficient

Weekly Downloads

369

Version

1.0.3

License

ISC

Unpacked Size

6.03 kB

Total Files

9

Last publish

Collaborators

  • ka-weihe