Module:rad-stem: Difference between revisions

Jump to navigation Jump to search
m
Beautified
No edit summary
m (Beautified)
Line 1: Line 1:
local export = {}
local export = {}
local getArgs = require('Module:Arguments').getArgs
local getArgs = require("Module:Arguments").getArgs
local m_table = require('Module:table')
local m_table = require("Module:table")


local V = "aáàâảeéèiíìỉoóòøuúùûūủyýỳỷ"
local V = "aáàâảeéèiíìỉoóòøuúùûūủyýỳỷ"
Line 14: Line 14:


stem_data = {
stem_data = {
-- heavy stems --
    -- heavy stems --
['b'] = 'C', ['c'] = 'C', ['d'] = 'C', ['ð'] = 'C', ['dz'] = 'C', ['f'] = 'C', ['g'] = 'C', ['h'] = 'C', ['ħ'] = 'C', ['j'] = 'C', ['k'] = 'C', ['l'] = 'C', ['m'] = 'C', ['n'] = 'C', ['ņ'] = 'C', ['p'] = 'C', ['r'] = 'C', ['s'] = 'C', ['ș'] = 'C', ['t'] = 'C',['v'] = 'C', ['x'] = 'C', ['z'] = 'C', ['þ'] = 'C',
    ["b"] = "C",
    ["c"] = "C",
-- heavy spirants --
    ["d"] = "C",
['bH'] = 'CH', ['cH'] = 'CH', ['dH'] = 'CH', ['ðH'] = 'CH', ['dzH'] = 'CH', ['fH'] = 'CH', ['gH'] = 'CH', ['jH'] = 'CH', ['kH'] = 'CH', ['lḤ'] = 'CH', ['mḤ'] = 'CH', ['nḤ'] = 'CH', ['ņḤ'] = 'CH', ['pH'] = 'CH', ['rḤ'] = 'CH', ['sH'] = 'CH', ['șH'] = 'CH', ['tH'] = 'CH', ['vH'] = 'CH', ['xH'] = 'CH', ['zH'] = 'CH', ['þH'] = 'CH',
    ["ð"] = "C",
    ["dz"] = "C",
-- semi-light --
    ["f"] = "C",
['a^eG'] = 'G', ['a^oG'] = 'G', ['eG'] = 'G', ['G'] = 'G', ['ieG'] = 'G', ['iG'] = 'G', ['oG'] = 'G', ['øG'] = 'G', ['uG'] = 'G', ['yG'] = 'G', ['yeG'] = 'G',
    ["g"] = "C",
    ["h"] = "C",
-- light --
    ["ħ"] = "C",
['a'] = 'V', ['a^e'] = 'V', ['a^o'] = 'V', ['ai'] = 'V', ['au'] = 'V', ['e'] = 'V', ['i'] = 'V', ['ie'] = 'V', ['nj^e'] = 'V', ['o'] = 'V', ['ø'] = 'V', ['oe'] = 'V', ['ove'] = 'V', ['t^o'] = 'V', ['u'] = 'V', ['uve'] = 'V', ['Vj'] = 'V', ['y'] = 'V',
    ["j"] = "C",
    ["k"] = "C",
-- light spirant --
    ["l"] = "C",
['H'] = 'VH', ['HH'] = 'VH', [''] = 'VH', ['ḤḤ'] = 'VH',
    ["m"] = "C",
    ["n"] = "C",
    ["ņ"] = "C",
    ["p"] = "C",
    ["r"] = "C",
    ["s"] = "C",
    ["ș"] = "C",
    ["t"] = "C",
    ["v"] = "C",
    ["x"] = "C",
    ["z"] = "C",
    ["þ"] = "C",
    -- heavy spirants --
    ["bH"] = "CH",
    ["cH"] = "CH",
    ["dH"] = "CH",
    ["ðH"] = "CH",
    ["dzH"] = "CH",
    ["fH"] = "CH",
    ["gH"] = "CH",
    ["jH"] = "CH",
    ["kH"] = "CH",
    ["lḤ"] = "CH",
    ["mḤ"] = "CH",
    ["nḤ"] = "CH",
    ["ņḤ"] = "CH",
    ["pH"] = "CH",
    ["rḤ"] = "CH",
    ["sH"] = "CH",
    ["șH"] = "CH",
    ["tH"] = "CH",
    ["vH"] = "CH",
    ["xH"] = "CH",
    ["zH"] = "CH",
    ["þH"] = "CH",
    -- semi-light --
    ["a^eG"] = "G",
    ["a^oG"] = "G",
    ["eG"] = "G",
    ["G"] = "G",
    ["ieG"] = "G",
    ["iG"] = "G",
    ["oG"] = "G",
    ["øG"] = "G",
    ["uG"] = "G",
    ["yG"] = "G",
    ["yeG"] = "G",
    -- light --
    ["a"] = "V",
    ["a^e"] = "V",
    ["a^o"] = "V",
    ["ai"] = "V",
    ["au"] = "V",
    ["e"] = "V",
    ["i"] = "V",
    ["ie"] = "V",
    ["nj^e"] = "V",
    ["o"] = "V",
    ["ø"] = "V",
    ["oe"] = "V",
    ["ove"] = "V",
    ["t^o"] = "V",
    ["u"] = "V",
    ["uve"] = "V",
    ["Vj"] = "V",
    ["y"] = "V",
    -- light spirant --
    ["H"] = "VH",
    ["HH"] = "VH",
    [""] = "VH",
    ["ḤḤ"] = "VH"
}
}


