changes to badges and types n stuff

This commit is contained in:
UndeadMaelys 2022-05-08 18:31:09 +02:00
parent 3d0fc9145f
commit 941f701d7d
7 changed files with 1072 additions and 739 deletions

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 = [[
@ -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
@ -126,7 +177,7 @@ function add_word(str)
end end
if add then if add then
table.insert(word_list,str) table.insert(word_list,str)
if not in_dictionary(str) then io.stderr:write("Error: \""..str.."\" is not known\n") end if not in_dictionary(str) then printW("\"" .. str .. "\" is not known") end
end end
end end
@ -161,9 +212,11 @@ function check_symbol(str)
end end
function find_n_replace(str, tbl,find,repl,indicator) function find_n_replace(str, tbl,find,repl,indicator)
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) str = string.gsub(str,find, repl)
table.insert(tbl,indicator)
end
end end
return str, tbl return str, tbl
end end
@ -174,37 +227,75 @@ function in_dictionary(str)
end end
end end
function check_morphemes(str, tbl,match,repl,indicator) function categorize_word(str,indicators)
local ind = {}
for _, v in pairs(words) do
if strip_symbols(v[1]) == strip_spaces(str) then
table.insert(ind, string.lower(v[3]))
break
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,"kushu","ku","comfy-mood") str, tbl = revert_mood(str, tbl,"ha","","excited-mood")
str, tbl = find_n_replace(str, tbl,"kuha","ku","excited-mood") -- once we've cleaned moods lets try to get tense
str, tbl = find_n_replace(str, tbl,"faku","ku","negated") 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)
str, tbl = find_n_replace(str, tbl,"fa"..match,repl,indicator.."-negated")
str, tbl = find_n_replace(str, tbl,match,repl,indicator)
return str, tbl return str, tbl
end end
@ -286,7 +377,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()

View File

@ -4,7 +4,6 @@
<p id="popup-heo"></p> <p id="popup-heo"></p>
<div class="spacer"></div> <div 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>

10
ime.js
View File

@ -4,11 +4,11 @@
// let h; // let h;
// window.onload = () => { window.onload = () => {
// document.querySelectorAll(".ime").forEach(input => { document.querySelectorAll(".ime").forEach(input => {
// h = new HeonianIME(input); h = new HeonianIME(input);
// }); });
// } }
class HeonianIME { class HeonianIME {
constructor(what) { constructor(what) {

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

164
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,80 @@ 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"
},
"noun": {
"name": "Noun",
"description": "This word refers to a concept.",
"color": badge_type,
"type": "Type",
"bending": "none"
},
"pronoun": {
"name": "Pronoun",
"description": "This word occupies the place of a noun.",
"color": badge_type,
"type": "Type",
"bending": "none"
},
"expression": {
"name": "Expression",
"description": "This is an idiomatic expression.",
"color": badge_type,
"type": "Type",
"bending": "none"
},
// 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.",
@ -41,6 +102,7 @@ let quirkBadges = {
"type": "Case", "type": "Case",
"bending": "la" "bending": "la"
}, },
// NUMBER
"plural": { "plural": {
"name": "Plural", "name": "Plural",
"description": "This word is denoted as more than one", "description": "This word is denoted as more than one",
@ -48,20 +110,37 @@ let quirkBadges = {
"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 +148,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,34 +163,74 @@ 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": "-bash"
},
"comfy-mood": { "comfy-mood": {
"name": "Comfortable", "name": "Negated Comfort",
"description": "This word expresses a comfortable mood..", "description": "This word denies a comfortable mood.",
"color": badge_mood, "color": badge_mood,
"type": "Mood", "type": "Mood",
"bending": "-tash" "bending": "-fabash"
}, },
// EXCITEMENT
"excited-mood": { "excited-mood": {
"name": "Excitement", "name": "Excitement",
"description": "This word expresses a excited mood..", "description": "This word expresses a excited mood.",
"color": badge_mood, "color": badge_mood,
"type": "Mood", "type": "Mood",
"bending": "-tash" "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.",
@ -111,6 +238,7 @@ let quirkBadges = {
"type": "Negation", "type": "Negation",
"bending": "-fa-" "bending": "-fa-"
}, },
// UNKNOWN
"unknown-tag": { "unknown-tag": {
"name": "Unknown tag", "name": "Unknown tag",
"color": "#393939", "color": "#393939",
@ -142,15 +270,15 @@ 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() != "") {
@ -166,7 +294,7 @@ function showPopup(ogword, word, quirks = "") {
badge.onclick = () => { badge.onclick = () => {
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-quirks-container").style.display = "none";
p.querySelector("#popup-heo").innerText = quirkBadges[quirk]["bending"]; p.querySelector("#popup-heo").innerText = quirkBadges[quirk]["bending"];
} }
@ -244,7 +372,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;
} }
}); });

1359
test.html

File diff suppressed because it is too large Load Diff