diff --git a/converter.lua b/converter.lua index ad762c1..0fd9f71 100644 --- a/converter.lua +++ b/converter.lua @@ -17,9 +17,9 @@ function process_content(content) end - local ac = content + local ac = check_symbol(content) while string.find(ac, " ") do - local new_word = string.sub(ac, 0, string.find(ac, " ")) + local new_word = string.sub(ac, 0, string.find(ac, " ")-1) local indicators = {} if i == 1 then @@ -29,8 +29,8 @@ function process_content(content) end new_word = strip_symbols(new_word) - new_word = replace_symbols(new_word) new_word, indicators = revert_verbs(new_word, indicators) + new_word, indicators = revert_nouns(new_word,indicators) add_word(new_word) local html_stuff = [[ @@ -146,28 +146,62 @@ function strip_symbols(str) return str end -function replace_symbols(str) +function replace_sign(str) while string.find(str, "%-") do str = string.gsub(str, "%-"," ") end return str end +function check_symbol(str) + if not in_dictionary(str) then + return replace_sign(str) + end +end + function find_n_replace(str, tbl,find,repl,indicator) if string.find(str, find) then - str = string.gsub(str, find, repl) + str = string.gsub(str,find, repl) table.insert(tbl,indicator) end return str, tbl end + +function in_dictionary(str) + for i=1, #words do + if words[i][1] == str then return true end + end +end + +function check_morphemes(str, tbl,match,repl,indicator) + if not in_dictionary(str) then + local flen = string.len(match) + if string.sub(str, -flen) == match + and string.sub(str,-3) ~= "ton" then + str = string.sub(str, 0,string.len(str)-flen) + table.insert(tbl,indicator) + end + end + return str, tbl +end + +function revert_nouns(str, tbl) + str, tbl = check_morphemes(str,tbl,"lan","","genitive") + str, tbl = check_morphemes(str,tbl,"la","","possesive") + str, tbl = check_morphemes(str,tbl,"n","","plural") + str, tbl = check_morphemes(str,tbl,"lfur","","formal") + str, tbl = check_morphemes(str,tbl,"lafura","","formal") + return str, tbl +end + 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") + 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 diff --git a/test.html b/test.html index 750a320..f081a4c 100644 --- a/test.html +++ b/test.html @@ -55,116 +55,116 @@ LU'NYA
- nyan'pash! + nyan'pash! - balfur + balfur - yu + yu - e + e - she + she - polika'nya + polika'nya - dre? + dre?
- ! + ! - + - + - + - + - + - ? + ?
@@ -189,104 +189,104 @@ ESH'NYUI- re + re - chu + chu - meshu + meshu - yu + yu - polika'nya + polika'nya
- + - + - + - + - +
- (po'nyash!!!) + (po'nyash!!!)
- (!!!) + (!!!)
@@ -311,56 +311,56 @@ LU'NYA- aa, + aa, - anko! + anko!
- , + , - ! + !
- (po'nyash!) + (po'nyash!)
- (!) + (!)
@@ -385,184 +385,184 @@ ESH'NYUI- ba + ba - yu + yu - e + e - wawote + wawote - to + to - pu + pu - mipura + mipura - lili'nya + lili'nya - dre? + dre? - +
- + - + - + - + - + - + - + - + - ? + ? - +
- uwu + uwu
- +
@@ -587,244 +587,244 @@ LU'NYA- relfur + relfur - chu + chu - mya + mya - pu + pu - yu + yu - mya + mya - relfur + relfur - lup + lup - apatka'nya + apatka'nya - faka'nya'pash + faka'nya'pash - ponme + ponme - mya + mya - wawote + wawote - polika'nya + polika'nya - peekaka'nya'pash. + peekaka'nya'pash.
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
@@ -849,120 +849,120 @@ ESH'NYUI- mi'shi'pash~ + mi'shi'pash~
- ~ + ~
- balfur + balfur - yu + yu - e + e - ton + ton - polika'nya + polika'nya - dre? + dre?
- + - + - + - + - + - ? + ?
@@ -987,220 +987,220 @@ LU'NYA- mishi'pash!! + mishi'pash!! - +
- !! + !! - +
- relfurla + relfurla - mya + mya - ton + ton - polika'nya + polika'nya - yu + yu - meluton + meluton - ka'nya! + ka'nya! - +
- + - + - + - + - + - + - ! + ! - +
- balfurla + balfurla - yu + yu - dra? + dra?
- + - + - ? + ?
@@ -1225,248 +1225,248 @@ ESH'NYUI- relfurla + relfurla - yu + yu - esh'dre + esh'dre - mya + mya - ton + ton - polika'nya + polika'nya - yu + yu - puroton + puroton - ka'nya~ + ka'nya~
- + - + - + - + - + - + - + - + - ~ + ~
- relfur + relfur - yu + yu - shi'ro'bae'pu + shi'ro'bae'pu - yu + yu - pon'ya + pon'ya - ka'nya~ + ka'nya~
- + - + - + - + - + - ~ + ~
@@ -1491,84 +1491,84 @@ LU'NYA- puroton + puroton - yu + yu - ponya + ponya - ton + ton - ka'nya! + ka'nya!
- + - + - + - + - ! + !
@@ -1593,136 +1593,152 @@ ESH'NYUI- be'nyui-rerenlafura + be'nyui - yu + rerenlafura - meluton + yu - mimifaka'nya… + meluton + + + + mimifaka'nya…
- + - + - + - … + + + + + …
- relfur + relfur - yu + yu - meluton + meluton - mimiku'pash~ + mimiku'pash~
- + - + - + - ~ + ~
@@ -1747,152 +1763,168 @@ LU'NYA- o'o, + o'o, - relfur + relfur - chu + chu - parefaka'nya… + parefaka'nya…
- , + , - + - + - … + …
- be'nyui-babanlafura + be'nyui - yu + babanlafura - meluton + yu - naomiminku + meluton - dre? + naomiminku + + + + dre?
- + - + - + - + - ? + + + + + ?
@@ -1917,332 +1949,332 @@ ESH'NYUI- uu, + uu, - relfur + relfur - yu + yu - naomiminku + naomiminku - mya + mya - mimifuku + mimifuku - mya + mya - ton + ton - ka'nya... + ka'nya...
- , + , - + - + - + - + - + - + - + - . + .
- relfur + relfur - yu + yu - guraton + guraton - to + to - meluton + meluton - mimifuku.. + mimifuku.. - +
- + - + - + - + - + - . + . - +
- relfur + relfur - yu + yu - ton + ton - mimiku'pash~ + mimiku'pash~
- + - + - + - ~ + ~
@@ -2267,216 +2299,232 @@ LU'NYA- ishi-balfur + ishi - yu + balfur - mishi'pash! + yu - + mishi'pash! + + + +
- + - + - ! + - + ! + + + +
- balfur + balfur - chu + chu - mya + mya - arilaen + arilaen - yu + yu - en + en - ka'nya + ka'nya - peekaka'nya + peekaka'nya - fa'dre? + fa'dre?
- + - + - + - + - + - + - + - + - ? + ?
@@ -2501,204 +2549,220 @@ ESH'NYUI- yesh-balfur + yesh - yu + balfur - mishi'pash~ + yu + + + + mishi'pash~
- + - + - ~ + + + + + ~
- (>///////////////<) + (>///////////////<)
- (>///////////////<) + (>///////////////<)
- relfur + relfur - yu + yu - ari'laen + ari'laen - parefaka'nya, + parefaka'nya, - balfur + balfur - yu + yu - pareka'nya + pareka'nya - dra? + dra?
- + - + - + - , + , - + - + - + - ? + ?
@@ -2723,284 +2787,284 @@ LU'NYA- relfur + relfur - chu + chu - arilaen + arilaen - dedaka'nya. + dedaka'nya. - +
- + - + - + - + - +
- imanla + imanla - rila + rila - shashka'nya'pash. + shashka'nya'pash. - +
- + - + - + - +
- imanla + imanla - shoo + shoo - chu + chu - ike + ike - to + to - pikeshe + pikeshe - ka'nya. + ka'nya. - +
- + - + - + - + - + - + - + - +
@@ -3011,68 +3075,68 @@ LU'NYA- relfur + relfur - chu + chu - arilaenlan + arilaenlan - luka'nya'pash. + luka'nya'pash.
- + - + - + - +
@@ -3097,100 +3161,100 @@ ESH'NYUI- arilaenla + arilaenla - shoo + shoo - chu + chu - pikeshe + pikeshe - fuka'nya'bash + fuka'nya'bash - dra? + dra?
- + - + - + - + - + - ? + ?
@@ -3215,184 +3279,184 @@ LU'NYA- gao + gao - chu + chu - relfur + relfur - yu + yu - fayu + fayu - kan'ya. + kan'ya. - +
- + - + - + - + - + - + - +
- relfur + relfur - chu + chu - arilaen + arilaen - dedaka'nya. + dedaka'nya.
- + - + - + - +
@@ -3415,7 +3479,7 @@ LU'NYA