light_noun_data = { -- NOM, V, ^V, dat, acc, ins, pl, voc
light_noun_data = {
['a'] = {"a", "a", "a", "an", "ast"},
    -- NOM, V, ^V, dat, acc, ins, pl, voc
['a^e'] = {"Ra", "a", "e", "an", "ast"},
    ["a"] = {"a", "a", "a", "an", "ast"},
['a^o'] = {"Ra", "a", "u", "an", "ast"},
    ["a^e"] = {"Ra", "a", "e", "an", "ast"},
['ai'] = {"ai", "ai"},
    ["a^o"] = {"Ra", "a", "u", "an", "ast"},
['áj'] = {"áj", "áj"},
    ["ai"] = {"ai", "ai"},
['au'] = {"au", "au"},
    ["áj"] = {"áj", "áj"},
['e'] = {"Ra", "e", "=i"},
    ["au"] = {"au", "au"},
['i'] = {"Re", "=i"},
    ["e"] = {"Ra", "e", "=i"},
['ie'] = {"íRa", "ie"},
    ["i"] = {"Re", "=i"},
['o'] = {"Ra", "o", "u", "un", "ust"},
    ["ie"] = {"íRa", "ie"},
['ø'] = {"Ra", "ø", "y"},
    ["o"] = {"Ra", "o", "u", "un", "ust"},
['u'] = {"Re", "u"},
    ["ø"] = {"Ra", "ø", "y"},
['y'] = {"Re", "y"},
    ["u"] = {"Re", "u"},
    ["y"] = {"Re", "y"},
['a^eG'] = {"ár", "í", "á", "ád", "aúr", "ai", "áse"},
    ["a^eG"] = {"ár", "í", "á", "ád", "aúr", "ai", "áse"},
['a^oG'] = {"ár", "ív", "á", "ád", "aúr", "ai", "áse"},
    ["a^oG"] = {"ár", "ív", "á", "ád", "aúr", "ai", "áse"},
['eG'] = {"ír", "í", "ea", "íd", "eúr", "í", "íse"},
    ["eG"] = {"ír", "í", "ea", "íd", "eúr", "í", "íse"},
['iG'] = {"ír", "í", "ea", "íd", "iúr", "í", "íse"},
    ["iG"] = {"ír", "í", "ea", "íd", "iúr", "í", "íse"},
['ieG'] = {"ỉr", "ỉ", "iea", "ỉd", "ieúr", "ỉ", "ỉse"},
    ["ieG"] = {"ỉr", "ỉ", "iea", "ỉd", "ieúr", "ỉ", "ỉse"},
['oG'] = {"úr", "ív", "oa", "úd", "oúr", "í", "úse"},
    ["oG"] = {"úr", "ív", "oa", "úd", "oúr", "í", "úse"},
['øG'] = {"ýr", "ýj", "øa", "ýd", "øúr", "ý", "ýse"},
    ["øG"] = {"ýr", "ýj", "øa", "ýd", "øúr", "ý", "ýse"},
['uG'] = {"úr", "ív", "oa", "úd", "ủr", "í", "úse"},
    ["uG"] = {"úr", "ív", "oa", "úd", "ủr", "í", "úse"},
['yG'] = {"ýr", "ýj", "øa", "ýd", "yúr", "ý", "ýse"},
    ["yG"] = {"ýr", "ýj", "øa", "ýd", "yúr", "ý", "ýse"},
['yeG'] = {"ỷr", "ỷ", "yea", "ỷd", "yeúr", "ỷ", "ỷse"},
    ["yeG"] = {"ỷr", "ỷ", "yea", "ỷd", "yeúr", "ỷ", "ỷse"},
['G'] = {"jr", "j", "a", "x", "úr", "j", "șe"},
    ["G"] = {"jr", "j", "a", "x", "úr", "j", "șe"}
}
}


pos_data = { "noun", "verb" }
pos_data = {"noun", "verb"}


-- this function resolves all consonant clashes
-- this function resolves all consonant clashes
function resolve_ending(resolution)
function resolve_ending(resolution)
    local function resolve(to_Match, to_Replace)
local function resolve(to_Match, to_Replace)
        if mw.ustring.find(resolution, to_Match) then
if mw.ustring.find(resolution, to_Match) then
            resolution = mw.ustring.gsub(resolution, to_Match, to_Replace)
resolution = mw.ustring.gsub(resolution, to_Match, to_Replace)
        -- mw.log( "/" .. to_Match .. "/ → " .. to_Replace .. " : " .. resolution )
-- mw.log( "/" .. to_Match .. "/ → " .. to_Replace .. " : " .. resolution )
        end
end
    end
end
-- resolve heavy spirant stems --
resolve("", "")


resolve("([^Ḥ])Ḥ%=e", "%1ge")
    -- resolve heavy spirant stems --
resolve("(ie[HḤ][HḤ]?%=e)$", "íe")
resolve("(ye[HḤ][HḤ]?%=e)$", "ýe")
resolve("(a[HḤ][HḤ]?%=e)$", "ai")
resolve("(e[HḤ][HḤ]?%=e)$", "ei")
resolve("(ø[HḤ][HḤ]?%=e)$", "øi")
resolve("(i[HḤ][HḤ]?%=e)$", "iè")
resolve("(y[HḤ][HḤ]?%=e)$", "yè")
resolve("(â[HḤ][HḤ]%=e)$", "âi")
resolve("(ieH%=i%=s)", "ies")
resolve("(ieH%=i)", "eí")
resolve("([ei][HḤ]%=i)", "=í")
resolve("(í[HḤ]%=i)", "ỉ")
resolve("([øy][HḤ]%=i)", "=ý")
resolve("(ý[HḤ]%=i)", "ỷ")
resolve("([ouû]H%=[ei])", "ui")
resolve("([ouû]H%=se)", "ûse")
resolve("(aH%=[ei])", "ai")
resolve("([" .. V .. "])H%=[ei]", "%1j=e")
resolve("ieH%=([aú])", "eív=%1")
resolve("([" .. V .. "])H%=([aú])", "%1v=%2")
-- resolve semi-light and light spirant stems
resolve("(%=ý%=s)$", "yes")
resolve("(%=ú%=s)$", "uos")
resolve("(%=ỉ%=s)$", "ỉes")
resolve("([" .. C .. "][" .. C .. "])%=í%=s$", "%1ies")
resolve("([jșķx])%=í%=s$", "%1ies")
resolve("(%=í%=s)$", "jes")
-- resolve light stems
resolve("%=tr", "t=s")
resolve("%=njr", "nj=s")
resolve("aij%=R([ae])$", "aí%1")
resolve("([^a])uv%=R([ae])$", "%1ú=%2")
resolve("([^au])ov%=R([ae])$", "%1ú=%2")
resolve("^[ou]v%=R([ae])$", "ú=%1")
resolve("[ùò]v%=R([ae])$", "ú%1")
resolve("uav%=Ra$", "uò=Ra")
resolve("([^eoø])av%=Ra$", "%1o=Ra")
resolve("uav%=(R?e)$", "uò=%1")
resolve("([^eoø])av%=(R?e)$", "%1o=%2")
resolve("([oò])%=Ra$", "%1à")
-- resolve spirants
resolve("ḤḤ%=g", "=k")
resolve("ḤḤ%=d", "=t")
resolve("ḤḤ%=s", "=s")
resolve("ḤḤ%=a", "=à")
resolve("ḤḤ%=úr", "úr")
resolve("ḤḤ%=e", "=e")
resolve("ḤḤ%=i", "=șe")
resolve("HH%=g", "=ak")
resolve("HH%=d", "=at")
resolve("HH%=s", "=as")
resolve("HH%=a", "=à")
resolve("HH%=úr", "úr")
resolve("HH%=e", "=e")
resolve("HH%=i", "=așe")
resolve("y%=à$", "ya")
resolve("y%=a$", "øa")
resolve("i%=à$", "ia")
resolve("i%=a$", "ea")
resolve("u%=à$", "ua")
resolve("u%=a$", "oa")
resolve("[aà]%=[aà]", "á")
resolve("[áả]%=[aà]", "ả")
resolve("â%=([aàáả])", "o%1")
resolve("kH%=g", "k")
resolve("kH%=d", "kt")
resolve("[ḤH]%=g", "g")
resolve("[ḤH]%=([ds])", "=%1")
resolve("Ḥ%=i", "j=i")
resolve("H%=i", "ș=i")
resolve("Ḥ%=([" .. V .. "])", "g%1")


-- resolve =g/=d
    resolve("", "")
resolve("([rvħh])%=g","%1=u")
 
