UNPKG

fast-dice-coefficient

Version:

Fastest implementation of Sørensen–Dice coefficient.

41 lines (29 loc) 1.28 kB
// Generated by CoffeeScript 2.3.1 var Benchmark, dice, diceCoefficient, levenshtein, natural, str1, str2, stringSimilarity, suite; Benchmark = require('benchmark'); suite = new Benchmark.Suite; Benchmark.options.minSamples = 100; dice = require('./dice'); diceCoefficient = require('dice-coefficient'); stringSimilarity = require('string-similarity'); natural = require('natural'); levenshtein = require('fast-levenshtein'); str1 = 'kvhjzsb iasbgszpopcvsk fbsdkuzbjfszkbdkuv bsdguajwrsdbsigubsvja bubnncepqei wpqweqotpwq brnwnerwervw'; str2 = 'sdyusu webhfwew wenjwejnkwejn ewrnjkwrnjkwern kqnewnrener bertbertbqhqwbeghewrrpe owieoweowerbevevwq'; suite.add('fast-levenshtein', function() { return levenshtein.get(str1, str2); }).add('stringSimilarity', function() { return stringSimilarity.compareTwoStrings(str1, str2); }).add('natural.DiceCoefficient', function() { return natural.DiceCoefficient(str1, str2); }).add('dice-coefficient', function() { return diceCoefficient(str1, str2); }).add('fast-dice-coefficient', function() { return dice(str1, str2); }).on('cycle', function(event) { console.log(String(event.target)); }).on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')); }).run({ 'async': true });