Compare commits

..

16 Commits

Author SHA1 Message Date
UndeadMaelys
1b43c52f5d adapted to the new words file 2022-06-06 07:14:01 +02:00
UndeadMaelys
ec76802316 fix badges. fix pronouns duals categorization and generated description 2022-05-10 18:36:05 +02:00
UndeadMaelys
6da5e47e5c better fix for possesion of previous commit 2022-05-10 17:38:15 +02:00
UndeadMaelys
4111112ff3 fixed submodules to include heonian ime and QTC separatedly. Also fixed a bug on the converter (now renamed to generator) so it detects formal possesivess 2022-05-10 17:29:20 +02:00
UndeadMaelys
82b751a9e5 improvements to mood detection, fixed missing word types badges, fixed badge definition 2022-05-09 13:24:28 +02:00
UndeadMaelys
1817ac9d9d fixed misllableed moods in js 2022-05-08 20:16:01 +02:00
87f1a59ceb fix le js 2022-05-08 18:46:56 +02:00
UndeadMaelys
941f701d7d changes to badges and types n stuff 2022-05-08 18:31:09 +02:00
Bizcochito
3d0fc9145f added a word not found allert to stderr when word is not in dictionary 2022-05-07 21:26:44 +02:00
Bizcochito
81d25ec8f1 added 2 moods 2022-05-07 20:40:36 +02:00
Bizcochito
ee20f99f9c added 2 moods 2022-05-07 20:38:33 +02:00
f620bcf1f0 yaaaa 2022-05-07 15:06:20 +02:00
8095cae7cb ime bettter 2022-05-07 14:31:50 +02:00
be9fe1e3a3 finished?! 2022-05-07 12:33:35 +02:00
cddd475909 ariririririririri is now supported 2022-05-07 12:08:35 +02:00
ef877a53bd had too n_n 2022-05-07 11:58:21 +02:00
17 changed files with 2268 additions and 1346 deletions

6
.gitmodules vendored
View File

@@ -1,3 +1,9 @@
[submodule "heonian-content"] [submodule "heonian-content"]
path = heonian-content path = heonian-content
url = https://git.succubi.services/lustlion/heonian-content url = https://git.succubi.services/lustlion/heonian-content
[submodule "heonian-ime"]
path = heonian-ime
url = git@ssh.succubi.services:remi/heonian-ime.git
[submodule "quick-terminal-customization"]
path = quick-terminal-customization
url = git@ssh.succubi.services:lustlion/quick-terminal-customization.git

85
color.lua Normal file
View File

@@ -0,0 +1,85 @@
function Enum(tbl)
for i = 1, #tbl do
local v = tbl[i]
tbl[v] = i
end
return tbl
end
COLOR = Enum {
"Black",
"Red",
"Green",
"Yellow",
"Blue",
"Purple",
"Cyan",
"LightGray",
"Gray",
"HighRed",
"HighGreen",
"HighYellow",
"HighBlue",
"HighPurple",
"HighCyan",
"White"
}
EFFECT = Enum {
"Normal",
"Bold",
"Dim",
"Italic",
"Underline",
"BlinkSlow",
"BlinkFast",
"Invert",
"Conceal",
"CrossedOut"
}
function effectText(Effect, ...)
local Text = ""
local tab = false
for _, v in pairs({...}) do
if not tab then
tab = true
else
Text = Text .. "\t"
end
Text = Text .. v
end
return "\027["..tostring(Effect-1).."m"..Text.."\027[0;m"
end
function colorText(Color, ...)
local Text = ""
local tab = false
for _, v in pairs({...}) do
if not tab then
tab = true
else
Text = Text .. "\t"
end
Text = Text .. v
end
return "\027[38;5;"..tostring(Color-1).."m"..Text.."\027[0;m"
end
function colorTextBackground(Color, ...)
local Text = ""
local tab = false
for _, v in pairs({...}) do
if not tab then
tab = true
else
Text = Text .. "\t"
end
Text = Text .. v
end
return "\027[48;5;"..tostring(Color-1).."m"..Text.."\027[0;m"
end
function scrollTerminalUp(amount)
return "\027["..amount.."T"
end

View File