resolve("(j%=g)","j")
    resolve("([^Ḥ])Ḥ%=e", "%1ge")
resolve("(j%=d)","x")
    resolve("(ie[HḤ][HḤ]?%=e)$", "íe")
    resolve("(ye[HḤ][HḤ]?%=e)$", "ýe")
resolve("([pf]%=g)","f")
    resolve("(a[HḤ][HḤ]?%=e)$", "ai")
resolve("([pf]%=d)","f=t")
    resolve("(e[HḤ][HḤ]?%=e)$", "ei")
resolve("(g%=g)","g")
    resolve("(ø[HḤ][HḤ]?%=e)$", "øi")
resolve("(k%=g)","k")
    resolve("(i[HḤ][HḤ]?%=e)$", "iè")
resolve("(k%=d)","t")
    resolve("(y[HḤ][HḤ]?%=e)$", "yè")
    resolve("(â[HḤ][HḤ]%=e)$", "âi")
resolve("(m%=g)","n=g")
 
    resolve("(ieH%=i%=s)", "ies")
resolve("b%=([gd])","v=%1")
    resolve("(ieH%=i)", "eí")
    resolve("([ei][HḤ]%=i)", "=í")
resolve("(j[ctþ]%=g)","ș=k")
    resolve("(í[HḤ]%=i)", "ỉ")
resolve("(j[ctþ]%=d)","ș=t")
    resolve("([øy][HḤ]%=i)", "=ý")
    resolve("(ý[HḤ]%=i)", "ỷ")
resolve("j[dð]%=([gd])","x=%1")
 
resolve("jdz%=([gd])","x=%1")
    resolve("([ouû]H%=[ei])", "ui")
    resolve("([ouû]H%=se)", "ûse")
resolve("([sș]?[șķ]%=g)","ș=k")
    resolve("(aH%=[ei])", "ai")
resolve("([sș]?[șķ]%=d)","ș=t")
    resolve("([" .. V .. "])H%=[ei]", "%1j=e")
    resolve("ieH%=([aú])", "eív=%1")
resolve("[zx]?d?x%=([gd])","x=%1")
    resolve("([" .. V .. "])H%=([aú])", "%1v=%2")
 
resolve("(s?[cstþ]%=g)","s=k")
    -- resolve semi-light and light spirant stems
resolve("(s?[cstþ]%=d)","s=t")
    resolve("(%=ý%=s)$", "yes")
    resolve("(%=ú%=s)$", "uos")
resolve("z?[zdð]%=([gd])","z=%1")
    resolve("(%=ỉ%=s)$", "ỉes")
resolve("z?dz%=([gd])","z=%1")
    resolve("([" .. C .. "][" .. C .. "])%=í%=s$", "%1ies")
    resolve("([jșķx])%=í%=s$", "%1ies")
resolve("([" .. C .. "])[mnņ]%=([gd])", "%1=%2")
    resolve("(%=í%=s)$", "jes")
 
-- resolve =s
    -- resolve light stems
resolve("([^a])u([sș])%=se","%1û%2e")
    resolve("%=tr", "t=s")
resolve("([sș])%=s","%1")
    resolve("%=njr", "nj=s")
resolve("j%=s","ș")
    resolve("aij%=R([ae])$", "aí%1")
    resolve("([^a])uv%=R([ae])$", "%1ú=%2")
-- resolve VvC
    resolve("([^au])ov%=R([ae])$", "%1ú=%2")
resolve("([^eoø])av%=([^" .. V .. "])","%1au=%2")
    resolve("^[ou]v%=R([ae])$", "ú=%1")
resolve("^av%=([^" .. V .. "])","au=%1")
    resolve("[ùò]v%=R([ae])$", "ú%1")
resolve("(àv%=)","au=")
    resolve("uav%=Ra$", "uò=Ra")
    resolve("([^eoø])av%=Ra$", "%1o=Ra")
resolve("([^a])uv%=([^" .. V .. "])","%1ú=%2")
    resolve("uav%=(R?e)$", "uò=%1")
resolve("([^au])ov%=([^" .. V .. "])","%1ú=%2")
    resolve("([^eoø])av%=(R?e)$", "%1o=%2")
resolve("^[ou]v%=([^" .. V .. "])","ú=%1")
    resolve("([oò])%=Ra$", "%1à")
resolve("([òù]v%=)","ú=")
 
    -- resolve spirants
resolve("([^iy])ev%=([^" .. V .. "])","%1ø=%2")
    resolve("ḤḤ%=g", "=k")
resolve("^ev%=([^" .. V .. "])","ø=%1")
    resolve("ḤḤ%=d", "=t")
resolve("(èv%=)","ø=")
    resolve("ḤḤ%=s", "=s")
    resolve("ḤḤ%=a", "=à")
resolve("([^aeuøuâ])iv%=([^" .. V .. "])","%1y=%2")
    resolve("ḤḤ%=úr", "úr")
resolve("^iv%=([^" .. V .. "])","y=%1")
    resolve("ḤḤ%=e", "=e")
resolve("(ìv%=)","y=")
    resolve("ḤḤ%=i", "=șe")
 
    resolve("HH%=g", "=ak")
-- resolve CvC
    resolve("HH%=d", "=at")
-- resolve("mv%=([" .. C .. "])","nu=%1")
    resolve("HH%=s", "=as")
resolve("([" .. C .. "])v%=([" .. C .. "])","%1u=%2")
    resolve("HH%=a", "=à")
resolve("vv%=([aiuú])","v=%1")
    resolve("HH%=úr", "úr")
resolve("([" .. C .. "])v%=R?e$","%1u=i")
    resolve("HH%=e", "=e")
resolve("([" .. C .. "])v%=Ra$","%1u=a")
    resolve("HH%=i", "=așe")
    resolve("y%=à$", "ya")
-- resolve -ûve → -úe
    resolve("y%=a$", "øa")
resolve("ûv%=R?e", "ú=e")
    resolve("i%=à$", "ia")
resolve("ûv%=R?e", "ú=e")
    resolve("i%=a$", "ea")
    resolve("u%=à$", "ua")
-- resolve aja, ava
    resolve("u%=a$", "oa")
resolve("([^eoø])a[vj]%=a","%1á")
    resolve("[aà]%=[aà]", "á")
resolve("(à[vj]%=a)","á")
    resolve("[áả]%=[aà]", "ả")
    resolve("â%=([aàáả])", "o%1")
-- resolve f/þ~v/ð
 
resolve("([" .. V .. O .. L .. J .. "])f%=([" .. V .. J .. "])","%1v=%2")
    resolve("kH%=g", "k")
resolve("([" .. V .. O .. L .. J .. "])þ%=([" .. V .. J .. "])","%1ð=%2")
    resolve("kH%=d", "kt")
    resolve("[ḤH]%=g", "g")
-- resolve k/g + front vowel
    resolve("[ḤH]%=([ds])", "=%1")
resolve("k%=([ie])","c=%1")
    resolve("Ḥ%=i", "j=i")
resolve("g%=([ie])","dz=%1")
    resolve("H%=i", "ș=i")
    resolve("Ḥ%=([" .. V .. "])", "g%1")
