Awesome Open Source
Awesome Open Source

dice-coefficient

Build Coverage Downloads Size

SrensenDice coefficient.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install dice-coefficient

API

This package exports the following identifiers: diceCoefficient. There is no default export.

import {diceCoefficient} from 'dice-coefficient'

diceCoefficient('abc', 'abc') // => 1
diceCoefficient('abc', 'xyz') // => 0
diceCoefficient('night', 'nacht') // => 0.25
diceCoefficient('night', 'nacht') === dice('NiGhT', 'NACHT') // => true

CLI

Usage: dice-coefficient [options] <word> <word>

SrensenDice coefficient

Options:

  -h, --help           output usage information
  -v, --version        output version number

Usage:

# output edit distance
$ dice-coefficient night nacht
# 0.25

# output edit distance from stdin
$ echo "saturday sunday" | dice-coefficient
# 0.3333333333333333

Related

License

MIT Titus Wormer


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,552,287
Index (407
Dice (257
Similarity (150
Related Projects