1levenshtein [](https://travis-ci.org/agnivade/levenshtein) [](https://goreportcard.com/report/github.com/agnivade/levenshtein) [](https://godoc.org/github.com/agnivade/levenshtein)
2===========
3
4[Go](http://golang.org) package to calculate the [Levenshtein Distance](http://en.wikipedia.org/wiki/Levenshtein_distance)
5
6The library is fully capable of working with non-ascii strings. But the strings are not normalized. That is left as a user-dependant use case. Please normalize the strings before passing it to the library if you have such a requirement.
7- https://blog.golang.org/normalization
8
9Install
10-------
11
12 go get github.com/agnivade/levenshtein
13
14Example
15-------
16
17```go
18package main
19
20import (
21 "fmt"
22 "github.com/agnivade/levenshtein"
23)
24
25func main() {
26 s1 := "kitten"
27 s2 := "sitting"
28 distance := levenshtein.ComputeDistance(s1, s2)
29 fmt.Printf("The distance between %s and %s is %d.\n", s1, s2, distance)
30 // Output:
31 // The distance between kitten and sitting is 3.
32}
33
34```
35
36Benchmarks
37----------
38
39```
40name time/op
41Simple/ASCII-4 537ns ± 2%
42Simple/French-4 956ns ± 0%
43Simple/Nordic-4 1.95µs ± 1%
44Simple/Tibetan-4 1.53µs ± 2%
45
46name alloc/op
47Simple/ASCII-4 96.0B ± 0%
48Simple/French-4 128B ± 0%
49Simple/Nordic-4 192B ± 0%
50Simple/Tibetan-4 144B ± 0%
51
52name allocs/op
53Simple/ASCII-4 1.00 ± 0%
54Simple/French-4 1.00 ± 0%
55Simple/Nordic-4 1.00 ± 0%
56Simple/Tibetan-4 1.00 ± 0%
57```