language-spelling-0.3: Various tools to detect/correct mistakes in words

Safe HaskellNone

Language.Distance

Contents

Description

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

Right now, two algorithms are provided, Levenshtein and DamerauLevenshtein.

Synopsis

Types

data Distance algo Source

Instances

Eq (Distance algo) 
Eq (Distance algo) => Ord (Distance algo) 
Show (Distance algo) 

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.

Methods

distance :: ListLike full sym => full -> full -> Distance algoSource

Instances

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.

Instances

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

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