...

Text file src/github.com/agnivade/levenshtein/README.md

Documentation: github.com/agnivade/levenshtein

     1levenshtein [![Build Status](https://travis-ci.org/agnivade/levenshtein.svg?branch=master)](https://travis-ci.org/agnivade/levenshtein) [![Go Report Card](https://goreportcard.com/badge/github.com/agnivade/levenshtein)](https://goreportcard.com/report/github.com/agnivade/levenshtein) [![PkgGoDev](https://pkg.go.dev/badge/github.com/agnivade/levenshtein)](https://pkg.go.dev/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
     9#### Limitation
    10
    11As a performance optimization, the library can handle strings only up to 65536 characters (runes). If you need to handle strings larger than that, please pin to version 1.0.3.
    12
    13Install
    14-------
    15
    16    go get github.com/agnivade/levenshtein
    17
    18Example
    19-------
    20
    21```go
    22package main
    23
    24import (
    25	"fmt"
    26	"github.com/agnivade/levenshtein"
    27)
    28
    29func main() {
    30	s1 := "kitten"
    31	s2 := "sitting"
    32	distance := levenshtein.ComputeDistance(s1, s2)
    33	fmt.Printf("The distance between %s and %s is %d.\n", s1, s2, distance)
    34	// Output:
    35	// The distance between kitten and sitting is 3.
    36}
    37
    38```
    39
    40Benchmarks
    41----------
    42
    43```
    44name              time/op
    45Simple/ASCII-4     330ns ± 2%
    46Simple/French-4    617ns ± 2%
    47Simple/Nordic-4   1.16µs ± 4%
    48Simple/Tibetan-4  1.05µs ± 1%
    49
    50name              alloc/op
    51Simple/ASCII-4     96.0B ± 0%
    52Simple/French-4     128B ± 0%
    53Simple/Nordic-4     192B ± 0%
    54Simple/Tibetan-4    144B ± 0%
    55
    56name              allocs/op
    57Simple/ASCII-4      1.00 ± 0%
    58Simple/French-4     1.00 ± 0%
    59Simple/Nordic-4     1.00 ± 0%
    60Simple/Tibetan-4    1.00 ± 0%
    61```
    62
    63Comparisons with other libraries
    64--------------------------------
    65
    66```
    67name                     time/op
    68Leven/ASCII/agniva-4      353ns ± 1%
    69Leven/ASCII/arbovm-4      485ns ± 1%
    70Leven/ASCII/dgryski-4     395ns ± 0%
    71Leven/French/agniva-4     648ns ± 1%
    72Leven/French/arbovm-4     791ns ± 0%
    73Leven/French/dgryski-4    682ns ± 0%
    74Leven/Nordic/agniva-4    1.28µs ± 1%
    75Leven/Nordic/arbovm-4    1.52µs ± 1%
    76Leven/Nordic/dgryski-4   1.32µs ± 1%
    77Leven/Tibetan/agniva-4   1.12µs ± 1%
    78Leven/Tibetan/arbovm-4   1.31µs ± 0%
    79Leven/Tibetan/dgryski-4  1.16µs ± 0%
    80```

View as plain text