-- resolve palatal + i
 
resolve("([jșxķ])%=i","%1=e")
    -- resolve =g/=d
    resolve("([rvħh])%=g", "%1=u")
-- resolve misc.
    resolve("(j%=g)", "j")
resolve("(v%=g)","v")
    resolve("(j%=d)", "x")
resolve("[HḤ][HḤ]%=", "=")
 
resolve("[HḤ]%=", "=")
    resolve("([pf]%=g)", "f")
resolve("%=(%S*)R", "=%1")
    resolve("([pf]%=d)", "f=t")
resolve("(%=)","")
    resolve("(g%=g)", "g")
resolve("(°)","")
    resolve("(k%=g)", "k")
    resolve("(k%=d)", "t")
return resolution
 
    resolve("(m%=g)", "n=g")
 
    resolve("b%=([gd])", "v=%1")
 
    resolve("(j[ctþ]%=g)", "ș=k")
    resolve("(j[ctþ]%=d)", "ș=t")
 
    resolve("j[dð]%=([gd])", "x=%1")
    resolve("jdz%=([gd])", "x=%1")
 
    resolve("([sș]?[șķ]%=g)", "ș=k")
    resolve("([sș]?[șķ]%=d)", "ș=t")
 
    resolve("[zx]?d?x%=([gd])", "x=%1")
 
    resolve("(s?[cstþ]%=g)", "s=k")
    resolve("(s?[cstþ]%=d)", "s=t")
 
    resolve("z?[zdð]%=([gd])", "z=%1")
    resolve("z?dz%=([gd])", "z=%1")
 
    resolve("([" .. C .. "])[mnņ]%=([gd])", "%1=%2")
 
    -- resolve =s
    resolve("([^a])u([sș])%=se", "%1û%2e")
    resolve("([sș])%=s", "%1")
    resolve("j%=s", "ș")
 
    -- resolve VvC
    resolve("([^eoø])av%=([^" .. V .. "])", "%1au=%2")
    resolve("^av%=([^" .. V .. "])", "au=%1")
    resolve("(àv%=)", "au=")
 
    resolve("([^a])uv%=([^" .. V .. "])", "%1ú=%2")
    resolve("([^au])ov%=([^" .. V .. "])", "%1ú=%2")
    resolve("^[ou]v%=([^" .. V .. "])", "ú=%1")
    resolve("([òù]v%=)", "ú=")
 
    resolve("([^iy])ev%=([^" .. V .. "])", "%1ø=%2")
    resolve("^ev%=([^" .. V .. "])", "ø=%1")
    resolve("(èv%=)", "ø=")
 
    resolve("([^aeuøuâ])iv%=([^" .. V .. "])", "%1y=%2")
    resolve("^iv%=([^" .. V .. "])", "y=%1")
    resolve("(ìv%=)", "y=")
 
    -- resolve CvC
    -- resolve("mv%=([" .. C .. "])","nu=%1")
    resolve("([" .. C .. "])v%=([" .. C .. "])", "%1u=%2")
    resolve("vv%=([aiuú])", "v=%1")
    resolve("([" .. C .. "])v%=R?e$", "%1u=i")
    resolve("([" .. C .. "])v%=Ra$", "%1u=a")
 
    -- resolve -ûve → -úe
    resolve("ûv%=R?e", "ú=e")
    resolve("ûv%=R?e", "ú=e")
 
    -- resolve aja, ava
    resolve("([^eoø])a[vj]%=a", "%1á")
    resolve("(à[vj]%=a)", "á")
 
    -- resolve f/þ~v/ð
    resolve("([" .. V .. O .. L .. J .. "])f%=([" .. V .. J .. "])", "%1v=%2")
    resolve("([" .. V .. O .. L .. J .. "])þ%=([" .. V .. J .. "])", "%1ð=%2")
 
    -- resolve k/g + front vowel
    resolve("k%=([ie])", "c=%1")
    resolve("g%=([ie])", "dz=%1")
 
    -- resolve palatal + i
    resolve("([jșxķ])%=i", "%1=e")
 
    -- resolve misc.
    resolve("(v%=g)", "v")
    resolve("[HḤ][HḤ]%=", "=")
    resolve("[HḤ]%=", "=")
    resolve("%=(%S*)R", "=%1")
    resolve("(%=)", "")
    resolve("(°)", "")
 
    return resolution
end
end


function export.getNounStem(args) -- rad-inflection|pos|principle_part| 3 | 4 | 5, outputs table of principle parts
function export.getNounStem(args) -- rad-inflection|pos|principle_part| 3 | 4 | 5, outputs table of principle parts
local principle_parts = {
    local principle_parts = {
["nom"] = "",
        ["nom"] = "",
["voc"] = "",
        ["voc"] = "",
["gen"] = "",
        ["gen"] = "",
["dat"] = "",
        ["dat"] = "",
["acc"] = "",
        ["acc"] = "",
["ins"] = "",
        ["ins"] = "",
["nompl"] = "",
        ["nompl"] = "",
["genpl"] = "",
        ["genpl"] = "",
["genpl_short"] = "",
        ["genpl_short"] = "",
["anim"] = "",
        ["anim"] = ""
}
    }
 
local stem = ""
    local stem = ""
local stem_broken = ""
    local stem_broken = ""
local stem_broken_e = ""
    local stem_broken_e = ""
local stem_raised = ""
    local stem_raised = ""
local ending = ""
    local ending = ""
 
-- create stem and ending parameters --  
    -- create stem and ending parameters --
--mw.log("Parameters:")
    --mw.log("Parameters:")
if stem_data[args[4]] or stem_data[args[5]] or stem_data[args[6]] then
    if stem_data[args[4]] or stem_data[args[5]] or stem_data[args[6]] then
        local v_index = 4 -- max nucleus position
local v_index = 4 -- max nucleus position
 
        while true do
while true do
            if mw.ustring.find(args[v_index], "([%^%~])") and args[v_index + 1] ~= nil then
if mw.ustring.find(args[v_index], "([%^%~])") and args[v_index + 1] ~= nil then
                if mw.ustring.find(args[v_index], "([%^])") then
if mw.ustring.find(args[v_index], "([%^])") then
                    stem = mw.ustring.match(args[v_index], "([^%^]+)%^") or ""
stem = mw.ustring.match(args[v_index], "([^%^]+)%^") or ""
                    stem_raised = mw.ustring.match(args[v_index], "%^([^%^]+)")
stem_raised = mw.ustring.match(args[v_index], "%^([^%^]+)")
                else
else
                    stem = args[v_index]
stem = args[v_index]
                    stem_raised = args[v_index]
stem_raised = args[v_index]
                end
end
                if mw.ustring.find(stem, "([%~])") then
if mw.ustring.find(stem, "([%~])") then
                    stem_broken = mw.ustring.match(stem, "%~([^%~%^]+)")
stem_broken = mw.ustring.match(stem, "%~([^%~%^]+)")
                    stem = mw.ustring.match(stem, "([^%~]+)%~")
stem = mw.ustring.match(stem, "([^%~]+)%~")
                    if stem_raised == args[v_index] then
