Compare commits

...

26 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
1888f794b1 Merge branch 'master' of https://git.succubi.services/lustlion/heonian-conversation 2022-05-07 11:55:48 +02:00
ad22fd715e working backspace button :) 2022-05-07 11:55:45 +02:00
UndeadMaelys
cd6deac0b4 fixed nouns not being properly checked in database 2022-05-07 10:20:33 +02:00
c01ebee0ae ime - initial version 2022-05-07 00:08:08 +02:00
e775b7d6a2 minor design changes 2022-05-06 17:20:00 +02:00
6823641f73 design changes for popup 2022-05-06 17:07:07 +02:00
UndeadMaelys
cb09f7235d chchanged badge colors, added more badges types, handled formal1 and formal2 separately 2022-05-06 16:55:40 +02:00
UndeadMaelys
6d7ae9cefd clean 2022-05-06 16:05:37 +02:00
UndeadMaelys
5b3a9555d1 fix wrong input 2022-05-06 16:05:37 +02:00
UndeadMaelys
0beb347849 polite, plural, possesive, genitive morphemes handled. 2022-05-06 16:05:37 +02:00
19 changed files with 3170 additions and 1945 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

244
R2H2.lua
View File

@@ -1,244 +0,0 @@
--functions
function CopyToClipboard(textString)
outClipFile, err = io.open("clipboardTempFile",'w')
if err then
print("[Error Opening Clipboard Temporary File for Writing]")
return
end
outClipFile:write(textString,'\n')
outClipFile:close()
command = 'cat "' .. "clipboardTempFile" .. '" | xclip -selection clipboard &'
os.execute(command)
os.execute("rm clipboardTempFile")
end
function PrintPosition(string)
local print_text = ""
for i = 1, string.len(string) do
while i >= 10 do i = i - 10 end
print_text = print_text .. tostring(i)
end
print("pos: " .. print_text)
print_text = ""
for i = 1, string.len(string) do
i = math.floor(i/10)
while i >= 10 do i = i - 10 end
if i == 0 then i = " " end
print_text = print_text .. tostring(i)
end
print(" " ..print_text)
end
-- DATA
-- vowels
vowel_table = {"a","e","i","o","u"}
symbol_vowel = {"","","","",""}
symbol_extending_vowel = {"","","","",""}
-- consonants
consonant_table = {"g","sh","r","ny","ch","n","y","f","t","k","w","l","p","b","d","h","m"}
symbol_consonant = {"","","","","","","","","","","","","","","","",""}
symbol_extending_consonant = {"","","","","","","","","","","","","","","","",""}
-- composites
composing_consonant_table = {"g","sh","r","ny","ch","m","y","f","t","k","w","l","p","b","d","h"}
symbol_composite = {
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""}
}
-- program start
function convertToHeonian(text)
local step = true -- this is set to false when a conclusion has been reached
local transcribed = false
local transcribed_text = ""
local debug = false
local autocopy = false
for _, v in pairs(arg) do
if v == "-v" or v == "--verbose" then debug = true end
if v == "-c" or v == "--copy" then autocopy = true end
end
-- if its necessary to run the script, then we continue :D
if step then
-- prepare text
-- 1. add syllable marker at start if it isn't already present.
if string.sub(text,1,1) ~= "." then text = "." .. text end
-- 2. turn [x] into [ksh]
text = string.gsub(text,"x","ksh")
-- 3. turn [z] into [dsh]
text = string.gsub(text,"z","d.sh")
-- 4. turn [j] into [y]
text = string.gsub(text,"j","y")
-- read input and transcribe
-- debug log
if debug then print("") end
if debug then print("src: ".. text) end
if debug then PrintPosition(text) end
-- sort through all the letters
local i = 1
while i < string.len(text)+1 do
local pos = i
-- know current pos, since we will be modifying i but still evaluating from the position
local char_step = true
-- this is false when a conclusion has been reached about what symbol does the next segment correspond to
local debug_s = ""
-- debug string
local new_syllable = false
-- this is true when a new syllable begins, and is used to distinguish normal vowels and consonants from trailing ones
if i == 1 then new_syllable = true end
if string.sub(text,i,i) == "\t"
or string.sub(text,i,i) == "-" then -- check if its an unsupported symbol to skip it.
-- adjust i
i = i + 1
pos = i
char_step = false
end
-- init checkup
if string.sub(text,i,i) == "."
or string.sub(text,i,i) == "'"
or string.sub(text,i,i) == " "
or string.sub(text,i,i) == "" then -- this forces the new syllable, since . is the syllable separator, also skips the symbol and repositions
if string.sub(text,i,i) == " " then -- spaces are exception
transcribed_text = transcribed_text .. " "
new_syllable = true
end
-- debug log
if debug then print("") end
if debug then print(" @[".. tostring(i).."]"..debug_s.." new syllable MARKER found") end
-- start syllable
new_syllable = true
debug_s = ""
-- adjust i
i = i + 1
-- debug log
if debug then print(" >>> adjusting by (1) from [".. pos .. "] to [".. i .. "]" ) end
-- adjust pos
pos = i
end
-- debug log
if debug then print("") end
if debug then print(" @[".. tostring(i).."]"..debug_s.." checking string: ".. string.sub(text,i,i)) end -- debug print positional info
-- lets check if it is a composite
if char_step == true then
local cons_id = 0
local length = 0
-- check if its valid consonant for a composite
for _, consonant in pairs(composing_consonant_table) do
cons_id = cons_id + 1
-- get consonant length its checking against, so we can properly compare.
length = string.len(consonant)
-- debug log
--if debug then print(" checking composite consonant: " .. composing_consonant_table[cons_id]) end
if string.sub(text,i,i+length-1) == consonant then
-- debug log
if debug then print(" (!) valid consonant: " .. composing_consonant_table[cons_id]) end
-- check if its a valid vowel AFTER the valid consonant, while sorting through all vowels
local vowel_id = 0
for _, vowel in pairs(vowel_table) do
vowel_id = vowel_id + 1
--if debug then print(" checking composite: " .. composing_consonant_table[cons_id]..vowel_table[vowel_id]) end
if string.sub(text,i+length,i+length) == vowel then
-- adjust by consonant length + vowel
i = i + string.len(consonant) + 1
-- debug log
if debug then print(" (!) valid composite: " .. consonant .. vowel ..", length: "..length+1) end
if debug then print(" >>> adjusting by (" .. tostring(length+1) .. ") from [".. pos .. "] to [".. i .. "]" ) end
-- transcribe; conclude;
transcribed_text = transcribed_text .. symbol_composite[vowel_id][cons_id]
char_step = false
break
end
end
-- no need to check for more consonants if one is valid
break
end
end
if debug then if char_step ~= false then print(" [!] invalid composite") end end
end
-- lets check if it is a non composite vowel
if char_step == true then
local id = 0
local length = 0
for _, vowel in pairs(vowel_table) do
id = id+ 1
-- get vowel length its checking against, so we can properly compare.
length = string.len(vowel)
-- debug log
--if debug then print(" checking standalone vowel: " .. vowel_table[id]) end
if string.sub(text,i,i+length-1) == vowel then
i = i + string.len(vowel)
-- debug log
if debug then print(" (!) valid vowel: " .. vowel_table[id]) end
if debug then print(" >>> adjusting by (" .. tostring(length) .. ") from [".. pos .. "] to [".. i .. "]" ) end
-- transcribe; conclude;
local table = nil
if new_syllable then
table = symbol_vowel
else
table = symbol_extending_vowel
end
transcribed_text = transcribed_text .. table[id]
char_step = false
break
end
end
end
-- lets check if it is a non composite consonant
if char_step == true then
local id = 0
local length = 0
for _, consonant in pairs(consonant_table) do
id = id+ 1
-- get consonant length its checking against, so we can properly compare.
length = string.len(consonant)
-- debug log
--if debug then print(" checking standalone consonant: " .. consonant_table[id]) end
if string.sub(text,i,i+length-1) == consonant then
i = i + string.len(consonant)
-- debug log
if debug then print(" (!) valid consonant: " .. consonant_table[id]) end
if debug then print(" >>> adjusting by (" .. tostring(length) .. ") from [".. pos .. "] to [".. i .. "]" ) end
-- transcribe; conclude;
local table = nil
if new_syllable then
table = symbol_consonant
else
table = symbol_extending_consonant
end
transcribed_text = transcribed_text .. table[id]
char_step = false
break
end
end
end
-- if no idea, move on, and just be confused. prints ?
if char_step == true then
-- debug log
if debug then print(" [!] no idea; moving on to next [".. pos + 1 .."]") end
-- no idea
transcribed_text = transcribed_text .. string.sub(text,i,i)
i = i + 1
-- debug log
if debug then print(" >>> adjusting by (1) from [".. pos .. "] to [".. i .. "]" ) end
end
end
-- output
if autocopy then CopyToClipboard(string.sub(transcribed_text,0,-1)) end
return transcribed_text
end
end

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
@@ -17,9 +67,9 @@ function process_content(content)
end end
local ac = content local ac = check_symbol(content)
while string.find(ac, " ") do while string.find(ac, " ") do
local new_word = string.sub(ac, 0, string.find(ac, " ")) local new_word = string.sub(ac, 0, string.find(ac, " ")-1)
local indicators = {} local indicators = {}
if i == 1 then if i == 1 then
@@ -29,8 +79,9 @@ function process_content(content)
end end
new_word = strip_symbols(new_word) new_word = strip_symbols(new_word)
new_word = replace_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 = 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
@@ -146,28 +198,131 @@ function strip_symbols(str)
return str return str
end end
function replace_symbols(str) function replace_sign(str)
while string.find(str, "%-") do while string.find(str, "%-") do
str = string.gsub(str, "%-"," ") str = string.gsub(str, "%-"," ")
end end
return str return str
end end
function find_n_replace(str, tbl,find,repl,indicator) function check_symbol(str)
if string.find(str, find) then if not in_dictionary(str) then
str = string.gsub(str, find, repl) return replace_sign(str)
table.insert(tbl,indicator) 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 end
return str, tbl return str, tbl
end 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)
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,"la","","possesive")
str, tbl = check_morphemes(str,tbl,"n","","plural")
return str, tbl
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
@@ -249,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

