# `Similarity.SorensenDice`
[🔗](https://github.com/preciz/similarity/blob/v0.5.1/lib/similarity/sorensen_dice.ex#L1)

String similarity comparison with the Sorensen-Dice algorithm.

[Wikipedia](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient)

# `sorensen_dice`

Calculates the similarity between the left and right attributes,
using Sorensen-Dice coefficient.

Attribute can be a string, list or a MapSet.

Raises `ArgumentError` when `:ngram_size` is not a positive integer or either
string is shorter than it, including when the strings are identical.

## Examples

    iex> Similarity.SorensenDice.sorensen_dice("alma", "korte")
    0.0

    iex> Similarity.SorensenDice.sorensen_dice("alma", "alma")
    1.0

    iex> Similarity.SorensenDice.sorensen_dice("just letters", "letters just", ngram_size: 1)
    1.0

    iex> Similarity.SorensenDice.sorensen_dice("this that", "just that")
    0.42857142857142855

    iex> Similarity.SorensenDice.sorensen_dice([1, 2, 3], [1, 2, 3])
    1.0

    iex> Similarity.SorensenDice.sorensen_dice([1, 2, 3], [1, 2, 3, 4])
    0.8571428571428571

---

*Consult [api-reference.md](api-reference.md) for complete listing*
