dice-coefficient
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -5,6 +5,20 @@ 'use strict'; | ||
var distance, source; | ||
var distance, source, natural, cljFuzzy; | ||
distance = require('..'); | ||
try { | ||
natural = require('natural').DiceCoefficient; | ||
cljFuzzy = require('clj-fuzzy').metrics.dice; | ||
} catch (error) { | ||
console.log(error); | ||
throw new Error( | ||
'\u001B[0;31m' + | ||
'The libraries needed by this benchmark could not be found. ' + | ||
'Please execute:\n' + | ||
'\tnpm run install-benchmark\n\n' + | ||
'\u001B[0m' | ||
); | ||
} | ||
/* The first 100 words from Letterpress: https://github.com/atebits/Words */ | ||
@@ -118,3 +132,4 @@ source = Array(11).join([ | ||
var iterator = -1, | ||
value, previousValue; | ||
previousValue = source[source.length - 1], | ||
value; | ||
@@ -129,1 +144,31 @@ while (value = source[++iterator]) { | ||
}); | ||
suite('natural', function () { | ||
bench('op/s * 1,000', function (next) { | ||
var iterator = -1, | ||
previousValue = source[source.length - 1], | ||
value; | ||
while (value = source[++iterator]) { | ||
natural(previousValue, value); | ||
previousValue = value; | ||
} | ||
next(); | ||
}); | ||
}); | ||
suite('clj-fuzzy', function () { | ||
bench('op/s * 1,000', function (next) { | ||
var iterator = -1, | ||
previousValue = source[source.length - 1], | ||
value; | ||
while (value = source[++iterator]) { | ||
cljFuzzy(previousValue, value); | ||
previousValue = value; | ||
} | ||
next(); | ||
}); | ||
}); |
{ | ||
"name": "dice-coefficient", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Sørensen–Dice coefficient", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
0.1.0 / 2014-07-14 | ||
================== | ||
* Added competition to benchmarks (fixes #1) | ||
* Update eslint, istanbul | ||
* Removed functionality to browserify unit tests by default | ||
0.0.1 / 2014-06-27 | ||
@@ -3,0 +10,0 @@ ================== |
{ | ||
"name": "dice-coefficient", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Sørensen–Dice coefficient", | ||
@@ -14,5 +14,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"browserify": "^4.1.11", | ||
"eslint": "^0.6.2", | ||
"istanbul": "~0.2.12", | ||
"eslint": "^0.7.4", | ||
"istanbul": "^0.3.0", | ||
"jscs": "^1.5.4", | ||
@@ -34,7 +33,8 @@ "matcha": "^0.5.0", | ||
"lint-style": "node_modules/.bin/jscs index.js spec/dice-coefficient.spec.js benchmark/index.js --reporter=inline", | ||
"prepublish": "npm run build-browser", | ||
"build-browser": "browserify spec/dice-coefficient.spec.js -o spec/browser.spec.js", | ||
"install-browser-test": "npm install browserify", | ||
"build-browser-test": "node_modules/.bin/browserify spec/dice-coefficient.spec.js -o spec/browser.spec.js", | ||
"coverage": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -- spec/dice-coefficient.spec.js", | ||
"benchmark" : "node_modules/.bin/matcha", | ||
"make": "npm run build-browser && npm run lint && npm run coverage" | ||
"install-benchmark": "npm install clj-fuzzy natural", | ||
"make": "npm run lint && npm run coverage" | ||
}, | ||
@@ -41,0 +41,0 @@ "testling": { |
@@ -34,8 +34,32 @@ # dice-coefficient [![Build Status](https://travis-ci.org/wooorm/dice-coefficient.svg?branch=master)](https://travis-ci.org/wooorm/dice-coefficient) [![Coverage Status](https://img.shields.io/coveralls/wooorm/dice-coefficient.svg)](https://coveralls.io/r/wooorm/dice-coefficient?branch=master) | ||
## Other Lancaster implementations | ||
- [NaturalNode/natural](https://github.com/NaturalNode/natural); | ||
- [Yomguithereal/clj-fuzzy](https://github.com/Yomguithereal/clj-fuzzy) — A bit slow. | ||
- [minuteman3/node-dice](https://github.com/minuteman3/node-dice) — Does not check bigrams, rather just unigrams. Thus producing different results (e.g., the difference between “nacht” and “night” according to node-dice is 0.6 rather than, [according to the formula](http://en.wikipedia.org/wiki/Dice%27s_coefficient#Formula), 0.25) | ||
## Benchmark | ||
On a MacBook Air, it runs about 748,000 op/s (run the benchmarks yourself with `npm run benchmark`). | ||
Run the benchmark yourself: | ||
```sh | ||
$ npm run install-benchmark # Just once of course. | ||
$ npm run benchmark | ||
``` | ||
On a MacBook Air, it runs about 748,000 op/s, which is more than 4 times faster than natural. | ||
``` | ||
dice-coefficient | ||
748 op/s » op/s * 1,000 | ||
natural | ||
154 op/s » op/s * 1,000 | ||
clj-fuzzy | ||
10 op/s » op/s * 1,000 | ||
``` | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
5
65
0
14905
11
356
1