allows to search with id
This commit is contained in:
parent
0d9f64bf58
commit
39335c7e09
44
add_word.lua
Normal file
44
add_word.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
return function(query)
|
||||||
|
results_table = {}
|
||||||
|
for i=1, #words do
|
||||||
|
local exit = true
|
||||||
|
local all = true
|
||||||
|
for _, v in pairs(arg) do
|
||||||
|
if v == "-r" or v == "--raw" then
|
||||||
|
all = false
|
||||||
|
word = string.gsub(words[i][1],"%p","")
|
||||||
|
if string.find(word, query) then
|
||||||
|
exit = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if v == "-e" or v == "--english" then
|
||||||
|
all = false
|
||||||
|
word = string.gsub(words[i][2],"%p","")
|
||||||
|
if string.find(word, query) then
|
||||||
|
exit = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if all == true then
|
||||||
|
for j=1, #words[i]-1 do
|
||||||
|
word = string.gsub(words[i][j],"%p","")
|
||||||
|
if string.find(word, query) then
|
||||||
|
exit = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not exit then
|
||||||
|
local word = {i,words[i]}
|
||||||
|
table.insert(results_table,word)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #results_table ~= 0 then
|
||||||
|
results_table = adjustTableSizes(results_table)
|
||||||
|
printOutputTable(results_table)
|
||||||
|
else
|
||||||
|
print("no words found for <" .. query .. ">")
|
||||||
|
end
|
||||||
|
end
|
51
lexicon
51
lexicon
@ -5,11 +5,14 @@ if not arg[1] then print("no argument, try again") return end
|
|||||||
require "R2H2"
|
require "R2H2"
|
||||||
require "color"
|
require "color"
|
||||||
|
|
||||||
|
|
||||||
adjustTableSizes = require "output_sizes"
|
adjustTableSizes = require "output_sizes"
|
||||||
printOutputTable = require "output_word"
|
printOutputTable = require "output_word"
|
||||||
|
|
||||||
showList = require "show_list"
|
showList = require "show_list"
|
||||||
searchList = require "search_list"
|
searchList = require "search_list"
|
||||||
|
removeWord = require "remove_word"
|
||||||
|
addWord = require "add_word"
|
||||||
|
|
||||||
words = dofile("words.lua")
|
words = dofile("words.lua")
|
||||||
|
|
||||||
@ -29,7 +32,7 @@ or arg[1] == "how"
|
|||||||
or arg[1] == "howdo" then
|
or arg[1] == "howdo" then
|
||||||
print([[
|
print([[
|
||||||
|
|
||||||
[a]ll
|
[l]ist
|
||||||
- shows all words in heonian.
|
- shows all words in heonian.
|
||||||
|
|
||||||
[h]elp
|
[h]elp
|
||||||
@ -46,17 +49,17 @@ Parameters:
|
|||||||
-c / --copy (copies transcription to keyboard)
|
-c / --copy (copies transcription to keyboard)
|
||||||
-e / --english (limits the search to the translated words)
|
-e / --english (limits the search to the translated words)
|
||||||
-h / --help (shows what does the command do)
|
-h / --help (shows what does the command do)
|
||||||
-r / --raw (limits the search to the heonian words)
|
-r / --raw (limits the search to the heonian words)
|
||||||
-v / --verbose (shows the transcription process)
|
-v / --verbose (shows the transcription process)
|
||||||
]])
|
]])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if arg[1] == "a"
|
if arg[1] == "l"
|
||||||
or arg[1] == "all" then
|
or arg[1] == "list" then
|
||||||
if please_help then
|
if please_help then
|
||||||
print([[
|
print([[
|
||||||
|
|
||||||
[a]ll
|
[l]ist
|
||||||
- shows all words in heonian.
|
- shows all words in heonian.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -81,6 +84,7 @@ Parameters:
|
|||||||
-a / --all (shows more info on the word, if any)
|
-a / --all (shows more info on the word, if any)
|
||||||
-e / --english (limits the search to the translated words)
|
-e / --english (limits the search to the translated words)
|
||||||
-r / --raw (limits the search to the heonian words)
|
-r / --raw (limits the search to the heonian words)
|
||||||
|
-i / --id (searches using word id)
|
||||||
]])
|
]])
|
||||||
else
|
else
|
||||||
if arg[2] then searchList(arg[2])
|
if arg[2] then searchList(arg[2])
|
||||||
@ -107,3 +111,40 @@ Parameters:
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if arg[1] == "r"
|
||||||
|
or arg[1] == "remove" then
|
||||||
|
if please_help then
|
||||||
|
print([[
|
||||||
|
|
||||||
|
[r]emove <word_id>
|
||||||
|
- removes the word from the lexicon
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
-h / --help (shows what does the command do)
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
if arg[2] then removeWord(arg[2])
|
||||||
|
else print("no word to remove") end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if arg[1] == "a"
|
||||||
|
or arg[1] == "remove" then
|
||||||
|
if please_help then
|
||||||
|
print([[
|
||||||
|
|
||||||
|
[r]emove <word_id>
|
||||||
|
- removes the word from the lexicon
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
-h / --help (shows what does the command do)
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
if arg[2] then addWord(...)
|
||||||
|
else print("no word to add") end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
44
remove_word.lua
Normal file
44
remove_word.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
return function(query)
|
||||||
|
results_table = {}
|
||||||
|
for i=1, #words do
|
||||||
|
local exit = true
|
||||||
|
local all = true
|
||||||
|
for _, v in pairs(arg) do
|
||||||
|
if v == "-r" or v == "--raw" then
|
||||||
|
all = false
|
||||||
|
word = string.gsub(words[i][1],"%p","")
|
||||||
|
if string.find(word, query) then
|
||||||
|
exit = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if v == "-e" or v == "--english" then
|
||||||
|
all = false
|
||||||
|
word = string.gsub(words[i][2],"%p","")
|
||||||
|
if string.find(word, query) then
|
||||||
|
exit = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if all == true then
|
||||||
|
for j=1, #words[i]-1 do
|
||||||
|
word = string.gsub(words[i][j],"%p","")
|
||||||
|
if string.find(word, query) then
|
||||||
|
exit = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not exit then
|
||||||
|
local word = {i,words[i]}
|
||||||
|
table.insert(results_table,word)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #results_table ~= 0 then
|
||||||
|
results_table = adjustTableSizes(results_table)
|
||||||
|
printOutputTable(results_table)
|
||||||
|
else
|
||||||
|
print("no words found for <" .. query .. ">")
|
||||||
|
end
|
||||||
|
end
|
@ -1,6 +1,19 @@
|
|||||||
return function(query)
|
return function(query)
|
||||||
results_table = {}
|
results_table = {}
|
||||||
|
local skip_regular = false
|
||||||
|
for _, v in pairs(arg) do
|
||||||
|
if v == "-i" or v == "--id" then
|
||||||
|
skip_regular = true
|
||||||
|
local id = tonumber(query)
|
||||||
|
if words[id] then
|
||||||
|
local word = {id,words[id]}
|
||||||
|
table.insert(results_table,word)
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
for i=1, #words do
|
for i=1, #words do
|
||||||
|
if skip_regular then break end
|
||||||
local exit = true
|
local exit = true
|
||||||
local all = true
|
local all = true
|
||||||
for _, v in pairs(arg) do
|
for _, v in pairs(arg) do
|
||||||
@ -39,6 +52,10 @@ return function(query)
|
|||||||
results_table = adjustTableSizes(results_table)
|
results_table = adjustTableSizes(results_table)
|
||||||
printOutputTable(results_table)
|
printOutputTable(results_table)
|
||||||
else
|
else
|
||||||
print("no words found for <" .. query .. ">")
|
if skip_regular then
|
||||||
|
print("no word found for id #" .. query)
|
||||||
|
else
|
||||||
|
print("no words found for query <" .. query .. ">")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -55,7 +55,7 @@ table.insert(t,{"do.me","dust","noun","","",""})
|
|||||||
table.insert(t,{"dra","indicates question","marker","","",""})
|
table.insert(t,{"dra","indicates question","marker","","",""})
|
||||||
table.insert(t,{"dsho.ei","fate","noun","","fern's name",""})
|
table.insert(t,{"dsho.ei","fate","noun","","fern's name",""})
|
||||||
table.insert(t,{"dsho.ei.an","shared destiny, together","modifier","fate + path","fern's name","walking the same path -> sharing the same fate -> together"})
|
table.insert(t,{"dsho.ei.an","shared destiny, together","modifier","fate + path","fern's name","walking the same path -> sharing the same fate -> together"})
|
||||||
table.insert(t,{"dsho.ei.an.un","romantic partner, (fated)","noun","fate + path + being","fern's name",""})
|
table.insert(t,{"dsho.ei.an.un","fated partner","noun","fate + path + being","fern's name",""})
|
||||||
table.insert(t,{"du.tan","smoke","noun","","",""})
|
table.insert(t,{"du.tan","smoke","noun","","",""})
|
||||||
table.insert(t,{"duch","seed","noun","","",""})
|
table.insert(t,{"duch","seed","noun","","",""})
|
||||||
table.insert(t,{"e","which","pronoun","","",""})
|
table.insert(t,{"e","which","pronoun","","",""})
|
||||||
|
Loading…
Reference in New Issue
Block a user