Module:moh-verb

local export = {}

local div_top = [=[ Forms of PAGENAME ]=]

local div_bottom = [=[ ]=]

local patient_table = [=[

local agent_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 get_index(str, list) if list == nil then return -1 end for i = 1, #list do		if str == list[i] then return i end end return -1 end

local function in_set(str, list) if get_index(str, list) ~= -1 then return true else return false end end

tenses = {"habitual", "fact", "fut", "opt"} -- form numbers are based off of Lounsbury local patient_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 patient_form_nums = {"16", "19", "21", "22", "20", "17", "7", "18", "8", "24", "23"} -- wawa becomes on; wa becomes we before s and t; i deleted after wa’

-- wawa > on, awa > aon, hr before e/en/o/on, and ts before i stems prevents strict composition

local agent_form_names =  {"1|s", "2|s", "3|m|s", "3|f//impers|s", "3|f//n|s", "1|d|incl", "1|d|excl", "2|d", "3|m|d", "3|f|d", "1|p|incl", "1|p|excl", "2|p", "3|m|p", "3|f|p"} local agent_form_nums = {"1", "6", "10", "11", "9", "4", "2", "7", "14", "12", "5", "3", "8", "15", "13"}

local trans_nums = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",--agent "16","17","18","19","7a","8a", "20", "21", "22", "23", "24", --patient "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "31a", "32a", "38", --he/him "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "43a", "49", "50", "51", --they "52", "53", "54", "55", "56", "57", "58" } local trans_names = { "I > it", "we two (excl) > it", "we all (excl) > it", "we two (incl) > it", "we (incl) > it", "you > it", "you two > it", "you all > it", "she/it > it", "it/she > it", "she/s.o. > it", "they both (f) > it", "they all (f) > it", "they both (m) > it", "they all (m) > it",--agent "it > me", "it > us two", "it > us all", "it > you", "it > you two", "it > you all", "it > it/her", "it > him", "it > her/s.o.", "it > them (f)", "it > them (m)", --patient "I > him", "We two (excl) > him", "We all (excl) > him", "we two (incl) > it", "we all (incl) > it", "you > him", "you two > him", "you all > him", "she/s.o./they > him", "he > me", "he > us two", "he > us all", "he > you", "he > you two", "he > you all", "he > they/s.o.", -- he	"I > they/s.o.", "we (excl) > they/s.o.", "we (incl) > they/s.o.", "you > they/s.o.", "you (pl) > they/s.o.", "they (f) > they/s.o.", "they(m) > they/s.o.", "they/s.o. > me", "they/s.o. > us", "they/s.o. > you", "they/s.o. > you (pl)", "they/s.o. > she/it", "she/s.o > them(f)/s.o.", "she/s.o. > them(m)/s.o.", -- they "I > you", "I/us two > you/you two", "I/us > you/you all", "you > me", "you/you two > me/us two", "you/you all > me/us", "s.o. > s.o." --rest }

local prefixes = { -- agent ["1"] = {"k",	 "ke",   "ka",    "k",    "k",    "ki",    "t"}, ["2"] = {"iakeni", "iakeni","iatia", "iaken", "iaken", "iakeni", "iakeni" }, ["3"] = {"iakwa", "iakwa","iakwa", "iakw", "iati", "iakwen", "iakwa" }, -- check ["4"] = {"teni", "teni",  "tia",  "ten",  "ten",  "teni",  "teni" }, ["5"] = {"tewa", "tewa",  "tewa",  "tew", "ti",   "tewen",  "tewa" }, ["6"] = {"s",    "se",    "sa",    "s",   "s",    "tsi",   "ts" }, ["7"] = {"seni", "seni",  "ts",   "sen",   "sen", "seni",  "seni" }, ["7a"] = {"seni", "seni",  "ts",   "sen",   "sen", "seni",  "seni" }, ["8"] = {"sewa", "sewa",  "sewa", "sew",   "ts",  "sewen",  "sewa" }, ["8a"] = {"sewa", "sewa",  "sewa", "sew",   "ts",  "sewen",  "sewa" }, ["9"] = {"ka", "ka",  "w", "w",  "i",  "ken",  "ka" }, ["10"] = {"ra", "ra",  "ra", "r",  "r",  "ren",  "ra" }, ["11"] = {"ie", "ie",  "ion", "iak",  "iak",  "ie",  "ie" }, ["12"] = {"keni", "keni", "tia", "ken", "ken", "keni", "keni"}, ["13"] = {"konti", "konti", "kon", "konn", "konn", "konti", "konti"}, ["14"] = {"ni", "ni", "ia", "n", "n", "ni", "ni"}, ["15"] = {"rati", "rati", "ron", "ronn", "ronn", "rati", "rati"}, --patient ["16"] = {"wak", "wake", "waka", "wak", "wak", "waki", "wat"}, ["17"] = {"ionkeni", "ionkeni", "iontia", "ionken", "ionken", "ionkeni", "ionkeni"}, ["18"] = {"ionkwa", "ionkwa", "ionkwa", "ionkw", "ionti", "ionkwen", "ionkwa"}, ["19"] = {"sa", "sa", "sa", "s", "s", "sen", "sa"}, ["20"] = {"io", "io", "io", "iaw", "ia", "io", "io"}, ["21"] = {"ro", "ro", "ro", "raw", "ra", "ro", "ro"}, ["22"] = {"iako", "iako", "iako", "iakaw", "iaka", "iako", "iako"}, ["23"] = {"ioti", "ioti", "iona", "ion", "ion", "ioti", "ioti"}, ["24"] = {"roti", "roti", "rona", "ron", "ron", "roti", "roti"}, --transitive ["25"] = {"ri", "ri", "riia", "rii", "rii", "ri", "ri"}, ["26"] = {"shakeni", "shakeni", "shatia", "shaken", "shaken", "shakeni", "shakeni"}, ["27"] = {"shakwa", "shakwa", "shakwa", "shakw", "shati", "shakwen", "shakwa"}, ["28"] = {"tshiteni", "tshiteni", "tshiti", "tshiten", "tshiten", "tshiteni", "tshiteni"}, ["29"] = {"tshitewa", "tshitewa", "tshitewa", "tshitew", "tshiti", "tshitewen", "tshitewa"}, ["30"] = {"tsh", "tshe", "tsha", "tsh", "tsh", "tshi", "tsh"}, -- h-stem not handled properly ["31"] = {"tshiseni", "tshiseni", "tshitsa", "tshisen", "tshisen", "tshiseni", "tshiseni"}, ["31a"] = {"tshiseni", "tshiseni", "tshitsa", "tshisen", "tshisen", "tshiseni", "tshiseni"}, ["32"] = {"tshisewa", "tshisewa", "tshisewa", "tshisew", "tshits", "tshisewen", "tshisewa"}, ["32a"] = {"tshisewa", "tshisewa", "tshisewa", "tshisew", "tshits", "tshisewen", "tshisewa"}, --	["33"] = {"ronwa", "ronwa", "ronwa", "ronw", "roni", "ronwen", "ronwa"}, ["34"] = {"rak", "rake", "rakwa", "rak", "rak", "rak", "rat"}, ["35"] = {"shonkeni", "shonkeni", "shontia", "shonken", "shonken", "shonkeni", "shonkeni"}, ["36"] = {"shonkwa", "shonkwa", "shonkwa", "shonkw", "shonti", "shonkwen", "shonkwa"}, ["37"] = {"ia", "ia", "ia", "i", "i", "ien", "ia"}, ["38"] = {"shako", "shako", "shako", "shakaw", "shaka", "shako", "shako"}, ["39"] = {"khe", "khe", "kheia", "khei", "khei", "khe", "khe"}, ["40"] = {"iakhi", "iakhi", "iakhiia", "iakhii", "iakhii", "iakhi", "iakhi"}, ["41"] = {"iethi", "iethi", "iethiia", "iethii", "iethii", "iethi", "iethi"}, ["42"] = {"she", "she", "sheia", "shei", "shei", "she", "she"}, ["43"] = {"ietshi", "ietshi", "ietshiia", "ietshii", "ietshii", "ietshi", "ietshi"}, ["43a"] = {"ietshi", "ietshi", "ietshiia", "ietshii", "ietshii", "ietshi", "ietshi"}, ["44"] = {"iakoti", "iakoti", "iakona", "iakon", "iakon", "iakoti", "iakoti"}, ["45"] = {"shakoti", "shakoti", "shakona", "shakon", "shakon", "shakoti", "shakoti"}, ["46"] = {"ionk", "ionke", "ionkw", "ionk", "ionk", "ionk", "iont"}, ["47"] = {"ionkhi", "ionkhi", "ionkhiia", "ionkhii", "ionkhii", "ionkhi", "ionkhi"}, ["48"] = {"iesa", "iesa", "iesa", "ies", "ies", "iesen", "iesa"}, -- has variants with ion- ["49"] = {"konwa", "konwa", "konwa", "konw", "koni", "konwen", "konwa"}, -- has variant konwai before o/on ["50"] = {"konwati", "konwati", "konwana", "konwan", "konwan", "konwati", "konwati"}, ["51"] = {"ronwati", "ronwati", "ronwana", "ronwan", "ronwan", "ronwati", "ronwati"}, ["52"] = {"kon", "kon", "konia", "koni", "koni", "kon", "kon"}, ["53"] = {"keni", "keni", "tia", "ken", "ken", "keni", "keni"}, ["54"] = {"kwa", "kwa", "kwa", "kw", "ti", "kwen", "kwa"}, ["55"] = {"tak", "take", "takwa", "tak", "tak", "tak", "tat"}, ["56"] = {"takeni", "takeni", "tatia", "taken", "taken", "takeni", "takeni"}, ["57"] = {"takwa", "takwa", "takwa", "takw", "tati", "takwen", "takwa"}, ["58"] = {"iontat", "iontate", "iontat", "iontat", "iontat", "iontat", "iontat"} }

--patterns for future use local start_patterns = { ["exceptions"] = {"6", "9", "10", "30"}, ["i"] = {"2", "3", "11", "17", "18", "20", "23", "40", "41", "43", "44", "46", "47", "48", "58"}, -- i deleted after wa’ ["h"] = {"14", "26", "27", "30", "35", "36", "37", "38", "42", "45"}, -- h reappears after en, wa, a - 6 needs to be handled special ["s/t"] = {"4", "5", "7", "8", "19", "55", "56", "57"}, -- wa’ > we and a > aie before wa -- (does sh- (26, 27, 35, 36 38, 45) and tsh- (28, 29, 31, 32 count?) for s/t?	["r"] = {"15", "21", "24", "25", "33", "34", "51"} -- r > h, 10 needs to be handled speciall } local end_patterns = {	["o"] = {"20", "21", "22", "38"}, --	["i"] = {"25", "40", "41", "43", "47"}, -- epenthetic i	["e"] = {"38", "42"},	["ni"] = {}, -- pay attention to a-stems	["wa"] = {}, -- pay attention to o/on-stems	["ti"] = {"44", "45", "50", "51"} }

local function find_stress(word) return word end

local init_index = { ["C"] = 1, ["R"] = 2, ["A"] = 3, ["E"] = 4, ["O"] = 5, ["I"] = 6, ["Y"] = 7, ["H"] = 1 } local function combine_prefix(pref_num, class, tense, neg) index = init_index[class] pref = prefixes[pref_num][index] -- get the appropriate base if tense == "base" and neg == false then if class == "H" and pref_num == "30" then return "ts" end return pref elseif tense == "base" and neg == true then if in_set(pref_num, start_patterns["h"]) then return "teh" .. pref elseif in_set(pref_num, start_patterns["r"]) then return "teh" .. usub(pref,2,-1) elseif in_set(pref_num, start_patterns["exceptions"]) then if pref_num == "6" then alt_6 = {"hs", "hse", "hsa", "hs", "hs", "hs", "hs"} return "te".. alt_6[index] -- sy becomes ts, but goes back to sy 			elseif pref_num == "9" then alt_9 = {"ka", "ka",  "w", "w",  "i",  "ken",  "ka" } return "te" .. alt_9[index] elseif pref_num == "10" then alt_10 = {"ha", "ha", "ha", "hr", "hr", "ha", "ha"} return "te" .. alt_10[index] else return "te" .. prefix end else return "te" .. pref end end end

local function build_trans_table(pagename) trans_table = rsub(div_top, "PAGENAME", pagename) trans_table = trans_table .. "{| class=\"wikitable\"\n!-\n! Positive \n" for i = 1, #trans_nums do new_line = "|-\n! scope=row | " .. trans_names[i] .. "\n| {" .. trans_nums[i] .. "} \n" trans_table = trans_table .. new_line end trans_table = trans_table .. "\n|}" trans_table = trans_table .. div_bottom return trans_table end

function export.show(frame) PAGENAME = mw.title.getCurrentTitle.text verb_type = frame.args[1] text = frame.args[2] stem = ulower(text) init = usub(stem,1,1) second = usub(stem,2,2) class = nil if links ~= nil and links == "true" then links = true else links = false end --get stem class init = usub(stem,1,1) second = usub(stem,2,2) 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" elseif init == "h" then class = "H" else class = "C" end local forms = {} if verb_type == "transitive" then for i = 1, #trans_nums do			prefix_num = trans_nums[i] forms[prefix_num] = combine_prefix(prefix_num, class, "base", false) .. stem end form_table = build_trans_table(PAGENAME) return m_string_utilities.format(form_table, forms) elseif verb_type == "stative agent" then prefix_forms = {} for i = 1, #agent_form_nums do			prefix_num = agent_form_nums[i] prefix_name = agent_form_names[i] neg_prefix_name = "neg|" .. prefix_name form = combine_prefix(prefix_num, class, "base", false) .. stem neg_form = combine_prefix(prefix_num, class, "base", true) .. stem if links then link = m_links.full_link({term = form, lang = lang, accel = {form = prefix_name}}, "term", false) neg_link = m_links.full_link({term = form, lang = lang, accel = {form = neg_prefix_name}}, "term", false) forms[prefix_name] = link forms[neg_prefix_name] = neg_link else forms[prefix_name] = form forms[neg_prefix_name] = neg_form end end return m_string_utilities.format(agent_table, forms) elseif verb_type == "stative patient" then prefix_forms = {} for i = 1, #patient_form_nums do			prefix_num = patient_form_nums[i] prefix_name = patient_form_names[i] neg_prefix_name = "neg|" .. prefix_name prefix_forms[i] = combine_prefix(prefix_num, class, "base") form = combine_prefix(prefix_num, class, "base", false) .. stem neg_form = combine_prefix(prefix_num, class, "base", true) .. stem if links then link = m_links.full_link({term = form, lang = lang, accel = {form = prefix_name}}, "term", false) neg_link = m_links.full_link({term = form, lang = lang, accel = {form = neg_prefix_name}}, "term", false) forms[prefix_name] = link forms[neg_prefix_name] = neg_link else forms[prefix_name] = form forms[neg_prefix_name] = neg_form end end return m_string_utilities.format(patient_table, forms) else return "no type" end end

function export.prefix_table(frame) -- find prefix number to get forms PAGENAME = usub(mw.title.getCurrentTitle.text,1,-2) for num, form in pairs(prefixes) do		if form[1] == PAGENAME then prefix_num = num end end local prefix_forms = prefixes[prefix_num] -- cut the a from a-stems, i- from i-stems local a_stem_final = usub(prefix_forms[3],-1,-1) if a_stem_final == "a" then prefix_forms[3] = usub(prefix_forms[3],1,-2) elseif a_stem_final == "o" then prefix_forms[3] = usub(prefix_forms[3],1,-2) .. " o " else end local i_stem_final = usub(prefix_forms[6],-1,-1) if i_stem_final == "i" then prefix_forms[6] = usub(prefix_forms[6],1,-2) elseif i_stem_final == "o" then prefix_forms[6] = usub(prefix_forms[6],1,-2) .. " o " elseif i_stem_final == "n" then i_stem_final = usub(prefix_forms[6],-2,-1) if i_stem_final == "en" then prefix_forms[6] = usub(prefix_forms[6],1,-3) .. " en " elseif i_stem_final == "on" then prefix_forms[6] = usub(prefix_forms[6],1,-3) .. " on " else end else end

local prefix_table = [=[ {| class="wikitable" !-	! colspan="7" | Initial consonant |-	! Environment !! t/s/h/k !! n/r/w/’ !! a !! e/en!! o/on!! i !! y	|- ]=]	line = "| scope=row | Word-Initial \n| " for i = 1, 6 do line = line .. prefix_forms[i] .. "-" .. " || " end line = line .. prefix_forms[7] .. "-"	prefix_table = prefix_table .. line prefix_table = prefix_table .. "\n|}" return prefix_table end

return export