Module:fax-verb

local lang = require("Module:languages").getByCode("fax") local m_utilities = require("Module:utilities") local m_links = require("Module:links") local m_data = require("Module:fax-verb/data")

local match = mw.ustring.match local gmatch = mw.ustring.gmatch local gsub = mw.ustring.gsub local PAGENAME = mw.title.getCurrentTitle.text

local export = {}

-- Dialects. Arbitrary order (alphabetical) local d = {["L"] = 1, ["M"] = 2, ["V"] = 3} local d_full = {["L"] = "Lagarteiru", ["M"] = "Mañegu", ["V"] = "Valverdeñu"}

-- Inflection functions function export.show(frame) local parent_args = frame:getParent.args local dialects = parent_args[1] or nil local base = parent_args[2] or PAGENAME --find the ending of the verb local infl_type = "" if base:match("[aei]lsi$") then infl_type = base:match("[aei]lsi$") elseif base:match("[aei]l$") then infl_type = base:match("[aei]l$") else if not m_data[base] then error("This word doesn't have a valid ending.") end end

local data = {forms = {}, categories = {}} data.head = base data.infl_type = infl_type data.prefix = parent_args.prefix or "" -- Generate the forms if m_data[base] then m_data[base](parent_args, data) else args = require("Module:parameters").process(parent_args, m_data[infl_type].params, true) m_data[infl_type](args, data) end data.info = m_links.full_link({lang = lang, alt = data.prefix .. data.head}, "term") --generate the table and add categories if not dialects then error("Please provide the dialects in which this verb is used.") elseif not dialects:match("^L?M?V?$") then error("Please provide the dialects in which this verb is used in the proper format.") else local tables = "" for dialect in gmatch(dialects, "%u") do			data.dialect = dialect tables = tables .. make_table(data) end return tables .. (not parent_args.nocat and m_utilities.format_categories(data.categories, lang) or "") end end

-- Make the table function make_table(data) function export.accel_dialect return data.dialect end local function repl(param) if param == "info" then return mw.getContentLanguage:ucfirst(data.info or "") elseif param == "dialect" then return mw.getContentLanguage:ucfirst(d_full[data.dialect] or "") elseif param == "alternation" then return mw.getContentLanguage:ucfirst(data.alternation or "") end local np = data.forms[param] local forms = np and (np["LMV"] and np[1] or np[d[data.dialect]]) or nil if not forms then return "&mdash;" end local function make_accel(key, partmsg) local accel_form, pos, lemma = {}, "verb", PAGENAME key = key:gsub("impfsi", "impf") if key == "infinitive" or key == "gerund" then accel_form = {key:sub(1,3)} elseif key == "partmsg" then accel_form = {"past", "part"} pos = "past participle" elseif key:sub(1,4) == "part" then accel_form = {key:sub(5,5), key:sub(6,7)} pos = "past participle" lemma = partmsg or "test" elseif key:match("impr") then accel_form = {key:sub(5,5), key:sub(6,7), key:sub(1,4)} else accel_form = {key:sub(8,8), key:sub(9,10), key:sub(1,4), key:sub(5,7)} end return {form = table.concat(accel_form, "|"), pos = pos, lemma = lemma} end local ret, partmsg = {}, "" for _, subform in ipairs(forms) do if param == "partmsg" then partmsg = data.prefix .. subform end table.insert(ret, m_links.full_link({lang = lang, term = data.prefix .. subform, accel = make_accel(param, partmsg)})) end return table.concat(ret, " ") end local wikicode = [=[ Conjugation of ]=]	return gsub(wikicode, "", repl) end

return export