polite, plural, possesive, genitive morphemes handled.

This commit is contained in:
UndeadMaelys 2022-05-06 15:34:37 +02:00
parent 2faca4b4bd
commit 0beb347849
2 changed files with 1445 additions and 1417 deletions

View File

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

2806
test.html

File diff suppressed because it is too large Load Diff