Safe Haskell | None |
---|

Generic interface to calculate the edit instance between two list-like things using various algorithms.

Right now, two algorithms are provided, `Levenshtein`

and
`DamerauLevenshtein`

.

- data Distance algo
- getDistance :: Distance algo -> Int
- class EditDistance sym algo where
- data Levenshtein
- levenshtein :: (ListLike full sym, Eq sym) => full -> full -> Distance Levenshtein
- data DamerauLevenshtein
- damerauLevenshtein :: (ListLike full sym, Ord sym) => full -> full -> Distance DamerauLevenshtein

# Types

getDistance :: Distance algo -> IntSource

class EditDistance sym algo whereSource

Generic typeclass for edit distances. Specify the type manually to use a specific algorithm, for instance

distance "foo" "bar" ::`Distance`

`DamerauLevenshtein`

Monomorphic functions are also provided, see `levenshtein`

and
`damerauLevenshtein`

.

Ord sym => EditDistance sym DamerauLevenshtein | |

Eq sym => EditDistance sym Levenshtein |

# Algorithms

## Levenshtein

data Levenshtein Source

The classic Levenshtein distance, where adding, removing or changing a character are taken into account.

More information: https://en.wikipedia.org/wiki/Levenshtein_distance.

Eq sym => EditDistance sym Levenshtein | |

(Ord sym, ListLike full sym, EditDistance sym Levenshtein) => Search (TSTDist full sym Levenshtein) full Levenshtein |

levenshtein :: (ListLike full sym, Eq sym) => full -> full -> Distance LevenshteinSource

## Damerau-Levenshtein

data DamerauLevenshtein Source

Like `Levenshtein`

, but transpositions are also taken into account:
https://en.wikipedia.org/wiki/Damerau-Levenshtein_distance.

Ord sym => EditDistance sym DamerauLevenshtein | |

(Ord sym, ListLike full sym, EditDistance sym DamerauLevenshtein) => Search (TSTDist full sym DamerauLevenshtein) full DamerauLevenshtein |

damerauLevenshtein :: (ListLike full sym, Ord sym) => full -> full -> Distance DamerauLevenshteinSource