now smarter, still dumb

This commit is contained in:
UndeadMaelys 2022-05-05 17:37:58 +02:00
parent 5a15cfc817
commit 55bd92ec76
2 changed files with 3310 additions and 401 deletions

View File

@ -2,6 +2,99 @@ require "r2h2_modified"
words = dofile("heonian-content/words.lua") words = dofile("heonian-content/words.lua")
function apply(text)
print(text)
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 = content
while string.find(ac, " ") do
local new_word = string.sub(ac, 0, string.find(ac, " "))
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 = replace_symbols(new_word)
new_word, indicators = revert_verbs(new_word, indicators)
add_word(new_word)
local html_stuff = [[
<span
class="clickable"
onclick="showPopup('REPLACE_WORD','REPLACE_SEARCH','REPLACE_DATA')"
onmouseover="checkHover('REPLACE_WORD','REPLACE_SEARCH','REPLACE_DATA')"
onmouseout="clearHover()">
REPLACE_PRINT
</span>
]]
local REPLACE_PRINT = print_text
while string.find(html_stuff, "REPLACE_PRINT") do
html_stuff = string.gsub(html_stuff, "REPLACE_PRINT", REPLACE_PRINT)
end
local REPLACE_WORD = print_text
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
local REPLACE_SEARCH = new_word
while string.find(html_stuff, "REPLACE_SEARCH") do
html_stuff = string.gsub(html_stuff, "REPLACE_SEARCH", REPLACE_SEARCH)
end
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
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.
--print(print_text, table.unpack(indicators))
end
apply_html("html/convo/text/end.html")
end
end
function cell_builder(...) function cell_builder(...)
arg = {...} arg = {...}
for i=1, #arg do for i=1, #arg do
@ -60,21 +153,22 @@ function replace_symbols(str)
return str return str
end end
function find_n_replace(str,find,repl) function find_n_replace(str, tbl,find,repl,indicator)
while string.find(str, find) do if string.find(str, find) then
str = string.gsub(str, find, repl) str = string.gsub(str, find, repl)
table.insert(tbl,indicator)
end end
return str return str, tbl
end end
function revert_verbs(str) function revert_verbs(str, tbl)
str = find_n_replace(str, "kanya","ku") str, tbl = find_n_replace(str, tbl,"kanya","ku","present-tense")
str = find_n_replace(str, "kome","ku") str, tbl = find_n_replace(str, tbl,"kome","ku","past-tense")
str = find_n_replace(str, "kupash","ku") str, tbl = find_n_replace(str, tbl,"kupash","ku","volitional-mood")
str = find_n_replace(str, "kudash","ku") str, tbl = find_n_replace(str, tbl,"kudash","ku","imperative-mood")
str = find_n_replace(str, "kubash","ku") str, tbl = find_n_replace(str, tbl,"kubash","ku","shy-mood")
str = find_n_replace(str, "kutash","ku") str, tbl = find_n_replace(str, tbl,"kutash","ku","threat-mood")
str = find_n_replace(str, "faku","ku") str, tbl = find_n_replace(str, tbl,"faku","ku","negated")
return str return str, tbl
end end
function apply_html(path) function apply_html(path)
@ -87,10 +181,6 @@ function apply_html(path)
apply(html) apply(html)
end end
function apply(text)
print(text)
end
function convo_image(string,alt_text) function convo_image(string,alt_text)
if string then if string then
apply_html("html/convo/header/image/start.html") apply_html("html/convo/header/image/start.html")
@ -165,7 +255,7 @@ file:close()
-- first analyze text -- first analyze text
-- (this is the fun part) -- (this is the fun part)
local content = "" word_list = {}
local p = 0 local p = 0
local s = 0 local s = 0
local convo = false local convo = false
@ -187,14 +277,7 @@ while p ~= nil do
elseif string.sub(text,p+1,p+1) == "\t" then elseif string.sub(text,p+1,p+1) == "\t" then
-- its tabbed so its spoken? -- its tabbed so its spoken?
convo_start() convo_start()
apply_html("html/convo/text/start_roman.html") process_content(string.sub(text,p+2,np-1))
apply(string.sub(text,p+2,np-1))
content = content .. " " .. string.sub(text,p+2,np-1)
apply_html("html/convo/text/end.html")
-- heonian
apply_html("html/convo/text/start_heonian.html")
apply(mod_convertToHeonian(string.sub(text,p+2,np-1)).."")
apply_html("html/convo/text/end.html")
elseif string.sub(text,p+1,p+1) == "h" then elseif string.sub(text,p+1,p+1) == "h" then
-- spoken but forced to h -- spoken but forced to h
convo_start() convo_start()
@ -271,16 +354,6 @@ apply_html("html/spacer.html")
-- fourth lets make word lists -- fourth lets make word lists
-- process contents -- process contents
content = strip_symbols(content)
content = replace_symbols(content)
content = revert_verbs(content)
word_list = {}
while string.find(content, " ") do
add_word(string.sub(content, 0, string.find(content, " ")))
content = string.sub(content, string.find(content, " ")+1)
--print(string.find(content, " "))
end
-- lets print the words -- lets print the words
apply_html("html/spacer.html") apply_html("html/spacer.html")

3568
test.html

File diff suppressed because it is too large Load Diff