# fast-dice-coefficient

> Fastest implementation of Sørensen–Dice coefficient.

Latest version **1.0.3** (published 2018-11-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install fast-dice-coefficient
pnpm add fast-dice-coefficient
yarn add fast-dice-coefficient
bun add fast-dice-coefficient
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2018-11-17 |
| First published | 2018-11-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Maintainers | ka-weihe |
| Keywords | sorensen, dice, coefficient, string, similarity, fast |

## Links

- npm: https://www.npmjs.com/package/fast-dice-coefficient
- Repository: https://github.com/ka-weihe/fast-dice-coefficient
- Homepage: https://github.com/ka-weihe/fast-dice-coefficient#readme
- Issues: https://github.com/ka-weihe/fast-dice-coefficient/issues
- npm.io page: https://npm.io/package/fast-dice-coefficient

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2018-11-17
- 1.0.2 — 2018-11-16
- 1.0.1 — 2018-11-16
- 1.0.0 — 2018-11-16

## README

# fast-dice-coefficient
Fastest implementation of [Sørensen–Dice coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient). This implementation has linear time complexity O(n), as opposed to other solutions: [string-similarity](https://www.npmjs.com/package/string-similarity), [dice-coefficient](https://www.npmjs.com/package/dice-coefficient), etc., running in quadratic time O(n<sup>2</sup>).

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
``` javascript
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   |

---
_Source: https://npm.io/package/fast-dice-coefficient · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