if stem_raised == args[v_index] then
                        stem_raised = stem
stem_raised = stem
                    end
end
                else
else
                    stem_broken = stem
stem_broken = stem
                end
end
                break
break
            else
else
                if mw.ustring.find(V, mw.ustring.sub(args[v_index], -1)) and args[v_index + 1] ~= nil then
if mw.ustring.find(V, mw.ustring.sub(args[v_index], -1)) and args[v_index + 1] ~= nil then
                    stem = args[v_index]
stem = args[v_index]
                    stem_raised = stem
stem_raised = stem
                    stem_broken = stem
stem_broken = stem
                    break
break
                elseif v_index == 3 then
elseif v_index == 3 then
                    stem = args[3]
stem = args[3]
                    stem_raised = stem
stem_raised = stem
                    stem_broken = stem
stem_broken = stem
                    break
break
                else
else
                    v_index = 3
v_index = 3
                end
end
            end
end
        end
end
 
        if stem_broken == "u" then
if stem_broken == "u" then
            stem_broken_e = "û"
stem_broken_e = "û"
        else
else
            stem_broken_e = stem_broken
stem_broken_e = stem_broken
        end
end
 
        if v_index > 3 then
if v_index > 3 then
            stem = args[v_index - 1] .. stem
stem = args[v_index - 1] .. stem
            stem_broken = args[v_index - 1] .. stem_broken
stem_broken = args[v_index - 1] .. stem_broken
            stem_broken_e = args[v_index - 1] .. stem_broken_e
stem_broken_e = args[v_index - 1] .. stem_broken_e
            stem_raised = args[v_index - 1] .. stem_raised
stem_raised = args[v_index - 1] .. stem_raised
        end
end
 
        if args[v_index + 2] ~= nil then
if args[v_index + 2] ~= nil then
            ending = args[v_index + 2]
ending = args[v_index + 2]
 
            stem = stem .. args[v_index + 1]
stem = stem .. args[v_index + 1]
            stem_broken = stem_broken .. args[v_index + 1]
stem_broken = stem_broken .. args[v_index + 1]
            stem_broken_e = stem_broken_e .. args[v_index + 1]
stem_broken_e = stem_broken_e .. args[v_index + 1]
            stem_raised = stem_raised .. args[v_index + 1]
stem_raised = stem_raised .. args[v_index + 1]
        elseif args[v_index + 1] ~= nil then
            ending = args[v_index + 1]
elseif args[v_index + 1] ~= nil then
        elseif stem_data[args[v_index]] then
ending = args[v_index + 1]
            ending = args[v_index]
            stem = ""
elseif stem_data[args[v_index]] then
            stem_broken = ""
ending = args[v_index]
            stem_broken_e = ""
stem = ""
            stem_raised = ""
stem_broken = ""
        else
stem_broken_e = ""
            error("No valid ending detected")
stem_raised = ""
        end
else error("No valid ending detected") end
    elseif stem_data[args[3]] then
elseif stem_data[args[3]] then
        ending = args[3]
ending = args[3]
        stem = ""
stem = ""
        stem_broken = ""
stem_broken = ""
        stem_broken_e = ""
stem_broken_e = ""
        stem_raised = ""
stem_raised = ""
    else
else
        error("Invalid format: Please format the arguments as hv|o~u^u|þ, dv|a^u|n|þ, he|rḤ or lorál|eH")
error("Invalid format: Please format the arguments as hv|o~u^u|þ, dv|a^u|n|þ, he|rḤ or lorál|eH")
    end
end
 
    if stem_data[ending] == "C" or stem_data[ending] == "CH" or stem_data[ending] == "VH" then
if stem_data[ending] == 'C' or stem_data[ending] == 'CH' or stem_data[ending] == 'VH' then
        stem = stem .. ending
stem = stem .. ending
        stem_broken = stem_broken .. ending
stem_broken = stem_broken .. ending
        stem_broken_e = stem_broken_e .. ending
stem_broken_e = stem_broken_e .. ending
        stem_raised = stem_raised .. ending
stem_raised = stem_raised .. ending
    end
end
    --
 
--[[
    --[[
mw.log("Stem: " .. stem)
mw.log("Stem: " .. stem)
if stem_broken then mw.log("Broken stem: " .. stem_broken ) end
if stem_broken then mw.log("Broken stem: " .. stem_broken ) end
Line 365: Line 433:
if stem_raised then mw.log("Raised stem: " .. stem_raised ) end
if stem_raised then mw.log("Raised stem: " .. stem_raised ) end
mw.log("Ending: " .. ending)
mw.log("Ending: " .. ending)
]]--
]] -- generate endings from declension type --
 
-- generate endings from declension type --
    -- HEAVY AND HEAVY SPIRANT --
    if stem_data[ending] == "C" or stem_data[ending] == "CH" or stem_data[ending] == "VH" then
-- HEAVY AND HEAVY SPIRANT --
        -- LIGHT --
if stem_data[ending] == 'C' or stem_data[ending] == 'CH' or stem_data[ending] == 'VH' then
        if
if ending == "j" and not (mw.ustring.sub(stem, -2) == "oj" and mw.ustring.sub(stem, -3) ~= "aoj" and mw.ustring.sub(stem, -3) ~= "uoj") then
            ending == "j" and
principle_parts["nom"] = stem .. "=s"
                not (mw.ustring.sub(stem, -2) == "oj" and mw.ustring.sub(stem, -3) ~= "aoj" and
principle_parts["acc"] = stem .. "=d"
                    mw.ustring.sub(stem, -3) ~= "uoj")
principle_parts["voc"] = stem .. "=se"
        then
else
            principle_parts["nom"] = stem .. "=s"
principle_parts["nom"] = stem_broken .. "=s"
            principle_parts["acc"] = stem .. "=d"
principle_parts["acc"] = stem_broken .. "=d"
            principle_parts["voc"] = stem .. "=se"
principle_parts["voc"] = stem_broken .. "=se"
        else
end
            principle_parts["nom"] = stem_broken .. "=s"
if (ending == 'v' or ending == 'r') and stem_raised == stem then
            principle_parts["acc"] = stem_broken .. "=d"
principle_parts["gen"] = stem .. "=g"
            principle_parts["voc"] = stem_broken .. "=se"
elseif stem_raised ~= stem then
        end
principle_parts["gen"] = stem_raised .. "=g"
        if (ending == "v" or ending == "r") and stem_raised == stem then
else
            principle_parts["gen"] = stem .. "=g"
principle_parts["gen"] = stem_broken .. "=g"
        elseif stem_raised ~= stem then
end
            principle_parts["gen"] = stem_raised .. "=g"
principle_parts["dat"] = stem .. "=a"
        else
principle_parts["ins"] = stem .. "=úr"
            principle_parts["gen"] = stem_broken .. "=g"
principle_parts["nompl"] = stem_broken_e .. "=e"
        end
principle_parts["genpl"] = stem .. "=i"
        principle_parts["dat"] = stem .. "=a"
