added submodule content, work on uh words in progress
This commit is contained in:
110
converter.lua
110
converter.lua
@@ -1,8 +1,20 @@
|
||||
require "R2H2"
|
||||
require "r2h2_modified"
|
||||
|
||||
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_symbols(str)
|
||||
local symbol_table = "'~()!?:></.\t"
|
||||
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),"")
|
||||
@@ -11,15 +23,29 @@ function strip_symbols(str)
|
||||
return str
|
||||
end
|
||||
|
||||
function reverse_verbs(str)
|
||||
while string.find(str, "kanya") do
|
||||
str = string.gsub(str, "kanya","ku")
|
||||
function replace_symbols(str)
|
||||
while string.find(str, "%-") do
|
||||
str = string.gsub(str, "%-"," ")
|
||||
end
|
||||
while string.find(str, "kome") do
|
||||
str = string.gsub(str, "kome","ku")
|
||||
return str
|
||||
end
|
||||
|
||||
function find_n_replace(str,find,repl)
|
||||
while string.find(str, find) do
|
||||
str = string.gsub(str, find, repl)
|
||||
end
|
||||
return str
|
||||
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
|
||||
end
|
||||
|
||||
function apply_html(path)
|
||||
-- copy
|
||||
@@ -28,23 +54,36 @@ function apply_html(path)
|
||||
|
||||
file:close()
|
||||
-- paste
|
||||
print(html)
|
||||
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")
|
||||
print(string)
|
||||
apply(string)
|
||||
apply_html("html/convo/header/image/middle.html")
|
||||
print(alt_text)
|
||||
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")
|
||||
print(string)
|
||||
apply(string)
|
||||
apply_html("html/convo/header/date/end.html")
|
||||
end
|
||||
end
|
||||
@@ -58,7 +97,7 @@ end
|
||||
|
||||
function convo_header_end()
|
||||
if header then
|
||||
header = false
|
||||
header = false
|
||||
apply_html("html/convo/header/end.html")
|
||||
end
|
||||
end
|
||||
@@ -78,6 +117,10 @@ 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
|
||||
@@ -97,6 +140,7 @@ local p = 0
|
||||
local s = 0
|
||||
local convo = false
|
||||
local header = false
|
||||
local notes = false
|
||||
local green = true
|
||||
local skip = 1
|
||||
local user = {}
|
||||
@@ -114,18 +158,32 @@ while p ~= nil do
|
||||
-- its tabbed so its spoken?
|
||||
convo_start()
|
||||
apply_html("html/convo/text/start_roman.html")
|
||||
print(string.sub(text,p+2,np-1))
|
||||
--content = content .. " " .. reverse_verbs(strip_symbols(string.sub(text,p+2,np-1)))
|
||||
--print("\n"..reverse_verbs(strip_symbols(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")
|
||||
print(convertToHeonian(string.sub(text,p+2,np-1)).."")
|
||||
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
|
||||
-- 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()
|
||||
@@ -153,7 +211,7 @@ while p ~= nil do
|
||||
|
||||
-- print name
|
||||
apply_html("html/convo/header/name/start.html")
|
||||
print(string.sub(text,p+1,np-1))
|
||||
apply(string.sub(text,p+1,np-1))
|
||||
apply_html("html/convo/header/name/end.html")
|
||||
|
||||
-- lets check for dates
|
||||
@@ -179,9 +237,21 @@ end
|
||||
apply_html("html/convo/end.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
|
||||
|
||||
for i=1, #word_list do
|
||||
print(word_list[i])
|
||||
end
|
||||
|
||||
-- lets end the html
|
||||
apply_html("html/end.html")
|
||||
|
||||
|
||||
-- print(content)
|
||||
Reference in New Issue
Block a user