Module:moh-noun

local export = {}

local div_top = [=[ Possesive forms of PAGENAME ]=]

local div_bottom = [=[ ]=]

local poss_table = [=[

local lang = require("Module:languages").getByCode("moh") local m_string_utilities = require("Module:string utilities") local m_links = require("Module:links")

local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local ulower = mw.ustring.lower local usub = mw.ustring.sub

local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end

local function penultimate(form) return form end

local form_names = {"1|s", "2|s", "3|m|s", "3|f//impers|s", "3|f//n|s", "1|d", "2|d", "1|p", "2|p", "3|m|d//p", "3|f|d//p"} local poss = { ["C"] = {"ak", "sa", "rao", "ako", "ao", "onkeni", "seni", "onkwa", "sewa", "raoti", "aoti"}, ["R"] = {"ake", "sa", "rao", "ako", "ao", "onkeni", "seni", "onkwa", "sewa", "raoti", "aoti"}, ["A"] = {"akwa", "sa", "rao", "ako", "ao", "ontia", "tsa", "onkwa", "sewa", "raona", "aona"}, ["E"] = {"akw", "s", "raw", "akaw", "aw", "onken", "sen", "onkw", "sew", "raon", "aon"}, ["O"] = {"ak", "s", "ra", "aka", "a", "onken", "sen", "onti", "ts", "raon", "aon"}, ["I"] = {"aki", "sen", "rao", "ako", "ao", "onkeni", "seni", "onkwen", "sewen", "raoti", "aoti"}, ["Y"] = {"at", "sen", "rao", "ako", "ao", "onkeni", "seni", "onkwen", "sewen", "raoti", "aoti"}, }

local neg_poss = { ["C"] = {"tewak", "tesa", "teho", "teio", "teiako", "teionkeni", "teseni", "teionkwa", "tesewa", "tehoti", "teioti"}, ["R"] = {"tewake", "tesa", "teho", "teio", "teiako", "teionkeni", "teseni", "teionkwa", "tesewa", "tehoti", "teioti"}, ["A"] = {"tewaka", "tesa", "teho", "teio", "teiako", "teiontia", "tetsa", "teionkwa", "tesewa", "tehona", "teiona"}, ["E"] = {"tewak", "tes", "tehaw", "teiaw", "teiakaw", "teionken", "tesen", "teionkw", "tesew", "tehon", "teion"}, ["O"] = {"tewak", "tes", "teha", "teia", "teiaka", "teionken", "tesen", "teionti", "tets", "tehon", "teion"}, ["Y"] = {"tewat", "tesa", "teho", "teio", "teiako", "teionkeni", "teseni", "teionkwa", "tesewa", "tehoti", "teioti"} }

local function build_table(PAGENAME, forms, neg_forms) full_table = rsub(div_top, "PAGENAME", PAGENAME) .. "\n" .. m_string_utilities.format(poss_table, forms) .. "\n" .. m_string_utilities.format(poss_table, neg_forms) .. div_bottom return full_table end

function export.show(frame) PAGENAME = mw.title.getCurrentTitle.text text = frame.args[1] ending = frame.args[2] -- control whether links get generated links = frame.args["link"] if links ~= nil and links == "true" then links = true else links = false end -- figure out the stem, and cut off initial vowel stem = ulower(text) init = usub(stem,1,1) second = usub(stem,2,2) class = nil if init == "a" then class = "A" stem = usub(stem,2,-1) elseif init == "e" then class = "E" elseif init == "o" then	class = "O" elseif init == "i" then if second == "a" or second == "e" or second == "o" then class = "Y" else class = "I" stem = ulower(usub(stem,2,-1)) end elseif init == "n" or init == "r" or init == "w" or init == "’" then class = "R" else class = "C" end prefixes = poss[class] neg_prefixes = neg_poss[class] local forms = {} local neg_forms = {} forms["TYPE"] = "Possesive" forms["PAGENAME"] = PAGENAME neg_forms["TYPE"] = "Negative possesive" neg_forms["PAGENAME"] = PAGENAME for i = 1,11 do form = prefixes[i] .. stem .. ending neg_form = neg_prefixes[i] .. stem .. ending if links then link = m_links.full_link({term = form, lang = lang, accel = {form = form_names[i] .. "|poss"}}, "term", false) forms[form_names[i]] = link neg_link = m_links.full_link({term = form, lang = lang, accel = {form = form_names[i] .. "|neg|poss"}}, "term", false) neg_forms[form_names[i]] = neg_link else forms[form_names[i]] = form neg_forms[form_names[i]] = neg_form end end return build_table(PAGENAME ,forms, neg_forms) end

return export