@@ -1,16 +1,17 @@
<div id="popup-container" style="opacity: 0; pointer-events: none;"> <div id="popup-container" style="opacity: 0; pointer-events: none;">
<div id="popup"> <div id="popup">
<h1>um</h1> <h1>um</h1>
<div> <p id="popup-heo"></p>
<b><span id="popup-e">heonian: </span></b><span id="popup-heo"></span><br> <div id="spacerhide" class="spacer"></div>
<b>type: </b><span id="popup-type"></span><br> <div id="popup-middle">
<div id="popup-quirks-container"><b>quirks:</b> <span id="popup-quirks"></span></div> <div id="popup-quirks-container"><span id="popup-quirks"></span></div>
</div> </div>
<div class="spacer"></div>
<p id="popup-meaning"></p> <p id="popup-meaning"></p>
</div> </div>
</div> </div>
<div id="smol-popup" style="opacity: 0; pointer-events: none;"> <div id="smol-popup" style="opacity: 0; pointer-events: none;">
<h1>um</h1> <h1>um</h1>
<p id="smol-meaning"></p> <p id="smol-meaning"></p>
<p style="font-size:0.75rem">click for more info!</p> <p>click for more info!</p>
</div> </div>

28
ime.html Normal file
View File

@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ime test</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@font-face {
font-family: "heonian";
src: url('HeonianAlone.otf');
}
textarea {
font-family: "heonian";
font-size: 32px;
}
</style>
</head>
<body>
<p>type in ime, wow!!!!!!!!!!!</p>
<textarea type="text" class="ime">
</textarea>
<script src="./heonian-ime/ime.js" async defer></script>
</body>
</html>

