From 720aefbffa09db4ad69f23f94e05ac5e2312d419 Mon Sep 17 00:00:00 2001 From: UndeadMaelys Date: Thu, 5 May 2022 08:27:07 +0200 Subject: [PATCH] improved r2h2 detecton for new syllable starts --- R2H2.lua | 16 +++++++++------- input.txt | 2 +- test.html | 36 ++++++++++++++++++------------------ 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/R2H2.lua b/R2H2.lua index 4413151..3611212 100644 --- a/R2H2.lua +++ b/R2H2.lua @@ -91,15 +91,12 @@ function convertToHeonian(text) -- 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 string.sub(text,i,i) == " " - or string.sub(text,i,i) == "\t" + + 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 - if string.sub(text,i,i) == " " then -- spaces are exception - transcribed_text = transcribed_text .. " " - new_syllable = true - end i = i + 1 pos = i char_step = false @@ -107,7 +104,12 @@ function convertToHeonian(text) -- 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 diff --git a/input.txt b/input.txt index 3de5843..be2a8c3 100644 --- a/input.txt +++ b/input.txt @@ -40,7 +40,7 @@ ESH'NYUI relfur yu meluton mimiku'pash~ LU'NYA - 'o, relfur chu parefaka'nya… + o'o, relfur chu parefaka'nya… be'nyui-babanlafura yu meluton naomiminku dre? ESH'NYUI diff --git a/test.html b/test.html index b284eb4..86181eb 100644 --- a/test.html +++ b/test.html @@ -56,7 +56,7 @@ LU'NYA nyan'pash! balfur yu e she polika'nya dre?

-!      ? +!      ?

@@ -116,7 +116,7 @@ LU'NYA aa, anko!

-, ! +, !

(po'nyash!) @@ -146,7 +146,7 @@ ESH'NYUI ba yu e wawote to pu mipura lili'nya dre?

-        ? +        ?

uwu @@ -176,7 +176,7 @@ LU'NYA relfur chu mya pu yu mya relfur lup apatka'nya faka'nya'pash ponme mya wawote polika'nya peekaka'nya'pash.

-               +              

@@ -206,7 +206,7 @@ mi'shi'pash~ balfur yu e ton polika'nya dre?

-     ? +     ?

@@ -242,7 +242,7 @@ relfurla mya ton polika'nya yu meluton ka'nya! balfurla yu dra?

-  ? +  ?

@@ -266,7 +266,7 @@ ESH'NYUI relfurla yu esh'dre mya ton polika'nya yu puroton ka'nya~

-        ~ +        ~

relfur yu shi'ro'bae'pu yu pon'ya ka'nya~ @@ -347,16 +347,16 @@ LU'NYA

-'o, relfur chu parefaka'nya… +o'o, relfur chu parefaka'nya…

-',   … +,   …

be'nyui-babanlafura yu meluton naomiminku dre?

-    ? +    ?

@@ -380,7 +380,7 @@ ESH'NYUI uu, relfur yu naomiminku mya mimifuku mya ton ka'nya...

-,        . +,        .

relfur yu guraton to meluton mimifuku.. @@ -422,7 +422,7 @@ ishi-balfur yu mishi'pash! balfur chu mya arilaen yu en ka'nya peekaka'nya fa'dre?

-        ? +        ?

@@ -458,7 +458,7 @@ yesh-balfur yu mishi'pash~ relfur yu ari'laen parefaka'nya, balfur yu pareka'nya dra?

-   ,    ? +   ,    ?

@@ -482,7 +482,7 @@ LU'NYA relfur chu arilaen dedaka'nya.

-    +   

imanla rila shashka'nya'pash. @@ -494,7 +494,7 @@ imanla rila shashka'nya'pash. imanla shoo chu ike to pikeshe ka'nya.

-       +      

@@ -504,7 +504,7 @@ imanla shoo chu ike to pikeshe ka'nya. relfur chu arilaenlan luka'nya'pash.

-    +   

@@ -528,7 +528,7 @@ ESH'NYUI arilaenla shoo chu pikeshe fuka'nya'bash dra?

-     ? +     ?

@@ -558,7 +558,7 @@ gao chu relfur yu fayu kan'ya. relfur chu arilaen dedaka'nya.

-    +   