Implementation of bk-trees with Levenshtein distance in Lua, inspired by an article:
Most commonly used for fuzzy string matching, for spellcheckers or similar.
- Lua >= 5.1
lua example/spelling.lua
Requires busted, simply run busted to run the tests in the spec folder.
busted
v1.0.3
- zip https://github.com/profan/lua-bk-tree/archive/v1.0.3.zip
- tar.gz https://github.com/profan/lua-bk-tree/archive/v1.0.3.tar.gz
git clone git@github.com:profan/lua-bk-tree.git
luarocks install bk-tree
Gives you the words in the tree within 1 edit distance to beutiful
, in this case beautiful
local bktree = require "bk-tree"
local tree = bktree:new("book")
tree:insert("perceive")
tree:insert("original")
tree:insert("beautiful")
local result = tree:query("beutiful", 1)
for k, v in pairs(result) do
print (v.str)
end
Do inspect the bundled examples !
See attached LICENSE file.