472
ime.js Normal file
View File

@@ -0,0 +1,472 @@
// 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 h;
window.onload = () => {
document.querySelectorAll(".ime").forEach(input => {
h = new HeonianIME(input);
});
}
class HeonianIME {
constructor(what) {
this.input = [];
this.currentWord = [];
this.selected = -1;
this.inputState = 0; //STARTING, COMPOSTING, TRAILING, Fucking Nothing, ...cleanup
this.stateState = 0; //depends on the state
this.inputFull = [];
this.inputCurrent = "";
this.ourHtml;
this.oldText = [];
this.hVowels = { //standalone, composing, trailing
"a": ["0", "5", "A"],
"e": ["1", "6", "B"],
"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);
}
}
this.imeDown = ()=>{};
this.mouse = ()=>{};
//close enough?
}
imePush() {
//basically equavlient to pressing enter.
if (this.selected == -1) {
if (this.currentWord.join() == "") { //blame js :)
let s = document.createElement("p");
s.innerText = this.input.join("");
document.body.appendChild(s);
this.input = [];
this.selected = -1;
} else {
this.input.push(this.currentWord);
this.currentWord = [];
}
this.imeReset();
} else {
if (this.selected + 1 >= this.input.length) {
this.selected = -1;
} else {
this.selected += 1;
}
this.imeReset(true);
}
}
imeDown(keyEvent, inputField) {
keyEvent.preventDefault();
switch (keyEvent.key) {
case "Backspace":
if (this.selected == -1) {
if (this.currentWord.join("") == "") {
this.currentWord = this.input.pop() || [];
} else {
this.imeRestore(this.currentWord);
// this.currentWord.pop();
}
} else {
this.imeRestore(this.input[this.selected]);
// this.input[this.selected].pop();
if (this.input[this.selected].join("") == "") {
this.input.splice(this.selected, 1);
this.imeMove("left");
}
}
break;
case "Enter":
this.imePush()
break;
case "Space":
//adds a ', on second press . an actual space
break;
case "ArrowLeft":
this.imeMove("left");
break;
case "ArrowRight":
this.imeMove("right");
break;
case "ArrowDown":
this.imeMove("start");
break;
case "ArrowUp":
this.imeMove("end");
break;
case "Escape":
this.imeDetach();
return;
default:
this.imeInput(keyEvent.key);
if (this.selected == -1) {
this.currentWord = this.inputFull;
} else {
this.input[this.selected] = this.inputFull;
}
break;
}
this.imeUpdate(inputField);
}
imeUpdate(inputField) {
let renderText = "";
this.input.forEach((w) => {
renderText += w.join("");
})
inputField.value = this.oldText[0] + renderText + this.currentWord.join("") + this.oldText[1];
if (this.selected == -1) {
inputField.setSelectionRange(this.oldText[0].length+renderText.length, this.oldText[0].length+renderText.length + this.currentWord.join("").length);
} else {
if (this.input.join("") != "") {
let from = 0;
for (let x = 0; x < this.selected; x++) {
from += this.input[x].join("").length;
}
let to = from + this.input[this.selected].join("").length;
inputField.setSelectionRange(this.oldText[0].length+from, this.oldText[0].length+to);
}
}
}
clamp(min, max, value) {
return Math.max(min, Math.min(max, value));
}
imeMove(direction) {
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";
if (ka == "k") {
if (hex[3] == 1) {
//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) {
if (array.length != 1) {
//0.1, i think?
// console.log("0.1");
this.imeChange(0, 1, true, array);
} else {
//standalone
// console.log("full reset");
this.imeReset();
}
} else {
//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 {
if (hex[3] <= 8) {
//standalone
// console.log("full reset");
this.imeReset();
} else {
//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);
}
}
}
}
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;
case 2: //trailing
if (this.hVowelsK.includes(key)) {
if (this.stateState == 1 && this.inputCurrent != "") {
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 {
this.inputFull.push(this.getUnicodeConsonant(key, "trailing"));
this.inputCurrent = key;
this.stateState += 1;
}
if (this.stateState == 2) {
this.stateState = 0;
this.inputState = 3;
};
break;
case 3: //go to next word uwu
if (this.hVowelsK.includes(key)) {
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.imePush();
this.imeInput(key);
}
break;
}
}
}

