Note: this was mostly meant for me to learn some basic Go. Right now it is really slow for distances > 2 (slower than the naive approach).
Efficiently index and search a dictionary by Levenshtein distance. This is done by creating a trie (prefix tree) as an index and then walking the trie for collecting all words within a given distance. We keep track of the number of edits that have been made and walk multiple paths at the same time until all edits are consumed.
It is safe to use with utf-8 strings as it uses runes internally.
Check out nicenshtein-server as well, it has a demo live at https://nicenshtein.now.sh.
Returns a new instance of a Nicenshtein index with the following methods:
Indexes every single line in the given file using AddWord
.
Adds a word
to the index.
Returns whether or not the index contains the given word
.
Will fill out
(maps words to distances) with all words that are within maxDistance
of word
.