principle_parts["genpl_short"] = principle_parts["genpl"] .. "=s"
        principle_parts["ins"] = stem .. "=úr"
principle_parts["anim"] = stem --for adjs only
        principle_parts["nompl"] = stem_broken_e .. "=e"
        principle_parts["genpl"] = stem .. "=i"
-- LIGHT --
        principle_parts["genpl_short"] = principle_parts["genpl"] .. "=s"
elseif ending == 'nj^e' then
        principle_parts["anim"] = stem --for adjs only
principle_parts["nom"] = stem_broken .. "nș"
    elseif ending == "nj^e" then
principle_parts["voc"] = stem_broken .. "nșe"
        principle_parts["nom"] = stem_broken .. "nș"
principle_parts["gen"] = stem_broken_e .. "njesk"
        principle_parts["voc"] = stem_broken .. "nșe"
principle_parts["dat"] = stem_broken_e .. "=" .. "nja"
        principle_parts["gen"] = stem_broken_e .. "njesk"
principle_parts["acc"] = stem_broken .. "nșt"
        principle_parts["dat"] = stem_broken_e .. "=" .. "nja"
principle_parts["ins"] = stem .. "nivúr"
        principle_parts["acc"] = stem_broken .. "nșt"
principle_parts["nompl"] = stem_broken .. "nxe"
        principle_parts["ins"] = stem .. "nivúr"
principle_parts["genpl"] = stem_broken .. "nje"
        principle_parts["nompl"] = stem_broken .. "nxe"
principle_parts["genpl_short"] = stem_broken_e .. "nje=s"
        principle_parts["genpl"] = stem_broken .. "nje"
elseif ending == 't^o' then
        principle_parts["genpl_short"] = stem_broken_e .. "nje=s"
principle_parts["nom"] = stem_broken .. "ts"
    elseif ending == "t^o" then
principle_parts["voc"] = stem_broken .. "tse"
        principle_parts["nom"] = stem_broken .. "ts"
principle_parts["gen"] = stem .. "tusk"
        principle_parts["voc"] = stem_broken .. "tse"
principle_parts["dat"] = stem .. "ta"
        principle_parts["gen"] = stem .. "tusk"
principle_parts["acc"] = stem_broken .. "tst"
        principle_parts["dat"] = stem .. "ta"
principle_parts["ins"] = stem_broken .. "tvúr"
        principle_parts["acc"] = stem_broken .. "tst"
principle_parts["nompl"] = stem_broken .. "tse"
        principle_parts["ins"] = stem_broken .. "tvúr"
principle_parts["genpl"] = stem_broken .. "tsi"
        principle_parts["nompl"] = stem_broken .. "tse"
principle_parts["genpl_short"] = stem .. "tu=s"
        principle_parts["genpl"] = stem_broken .. "tsi"
elseif stem_data[ending] == 'V' then
        principle_parts["genpl_short"] = stem .. "tu=s"
principle_parts["nom"] = stem_broken_e .. "=" .. light_noun_data[ending][1]
    elseif stem_data[ending] == "V" then
principle_parts["voc"] = stem .. light_noun_data[ending][2] .. "se"
        -- SEMI-LIGHT
principle_parts["gen"] = stem .. (light_noun_data[ending][3] or light_noun_data[ending][2]) .. "sk"
        principle_parts["nom"] = stem_broken_e .. "=" .. light_noun_data[ending][1]
principle_parts["dat"] = stem .. (light_noun_data[ending][4] or (light_noun_data[ending][2] .. "n"))
        principle_parts["voc"] = stem .. light_noun_data[ending][2] .. "se"
principle_parts["acc"] = stem .. (light_noun_data[ending][5] or (light_noun_data[ending][2] .. "st"))
        principle_parts["gen"] = stem .. (light_noun_data[ending][3] or light_noun_data[ending][2]) .. "sk"
principle_parts["ins"] = stem .. (light_noun_data[ending][6] or (light_noun_data[ending][2] .. "vúr"))
        principle_parts["dat"] = stem .. (light_noun_data[ending][4] or (light_noun_data[ending][2] .. "n"))
principle_parts["nompl"] = stem .. light_noun_data[ending][2] .. "re"
        principle_parts["acc"] = stem .. (light_noun_data[ending][5] or (light_noun_data[ending][2] .. "st"))
principle_parts["genpl"] = stem .. light_noun_data[ending][2]
        principle_parts["ins"] = stem .. (light_noun_data[ending][6] or (light_noun_data[ending][2] .. "vúr"))
principle_parts["genpl_short"] = stem .. (light_noun_data[ending][3] or light_noun_data[ending][2]) .. "=s"
        principle_parts["nompl"] = stem .. light_noun_data[ending][2] .. "re"
        principle_parts["genpl"] = stem .. light_noun_data[ending][2]
-- SEMI-LIGHT
        principle_parts["genpl_short"] = stem .. (light_noun_data[ending][3] or light_noun_data[ending][2]) .. "=s"
elseif stem_data[ending] == 'G' then
    elseif stem_data[ending] == "G" then
principle_parts["nom"] = stem_broken .. light_noun_data[ending][1]
        principle_parts["nom"] = stem_broken .. light_noun_data[ending][1]
principle_parts["voc"] = stem .. light_noun_data[ending][7]
        principle_parts["voc"] = stem .. light_noun_data[ending][7]
principle_parts["gen"] = stem_broken .. light_noun_data[ending][2]
        principle_parts["gen"] = stem_broken .. light_noun_data[ending][2]
principle_parts["dat"] = stem .. light_noun_data[ending][3]
        principle_parts["dat"] = stem .. light_noun_data[ending][3]
principle_parts["acc"] = stem .. light_noun_data[ending][4]
        principle_parts["acc"] = stem .. light_noun_data[ending][4]
principle_parts["ins"] = stem .. light_noun_data[ending][5]
        principle_parts["ins"] = stem .. light_noun_data[ending][5]
principle_parts["nompl"] = stem_broken .. light_noun_data[ending][6] .. "re"
        principle_parts["nompl"] = stem_broken .. light_noun_data[ending][6] .. "re"
principle_parts["genpl"] = stem_broken .. light_noun_data[ending][6]
        principle_parts["genpl"] = stem_broken .. light_noun_data[ending][6]
principle_parts["genpl_short"] = stem_broken .. "=" .. light_noun_data[ending][6] .. "=s"
        principle_parts["genpl_short"] = stem_broken .. "=" .. light_noun_data[ending][6] .. "=s"
end
    end
 
--mw.log("——— Resolving ———")
    --mw.log("——— Resolving ———")
for part, infl in pairs(principle_parts) do
    for part, infl in pairs(principle_parts) do
principle_parts[part] = resolve_ending(infl)
        principle_parts[part] = resolve_ending(infl)
end
    end
 
principle_parts["type"] = stem_data[ending]
    principle_parts["type"] = stem_data[ending]
 
--mw.logObject(principle_parts)
    --mw.logObject(principle_parts)
return principle_parts
    return principle_parts
end
end


