aboutsummaryrefslogtreecommitdiff
path: root/FuzzelExample.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-06-04 16:11:46 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-06-04 16:11:46 -0400
commit55674013e729a8ecb929bf5060e53859bd44b997 (patch)
tree083cbb1a67cd7c46cdacc62e084c6d0d21d98949 /FuzzelExample.lua
parent46562b4b62f6dd11dc19d401516d282c59de1cca (diff)
downloadfuzzel-55674013e729a8ecb929bf5060e53859bd44b997.tar.gz
fuzzel-55674013e729a8ecb929bf5060e53859bd44b997.tar.bz2
fuzzel-55674013e729a8ecb929bf5060e53859bd44b997.zip
Added an example of useing fuzzel
Diffstat (limited to 'FuzzelExample.lua')
-rw-r--r--FuzzelExample.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/FuzzelExample.lua b/FuzzelExample.lua
new file mode 100644
index 0000000..5bf62cf
--- /dev/null
+++ b/FuzzelExample.lua
@@ -0,0 +1,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"))