Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 11:16:11 +01:00
forgejo/vendor/github.com/couchbase/vellum/levenshtein2
Mura Li d77176912b Use Go1.11 module (#5743)
* Migrate to go modules

* make vendor

* Update mvdan.cc/xurls

* make vendor

* Update code.gitea.io/git

* make fmt-check

* Update github.com/go-sql-driver/mysql

* make vendor
2019-03-27 19:15:23 +08:00
..
alphabet.go Update bleve dependency to latest master revision (#6100) 2019-02-17 19:50:26 -05:00
dfa.go Update bleve dependency to latest master revision (#6100) 2019-02-17 19:50:26 -05:00
levenshtein.go Update bleve dependency to latest master revision (#6100) 2019-02-17 19:50:26 -05:00
levenshtein_nfa.go Update bleve dependency to latest master revision (#6100) 2019-02-17 19:50:26 -05:00
LICENSE Update bleve dependency to latest master revision (#6100) 2019-02-17 19:50:26 -05:00
parametric_dfa.go Update bleve dependency to latest master revision (#6100) 2019-02-17 19:50:26 -05:00
README.md Use Go1.11 module (#5743) 2019-03-27 19:15:23 +08:00

levenshtein

levenshtein automaton

This package makes it fast and simple to build a finite determinic automaton that computes the levenshtein distance from a given string.

Sample usage:

// build a re-usable builder
lb := NewLevenshteinAutomatonBuilder(2, false)

origTerm := "couchbasefts"
dfa := lb.BuildDfa("couchbases", 2)
ed := dfa.eval([]byte(origTerm))
if ed.distance() != 2 {
	log.Errorf("expected distance 2, actual: %d", ed.distance())
}

This implementation is inspired by blog post and is intended to be a port of original rust implementation: https://github.com/tantivy-search/levenshtein-automata

Micro Benchmark Results against the current vellum/levenshtein is as below.

BenchmarkNewEditDistance1-8       	   30000	     52684 ns/op	   89985 B/op	     295 allocs/op
BenchmarkOlderEditDistance1-8     	   10000	    132931 ns/op	  588892 B/op	     363 allocs/op

BenchmarkNewEditDistance2-8       	   10000	    199127 ns/op	  377532 B/op	    1019 allocs/op
BenchmarkOlderEditDistance2-8     	    2000	    988109 ns/op	 4236609 B/op	    1898 allocs/op