improvements to mood detection, fixed missing word types badges, fixed badge definition

This commit is contained in:
UndeadMaelys 2022-05-09 13:24:28 +02:00
parent 1817ac9d9d
commit 82b751a9e5
5 changed files with 390 additions and 387 deletions

View File

@ -99,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
@ -140,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.
printD(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
@ -211,12 +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 not in_dictionary(str) then if not in_dictionary(str) then
if string.find(str, find) 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) str = string.gsub(str,find, repl)
table.insert(tbl,indicator) table.insert(tbl,indicator)
end end
else
str = string.gsub(str,find, repl)
table.insert(tbl,indicator)
end
end
end end
return str, tbl return str, tbl
end end
@ -227,12 +234,31 @@ function in_dictionary(str)
end 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) function categorize_word(str,indicators)
local ind = {} local ind = {}
for _, v in pairs(words) do for _, v in pairs(words) do
if strip_symbols(v[1]) == strip_spaces(str) then if strip_symbols(v[1]) == strip_spaces(str) then -- if word is present
table.insert(ind, string.lower(v[3])) local ac = string.lower(v[3])
break ind = string.split(strip_symbols(ac), " ", ind) -- store types are indicators
end end
end end
for _, v in pairs(indicators) do for _, v in pairs(indicators) do
@ -259,6 +285,7 @@ function check_morphemes(str, tbl,match,repl,indicators)
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,"lfur","","formal-n1")
str, tbl = check_morphemes(str,tbl,"lafura","","formal-n2") str, tbl = check_morphemes(str,tbl,"lafura","","formal-n2")
@ -275,7 +302,7 @@ function revert_verbs(str, tbl)
str, tbl = revert_mood(str, tbl,"bash","","shy-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,"tash","","threat-mood")
str, tbl = revert_mood(str, tbl,"shu","","comfy-mood") str, tbl = revert_mood(str, tbl,"shu","","comfy-mood")
str, tbl = revert_mood(str, tbl,"ha","","excited-mood") str, tbl = revert_mood(str, tbl,"ha","","excited-mood", "sha")
-- once we've cleaned moods lets try to get tense -- 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,"kanya","ku",{"present-tense-formal","formal-v1"})
str, tbl = check_morphemes(str, tbl,"kome","ku",{"past-tense-formal","formal-v2"}) str, tbl = check_morphemes(str, tbl,"kome","ku",{"past-tense-formal","formal-v2"})
@ -293,9 +320,9 @@ function revert_verbs(str, tbl)
return str, tbl return str, tbl
end end
function revert_mood(str, tbl,match,repl,indicator) function revert_mood(str, tbl,match,repl,indicator, caution)
str, tbl = find_n_replace(str, tbl,"fa"..match,repl,indicator.."-negated") str, tbl = find_n_replace(str, tbl,"fa"..match,repl,indicator.."-negated",caution)
str, tbl = find_n_replace(str, tbl,match,repl,indicator) str, tbl = find_n_replace(str, tbl,match,repl,indicator,caution)
return str, tbl return str, tbl
end end

@ -1 +1 @@
Subproject commit cc8e904dcbfc916ebffa2cef029d82cd41592a47 Subproject commit d0d8345c1ff1d2840558a67c6fe98a97bc4a69e6

View File

@ -55,7 +55,7 @@ LU'NYA
ESH'NYUI ESH'NYUI
i eshnyui_blush.png i eshnyui_blush.png
yesh-balfur yu mishi'pashshu 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

View File

@ -36,6 +36,13 @@ let quirkBadges = {
"type": "Type", "type": "Type",
"bending": "" "bending": ""
}, },
"modifier": {
"name": "Modifier",
"description": "This word modifies another word to specify meaning.",
"color": badge_type,
"type": "Type",
"bending": ""
},
"expression": { "expression": {
"name": "Expression", "name": "Expression",
"description": "This is an idiomatic expression.", "description": "This is an idiomatic expression.",

711
test.html

File diff suppressed because it is too large Load Diff