added submodule content, work on uh words in progress

This commit is contained in:
UndeadMaelys 2022-05-05 11:54:20 +02:00
parent 2c4d3ab087
commit 35d4418bce
9 changed files with 312 additions and 21 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "heonian-content"]
path = heonian-content
url = https://git.succubi.services/lustlion/heonian-content

View File

@ -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
@ -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)

1
heonian-content Submodule

@ -0,0 +1 @@
Subproject commit 19de5190c0876edbeb307f09b540a2c4d111b783

View File

@ -1,2 +1 @@
</div>
</div>

1
html/convo/middle.html Normal file
View File

@ -0,0 +1 @@
</div>

View File

@ -0,0 +1,2 @@
</p>
</div>

View File

@ -0,0 +1,2 @@
<div class="notes">
<p>

View File

@ -0,0 +1 @@
<p class="convo-raw">

212
r2h2_modified.lua Normal file
View File

@ -0,0 +1,212 @@
--functions
-- DATA
-- vowels
vowel_table = {"a","e","i","o","u"}
symbol_vowel = {"","","","",""}
symbol_extending_vowel = {"","","","",""}
-- consonants
consonant_table = {"g","sh","r","ny","ch","n","y","f","t","k","w","l","p","b","d","h","m"}
symbol_consonant = {"","","","","","","","","","","","","","","","",""}
symbol_extending_consonant = {"","","","","","","","","","","","","","","","",""}
-- composites
composing_consonant_table = {"g","sh","r","ny","ch","m","y","f","t","k","w","l","p","b","d","h"}
symbol_composite = {
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""},
{"","","","","","","","","","","","","","","",""}
}
-- program start
function mod_convertToHeonian(text)
local step = true -- this is set to false when a conclusion has been reached
local transcribed = false
local transcribed_text = ""
local debug = false
local autocopy = false
for _, v in pairs(arg) do
if v == "-v" or v == "--verbose" then debug = true end
if v == "-c" or v == "--copy" then autocopy = true end
end
-- if its necessary to run the script, then we continue :D
if step then
-- prepare text
-- 1. add syllable marker at start if it isn't already present.
if string.sub(text,1,1) ~= "." then text = "." .. text end
-- 2. turn [x] into [ksh]
text = string.gsub(text,"x","ksh")
-- 3. turn [z] into [dsh]
text = string.gsub(text,"z","d.sh")
-- 4. turn [j] into [y]
text = string.gsub(text,"j","y")
-- read input and transcribe
-- debug log
if debug then print("") end
if debug then print("src: ".. text) end
if debug then PrintPosition(text) end
-- sort through all the letters
local i = 1
while i < string.len(text)+1 do
local pos = i
-- know current pos, since we will be modifying i but still evaluating from the position
local char_step = true
-- this is false when a conclusion has been reached about what symbol does the next segment correspond to
local debug_s = ""
-- debug string
local new_syllable = false
-- this is true when a new syllable begins, and is used to distinguish normal vowels and consonants from trailing ones
if i == 1 then new_syllable = true end
if string.sub(text,i,i) == "\t"
or string.sub(text,i,i) == "-" then -- check if its an unsupported symbol to skip it.
-- adjust i
i = i + 1
pos = i
char_step = false
end
-- init checkup
if string.sub(text,i,i) == "."
or string.sub(text,i,i) == "'"
or string.sub(text,i,i) == " "
or string.sub(text,i,i) == "" then -- this forces the new syllable, since . is the syllable separator, also skips the symbol and repositions
if string.sub(text,i,i) == " " then -- spaces are exception
transcribed_text = transcribed_text .. " "
new_syllable = true
end
-- debug log
if debug then print("") end
if debug then print(" @[".. tostring(i).."]"..debug_s.." new syllable MARKER found") end
-- start syllable
new_syllable = true
debug_s = ""
-- adjust i
i = i + 1
-- debug log
if debug then print(" >>> adjusting by (1) from [".. pos .. "] to [".. i .. "]" ) end
-- adjust pos
pos = i
end
-- debug log
if debug then print("") end
if debug then print(" @[".. tostring(i).."]"..debug_s.." checking string: ".. string.sub(text,i,i)) end -- debug print positional info
-- lets check if it is a composite
if char_step == true then
local cons_id = 0
local length = 0
-- check if its valid consonant for a composite
for _, consonant in pairs(composing_consonant_table) do
cons_id = cons_id + 1
-- get consonant length its checking against, so we can properly compare.
length = string.len(consonant)
-- debug log
--if debug then print(" checking composite consonant: " .. composing_consonant_table[cons_id]) end
if string.sub(text,i,i+length-1) == consonant then
-- debug log
if debug then print(" (!) valid consonant: " .. composing_consonant_table[cons_id]) end
-- check if its a valid vowel AFTER the valid consonant, while sorting through all vowels
local vowel_id = 0
for _, vowel in pairs(vowel_table) do
vowel_id = vowel_id + 1
--if debug then print(" checking composite: " .. composing_consonant_table[cons_id]..vowel_table[vowel_id]) end
if string.sub(text,i+length,i+length) == vowel then
-- adjust by consonant length + vowel
i = i + string.len(consonant) + 1
-- debug log
if debug then print(" (!) valid composite: " .. consonant .. vowel ..", length: "..length+1) end
if debug then print(" >>> adjusting by (" .. tostring(length+1) .. ") from [".. pos .. "] to [".. i .. "]" ) end
-- transcribe; conclude;
transcribed_text = transcribed_text .. symbol_composite[vowel_id][cons_id]
char_step = false
break
end
end
-- no need to check for more consonants if one is valid
break
end
end
if debug then if char_step ~= false then print(" [!] invalid composite") end end
end
-- lets check if it is a non composite vowel
if char_step == true then
local id = 0
local length = 0
for _, vowel in pairs(vowel_table) do
id = id+ 1
-- get vowel length its checking against, so we can properly compare.
length = string.len(vowel)
-- debug log
--if debug then print(" checking standalone vowel: " .. vowel_table[id]) end
if string.sub(text,i,i+length-1) == vowel then
i = i + string.len(vowel)
-- debug log
if debug then print(" (!) valid vowel: " .. vowel_table[id]) end
if debug then print(" >>> adjusting by (" .. tostring(length) .. ") from [".. pos .. "] to [".. i .. "]" ) end
-- transcribe; conclude;
local table = nil
if new_syllable then
table = symbol_vowel
else
table = symbol_extending_vowel
end
transcribed_text = transcribed_text .. table[id]
char_step = false
break
end
end
end
-- lets check if it is a non composite consonant
if char_step == true then
local id = 0
local length = 0
for _, consonant in pairs(consonant_table) do
id = id+ 1
-- get consonant length its checking against, so we can properly compare.
length = string.len(consonant)
-- debug log
--if debug then print(" checking standalone consonant: " .. consonant_table[id]) end
if string.sub(text,i,i+length-1) == consonant then
i = i + string.len(consonant)
-- debug log
if debug then print(" (!) valid consonant: " .. consonant_table[id]) end
if debug then print(" >>> adjusting by (" .. tostring(length) .. ") from [".. pos .. "] to [".. i .. "]" ) end
-- transcribe; conclude;
local table = nil
if new_syllable then
table = symbol_consonant
else
table = symbol_extending_consonant
end
transcribed_text = transcribed_text .. table[id]
char_step = false
break
end
end
end
-- if no idea, move on, and just be confused. prints ?
if char_step == true then
-- debug log
if debug then print(" [!] no idea; moving on to next [".. pos + 1 .."]") end
-- no idea
transcribed_text = transcribed_text .. string.sub(text,i,i)
i = i + 1
-- debug log
if debug then print(" >>> adjusting by (1) from [".. pos .. "] to [".. i .. "]" ) end
end
end
return transcribed_text
end
end