56
ime.txt Normal file
View File

@@ -0,0 +1,56 @@
Description of IME:
5 states:
- STARTING
- COMPOSING
- TRAILING
Nomenclature: [Whole] / [Up|Down]
At any times, enter can be pressed to finish the input process.
Pressing enter with input process already finished will send the message.
STATE 1 - STARTING
Any first letter input is displayed as non-composing non-trailing symbol.
The big standalone variant.
Consonant [K]
Vowel [A]
If CONSONANT was inputted:
- Move to COMPOSING if next a VOWEL is inputted.
- Repeat this step if not, but adding the input as a trailing letter instead (uppercase). This can only happen once.
If VOWEL was inputted, move to TRAILING.
STATE 2 - COMPOSING
Only vowels are inputted. It is transcribed to heonian as a downside letter.
Vowel -> [K|A]
Move to TRAILING.
STATE 3 - TRAILING. (UP TO 2 TIMES)
Any letter input is displayed as a trailing symbol.
Aka uppercase.
1-3 -> [A][N| ]
1-3-3 -> [A][N| ][N| ]
1-2-3 -> [K|A][N| ]
1-2-3-3 -> [K|A][N| ][N| ]
1-1-2-3 -> [K][K|A][N| ]
1-1-2-3-3 -> [K][K|A][N| ][N| ]
This process can be repeated up to two times.
https://cronut.cafe/~lustlion/myrheon/test/
0xE -> Heonian Letter
next two digits: Vowels / What Consonant
last digit: Standalone / Trailing / Composing
simplified:
1. First letter inputted is standalone except if composing.
2. There can only be one composing per syllable, if it manages to go composing it goes to trailing.
3. You can input up to two letters before either composing or ending the syllable.
4. You can have 0, 1 or 2 trailing letters.

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?
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

