edit-distance-vector

Calculate edit distances and edit scripts between vectors. https://github.com/thsutton/edit-distance-vector

Version on this page:1.0.0.4
LTS Haskell 9.18:1.0.0.4
Stackage Nightly 2017-12-14:1.0.0.4
Latest on Hackage:1.0.0.4
BSD3 licensed by Thomas Sutton
Maintained by me@thomas-sutton.id.au

Module documentation for 1.0.0.4

Edit Distance: Vector

Build Status

This is a small library for calculating the edit distance and edit script between two vectors. It is generic enough that you should be able to use it with vectors containing values of any type you like, with changes described by any type you like, and with costs represented by any type you like (with a few restrictions).

Installing

The edit-distance-vector package is a normal Haskell library and can be installed using the Cabal package management tool.

{bash} cabal update cabal install edit-distance-vector

edit-distance-vector is automatically tested on GHC versions 7.4.2, 7.6.3, 7.8.3, 7.10.1, 8.0.2 using the Travis CI service.

Usage

The interface to edit-distance-vector is very small; just import Data.Vector.Distance, create a Params value with the correct operations to deal with your types, and pass this to leastChanges along with your Vectors.

{haskell} import Data.Monoid

import qualified Data.Vector as V import Data.Vector.Distance

-- | Editing vectors of 'Char' values, with '(String, Int, Char)' describing -- changes, and the additive monoid of 'Int' describing costs. str :: Params Char (String, Int, Char) (Sum Int) str = Params { equivalent = (==) , delete = \i c -> ("delete", i, c) , insert = \i c -> ("insert", i, c) , substitute = \i c c' -> ("replace", i, c') , cost = const (Sum 1) , positionOffset = \ (op, , ) -> if op == "delete" then 0 else 1 }

main :: IO () main = do print $ leastChanges str (V.fromList "I am thomas") (V.fromList "My name is Thomas")

(See test/sample.hs for a version of this code that is compiled by the automated test suite.)

Changes

edit-distance-vector 1.0.0.4

* Relax version bounds to support GHC 8.0

edit-distance-vector 1.0.0.3

* Relax version bounds to support GHC 7.6.3 and 7.4.2

edit-distance-vector 1.0.0.2

* Relax version bounds to support GHC 7.6.3 and 7.4.2

edit-distance-vector 1.0.0.1

* Relax version bounds to support GHC 7.10.1.

edit-distance-vector 1.0

* Initial release extracted from aeson-diff package and rewritten to use
  Data.Vector.
Depends on 2 packages:
Used by 2 packages:
comments powered byDisqus