diff --git a/converter.lua b/converter.lua index 3bb8152..ab62529 100644 --- a/converter.lua +++ b/converter.lua @@ -2,6 +2,99 @@ require "r2h2_modified" 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 = [[ + + REPLACE_PRINT + + ]] + + 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(...) arg = {...} for i=1, #arg do @@ -60,21 +153,22 @@ function replace_symbols(str) return str end -function find_n_replace(str,find,repl) - while string.find(str, find) do +function find_n_replace(str, tbl,find,repl,indicator) + if string.find(str, find) then str = string.gsub(str, find, repl) + table.insert(tbl,indicator) end - return str + return str, tbl end -function revert_verbs(str) - str = find_n_replace(str, "kanya","ku") - str = find_n_replace(str, "kome","ku") - str = find_n_replace(str, "kupash","ku") - str = find_n_replace(str, "kudash","ku") - str = find_n_replace(str, "kubash","ku") - str = find_n_replace(str, "kutash","ku") - str = find_n_replace(str, "faku","ku") - return str +function revert_verbs(str, tbl) + str, tbl = find_n_replace(str, tbl,"kanya","ku","present-tense") + str, tbl = find_n_replace(str, tbl,"kome","ku","past-tense") + str, tbl = find_n_replace(str, tbl,"kupash","ku","volitional-mood") + str, tbl = find_n_replace(str, tbl,"kudash","ku","imperative-mood") + str, tbl = find_n_replace(str, tbl,"kubash","ku","shy-mood") + str, tbl = find_n_replace(str, tbl,"kutash","ku","threat-mood") + str, tbl = find_n_replace(str, tbl,"faku","ku","negated") + return str, tbl end function apply_html(path) @@ -87,10 +181,6 @@ function apply_html(path) apply(html) end -function apply(text) - print(text) -end - function convo_image(string,alt_text) if string then apply_html("html/convo/header/image/start.html") @@ -165,7 +255,7 @@ file:close() -- first analyze text -- (this is the fun part) -local content = "" +word_list = {} local p = 0 local s = 0 local convo = false @@ -187,14 +277,7 @@ while p ~= nil do elseif string.sub(text,p+1,p+1) == "\t" then -- its tabbed so its spoken? convo_start() - apply_html("html/convo/text/start_roman.html") - 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") + 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() @@ -271,16 +354,6 @@ apply_html("html/spacer.html") -- fourth lets make word lists -- 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 apply_html("html/spacer.html") diff --git a/test.html b/test.html index 048d057..34f0966 100644 --- a/test.html +++ b/test.html @@ -53,10 +53,120 @@ LU'NYA
-nyan'pash! balfur yu e she polika'nya dre? + + nyan'pash! + + + + balfur + + + + yu + + + + e + + + + she + + + + polika'nya + + + + dre? + +
-! ? + + ! + + + + + + + + + + + + + + + + + + + + + + + + ? + +
@@ -77,16 +187,108 @@ ESH'NYUI-re chu meshu yu polika'nya + + re + + + + chu + + + + meshu + + + + yu + + + + polika'nya + +
- + + + + + + + + + + + + + + + + + + + +
-(po'nyash!!!) + + (po'nyash!!!) + +
-(!!!) + + (!!!) + +
@@ -107,16 +309,60 @@ LU'NYA-aa, anko! + + aa, + + + + anko! + +
-, ! + + , + + + + ! + +
-(po'nyash!) + + (po'nyash!) + +
-(!) + + (!) + +
@@ -137,16 +383,188 @@ ESH'NYUI-ba yu e wawote to pu mipura lili'nya dre? + + ba + + + + yu + + + + e + + + + wawote + + + + to + + + + pu + + + + mipura + + + + lili'nya + + + + dre? + + + + + +
- ? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ? + + + + + +
-uwu + + uwu + +
- + + + +
@@ -167,10 +585,248 @@ 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. + +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -191,16 +847,124 @@ ESH'NYUI-mi'shi'pash~ + + mi'shi'pash~ + +
-~ + + ~ + +
-balfur yu e ton polika'nya dre? + + balfur + + + + yu + + + + e + + + + ton + + + + polika'nya + + + + dre? + +
- ? + + + + + + + + + + + + + + + + + + + + + + ? + +
@@ -221,22 +985,224 @@ 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? + +
- ? + + + + + + + + + + ? + +
@@ -257,16 +1223,252 @@ 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'nya~ + +
- ~ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ~ + +
-relfur yu shi'ro'bae'pu yu pon'ya ka'nya~ + + relfur + + + + yu + + + + shi'ro'bae'pu + + + + yu + + + + pon'ya + + + + ka'nya~ + +
- ~ + + + + + + + + + + + + + + + + + + + + + + ~ + +
@@ -287,10 +1489,88 @@ LU'NYA-puroton yu ponya ton ka'nya! + + puroton + + + + yu + + + + ponya + + + + ton + + + + ka'nya! + +
- ! + + + + + + + + + + + + + + + + + + ! + +
@@ -311,16 +1591,140 @@ 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'pash~ + +
- ~ + + + + + + + + + + + + + + ~ + +
@@ -341,16 +1745,156 @@ LU'NYA-o'o, relfur chu parefaka'nya… + + o'o, + + + + relfur + + + + chu + + + + parefaka'nya… + +
-, … + + , + + + + + + + + + + + + … + +
-be'nyui-babanlafura yu meluton naomiminku dre? + + be'nyui-babanlafura + + + + yu + + + + meluton + + + + naomiminku + + + + dre? + +
- ? + + + + + + + + + + + + + + + + + + ? + +
@@ -371,22 +1915,336 @@ 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'pash~ + +
- ~ + + + + + + + + + + + + + + ~ + +
@@ -407,16 +2265,220 @@ 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? + +
- ? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ? + +
@@ -437,22 +2499,208 @@ ESH'NYUI-yesh-balfur yu mishi'pash~ + + yesh-balfur + + + + yu + + + + mishi'pash~ + +
- ~ + + + + + + + + + + ~ + +
-(>///////////////<) + + (>///////////////<) + +
-(>///////////////<) + + (>///////////////<) + +
-relfur yu ari'laen parefaka'nya, balfur yu pareka'nya dra? + + relfur + + + + yu + + + + ari'laen + + + + parefaka'nya, + + + + balfur + + + + yu + + + + pareka'nya + + + + dra? + +
- , ? + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + ? + +
@@ -473,32 +2721,360 @@ 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. + +
- + + + + + + + + + + + + + + + +
-arilaenla shoo chu pikeshe fuka'nya'bash dra? + + arilaenla + + + + shoo + + + + chu + + + + pikeshe + + + + fuka'nya'bash + + + + dra? + +
- ? + + + + + + + + + + + + + + + + + + + + + + ? + +
@@ -543,16 +3213,188 @@ 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. + +
- + + + + + + + + + + + + + + + +
@@ -573,927 +3415,913 @@ relfur chu arilaen dedaka'nya.