304
main.js
View File

@@ -1,64 +1,265 @@
//since this _entire thing_ will be generated,
//you could "theoretically" (you definitive can)
//just sorta. skip the whole "scan all words" bit,
//which is why that's in a separate function
let words = {} let words = {}
let currentFont = "r"; let currentFont = "r";
let timeout = ""; let timeout = "";
let badge_type = "#696969"
let badge_generic = "#393939"
let badge_register= "#fed100"
let badge_number = "#420690"
let badge_case = "#690420"
let badge_tense = "#00dd00"
let badge_mood = "#dd00dd"
let badge_negation = "#133337"
let quirkBadges = { let quirkBadges = {
"present-tense": { // TYPES
"name": "Present tense", "verb": {
"description": "The word is in the present tense.", "name": "Verb",
"color": "#00dd00", "description": "This word expresses an action that the subject of the sentence performs.",
"type": "Tense", "color": badge_type,
"bending": "ka'nya" "type": "Type",
"bending": "-ku"
}, },
"past-tense": { "marker": {
"name": "Past tense", "name": "marker",
"description": "The word is in the past tense.", "description": "This word accomplishes some syntactic purpose in the sentence.",
"color": "#dd00dd", "color": badge_type,
"type": "Tense", "type": "Type",
"bending": "kome" "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",
"description": "This word is used in formal or sincere settings.",
"color": badge_register,
"type": "Register",
"bending": "-lfur"
},
"formal-n2": {
"name": "Formal",
"description": "This word is used in formal or sincere settings.",
"color": badge_register,
"type": "Register",
"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": {
"name": "Generic Possesive",
"description": "This word is describing a generic possesive relationship.",
"color": badge_case,
"type": "Case",
"bending": "-lan"
},
"possesive": {
"name": "Specific Possesive",
"description": "This word is describing a specific possesive relationship.",
"color": badge_case,
"type": "Case",
"bending": "-la"
},
// NUMBER
"dual": {
"name": "Dual",
"description": "This word is denoted as refering to exactly two entities.",
"color": badge_number,
"type": "Number",
"bending": ""
},
"plural": {
"name": "Plural",
"description": "This word is denoted as refering to at least more than one entity.",
"color": badge_number,
"type": "Number",
"bending": "-n"
},
// PRESENT TENSE
"present-tense-formal": {
"name": "Present",
"description": "This word is in the present tense.",
"color": badge_tense,
"type": "Tense",
"bending": "ku → ka'nya"
},
"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",
"description": "This word is in the past tense.",
"color": badge_tense,
"type": "Tense",
"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 mood", "name": "Feeling",
"description": "A feeling,", "description": "This word expresses a feeling or craving mood.",
"color": "#dd00dd", "color": badge_mood,
"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 mood", "name": "Imperative",
"description": "Commanding mood.", "description": "This word expresses a imperative mood.",
"color": "#dd0000", "color": badge_mood,
"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 mood", "name": "Shy",
"description": "Shy mood.", "description": "This word expresses a shy mood.",
"color": "#dddd00", "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 mood", "name": "Threat",
"description": "Threat mood.", "description": "This word expresses a threatening mood.",
"color": "#00dddd", "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": "Negated", "name": "Negative",
"description": "The word is negated.", "description": "The word is expressing a negated meaning.",
"color": "#7777dd", "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",
@@ -73,7 +274,6 @@ function init() {
document.querySelector("#popup-container").style.pointerEvents = "none"; document.querySelector("#popup-container").style.pointerEvents = "none";
} }
}); });
// above are commented out until wordlist is added~
document.querySelector("#font-button").addEventListener("click", () => {fontButton();}); document.querySelector("#font-button").addEventListener("click", () => {fontButton();});
} }
@@ -91,44 +291,46 @@ 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)";
p.querySelector("#popup-e").innerText = "heonian: ";
} 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-e").innerText = "romanization: ";
} }
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");
badge.classList.add("badge"); badge.classList.add("badge");
try { try {
badge.style.backgroundColor = quirkBadges[quirk]["color"]; badge.style.backgroundColor = quirkBadges[quirk]["color"];
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-e").innerText = "bending: ";
p.querySelector("#popup-heo").innerText = quirkBadges[quirk]["bending"]; p.querySelector("#popup-heo").innerText = quirkBadges[quirk]["bending"];
} }
} catch (e) { } catch (e) {
badge.style.backgroundColor = quirkBadges["unknown-tag"]["color"]; badge.style.backgroundColor = quirkBadges["unknown-tag"]["color"];
badge.style.boxShadow = "0px 0px 4px #" + quirkBadges["unknown-tag"]["color"] + "cc";
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";
@@ -194,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

2961
test.html

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,7 @@
--right-color: #61ce61; --right-color: #61ce61;
--font-normal: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; --font-normal: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--font-heonian: "heonian", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; --font-heonian: "heonian", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--popup-bg: rgba(255,255,255,0.6);
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
@@ -24,6 +25,7 @@
--spacer-color-2: rgba(255, 255, 255, 0.2); --spacer-color-2: rgba(255, 255, 255, 0.2);
--left-color: rgb(38,37,40); --left-color: rgb(38,37,40);
--right-color: #61ce61; --right-color: #61ce61;
--popup-bg: rgba(30,30,30,0.6);
} }
} }
@@ -175,6 +177,8 @@ main {
#popup { #popup {
width: 300px; width: 300px;
background-color: var(--left-color); background-color: var(--left-color);
-webkit-backdrop-filter: blur(20px);
backdrop-filter: blur(20px);
border-radius: 8px; border-radius: 8px;
padding: 8px; padding: 8px;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
@@ -184,6 +188,8 @@ main {
#smol-popup { #smol-popup {
width: 200px; width: 200px;
background-color: var(--left-color); background-color: var(--left-color);
-webkit-backdrop-filter: blur(20px);
backdrop-filter: blur(20px);
border-radius: 8px; border-radius: 8px;
padding: 8px; padding: 8px;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
@@ -192,24 +198,47 @@ main {
left: 0; left: 0;
transition: opacity 0.3s; transition: opacity 0.3s;
text-align: center; text-align: center;
/* padding-top: 0px; account for Funny */
} }
#popup h1 { @supports (backdrop-filter: blur(10px)) or (--webkit-backdrop-filter: blur(10px)) {
#popup, #smol-popup {
background-color: var(--popup-bg);
}
}
#popup h1, #smol-popup h1 {
text-align: center; text-align: center;
}
#smol-popup h1 {
margin: 0; margin: 0;
} }
#smol-popup p {
margin: 0;
}
#smol-popup p:last-child {
font-size: 0.75rem;
color: var(--spacer-color);
margin-top: 4px;
}
#popup-heo, #smol-heo { #popup-heo, #smol-heo {
font-family: "heonian"; font-family: var(--font-heonian);
text-align: center;
margin: 4px;
margin-bottom: 8px;
}
#popup-middle, #popup-meaning {
padding: 8px;
margin: 0;
} }
#popup-quirks { #popup-quirks {
display: flex; display: flex;
flex-flow: row wrap; flex-flow: row wrap;
justify-content: space-around; justify-content: space-around;
margin-top: 8px;
} }
#popup-quirks * { #popup-quirks * {