added a way to edit, remove, and add words
This commit is contained in:
135
lexicon
135
lexicon
@@ -6,23 +6,27 @@ require "R2H2"
|
||||
require "color"
|
||||
|
||||
|
||||
adjustTableSizes = require "output_sizes"
|
||||
printOutputTable = require "output_word"
|
||||
require "output_sizes"
|
||||
require "output_word"
|
||||
|
||||
showList = require "show_list"
|
||||
searchList = require "search_list"
|
||||
removeWord = require "remove_word"
|
||||
addWord = require "add_word"
|
||||
require "show_list"
|
||||
require "search_list"
|
||||
require "remove_word"
|
||||
require "add_word"
|
||||
require "edit_word"
|
||||
|
||||
words = dofile("words.lua")
|
||||
data_get = "words.lua"
|
||||
data_output = "words.lua"
|
||||
|
||||
words = dofile(data_get)
|
||||
|
||||
for _, v in pairs(arg) do
|
||||
if v == "-h"
|
||||
or v == "--help"
|
||||
or v == "--usage"
|
||||
or v == "--how"
|
||||
then
|
||||
please_help = true
|
||||
then
|
||||
please_help = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,38 +35,42 @@ or arg[1] == "help"
|
||||
or arg[1] == "how"
|
||||
or arg[1] == "howdo" then
|
||||
print([[
|
||||
|
||||
[l]ist
|
||||
- shows all words in heonian.
|
||||
|
||||
[e]dit <word_id>
|
||||
- removes the word from the lexicon
|
||||
|
||||
[h]elp
|
||||
- shows this message
|
||||
|
||||
|
||||
[l]ist
|
||||
- shows all words in heonian.
|
||||
|
||||
[n]ew
|
||||
- add new word to the data
|
||||
|
||||
[r]emove <word_id>
|
||||
- removes the word from the lexicon
|
||||
|
||||
[s]earch <query>
|
||||
- searches all words and shows only those that return to string.find()
|
||||
|
||||
|
||||
[tr]anscript <word>
|
||||
- transcripts the word to heonian script
|
||||
|
||||
Parameters:
|
||||
-a / --all (shows more info on the word, if any)
|
||||
-c / --copy (copies transcription to keyboard)
|
||||
-e / --english (limits the search to the translated words)
|
||||
General parameters:
|
||||
-h / --help (shows what does the command do)
|
||||
-r / --raw (limits the search to the heonian words)
|
||||
-v / --verbose (shows the transcription process)
|
||||
]])
|
||||
return
|
||||
end
|
||||
if arg[1] == "l"
|
||||
or arg[1] == "list" then
|
||||
if please_help then
|
||||
if please_help then
|
||||
print([[
|
||||
|
||||
[l]ist
|
||||
|
||||
[l]ist
|
||||
- shows all words in heonian.
|
||||
|
||||
Parameters:
|
||||
|
||||
Parameters:
|
||||
-h / --help (shows what does the command do)
|
||||
-a / --all (shows more info on the word, if any)
|
||||
]])
|
||||
@@ -73,13 +81,13 @@ Parameters:
|
||||
end
|
||||
if arg[1] == "s"
|
||||
or arg[1] == "search" then
|
||||
if please_help then
|
||||
if please_help then
|
||||
print([[
|
||||
|
||||
|
||||
[s]earch <query>
|
||||
- searches all words and shows only those that return to string.find()
|
||||
|
||||
Parameters:
|
||||
|
||||
Parameters:
|
||||
-h / --help (shows what does the command do)
|
||||
-a / --all (shows more info on the word, if any)
|
||||
-e / --english (limits the search to the translated words)
|
||||
@@ -94,13 +102,13 @@ Parameters:
|
||||
end
|
||||
if arg[1] == "tr"
|
||||
or arg[1] == "transcript" then
|
||||
if please_help then
|
||||
if please_help then
|
||||
print([[
|
||||
|
||||
|
||||
[tr]anscript <word>
|
||||
- transcripts the word to heonian script
|
||||
|
||||
Parameters:
|
||||
|
||||
Parameters:
|
||||
-h / --help (shows what does the command do)
|
||||
-v / --verbose (shows the transcription process)
|
||||
-c / --copy (copies transcription to keyboard)
|
||||
@@ -114,36 +122,67 @@ end
|
||||
|
||||
if arg[1] == "r"
|
||||
or arg[1] == "remove" then
|
||||
if please_help then
|
||||
if please_help then
|
||||
print([[
|
||||
|
||||
|
||||
[r]emove <word_id>
|
||||
- removes the word from the lexicon
|
||||
|
||||
Parameters:
|
||||
|
||||
Parameters:
|
||||
-h / --help (shows what does the command do)
|
||||
]])
|
||||
else
|
||||
if arg[2] then removeWord(arg[2])
|
||||
if arg[2]
|
||||
and tonumber(arg[2]) <= #words
|
||||
and tonumber(arg[2]) > 0 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
|
||||
if arg[1] == "n"
|
||||
or arg[1] == "new" then
|
||||
if please_help then
|
||||
print([[
|
||||
|
||||
[r]emove <word_id>
|
||||
- removes the word from the lexicon
|
||||
|
||||
Parameters:
|
||||
|
||||
[n]ew
|
||||
- add new word to the data
|
||||
|
||||
Parameters:
|
||||
-h / --help (shows what does the command do)
|
||||
]])
|
||||
else
|
||||
if arg[2] then addWord(...)
|
||||
else print("no word to add") end
|
||||
addWord()
|
||||
end
|
||||
end
|
||||
|
||||
if arg[1] == "e"
|
||||
or arg[1] == "edit" then
|
||||
if please_help then
|
||||
print([[
|
||||
|
||||
[e]dit <word_id>
|
||||
- removes the word from the lexicon
|
||||
|
||||
Parameters:
|
||||
-h / --help / (shows what does the command do)
|
||||
-mph / --modify-phonetics / edit the phonetics field
|
||||
-mm / --modify-meaning / edit the meaning field
|
||||
-mt / --modify-type / edit the type field
|
||||
-mco / --modify-canon-origin / edit the canon origin field
|
||||
-mmo / --modify-meta-origin / edit the meta origin field
|
||||
-mn / --modify-notes / edit the notes field
|
||||
-ma / --modify-all / edit all the fields
|
||||
|
||||
(-ma is enabled by default, disabled if other flags)
|
||||
]])
|
||||
else
|
||||
if arg[2]
|
||||
and tonumber(arg[2]) <= #words
|
||||
and tonumber(arg[2]) > 0 then
|
||||
editWord(arg[2])
|
||||
else print("no word to edit") end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user