function export.getVerbStem(args) -- outputs table of principle parts
    if args["pre"] then
        for arg, value in pairs(args) do
            if arg ~= "pre" and arg ~= "t" and arg ~= "vstem" and not mw.ustring.match(arg, "note$") then
                args[arg] = args["pre"] .. value
            end
        end
    end


function export.getVerbStem(args) -- outputs table of principle parts
    local principle_parts = {
        ["inf"] = args[1],
if args['pre'] then
        ["2s"] = args[2],
for arg, value in pairs(args) do
        ["pst"] = args[3],
if arg ~= "pre" and arg ~= "t" and arg ~= "vstem" and not mw.ustring.match(arg, "note$") then
        ["prespart"] = args[4],
args[arg] = args['pre'] .. value
        ["pspart"] = args[5],
end
        ["passinf"] = args[6],
end
        ["passprespart"] = args[7] or args[6]
end
    }
 
local principle_parts = {
    if args["vstem"] then
["inf"] = args[1],
        if args.vstem == "true" then
["2s"] = args[2],
            principle_parts["vstem"] = true
["pst"] = args[3],
        elseif args.vstem == "false" then
["prespart"] = args[4],
            principle_parts["vstem"] = false
["pspart"] = args[5],
        end
["passinf"] = args[6],
    elseif
["passprespart"] = args[7] or args[6],
        mw.ustring.match(principle_parts["2s"], "[^n]v$") and not mw.ustring.match(principle_parts["inf"], "ft$") and
}
            not mw.ustring.match(principle_parts["inf"], "aut$")
    then
if args["vstem"] then
        principle_parts["vstem"] = true
if args.vstem == "true" then
    else
principle_parts["vstem"] = true
        principle_parts["vstem"] = false
elseif args.vstem == "false" then
    end
principle_parts["vstem"] = false
 
end
    -- non-finite parameters
elseif mw.ustring.match(principle_parts["2s"],"[^n]v$") and not mw.ustring.match(principle_parts["inf"],"ft$") and not mw.ustring.match(principle_parts["inf"],"aut$") then
    if principle_parts.vstem then
principle_parts["vstem"] = true
        principle_parts["vnoun"] = args["vnoun"] or mw.ustring.gsub(principle_parts["2s"], "v$", "nș")
else
    else
principle_parts["vstem"] = false
        principle_parts["vnoun"] = args["vnoun"] or (mw.ustring.gsub(principle_parts["pspart"] .. "aș", "âaș$", "oàș"))
end
    end
    if mw.ustring.match(principle_parts["pspart"], "ru$") then
        principle_parts["pspart"] = mw.ustring.gsub(principle_parts["pspart"], "ru$", "rủ")
    else
        principle_parts["pspart"] = mw.ustring.gsub(principle_parts["pspart"] .. "ú", "âaș$", "oàș")
    end
 
    -- nonpast parameters
    if args["1s"] then
        principle_parts["1s"] = args["1s"]
    else
        if principle_parts["vstem"] then
            principle_parts["1s"] = mw.ustring.gsub(principle_parts["2s"], "v$", "") .. "e"
        else
            principle_parts["1s"] = principle_parts["2s"] .. "e"
        end
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([âø])e$", "%1i")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^eoø])ae$", "%1ai")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^i])ee$", "%1ei")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^aeuøâ])ie$", "%1iè")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "ye$", "yè")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^au])oe$", "%1ui")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^a])ue$", "%1ui")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "uave$", "uòe")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^eøo])ave$", "%1oe")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "iee$", "íe")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "yee$", "ýe")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "uoe$", "úe")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "aoe$", "aoi")
        principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "nve$", "nui")
    end
    if args["3s"] then
        principle_parts["3s"] = args["3s"]
    else
        principle_parts["3s"] = principle_parts["2s"] .. "ș"
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^eoø])aș$", "%1áș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "áș$", "ảș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^aeuøâ])iș$", "%1eaș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^i])eș$", "%1eaș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^a])uș$", "%1oaș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^au])oș$", "%1oaș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "aoș$", "aôș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "[øy]ș$", "øaș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "âș$", "oaș")
        if principle_parts["vstem"] then
            principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "vș$", "ș")
        end
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "[sș]ș$", "ș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "nvș$", "mș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^eoø])avș$", "%1auș")
        principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([nņlr])gș$", "%1ș")
    end
    principle_parts["pl"] = args["pl"]
    principle_parts["a"] = args["a"] or mw.ustring.gsub(principle_parts["2s"] .. "a", "([eoø])a$", "%1à")
    principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "aa$", "á")
    principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "áa$", "ả")
    principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "âa$", "oà")
    if principle_parts["vstem"] then
        principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "ava$", "á")
    end
    --principle_parts["aa"] = args["aa"] --or mw.ustring.gsub(principle_parts["2s"] .. "á", "([^eoø])avá$", "%1áva")
    --principle_parts["ai"] = args["ai"] --or mw.ustring.gsub(principle_parts["2s"] .. "ai", "([^eoø])avai$", "%1áe")
    if principle_parts["vstem"] then
        principle_parts["depers"] = args["depers"] or mw.ustring.gsub(principle_parts["2s"], "v$", "")
    else
        principle_parts["depers"] = args["depers"]
        if principle_parts["depers"] then
            principle_parts["depers"] = mw.ustring.gsub(principle_parts["depers"], "([^eoø])av$", "%1au")
        end
    end
    --principle_parts["o"] = mw.ustring.gsub(principle_parts["2s"] .. "o", "([au])o$", "%1ò")
    local imp_temp = args["depers"]
    if imp_temp then
        if mw.ustring.match(imp_temp, "au$") then
            imp_temp = nil
        else
            imp_temp = imp_temp .. "a"
        end
    end
    if principle_parts["vstem"] then
        principle_parts["imp"] = args["imp"] or mw.ustring.gsub(principle_parts["2s"], "v$", "ja")
    else
        principle_parts["imp"] = args["imp"] or imp_temp or nil
    end
    if args["r"] then
        principle_parts["r"] = args["r"]
    else
        principle_parts["r"] = (principle_parts["depers"] or principle_parts["2s"]) .. "r"
        if principle_parts["vstem"] then
            principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "vr$", "r")
        end
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "([sș])r$", "%1tr")
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "([zx])r$", "%1dr")
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "rr$", "r")
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "nr$", "rr")
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "mr$", "mbr")
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "ņr$", "ņgr")
        principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "nvr$", "nur")
    end
 
    -- past parameters
    principle_parts["apst"] = args["apst"] or mw.ustring.gsub(principle_parts["pst"] .. "a", "([eoø])a$", "%1à")
    principle_parts["apst"] = mw.ustring.gsub(principle_parts["apst"], "aa$", "á")
    principle_parts["apst"] = mw.ustring.gsub(principle_parts["apst"], "áa$", "ả")
    principle_parts["apst"] = mw.ustring.gsub(principle_parts["apst"], "âa$", "oà")
    -- principle_parts["aipst"] = args["aipst"]
    principle_parts["epst"] = args["epst"]
    if args["rpst"] then
        principle_parts["rpst"] = args["rpst"]
    else
        principle_parts["rpst"] = principle_parts["pst"] .. "r"
        principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "([sș])r$", "%1tr")
        principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "([zx])r$", "%1dr")
        principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "rr$", "r")
        principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "nr$", "rr")
        principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "mr$", "mbr")
        principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "ņr$", "ņgr")
    end


