blob: 5bf62cfd5ff0182e35c6deae70131072f0681064 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
--Include the module
local fuzzel = dofile("fuzzel.lua")
--A function that takes a table and returns a function that takes a string, and returns the closesting match in the table.
function suggestoption(tbl_options)
return function(str)
local closest = fuzzel.FuzzySearchDistance(str,tbl_options)
return closest
end
end
--A couple of options
local options = {
"Fat Cat",
"Lazy Dog",
"Brown Fox",
}
--Create the function, with our options
local suggestfunc = suggestoption(options)
--And use it, to see what option closest matches "Brown Cat"
print(suggestfunc("Brown Cat"))
|