local export = {}
local insert = table.insert
local remove = table.remove
local ulen = require("Module:string utilities").len
local lang = require("Module:languages").getByCode("nn")
local function process_inflection(inflections, inflection, label)
local i = 1
while true do
local form = inflection
if form == nil then
break
elseif form == "-" then
remove(inflection, i)
else
i = i + 1
end
end
if inflection then
inflection.label = label
insert(inflections, inflection)
end
end
function export.main(frame)
local PAGENAME = mw.loadData("Module:headword/data").pagename
-- Retrieve and process arguments
local boolean = {type = "boolean"}
local params = {
= {required = true, list = "pres_tense"},
= {required = true, list = "past_tense"},
= {required = true, list = "past_part"},
= true,
= {list = "pasv_inf"},
= {list = "pres_part"},
= {list = "imp"},
= {alias_of = 6, list = false},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
-- Figure out roots
local length = ulen(PAGENAME)
local root = PAGENAME
if length > 2 and not (length == 3 and PAGENAME:match("^")) then
root = PAGENAME:gsub("$", "")
end
local data = {lang = lang, pos_category = "verbs", categories = {}}
local inflections = {}
-- Add inflections
process_inflection(inflections, args, "present tense")
process_inflection(inflections, args, "past tense")
process_inflection(inflections, args, "past participle")
local root2 = args or root
local final_as_or_ast = PAGENAME:match("ast?$")
if not (args or final_as_or_ast) then
args = root2 .. "ast"
end
process_inflection(inflections, args, "passive infinitive")
if not (args or final_as_or_ast) then
args = root2 .. "ande"
end
process_inflection(inflections, args, "present participle")
if not args then
local imp = root
if length > 3 then
imp = imp:gsub("mm$", "m"):gsub("j$", "")
end
args = imp
end
process_inflection(inflections, args, "imperative")
data.inflections = inflections
return require('Module:headword').full_headword(data)
end
return export