-- non-finite parameters
    return principle_parts
if principle_parts.vstem then
principle_parts["vnoun"] = args["vnoun"] or mw.ustring.gsub(principle_parts["2s"],"v$","nș")
else
principle_parts["vnoun"] = args["vnoun"] or (mw.ustring.gsub(principle_parts["pspart"] .. "aș","âaș$","oàș"))
end
if mw.ustring.match(principle_parts["pspart"], "ru$") then
principle_parts["pspart"] = mw.ustring.gsub(principle_parts["pspart"], "ru$", "rủ")
else
principle_parts["pspart"] = mw.ustring.gsub(principle_parts["pspart"] .. "ú","âaș$","oàș")
end
-- nonpast parameters
if args["1s"] then
principle_parts["1s"] = args["1s"]
else
if principle_parts["vstem"] then
principle_parts["1s"] = mw.ustring.gsub(principle_parts["2s"], "v$", "") .. "e"
else
principle_parts["1s"] = principle_parts["2s"] .. "e"
end
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([âø])e$", "%1i")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^eoø])ae$", "%1ai")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^i])ee$", "%1ei")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^aeuøâ])ie$", "%1iè")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "ye$", "yè")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^au])oe$", "%1ui")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^a])ue$", "%1ui")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "uave$", "uòe")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "([^eøo])ave$", "%1oe")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "iee$", "íe")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "yee$", "ýe")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "uoe$", "úe")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "aoe$", "aoi")
principle_parts["1s"] = mw.ustring.gsub(principle_parts["1s"], "nve$", "nui")
end
if args["3s"] then
principle_parts["3s"] = args["3s"]
else
principle_parts["3s"] = principle_parts["2s"] .. "ș"
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^eoø])aș$", "%1áș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "áș$", "ảș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^aeuøâ])iș$", "%1eaș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^i])eș$", "%1eaș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^a])uș$", "%1oaș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^au])oș$", "%1oaș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "aoș$", "aôș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "[øy]ș$", "øaș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "âș$", "oaș")
if principle_parts["vstem"] then principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "vș$", "ș") end
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "[sș]ș$", "ș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "nvș$", "mș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([^eoø])avș$", "%1auș")
principle_parts["3s"] = mw.ustring.gsub(principle_parts["3s"], "([nņlr])gș$", "%1ș")
end
principle_parts["pl"] = args["pl"]
principle_parts["a"] = args["a"] or mw.ustring.gsub(principle_parts["2s"] .. "a", "([eoø])a$", "%1à")
principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "aa$", "á")
principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "áa$", "ả")
principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "âa$", "oà")
if principle_parts["vstem"] then principle_parts["a"] = mw.ustring.gsub(principle_parts["a"], "ava$", "á") end
--principle_parts["aa"] = args["aa"] --or mw.ustring.gsub(principle_parts["2s"] .. "á", "([^eoø])avá$", "%1áva")
--principle_parts["ai"] = args["ai"] --or mw.ustring.gsub(principle_parts["2s"] .. "ai", "([^eoø])avai$", "%1áe")
if principle_parts["vstem"] then
principle_parts["depers"] = args["depers"] or mw.ustring.gsub(principle_parts["2s"], "v$", "")
else
principle_parts["depers"] = args["depers"]
if principle_parts["depers"] then principle_parts["depers"] = mw.ustring.gsub(principle_parts["depers"], "([^eoø])av$", "%1au") end
end
--principle_parts["o"] = mw.ustring.gsub(principle_parts["2s"] .. "o", "([au])o$", "%1ò")
local imp_temp = args["depers"]
if imp_temp then
if mw.ustring.match(imp_temp, "au$") then
imp_temp = nil
else
imp_temp = imp_temp .. "a"
end
end
if principle_parts["vstem"] then
principle_parts["imp"] = args["imp"] or mw.ustring.gsub(principle_parts["2s"], "v$", "ja")
else
principle_parts["imp"] = args["imp"] or imp_temp or nil
end
if args["r"] then
principle_parts["r"] = args["r"]
else
principle_parts["r"] = (principle_parts["depers"] or principle_parts["2s"]) .. "r"
if principle_parts["vstem"] then principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "vr$", "r") end
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "([sș])r$", "%1tr")
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "([zx])r$", "%1dr")
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "rr$", "r")
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "nr$", "rr")
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "mr$", "mbr")
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "ņr$", "ņgr")
principle_parts["r"] = mw.ustring.gsub(principle_parts["r"], "nvr$", "nur")
end
-- past parameters
principle_parts["apst"] = args["apst"] or mw.ustring.gsub(principle_parts["pst"] .. "a", "([eoø])a$", "%1à")
principle_parts["apst"] = mw.ustring.gsub(principle_parts["apst"], "aa$", "á")
principle_parts["apst"] = mw.ustring.gsub(principle_parts["apst"], "áa$", "ả")
principle_parts["apst"] = mw.ustring.gsub(principle_parts["apst"], "âa$", "oà")
-- principle_parts["aipst"] = args["aipst"]
principle_parts["epst"] = args["epst"]
if args["rpst"] then
principle_parts["rpst"] = args["rpst"]
else
principle_parts["rpst"] = principle_parts["pst"] .. "r"
principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "([sș])r$", "%1tr")
principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "([zx])r$", "%1dr")
principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "rr$", "r")
principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "nr$", "rr")
principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "mr$", "mbr")
principle_parts["rpst"] = mw.ustring.gsub(principle_parts["rpst"], "ņr$", "ņgr")
end
return principle_parts
end
end


function export.getStem(frame)
function export.getStem(frame)
local args = getArgs(frame)
    local args = getArgs(frame)
local word = mw.title.getCurrentTitle().subpageText
    local word = mw.title.getCurrentTitle().subpageText
local to_Return = ""
    local to_Return = ""
 
if args[1] ~= nil and m_table.contains(pos_data, args[1]) then
    if args[1] ~= nil and m_table.contains(pos_data, args[1]) then
local pos = args[1]
        local pos = args[1]
else
    else
local error_text = "Parameter 1 must be:"
        local error_text = "Parameter 1 must be:"
for i, _ in pairs(data) do
        for i, _ in pairs(data) do
error_text = error_text .. " [" .. i .. "]"
            error_text = error_text .. " [" .. i .. "]"
end
        end
error(error_text)
        error(error_text)
end
    end
 
if args[1] == "noun" then
    if args[1] == "noun" then
to_Return = export.getNounStem(args)[args[2]]
        to_Return = export.getNounStem(args)[args[2]]
elseif args[1] == "verb" then
    elseif args[1] == "verb" then
to_Return = export.getVerbStem(args)[args[2]]
        to_Return = export.getVerbStem(args)[args[2]]
end
    end
 
return to_Return
    return to_Return
end
end


Navigation menu