@@ -1,12 +1,62 @@
require "r2h2_modified" require "r2h2_modified"
require "color"
words = dofile("heonian-content/words.lua") words = dofile("heonian-content/words.lua")
input = arg[1] or "input.txt"
function apply(text) function apply(text)
print(text) print(text)
end end
function printD(...)
io.stderr:write(
effectText(
EFFECT.Bold,
colorText(
COLOR.HighPurple,
"\tDEBUG:\t"
)
) ..
colorText(
COLOR.HighPurple,
table.unpack({...}) , "\n"
)
)
end
function printW(...)
io.stderr:write(
effectText(
EFFECT.Bold,
colorText(
COLOR.HighYellow,
"\t WARN:\t"
)
) ..
colorText(
COLOR.HighYellow,
table.unpack({...}) .. "\n"
)
)
end
function printE(...)
io.stderr:write(
effectText(
EFFECT.Bold,
colorText(
COLOR.HighRed,
"\tERROR:\t"
)
) ..
colorText(
COLOR.HighRed,
table.unpack({...}) .. "\n"
)
)
end
function process_content(content) function process_content(content)
content = content .. " " content = content .. " "
for i=1, 2 do for i=1, 2 do
@@ -31,6 +81,7 @@ function process_content(content)
new_word = strip_symbols(new_word) new_word = strip_symbols(new_word)
new_word, indicators = revert_verbs(new_word, indicators) new_word, indicators = revert_verbs(new_word, indicators)
new_word, indicators = revert_nouns(new_word,indicators) new_word, indicators = revert_nouns(new_word,indicators)
new_word, indicators = categorize_word(new_word,indicators)
add_word(new_word) add_word(new_word)
local html_stuff = [[ local html_stuff = [[
@@ -48,7 +99,7 @@ function process_content(content)
html_stuff = string.gsub(html_stuff, "REPLACE_PRINT", REPLACE_PRINT) html_stuff = string.gsub(html_stuff, "REPLACE_PRINT", REPLACE_PRINT)
end end
local REPLACE_WORD = print_text local REPLACE_WORD = strip_symbols(print_text)
while string.find(REPLACE_WORD, "%\'") do while string.find(REPLACE_WORD, "%\'") do
REPLACE_WORD = string.gsub(REPLACE_WORD, "%\'", "$") REPLACE_WORD = string.gsub(REPLACE_WORD, "%\'", "$")
end end
@@ -89,7 +140,7 @@ function process_content(content)
ac = string.sub(ac, string.find(ac, " ")+1) ac = string.sub(ac, string.find(ac, " ")+1)
-- now we print the thing with teh appropiate indicators. -- now we print the thing with teh appropiate indicators.
--print(print_text, table.unpack(indicators)) -- printD(print_text, table.unpack(indicators))
end end
apply_html("html/convo/text/end.html") apply_html("html/convo/text/end.html")
end end
@@ -125,7 +176,8 @@ function add_word(str)
end end
end end
if add then if add then
table.insert(word_list,str) table.insert(word_list,str)
if not in_dictionary(str) then printW("\"" .. str .. "\" is not known") end
end end
end end
@@ -159,10 +211,19 @@ function check_symbol(str)
end end
end end
function find_n_replace(str, tbl,find,repl,indicator) function find_n_replace(str, tbl,find,repl,indicator, caution)
if string.find(str, find) then if not in_dictionary(str) then
str = string.gsub(str,find, repl) if string.find(str, find) then
table.insert(tbl,indicator) if caution then
if not string.find(str, caution, string.find(str, find)+string.len(find)-string.len(caution)) then -- sometimes you want to avoid certain false positives
str = string.gsub(str,find, repl)
table.insert(tbl,indicator)
end
else
str = string.gsub(str,find, repl)
table.insert(tbl,indicator)
end
end
end end
return str, tbl return str, tbl
end end
@@ -173,35 +234,95 @@ function in_dictionary(str)
end end
end end
function check_morphemes(str, tbl,match,repl,indicator) function string.split(str, find, tbl)
split = tbl or {}
local p = 0
local continue = true
while continue do
word = string.sub(str,p,string.find(str,find,p+1,-1))
table.insert(split,strip_spaces(word))
if string.find(str,find,p) then
str = string.sub(str,p)
p = string.find(str,find,p)
continue = true
p = p + 1
else
continue = false
end
end
return split
end
function categorize_word(str,indicators)
local ind = {}
for _, v in pairs(words) do
if strip_symbols(v[1]) == strip_spaces(str) then -- if word is present
local ac = string.lower(v[3])
ind = string.split(strip_symbols(ac), " ", ind) -- store types are indicators
end
end
for _, v in pairs(indicators) do
table.insert(ind, v)
end
return str, ind
end
function check_morphemes(str, tbl,match,repl,indicators)
if type(indicators) ~= "table" then
indicators = {indicators}
end
if not in_dictionary(str) then if not in_dictionary(str) then
local flen = string.len(match) local flen = string.len(match)
if string.sub(str, -flen) == match if string.sub(str, -flen) == match then
and string.sub(str,-3) ~= "ton" then str = string.sub(str, 0,string.len(str)-flen) .. repl
str = string.sub(str, 0,string.len(str)-flen) if tbl then
table.insert(tbl,indicator) for _, v in pairs(indicators) do
table.insert(tbl,v)
end
end
end end
end end
return str, tbl return str, tbl
end end
function revert_nouns(str, tbl) function revert_nouns(str, tbl)
str, tbl = check_morphemes(str,tbl,"lfur","","formal-n1")
str, tbl = check_morphemes(str,tbl,"lafura","","formal-n2")
str, tbl = check_morphemes(str,tbl,"lan","","genitive") str, tbl = check_morphemes(str,tbl,"lan","","genitive")
str, tbl = check_morphemes(str,tbl,"la","","possesive") str, tbl = check_morphemes(str,tbl,"la","","possesive")
str, tbl = check_morphemes(str,tbl,"n","","plural") str, tbl = check_morphemes(str,tbl,"n","","plural")
str, tbl = check_morphemes(str,tbl,"lfur","","formal1")
str, tbl = check_morphemes(str,tbl,"lafura","","formal2")
return str, tbl return str, tbl
end end
function revert_verbs(str, tbl) function revert_verbs(str, tbl)
str, tbl = find_n_replace(str, tbl,"kanya","ku","present-tense") -- moods first
str, tbl = find_n_replace(str, tbl,"kome","ku","past-tense") str, tbl = revert_mood(str, tbl,"pash","","volitional-mood")
str, tbl = find_n_replace(str, tbl,"kupash","ku","volitional-mood") str, tbl = revert_mood(str, tbl,"dash","","imperative-mood")
str, tbl = find_n_replace(str, tbl,"kudash","ku","imperative-mood") str, tbl = revert_mood(str, tbl,"bash","","shy-mood")
str, tbl = find_n_replace(str, tbl,"kubash","ku","shy-mood") str, tbl = revert_mood(str, tbl,"tash","","threat-mood")
str, tbl = find_n_replace(str, tbl,"kutash","ku","threat-mood") str, tbl = revert_mood(str, tbl,"shu","","comfy-mood")
str, tbl = find_n_replace(str, tbl,"faku","ku","negated") str, tbl = revert_mood(str, tbl,"ha","","excited-mood", "sha")
-- once we've cleaned moods lets try to get tense
str, tbl = check_morphemes(str, tbl,"kanya","ku",{"present-tense-formal","formal-v1"})
str, tbl = check_morphemes(str, tbl,"kome","ku",{"past-tense-formal","formal-v2"})
-- maybe it's informal?
str, tbl = check_morphemes(str, tbl,"nya","",{"present-tense-informal","informal-v1"})
str, tbl = check_morphemes(str, tbl,"me","",{"past-tense-informal","informal-v2"})
for _, v in pairs(tbl) do
if v == "informal-v1"
or v == "informal-v2" then
str = str .. "ku"
end
end
-- negate
str, tbl = check_morphemes(str, tbl,"faku","ku","negated")
return str, tbl
end
function revert_mood(str, tbl,match,repl,indicator, caution)
str, tbl = find_n_replace(str, tbl,"fa"..match,repl,indicator.."-negated",caution)
str, tbl = find_n_replace(str, tbl,match,repl,indicator,caution)
return str, tbl return str, tbl
end end
@@ -283,7 +404,7 @@ end
-- lets make the html -- lets make the html
apply_html("html/start.html") apply_html("html/start.html")
-- get text -- get text
local file = io.open("input.txt","r") local file = io.open(input,"r")
local text = file:read("*all") local text = file:read("*all")
file:close() file:close()

574
generator.lua Normal file
View File

@@ -0,0 +1,574 @@
require "r2h2_modified"
require "quick-terminal-customization"
require "get_words"
words = getWords("heonian-content/words")
input = arg[1] or "input.txt"
function apply(text)
print(text)
end
function printD(...)
io.stderr:write(
string.effect(
TERMINAL_EFFECT.Bold,
string.color(
TERMINAL_COLOR.HighPurple,
"\tDEBUG:\t"
)
) ..
string.color(
TERMINAL_COLOR.HighPurple,
table.unpack({...}) , "\n"
)
)
end
function printW(...)
io.stderr:write(
string.effect(
TERMINAL_EFFECT.Bold,
string.color(
TERMINAL_COLOR.HighYellow,
"\t WARN:\t"
)
) ..
string.color(
TERMINAL_COLOR.HighYellow,
table.unpack({...}) .. "\n"
)
)
end
function printE(...)
io.stderr:write(
string.effect(
TERMINAL_EFFECT.Bold,
string.color(
TERMINAL_COLOR.HighRed,
"\tERROR:\t"
)
) ..
string.color(
TERMINAL_COLOR.HighRed,
table.unpack({...}) .. "\n"
)
)
end
function process_content(content)
content = content .. " "
for i=1, 2 do
if i == 1 then
apply_html("html/convo/text/start_roman.html")
else
apply_html("html/convo/text/start_heonian.html")
end
local ac = check_symbol(content)
while string.find(ac, " ") do
local new_word = string.sub(ac, 0, string.find(ac, " ")-1)
local indicators = {}
if i == 1 then
print_text = new_word
else
print_text = mod_convertToHeonian(new_word)
end
new_word = strip_symbols(new_word)
new_word, indicators = revert_verbs(new_word, indicators)
new_word, indicators = revert_nouns(new_word,indicators)
new_word, indicators = categorize_word(new_word,indicators)
add_word(new_word)
local REPLACE_WORD = strip_symbols(print_text)
local REPLACE_SEARCH = new_word
local REPLACE_PRINT = print_text
local REPLACE_DATA = ""
local k = 0
for _, v in pairs(indicators) do
if k > 0 then
REPLACE_DATA = REPLACE_DATA .. " "
end
REPLACE_DATA = REPLACE_DATA .. v
k = k + 1
end
local html_stuff = [[
<span
class="clickable"
onclick="showPopup('REPLACE_WORD','REPLACE_SEARCH','REPLACE_DATA')"
onmouseover="checkHover('REPLACE_WORD','REPLACE_SEARCH',this,'REPLACE_DATA')"
onmouseout="clearHover()">
REPLACE_PRINT
</span>
]]
while string.find(html_stuff, "REPLACE_PRINT") do
html_stuff = string.gsub(html_stuff, "REPLACE_PRINT", REPLACE_PRINT)
end
while string.find(REPLACE_WORD, "%\'") do
REPLACE_WORD = string.gsub(REPLACE_WORD, "%\'", "$")
end
while string.find(REPLACE_WORD, "%$") do
REPLACE_WORD = string.gsub(REPLACE_WORD, "%$", "\\\'")
end
while string.find(html_stuff, "REPLACE_WORD") do
html_stuff = string.gsub(html_stuff, "REPLACE_WORD", REPLACE_WORD)
end
while string.find(html_stuff, "REPLACE_SEARCH") do
html_stuff = string.gsub(html_stuff, "REPLACE_SEARCH", REPLACE_SEARCH)
end
if REPLACE_DATA and REPLACE_DATA ~= "" then
while string.find(REPLACE_DATA, "\t") do
REPLACE_DATA = string.gsub(REPLACE_DATA, "\t", " ")
end
while string.find(html_stuff, "REPLACE_DATA") do
html_stuff = string.gsub(html_stuff, "REPLACE_DATA", REPLACE_DATA)
end
else
html_stuff = string.gsub(html_stuff, ",'REPLACE_DATA'","")
end
apply(html_stuff)
ac = string.sub(ac, string.find(ac, " ")+1)
-- now we print the thing with teh appropiate indicators.
-- printD(print_text, table.unpack(indicators))
end
apply_html("html/convo/text/end.html")
end
end
function cell_builder(...)
arg = {...}
for i=1, #arg do
apply_html("html/words/definition/cell_start.html")
apply(arg[i])
apply_html("html/words/definition/cell_end.html")
end
end
function print_word_stuff(word)
apply_html("html/words/definition/start.html")
local exit = false
for _, v in pairs(words) do
if strip_symbols(v[1]) == strip_spaces(word) then
cell_builder(mod_convertToHeonian(word),v[1],v[3],v[2])
exit = true
end
end
if not exit then
-- personal pronuns
local PP = {
{"re","re","the speaker"," and someone else the listener doesn't know about"},
{"ba","ba","the listener"," and someone else the speaker doesn't know about"},
{"ima","ma","someone else","s who neither the speaker or the listener know about"}
}
for _, v1 in pairs(PP) do
for _, v2 in pairs(PP) do
if word == v1[1]..v2[2] then
exit = true
cell_builder(
mod_convertToHeonian(word),
word,
"Pronoun",
"This word refers to both "..v1[3] .. v2[4] .. ". \n\nIf in plural form, it refers to a group of people who all fit this definition."
)
end
end
end
if not exit then
cell_builder(mod_convertToHeonian(word),word, "???","???")
printW("\"" .. word .. "\" is not known")
end
end
apply_html("html/words/definition/end.html")
end
function add_word(str)
local add = true
for _, v in pairs(word_list) do
if v == str then
add = false
end
end
if add then
table.insert(word_list,str)
end
end
function strip_spaces(str)
while string.find(str, "% ") do
str = string.gsub(str, " ","")
end
return str
end
function strip_symbols(str)
local symbol_table = "'~()!?:></.,\t"
for i=1, #symbol_table do
while string.find(str, "%"..string.sub(symbol_table,i,i)) do
str = string.gsub(str, "%"..string.sub(symbol_table,i,i),"")
end
end
return str
end
function replace_sign(str)
while string.find(str, "%-") do
str = string.gsub(str, "%-"," ")
end
return str
end
function check_symbol(str)
if not in_dictionary(str) then
return replace_sign(str)
end
end
function find_n_replace(str, tbl,find,repl,indicator, caution)
if not in_dictionary(str) then
if string.find(str, find) then
if caution then
if not string.find(str, caution, string.find(str, find)+string.len(find)-string.len(caution)) then -- sometimes you want to avoid certain false positives
str = string.gsub(str,find, repl)
table.insert(tbl,indicator)
end
else
str = string.gsub(str,find, repl)
table.insert(tbl,indicator)
end
end
end
return str, tbl
end
function in_dictionary(str)
for i=1, #words do
if strip_symbols(words[i][1]) == str then return true end
end
end
function string.split(str, find, tbl)
split = tbl or {}
local p = 0
local continue = true
while continue do
word = string.sub(str,p,string.find(str,find,p+1,-1))
table.insert(split,strip_spaces(word))
if string.find(str,find,p) then
str = string.sub(str,p)
p = string.find(str,find,p)
continue = true
p = p + 1
else
continue = false
end
end
return split
end
function categorize_word(str,indicators)
local ind = {}
for _, v in pairs(words) do
if strip_symbols(v[1]) == strip_spaces(str) then -- if word is present
local ac = string.lower(v[3])
ind = string.split(strip_symbols(ac), " ", ind) -- store types are indicators
end
end
for _, v in pairs(indicators) do
table.insert(ind, v)
end
return str, ind
end
function check_morphemes(str, tbl,match,repl,indicators)
if type(indicators) ~= "table" then
indicators = {indicators}
end
if not in_dictionary(str) then
local flen = string.len(match)
if string.sub(str, -flen) == match then
str = string.sub(str, 0,string.len(str)-flen) .. repl
if tbl then
for _, v in pairs(indicators) do
table.insert(tbl,v)
end
end
end
end
return str, tbl
end
function revert_nouns(str, tbl)
-- possesion first
str, tbl = check_morphemes(str,tbl,"lan","","genitive")
str, tbl = check_morphemes(str,tbl,"la","","possesive")
-- then politeness
str, tbl = check_morphemes(str,tbl,"lfur","","formal-n1")
str, tbl = check_morphemes(str,tbl,"lafura","","formal-n2")
-- then plural
str, tbl = check_morphemes(str,tbl,"n","","plural")
-- personal pronuns
local PP = {
{"re","re"},
{"ba","ba"},
{"ima","ma"}
}
for _, v1 in pairs(PP) do
for _, v2 in pairs(PP) do
if str == v1[1]..v2[2] then
table.insert(tbl,"dual")
for _, vtbl in pairs(tbl) do
if vtbl == "plural" then
table.remove(tbl, #tbl)
break
end
end
table.insert(tbl,"pronoun")
end
end
end
return str, tbl
end
function revert_verbs(str, tbl)
-- moods first
str, tbl = revert_mood(str, tbl,"pash","","volitional-mood")
str, tbl = revert_mood(str, tbl,"dash","","imperative-mood")
str, tbl = revert_mood(str, tbl,"bash","","shy-mood")
str, tbl = revert_mood(str, tbl,"tash","","threat-mood")
str, tbl = revert_mood(str, tbl,"shu","","comfy-mood")
str, tbl = revert_mood(str, tbl,"ha","","excited-mood", "sha")
-- once we've cleaned moods lets try to get tense
str, tbl = check_morphemes(str, tbl,"kanya","ku",{"present-tense-formal","formal-v1"})
str, tbl = check_morphemes(str, tbl,"kome","ku",{"past-tense-formal","formal-v2"})
-- maybe it's informal?
str, tbl = check_morphemes(str, tbl,"nya","",{"present-tense-informal","informal-v1"})
str, tbl = check_morphemes(str, tbl,"me","",{"past-tense-informal","informal-v2"})
for _, v in pairs(tbl) do
if v == "informal-v1"
or v == "informal-v2" then
str = str .. "ku"
end
end
-- negate
str, tbl = check_morphemes(str, tbl,"faku","ku","negated")
return str, tbl
end
function revert_mood(str, tbl,match,repl,indicator, caution)
str, tbl = find_n_replace(str, tbl,"fa"..match,repl,indicator.."-negated",caution)
str, tbl = find_n_replace(str, tbl,match,repl,indicator,caution)
return str, tbl
end
function apply_html(path)
-- copy
local file = io.open(path,"r")
local html = file:read("*all")
file:close()
-- paste
apply(html)
end
function convo_image(string,alt_text)
if string then
apply_html("html/convo/header/image/start.html")
apply(string)
apply_html("html/convo/header/image/middle.html")
apply(alt_text)
apply_html("html/convo/header/image/end.html")
end
end
function convo_notes(string)
apply_html("html/convo/middle.html")
if string then
apply_html("html/convo/notes/start.html")
apply(string)
apply_html("html/convo/notes/end.html")
end
end
function convo_date(string)
if string then
apply_html("html/convo/header/date/start.html")
apply(string)
apply_html("html/convo/header/date/end.html")
end
end
function convo_header_start()
if not header then
header = true
apply_html("html/convo/header/start.html")
end
end
function convo_header_end()
if header then
header = false
apply_html("html/convo/header/end.html")
end
end
function convo_start(color)
convo_header_end()
if not convo then
if color then
apply_html("html/convo/start_green.html")
else
apply_html("html/convo/start_gray.html")
end
convo = true
end
end
function convo_end()
convo_header_end()
if convo then
if not notes then
apply_html("html/convo/middle.html")
end
notes = false
apply_html("html/convo/end.html")
convo = false
end
end
-- lets make the html
apply_html("html/start.html")
-- get text
local file = io.open(input,"r")
local text = file:read("*all")
file:close()
-- first analyze text
-- (this is the fun part)
word_list = {}
local p = 0
local s = 0
local convo = false
local header = false
local notes = false
local green = true
local skip = 1
local user = {}
while p ~= nil do
s = s + 1
local np = string.find(text,"\n",p+1)
if np and p - np ~= 1 then
if p then
skip = 1
if string.sub(text,p+1,p+1) == "\n"
or string.sub(text,p+1,p+1) == "/" then
-- end of new bubble
convo_end()
elseif string.sub(text,p+1,p+1) == "\t" then
-- its tabbed so its spoken?
convo_start()
process_content(string.sub(text,p+2,np-1))
elseif string.sub(text,p+1,p+1) == "h" then
-- spoken but forced to h
convo_start()
apply_html("html/convo/text/start_raw.html")
apply(mod_convertToHeonian(string.sub(text,p+3,np-1)).."")
apply_html("html/convo/text/end.html")
elseif string.sub(text,p+1,p+1) == "r" then
-- spoken but forced to r
convo_start()
apply_html("html/convo/text/start_raw.html")
apply(string.sub(text,p+3,np-1))
apply_html("html/convo/text/end.html")
elseif string.sub(text,p+1,p+1) == "i" then -- independant image, no username
convo_start(green)
convo_header_start()
convo_image(string.sub(text,p+3,np-1))
elseif string.sub(text,p+1,p+1) == "!" then -- independant image, no username
convo_notes(string.sub(text,p+3,np-1))
notes = true
else
-- new user name
convo_end()
if green then
green = false
else
green = true
end
convo_start(green)
-- this is a header section
convo_header_start()
-- lets check for images
local nl = string.find(text,"\n",p+1)
local nlp = string.find(text,"\n",nl+1)
current_user = string.sub(text,p+1,np-1)
user[current_user] = user[current_user] or {image = nil}
if nlp and string.sub(text,nl+1,nl+1) == "i" then
user[current_user].image = string.sub(text,nl+3,nlp-1)
skip = skip + 1
nl = string.find(text,"\n",nl+1)
nlp = string.find(text,"\n",nlp+1)
end
convo_image(user[current_user].image)
-- print name
apply_html("html/convo/header/name/start.html")
apply(string.sub(text,p+1,np-1))
apply_html("html/convo/header/name/end.html")
-- lets check for dates
if nlp and string.sub(text,nl+1,nl+1) == "d" then
convo_date(string.sub(text,nl+3,nlp-1))
skip = skip + 1
else
convo_date("")
end
header = true
end
end
while skip > 0 do
p = string.find(text,"\n",p+1)
skip = skip - 1
end
else
break
end
end
convo_end()
-- 3.5 separation
apply_html("html/spacer.html")
-- fourth lets make word lists
-- process contents
-- lets print the words
apply_html("html/spacer.html")
apply_html("html/words/start.html")
for i=1, #word_list do
print_word_stuff(word_list[i])
end
apply_html("html/words/end.html")
-- pop up
apply_html("html/pop_up.html")
-- lets end the html
apply_html("html/end.html")

49
get_words.lua Normal file
View File

@@ -0,0 +1,49 @@
function getWords(path)
local file = io.open(path,"r")
local text = file:read("*all")
file:close()
local t = {} -- this table will hold our words!!! words format is {word, translation, types, canon origin, meta origin, notes} last three are optional.
local p = 0 -- current position, nil if at end of file
while p do
p = p + 1
local new_word_data = ""
-- this isnt the whole word yet, but all the data around it separated with tabs, so lets get what we want.
-- careful if its uh end of file tho!
local np = string.find(text,"\n",p) -- np is the next word. this is so we can slice it
if np then
new_word_data = string.sub(text, p, np-1)
else
new_word_data = string.sub(text, p)
end
if new_word_data ~= "" then
local new_word = {} -- we'll hold it all here once spliced
local wp = 0 -- word data position!
while wp do -- nil if at end of string so.
wp = wp + 1 -- lets move past the tab we just found
local wnp = string.find(new_word_data, " ",wp)
local stuff = ""
-- we now splice the word every tab and add it to the uhhh
if wnp then
stuff = string.sub(new_word_data, wp, wnp-1) or stuff
else
stuff = string.sub(new_word_data,wp) or stuff
end
table.insert(new_word,stuff)
wp = wnp
end
-- now we add the word ot the word table
table.insert(t, new_word)
end
-- and move on the next
p = np
end
-- now we just. return the table.
return t
end

1
heonian-ime Submodule

Submodule heonian-ime added at c8157f53b1

View File

@@ -2,9 +2,8 @@
<div id="popup"> <div id="popup">
<h1>um</h1> <h1>um</h1>
<p id="popup-heo"></p> <p id="popup-heo"></p>
<div class="spacer"></div> <div id="spacerhide" class="spacer"></div>
<div id="popup-middle"> <div id="popup-middle">
<b>type: </b><span id="popup-type"></span><br>
<div id="popup-quirks-container"><span id="popup-quirks"></span></div> <div id="popup-quirks-container"><span id="popup-quirks"></span></div>
</div> </div>
<div class="spacer"></div> <div class="spacer"></div>

View File

@@ -23,6 +23,6 @@
<textarea type="text" class="ime"> <textarea type="text" class="ime">
</textarea> </textarea>
<script src="./ime.js" async defer></script> <script src="./heonian-ime/ime.js" async defer></script>
</body> </body>
</html> </html>

791
ime.js
View File

@@ -1,397 +1,472 @@
let input = []; // bug: if you fuck up input really badly, you might get a ??? unicode to print.
// it successfully breaks everything. however, im not managing to repro it so...
// (shruggie)
let currentWord = []; // let h;
let selected = -1;
window.onload = () => { window.onload = () => {
document.querySelectorAll(".ime").forEach(input => { document.querySelectorAll(".ime").forEach(input => {
input.addEventListener("keydown", (key) => { h = new HeonianIME(input);
imeDown(key, input);
});
input.addEventListener("mousedown", (e) => {
e.preventDefault();
input.focus();
imeUpdate(input);
})
}); });
} }
function imeDown(keyEvent, inputField) { class HeonianIME {
keyEvent.preventDefault(); constructor(what) {
switch (keyEvent.key) { this.input = [];
case "Backspace": this.currentWord = [];
if (selected == -1) { this.selected = -1;
if (currentWord.join("") == "") {
currentWord = input.pop() || [];
} else {
imeRestore(currentWord);
// currentWord.pop();
}
} else {
imeRestore(input[selected]);
// input[selected].pop();
if (input[selected].join("") == "") {
input.splice(selected,1);
imeMove("left");
}
}
break;
case "Enter":
if (selected == -1) {
if (currentWord.join() == "") { //blame js :)
let s = document.createElement("p");
s.innerText = input.join("");
document.body.appendChild(s);
input = [];
selected = -1;
} else {
input.push(currentWord);
currentWord = [];
}
} else {
if (selected+1 >= input.length) {
selected = -1;
} else {
selected += 1;
}
}
imeReset();
break;
case "Space":
//adds a '
break;
case "ArrowLeft":
imeMove("left");
break;
case "ArrowRight":
imeMove("right");
break;
case "ArrowDown":
imeMove("start");
break;
case "ArrowUp":
imeMove("end");
break;
default:
imeInput(keyEvent.key);
if (selected == -1) {
currentWord = inputFull;
} else {
input[selected] = inputFull;
}
break;
}
imeUpdate(inputField);
}
function imeUpdate(inputField) { this.inputState = 0; //STARTING, COMPOSTING, TRAILING, Fucking Nothing, ...cleanup
let renderText = ""; this.stateState = 0; //depends on the state
input.forEach((w) => { this.inputFull = [];
renderText += w.join(""); this.inputCurrent = "";
})
inputField.value = renderText + currentWord.join(""); this.ourHtml;
if (selected == -1) { this.oldText = [];
inputField.setSelectionRange(renderText.length, renderText.length+currentWord.join("").length);
} else { this.hVowels = { //standalone, composing, trailing
from = 0; "a": ["0", "5", "A"],
for (let x = 0; x < selected; x++) { "e": ["1", "6", "B"],
from += input[x].join("").length; "i": ["2", "7", "C"],
"o": ["3", "8", "D"],
"u": ["4", "9", "E"]
};
this.hConsonants = { //0 = standalone, 1 = composing, 2-6 = vowels
"g": "01",
"s": "02",
"r": "03",
"n": "04",
"c": "05",
"m": "06",
"j": "07",
"f": "08",
"t": "09",
"k": "0A",
"w": "0B",
"l": "0C",
"p": "0D",
"b": "0E",
"d": "0F",
"h": "10",
};
this.hVowelsK = Object.keys(this.hVowels)
this.hConsonantsK = Object.keys(this.hConsonants);
this.hConsonantsR = this.inverse(this.hConsonants);
this.ourHtml = what;
this.oldText = [what.value.slice(0, what.selectionStart), what.value.slice(what.selectionStart)];
what.addEventListener("keydown", (key) => {
this.imeDown(key, what);
});
what.addEventListener("mousedown", (e) => {
this.mouse(e, what);
});
}
mouse(e, what) {
e.preventDefault();
what.focus();
this.imeUpdate(what);
}
imeDetach() {
//how do we detach this without . uh,
let renderText = "";
this.input.forEach((w) => {
renderText += w.join("");
})
if (this.selected == -1) {
this.ourHtml.setSelectionRange(this.oldText[0].length+renderText.length, this.oldText[0].length+renderText.length);
} else {
if (this.input.join("") != "") {
let from = 0;
for (let x = 0; x < this.selected; x++) {
from += this.input[x].join("").length;
}
this.ourHtml.setSelectionRange(this.oldText[0].length+from, this.oldText[0].length+from);
}
} }
to = from+input[selected].join("").length; this.imeDown = ()=>{};
inputField.setSelectionRange(from, to); this.mouse = ()=>{};
//close enough?
} }
}
function clamp(min, max, value) { imePush() {
return Math.max(min, Math.min(max, value)); //basically equavlient to pressing enter.
} if (this.selected == -1) {
if (this.currentWord.join() == "") { //blame js :)
function imeMove(direction) { let s = document.createElement("p");
let d = 1; s.innerText = this.input.join("");
if (currentWord.join("") != "") { document.body.appendChild(s);
input.push(currentWord); this.input = [];
currentWord = []; this.selected = -1;
d = 2; } else {
} this.input.push(this.currentWord);
switch (direction) { this.currentWord = [];
case "start":
selected = 0;
break;
case "end":
selected = -1;
break;
case "left":
if (selected == -1) selected = input.length;
selected -= 1 * d;
if (selected != -1) {
selected = clamp(0,input.length,selected);
//is there even a point in clamping it here,,,,
} }
break; this.imeReset();
case "right": } else {
selected += 1 * d; if (this.selected + 1 >= this.input.length) {
selected = clamp(0,input.length,selected); this.selected = -1;
//tbh same here, like. } else {
//oh well ig ???/ this.selected += 1;
if (selected == input.length) {
selected = -1;
} }
break; this.imeReset(true);
}
} }
imeReset();
}
let inputState = 0; //STARTING, COMPOSTING, TRAILING, Fucking Nothing, ...cleanup imeDown(keyEvent, inputField) {
let stateState = 0; //depends on the state keyEvent.preventDefault();
let inputFull = []; switch (keyEvent.key) {
let inputCurrent = ""; case "Backspace":
if (this.selected == -1) {
let hVowels = { //standalone, composing, trailing if (this.currentWord.join("") == "") {
"a": ["0", "5", "A"], this.currentWord = this.input.pop() || [];
"e": ["1", "6", "B"], } else {
"i": ["2", "7", "C"], this.imeRestore(this.currentWord);
"o": ["3", "8", "D"], // this.currentWord.pop();
"u": ["4", "9", "E"] }
}; } else {
this.imeRestore(this.input[this.selected]);
let hConsonants = { //0 = standalone, 1 = composing, 2-6 = vowels // this.input[this.selected].pop();
"g": "01", if (this.input[this.selected].join("") == "") {
"s": "02", this.input.splice(this.selected, 1);
"r": "03", this.imeMove("left");
"n": "04", }
"c": "05", }
"m": "06", break;
"j": "07", case "Enter":
"f": "08", this.imePush()
"t": "09", break;
"k": "0A", case "Space":
"w": "0B", //adds a ', on second press . an actual space
"l": "0C", break;
"p": "0D", case "ArrowLeft":
"b": "0E", this.imeMove("left");
"d": "0F", break;
"h": "10", case "ArrowRight":
}; this.imeMove("right");
break;
function getUnicodeVowel(vowel, sot) { case "ArrowDown":
if (sot == "standalone") sot = 0; this.imeMove("start");
if (sot == "composing") sot = 1; break;
if (sot == "trailing") sot = 2; case "ArrowUp":
return String.fromCharCode(parseInt("E00" + hVowels[vowel][sot], 16)); this.imeMove("end");
} break;
case "Escape":
function getUnicodeConsonant(consonant, scv) { this.imeDetach();
if (scv == "standalone") {scv = 0;} return;
else if (scv == "trailing") {scv = 1;} default:
else {scv = Number(hVowels[scv][0])+2} this.imeInput(keyEvent.key);
return String.fromCharCode(parseInt("E" + hConsonants[consonant] + "" + scv, 16)); if (this.selected == -1) {
} this.currentWord = this.inputFull;
} else {
function inverse(obj){ this.input[this.selected] = this.inputFull;
var retobj = {}; }
for(var key in obj){ break;
retobj[obj[key]] = key; }
this.imeUpdate(inputField);
} }
return retobj;
}
let hVowelsK = Object.keys(hVowels) imeUpdate(inputField) {
let hConsonantsK = Object.keys(hConsonants); let renderText = "";
let hConsonantsR = inverse(hConsonants); this.input.forEach((w) => {
renderText += w.join("");
function debugInput(key) { })
console.log("pre "+key+": inputstate - "+inputState +", statestate - "+ stateState); inputField.value = this.oldText[0] + renderText + this.currentWord.join("") + this.oldText[1];
console.log("inputfull: " + inputFull.join(" ") + ", inputcurrent:" + inputCurrent); if (this.selected == -1) {
imeInput(key); inputField.setSelectionRange(this.oldText[0].length+renderText.length, this.oldText[0].length+renderText.length + this.currentWord.join("").length);
console.log("post "+key+": inputstate - "+inputState +", statestate - "+ stateState); } else {
console.log("inputfull: " + inputFull.join(" ") + ", inputcurrent:" + inputCurrent); if (this.input.join("") != "") {
console.log("------------------------------") let from = 0;
} for (let x = 0; x < this.selected; x++) {
from += this.input[x].join("").length;
function imeReset() { }
stateState = 0; let to = from + this.input[this.selected].join("").length;
inputState = 0; inputField.setSelectionRange(this.oldText[0].length+from, this.oldText[0].length+to);
inputFull = []; }
inputCurrent = ""; }
if (selected == -1) {
currentWord = [];
} else {
input[selected] = [];
} }
}
function imeInfo(decHex) { clamp(min, max, value) {
try { return Math.max(min, Math.min(max, value));
let hex = decHex.codePointAt(0).toString(16); }
hex[1] = parseInt(hex[1], 16);
hex[2] = parseInt(hex[2], 16); imeMove(direction) {
hex[3] = parseInt(hex[3], 16); let d = 1;
if (this.currentWord.join("") != "") {
this.input.push(this.currentWord);
this.currentWord = [];
d = 2;
}
switch (direction) {
case "start":
this.selected = 0;
break;
case "end":
this.selected = -1;
break;
case "left":
if (this.selected == -1) this.selected = this.input.length;
this.selected -= 1 * d;
if (this.selected != -1) {
this.selected = this.clamp(0, this.input.length, this.selected);
//is there even a point in clamping it here,,,,
}
break;
case "right":
this.selected += 1 * d;
this.selected = this.clamp(0, this.input.length, this.selected);
//tbh same here, like.
//oh well ig ???/
if (this.selected == this.input.length) {
this.selected = -1;
}
break;
}
this.imeReset(true);
}
getUnicodeVowel(vowel, sot) {
if (sot == "standalone") sot = 0;
if (sot == "composing") sot = 1;
if (sot == "trailing") sot = 2;
return String.fromCharCode(parseInt("E00" + this.hVowels[vowel][sot], 16));
}
getUnicodeConsonant(consonant, scv) {
if (scv == "standalone") { scv = 0; }
else if (scv == "trailing") { scv = 1; }
else {
scv = Number(this.hVowels[scv][0]) + 2
}
return String.fromCharCode(parseInt("E" + this.hConsonants[consonant] + "" + scv, 16));
}
inverse(obj) {
var retobj = {};
for (var key in obj) {
retobj[obj[key]] = key;
}
return retobj;
}
imeReset(soft = false) {
this.stateState = 0;
this.inputState = 0;
this.inputFull = [];
this.inputCurrent = "";
if (!soft) {
if (this.selected == -1) {
this.currentWord = [];
} else {
this.input[this.selected] = [];
}
}
}
imeInfo(decHex) {
try {
let hex = decHex.codePointAt(0).toString(16).split("");
hex[1] = hex[1].toString(16);//parseInt(hex[1], 16);
hex[2] = hex[2].toString(16);//parseInt(hex[2], 16);
hex[3] = hex[3].toString(16);//parseInt(hex[3], 16);
let ka = (hex[1] == 0 && hex[2] == 0) ? "a" : "k";
if (ka == "k") {
if (hex[3] == 1) {
//trailing
return ([ka, "trailing"])
} else if (hex[3] == 0) {
//standalone
//full reset / no restore necessary
return ([ka, "standalone"])
} else {
//composing
return ([ka, "composing"])
}
} else {
if (hex[3] <= 8) {
//standalone
return ([ka, "standalone"])
} else {
//trailing
return ([ka, "trailing"])
}
}
} catch {
return "";
}
}
imeChange(inState, stState, pop, array) {
this.inputState = inState;
this.stateState = stState;
if (pop) {
array.pop();
}
this.inputFull = array;
}
// @remi@snug.moe:
// we made a backspace key that works!!!!!!!
// @meduelelateta@sweet.succubi.services:
// ari fell asleep
imeRestore(array) {
let hex = array[array.length - 1].codePointAt(0).toString(16).split("");
hex[1] = hex[1].toString(16);//parseInt(hex[1], 16);
hex[2] = hex[2].toString(16);//parseInt(hex[2], 16);
hex[3] = hex[3].toString(16);//parseInt(hex[3], 16);
let previous = this.imeInfo(array[array.length - 2])[1];
let ka = (hex[1] == 0 && hex[2] == 0) ? "a" : "k"; let ka = (hex[1] == 0 && hex[2] == 0) ? "a" : "k";
if (ka == "k") { if (ka == "k") {
if (hex[3] == 1) { if (hex[3] == 1) {
//trailing //trailing
return([ka,"trailing"]) if (previous == "trailing") {
//trailing twice
// console.log("2.1");
this.imeChange(2, 1, true, array);
} else {
//trailing once
// console.log("2.0");
this.imeChange(2, 0, true, array);
}
} else if (hex[3] == 0) { } else if (hex[3] == 0) {
//standalone if (array.length != 1) {
//full reset / no restore necessary //0.1, i think?
return([ka,"standalone"]) // console.log("0.1");
this.imeChange(0, 1, true, array);
} else {
//standalone
// console.log("full reset");
this.imeReset();
}
} else { } else {
//composing //composing
return([ka,"composing"]) if (previous == "standalone") {
//0.1??
//recreate?? last digit???
let c = this.hConsonantsR[[hex[1], hex[2]].join("").toUpperCase()];
array.pop();
array.push(this.getUnicodeConsonant(c, "standalone"));
this.inputCurrent = c;
// console.log("0.1");
this.imeChange(0, 1, false, array);
} else {
//0.2???? fuck it lets try and find out ig
//recreate?? last digit???
let c = this.hConsonantsR[[hex[1], hex[2]].join("").toUpperCase()];
array.pop();
array.push(this.getUnicodeConsonant(c, "standalone"));
this.inputCurrent = c;
// console.log("0.2");
this.imeChange(0, 2, false, array);
}
} }
} else { } else {
if (hex[3] <= 8) { if (hex[3] <= 8) {
//standalone //standalone
return([ka,"standalone"]) // console.log("full reset");
this.imeReset();
} else { } else {
//trailing //trailing
return([ka,"trailing"]) if (previous == "trailing") {
} //trailing twice
} // console.log("2.1");
} catch { this.imeChange(2, 1, true, array);
return "";
}
}
function imeChange(inState, stState, pop, array) {
inputState = inState;
stateState = stState;
if (pop) {
array.pop();
}
inputFull = array;
}
function imeRestore(array) {
let hex = array[array.length-1].codePointAt(0).toString(16);
hex[1] = parseInt(hex[1], 16);
hex[2] = parseInt(hex[2], 16);
hex[3] = parseInt(hex[3], 16);
let previous = imeInfo(array[array.length-2])[1];
let ka = (hex[1] == 0 && hex[2] == 0) ? "a" : "k";
if (ka == "k") {
if (hex[3] == 1) {
//trailing
if (previous == "trailing") {
//trailing twice
console.log("2.1");
imeChange(2,1,true,array);
} else {
//trailing once
console.log("2.0");
imeChange(2,0,true,array);
}
} else if (hex[3] == 0) {
console.log(array.length);
if (array.length != 1) {
//0.1, i think?
console.log("0.1");
imeChange(0,1,true,array);
} else {
//standalone
console.log("full reset");
imeReset();
}
} else {
//composing
if (previous == "standalone") {
//0.1??
//recreate?? last digit???
let c = hConsonantsR[[hex[1], hex[2]].join("").toUpperCase()];
array.pop();
array.push(getUnicodeConsonant(c, "standalone"));
inputCurrent = c;
console.log("0.1");
imeChange(0,1,false,array);
} else {
//0.2???? fuck it lets try and find out ig
//recreate?? last digit???
let c = hConsonantsR[[hex[1], hex[2]].join("").toUpperCase()];
array.pop();
array.push(getUnicodeConsonant(c, "standalone"));
inputCurrent = c;
console.log("0.2");
imeChange(0,2,false,array);
}
}
} else {
if (hex[3] <= 8) {
//standalone
console.log("full reset");
imeReset();
} else {
//trailing
if (previous == "trailing") {
//trailing twice
console.log("2.1");
imeChange(2,1,true,array);
} else {
//trailing once
console.log("2.0");
imeChange(2,0,true,array);
}
}
}
}
function imeInput(key) {
key = key.toLowerCase();
if (!hConsonantsK.includes(key) && !hVowelsK.includes(key)) return;
switch (inputState) {
case 0: //starting
if (stateState == 0) {
if (hVowelsK.includes(key)) {
inputFull.push(getUnicodeVowel(key, "standalone"));
inputState = 2;
} else { } else {
inputFull.push(getUnicodeConsonant(key, "standalone")); //trailing once
stateState = 1; // console.log("2.0");
inputCurrent = key; this.imeChange(2, 0, true, array);
}
}
}
}
imeInput(key) {
key = key.toLowerCase();
if (!this.hConsonantsK.includes(key) && !this.hVowelsK.includes(key)) return;
switch (this.inputState) {
case 0: //starting
if (this.stateState == 0) {
if (this.hVowelsK.includes(key)) {
this.inputFull.push(this.getUnicodeVowel(key, "standalone"));
this.inputState = 2;
} else {
this.inputFull.push(this.getUnicodeConsonant(key, "standalone"));
this.stateState = 1;
this.inputCurrent = key;
}
break;
} else if (this.stateState == 1) {
if (this.hVowelsK.includes(key)) {
this.inputState = 1;
this.stateState = 0;
} else {
this.inputFull.push(this.getUnicodeConsonant(key, "trailing"));
this.inputCurrent = key;
this.stateState = 2;
break;
}
} else if (this.stateState == 2) {
if (this.hVowelsK.includes(key)) {
this.inputState = 1;
this.stateState = 0;
} else break;
}
case 1: //composing
if (this.hVowelsK.includes(key)) {
this.inputState = 2;
this.inputFull.pop();
this.inputFull.push(this.getUnicodeConsonant(this.inputCurrent, key));
this.inputCurrent = "";
} }
break; break;
} else if (stateState == 1) { case 2: //trailing
if (hVowelsK.includes(key)) { if (this.hVowelsK.includes(key)) {
inputState = 1; if (this.stateState == 1 && this.inputCurrent != "") {
stateState = 0; this.inputFull.pop();
let ic = this.inputCurrent;
let k = key;
this.imePush();
this.inputFull.pop();
this.inputFull.push(this.getUnicodeConsonant(ic, k));
this.inputCurrent = "";
this.inputState = 2;
} else {
this.inputFull.push(this.getUnicodeVowel(key, "trailing"));
this.inputCurrent = "";
this.stateState += 1;
}
} else { } else {
inputFull.push(getUnicodeConsonant(key, "trailing")); this.inputFull.push(this.getUnicodeConsonant(key, "trailing"));
inputCurrent = key; this.inputCurrent = key;
stateState = 2; this.stateState += 1;
break;
} }
} else if (stateState == 2) { if (this.stateState == 2) {
if (hVowelsK.includes(key)) { this.stateState = 0;
inputState = 1; this.inputState = 3;
stateState = 0; };
} else break; break;
} case 3: //go to next word uwu
case 1: //composing if (this.hVowelsK.includes(key)) {
if (hVowelsK.includes(key)) { this.inputFull.pop();
inputState = 2; let ic = this.inputCurrent;
inputFull.pop(); let k = key;
inputFull.push(getUnicodeConsonant(inputCurrent, key)); this.imePush();
inputCurrent = ""; this.inputFull.pop();
} this.inputFull.push(this.getUnicodeConsonant(ic, k));
break; this.inputCurrent = "";
case 2: //trailing this.inputState = 2;
if (hVowelsK.includes(key)) { } else {
inputFull.push(getUnicodeVowel(key, "trailing")); this.imePush();
stateState += 1; this.imeInput(key);
} else { }
inputFull.push(getUnicodeConsonant(key, "trailing")); break;
stateState += 1; }
}
if (stateState == 2) {
stateState = 0;
inputState = 3;
}
break;
case 3: //go to next word uwu
//todo :)
break;
} }
} }

View File

@@ -13,31 +13,31 @@ LU'NYA
(po'nyash!) (po'nyash!)
ESH'NYUI ESH'NYUI
ba yu e wawote to pu mipura lili'nya dre? ba yu e wawote to pu mipura lili'nya dre?
r uwu r uwu
LU'NYA LU'NYA
relfur chu mya pu yu mya relfur lup apatka'nya faka'nya'pash ponme mya wawote polika'nya peekaka'nya'pash. relfur chu mya pu yu mya relfur lup apatka'nya faka'nya'pash ponme mya wawote polika'nya peekaka'nya'pash.
ESH'NYUI ESH'NYUI
mi'shi'pash~ mi'shi'pashshu
balfur yu e ton polika'nya dre? balfur yu e ton polika'nya dre?
LU'NYA LU'NYA
mishi'pash!! mishi'pash!!
relfurla mya ton polika'nya yu meluton ka'nya! relfurla mya ton polika'nya yu meluton ka'nya!
balfurla yu dra? balfurla yu dra?
ESH'NYUI ESH'NYUI
relfurla yu esh'dre mya ton polika'nya yu puroton ka'nya~ relfurla yu esh'dre mya ton polika'nya yu puroton ka'nyashu
relfur yu shi'ro'bae'pu yu pon'ya ka'nya~ relfur yu shi'ro'bae'pu yu pon'ya ka'nyashu
LU'NYA LU'NYA
puroton yu ponya ton ka'nya! puroton yu ponya ton ka'nya!
ESH'NYUI ESH'NYUI
be'nyui-rerenlafura yu meluton mimifaka'nya… be'nyui-rerenlafura yu meluton mimifaka'nya…
relfur yu meluton mimiku'pash~ relfur yu meluton mimiku'pashshu
LU'NYA LU'NYA
o'o, relfur chu parefaka'nya… o'o, relfur chu parefaka'nya…
@@ -45,23 +45,23 @@ LU'NYA
ESH'NYUI ESH'NYUI
uu, relfur yu naomiminku mya mimifuku mya ton ka'nya... uu, relfur yu naomiminku mya mimifuku mya ton ka'nya...
relfur yu guraton to meluton mimifuku.. relfur yu guraton to meluton mimifuku..
relfur yu ton mimiku'pash~ relfur yu ton mimiku'pashshu
LU'NYA LU'NYA
ishi-balfur yu mishi'pash! ishi-balfur yu mishi'pash!
balfur chu mya arilaen yu en ka'nya peekaka'nya fa'dre? balfur chu mya arilaen yu en ka'nya peekaka'nya fa'dre?
ESH'NYUI ESH'NYUI
i eshnyui_blush.png i eshnyui_blush.png
yesh-balfur yu mishi'pash~ yesh-balfur yu mishi'pashshu
(>///////////////<) r (>///////////////<)
relfur yu ari'laen parefaka'nya, balfur yu pareka'nya dra? relfur yu ari'laen parefaka'nya, balfur yu pareka'nya dra?
LU'NYA LU'NYA
relfur chu arilaen dedaka'nya. relfur chu arilaen dedaka'nya.
imanla rila shashka'nya'pash. imanla rila shashka'nya'pash.
imanla shoo chu ike to pikeshe ka'nya. imanla shoo chu ike to pikeshe ka'nya.
/ /
relfur chu arilaenlan luka'nya'pash. relfur chu arilaenlan luka'nya'pash.
@@ -70,5 +70,5 @@ i eshnyui.png
arilaenla shoo chu pikeshe fuka'nya'bash dra? arilaenla shoo chu pikeshe fuka'nya'bash dra?
LU'NYA LU'NYA
gao chu relfur yu fayu kan'ya. gao chu relfur yu fayu kan'ya.
relfur chu arilaen dedaka'nya. relfur chu arilaen dedaka'nya.

View File

@@ -1,23 +1,40 @@
ITS ME PEKORA NOUNS
d deez d nya
r hiiiii!!!! ren
! uwu renla
renlan
relfur
renlafura
m
VERBS
r TENSES
utiku
utikanya
utikome
/
r FORMAL
utika'nya
utikome
/
r INFORMAL
uti'nya
uti'me
/
r FEELING
utikupash
utifakupash
utikufapash
utifakufapash
/
r IMPERATIVE
utikudash
utifakudash
utikufadash
utifaku
HOLY SHIT REMI HOLY SHIT REMI
d a d a
amogus amogus
it's meee pekora!!!!
i eshnyui.png
d yolo
so cool
so cool
so cool
how this work owo
so cool
so uwu
very good

206
main.js
View File

@@ -4,6 +4,7 @@ let currentFont = "r";
let timeout = ""; let timeout = "";
let badge_type = "#696969"
let badge_generic = "#393939" let badge_generic = "#393939"
let badge_register= "#fed100" let badge_register= "#fed100"
let badge_number = "#420690" let badge_number = "#420690"
@@ -13,20 +14,94 @@ let badge_mood = "#dd00dd"
let badge_negation = "#133337" let badge_negation = "#133337"
let quirkBadges = { let quirkBadges = {
"formal1": { // TYPES
"verb": {
"name": "Verb",
"description": "This word expresses an action that the subject of the sentence performs.",
"color": badge_type,
"type": "Type",
"bending": "-ku"
},
"marker": {
"name": "marker",
"description": "This word accomplishes some syntactic purpose in the sentence.",
"color": badge_type,
"type": "Type",
"bending": ""
},
"noun": {
"name": "Noun",
"description": "This word refers to a concept.",
"color": badge_type,
"type": "Type",
"bending": ""
},
"pronoun": {
"name": "Pronoun",
"description": "This word occupies the place of a noun.",
"color": badge_type,
"type": "Type",
"bending": ""
},
"modifier": {
"name": "Modifier",
"description": "This word modifies another word to specify meaning.",
"color": badge_type,
"type": "Type",
"bending": ""
},
"expression": {
"name": "Expression",
"description": "This is an idiomatic expression.",
"color": badge_type,
"type": "Type",
"bending": ""
},
// FORMAL REGISTER
"formal-n1": {
"name": "Formal", "name": "Formal",
"description": "This word is used in formal or sincere settings.", "description": "This word is used in formal or sincere settings.",
"color": badge_register, "color": badge_register,
"type": "Register", "type": "Register",
"bending": "-lfur" "bending": "-lfur"
}, },
"formal2": { "formal-n2": {
"name": "Formal", "name": "Formal",
"description": "This word is used in formal or sincere settings.", "description": "This word is used in formal or sincere settings.",
"color": badge_register, "color": badge_register,
"type": "Register", "type": "Register",
"bending": "-lafura" "bending": "-lafura"
}, },
"formal-v1": {
"name": "Formal",
"description": "This word is used in formal or sincere settings.",
"color": badge_register,
"type": "Register",
"bending": "ku -> kanya"
},
"formal-v2": {
"name": "Formal",
"description": "This word is used in formal or sincere settings.",
"color": badge_register,
"type": "Register",
"bending": "ku -> kome"
},
// INFORMAL REGISTER
"informal-v1": {
"name": "Informal",
"description": "This word is NOT used in formal or sincere settings.",
"color": badge_register,
"type": "Register",
"bending": "ku -> nya"
},
"informal-v2": {
"name": "Informal",
"description": "This word is NOT used in formal or sincere settings.",
"color": badge_register,
"type": "Register",
"bending": "ku -> me"
},
// POSSESIVES
"genitive": { "genitive": {
"name": "Generic Possesive", "name": "Generic Possesive",
"description": "This word is describing a generic possesive relationship.", "description": "This word is describing a generic possesive relationship.",
@@ -39,29 +114,54 @@ let quirkBadges = {
"description": "This word is describing a specific possesive relationship.", "description": "This word is describing a specific possesive relationship.",
"color": badge_case, "color": badge_case,
"type": "Case", "type": "Case",
"bending": "la" "bending": "-la"
},
// NUMBER
"dual": {
"name": "Dual",
"description": "This word is denoted as refering to exactly two entities.",
"color": badge_number,
"type": "Number",
"bending": ""
}, },
"plural": { "plural": {
"name": "Plural", "name": "Plural",
"description": "This word is denoted as more than one", "description": "This word is denoted as refering to at least more than one entity.",
"color": badge_number, "color": badge_number,
"type": "Number", "type": "Number",
"bending": "n" "bending": "-n"
}, },
"present-tense": { // PRESENT TENSE
"present-tense-formal": {
"name": "Present", "name": "Present",
"description": "This word is in the present tense.", "description": "This word is in the present tense.",
"color": badge_tense, "color": badge_tense,
"type": "Tense", "type": "Tense",
"bending": "ku → ka'nya" "bending": "ku → ka'nya"
}, },
"past-tense": { "present-tense-informal": {
"name": "Present",
"description": "This word is in the present tense.",
"color": badge_tense,
"type": "Tense",
"bending": "ku → nya"
},
// PAST TENSE
"past-tense-formal": {
"name": "Past", "name": "Past",
"description": "This word is in the past tense.", "description": "This word is in the past tense.",
"color": badge_tense, "color": badge_tense,
"type": "Tense", "type": "Tense",
"bending": "ku → kome" "bending": "ku → kome"
}, },
"past-tense-informal": {
"name": "Past",
"description": "This word is in the past tense.",
"color": badge_tense,
"type": "Tense",
"bending": "ku → me"
},
// VOLITIONAL
"volitional-mood": { "volitional-mood": {
"name": "Feeling", "name": "Feeling",
"description": "This word expresses a feeling or craving mood.", "description": "This word expresses a feeling or craving mood.",
@@ -69,6 +169,14 @@ let quirkBadges = {
"type": "Mood", "type": "Mood",
"bending": "-pash" "bending": "-pash"
}, },
"volitional-mood-negated": {
"name": "Negated Feeling",
"description": "This word denies feeling or craving mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-fapash"
},
// IMPERATIVE
"imperative-mood": { "imperative-mood": {
"name": "Imperative", "name": "Imperative",
"description": "This word expresses a imperative mood.", "description": "This word expresses a imperative mood.",
@@ -76,27 +184,82 @@ let quirkBadges = {
"type": "Mood", "type": "Mood",
"bending": "-dash" "bending": "-dash"
}, },
"imperative-mood-negated": {
"name": "Negated Imperative",
"description": "This word denies a imperative mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-fadash"
},
// SHY
"shy-mood": { "shy-mood": {
"name": "Shy", "name": "Shy",
"description": "This word expresses a shy mood..", "description": "This word expresses a shy mood.",
"color": badge_mood, "color": badge_mood,
"type": "Mood", "type": "Mood",
"bending": "-bash" "bending": "-bash"
}, },
"shy-mood-negated": {
"name": "Negated Shy",
"description": "This word denies a shy mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-fabash"
},
// THREAT
"threat-mood": { "threat-mood": {
"name": "Threat", "name": "Threat",
"description": "This word expresses a threatening mood..", "description": "This word expresses a threatening mood.",
"color": badge_mood, "color": badge_mood,
"type": "Mood", "type": "Mood",
"bending": "-tash" "bending": "-tash"
}, },
"threat-mood-negated": {
"name": "Negated Threat",
"description": "This word denies a threatening mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-fatash"
},
// COMF
"comfy-mood": {
"name": "Comfort",
"description": "This word expresses a comfortable mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-shu"
},
"comfy-mood-negated": {
"name": "Negated Comfort",
"description": "This word denies a comfortable mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-fashu"
},
// EXCITEMENT
"excited-mood": {
"name": "Excitement",
"description": "This word expresses a excited mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-ha"
},
"excited-mood-negated": {
"name": "Negated Excitement",
"description": "This word denies a excited mood.",
"color": badge_mood,
"type": "Mood",
"bending": "-faha"
},
// NEGATION
"negated": { "negated": {
"name": "Negative", "name": "Negative",
"description": "The word is expressing a negated meaning.", "description": "The word is expressing a negated meaning.",
"color": badge_negation, "color": badge_negation,
"type": "Negation", "type": "Negation",
"bending": "-fa-" "bending": "fa-"
}, },
// UNKNOWN
"unknown-tag": { "unknown-tag": {
"name": "Unknown tag", "name": "Unknown tag",
"color": "#393939", "color": "#393939",
@@ -128,19 +291,19 @@ function showPopup(ogword, word, quirks = "") {
let c = document.querySelector("#popup-container"); let c = document.querySelector("#popup-container");
word = cleanWord(word); word = cleanWord(word);
if (currentFont == "r") { if (currentFont == "r") {
p.querySelector("h1").innerText = words[word]["romanizationProper"]; p.querySelector("h1").innerText = ogword;
p.querySelector("#popup-heo").innerText = words[word]["heonian"]; p.querySelector("#popup-heo").innerText = words[word]["romanizationProper"] + " | " + words[word]["heonian"];
p.querySelector("h1").style.fontFamily = "var(--font-normal)"; p.querySelector("h1").style.fontFamily = "var(--font-normal)";
} else { } else {
p.querySelector("h1").innerText = words[word]["heonian"]; p.querySelector("h1").innerText = ogword;
p.querySelector("#popup-heo").innerText = words[word]["romanizationProper"]; p.querySelector("#popup-heo").innerText = words[word]["heonian"] + " | " + words[word]["romanizationProper"];
p.querySelector("h1").style.fontFamily = "var(--font-heonian)"; p.querySelector("h1").style.fontFamily = "var(--font-heonian)";
} }
p.querySelector("#popup-type").innerText = words[word]["type"]; //p.querySelector("#popup-type").innerText = words[word]["type"];
p.querySelector("#popup-meaning").innerText = words[word]["meaning"]; p.querySelector("#popup-meaning").innerText = words[word]["meaning"];
p.querySelector("#popup-quirks").innerHTML = ""; p.querySelector("#popup-quirks").innerHTML = "";
if (quirks.trim() != "") { if (quirks.trim() != "") {
p.querySelector("#popup-quirks-container").style.display = "block"; p.querySelector("#popup-middle").style.display = "block";
let qyuirks = quirks.split(" "); let qyuirks = quirks.split(" ");
qyuirks.forEach(quirk => { qyuirks.forEach(quirk => {
let badge = document.createElement("div"); let badge = document.createElement("div");
@@ -150,10 +313,11 @@ function showPopup(ogword, word, quirks = "") {
badge.style.boxShadow = "0px 0px 4px " + quirkBadges[quirk]["color"] + "cc"; badge.style.boxShadow = "0px 0px 4px " + quirkBadges[quirk]["color"] + "cc";
badge.innerText = quirkBadges[quirk]["name"]; badge.innerText = quirkBadges[quirk]["name"];
badge.onclick = () => { badge.onclick = () => {
p.querySelector("#spacerhide").style.display = "none";
p.querySelector("#popup-middle").style.display = "none";
p.querySelector("h1").innerText = quirkBadges[quirk]["name"]; p.querySelector("h1").innerText = quirkBadges[quirk]["name"];
p.querySelector("#popup-meaning").innerText = quirkBadges[quirk]["description"]; p.querySelector("#popup-meaning").innerText = quirkBadges[quirk]["description"];
p.querySelector("#popup-type").innerText = quirkBadges[quirk]["type"]; //p.querySelector("#popup-type").innerText = quirkBadges[quirk]["type"];
p.querySelector("#popup-quirks-container").style.display = "none";
p.querySelector("#popup-heo").innerText = quirkBadges[quirk]["bending"]; p.querySelector("#popup-heo").innerText = quirkBadges[quirk]["bending"];
} }
} catch (e) { } catch (e) {
@@ -162,9 +326,11 @@ function showPopup(ogword, word, quirks = "") {
badge.innerText = quirkBadges["unknown-tag"]["name"]; badge.innerText = quirkBadges["unknown-tag"]["name"];
} }
p.querySelector("#popup-quirks").appendChild(badge); p.querySelector("#popup-quirks").appendChild(badge);
p.querySelector("#spacerhide").style.display = "block";
}); });
} else { } else {
p.querySelector("#popup-quirks-container").style.display = "none"; p.querySelector("#spacerhide").style.display = "none";
p.querySelector("#popup-middle").style.display = "none";
} }
c.style.opacity = 1; c.style.opacity = 1;
c.style.pointerEvents = "all"; c.style.pointerEvents = "all";
@@ -230,7 +396,7 @@ function createWordList() { //sometimes i really dislike javascript..
words[n]["heonian"] = e[0].innerText; words[n]["heonian"] = e[0].innerText;
words[n]["romanization"] = e[1].innerText.replace(". ", ""); words[n]["romanization"] = e[1].innerText.replace(". ", "");
words[n]["romanizationProper"] = e[1].innerText; words[n]["romanizationProper"] = e[1].innerText;
words[n]["type"] = e[2].innerText; //words[n]["type"] = e[2].innerText;
words[n]["meaning"] = e[3].innerText; words[n]["meaning"] = e[3].innerText;
} }
}); });

0
test.htm Normal file
View File

1638
test.html

File diff suppressed because it is too large Load Diff

View File

@@ -223,7 +223,7 @@ main {
} }
#popup-heo, #smol-heo { #popup-heo, #smol-heo {
font-family: "heonian"; font-family: var(--font-heonian);
text-align: center; text-align: center;
margin: 4px; margin: 4px;
margin-bottom: 8px; margin-bottom: 8px;