local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("af")
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
PAGENAME = mw.title.getCurrentTitle().text
local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local params = {
= {list = true},
= {type = "boolean"},
}
if pos_functions then
for key, val in pairs(pos_functions.params) do
params = val
end
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = poscat, categories = {}, heads = args, inflections = {}}
if args then
data.pos_category = "suffixes"
if poscat == "adjectives" then
table.insert(data.categories, lang:getCanonicalName() .. " adjective-forming suffixes")
elseif poscat == "adverbs" then
table.insert(data.categories, lang:getCanonicalName() .. " adverb-forming suffixes")
elseif poscat == "nouns" then
table.insert(data.categories, lang:getCanonicalName() .. " noun-forming suffixes")
elseif poscat == "verbs" then
table.insert(data.categories, lang:getCanonicalName() .. " verb-forming suffixes")
else
error("No category exists for suffixes forming " .. poscat .. ".")
end
end
if pos_functions then
pos_functions.func(args, data)
end
return require("Module:headword").full_headword(data)
end
-- Display additional inflection information for an adjective
pos_functions = {
params = {
= {},
= {},
= {},
= {},
= {},
= {},
},
func = function(args, data)
local attr = args
local comp = args
local sup = args
local attr2 = args
local comp2 = args
local sup2 = args
-- Generate the missing forms
if not attr then
if PAGENAME:find("u$") then
attr = PAGENAME .. "we"
elseif mw.ustring.find(PAGENAME, "$") then
attr = PAGENAME
else
attr = PAGENAME .. "e"
end
end
if not comp then
if PAGENAME:find("r$") then
comp = PAGENAME .. "der"
elseif attr ~= "-" then
if not attr:find("$") then
comp = attr .. "er"
else
comp = attr .. "r"
end
else
comp = PAGENAME .. "er"
end
end
if not sup then
if attr == PAGENAME:gsub("nk$", "ng") then
sup = attr .. "ste"
elseif PAGENAME:find("u$") then
sup = PAGENAME .. "uste"
else
sup = PAGENAME .. "ste"
end
end
-- Attributive form
if attr == "-" then
table.insert(data.inflections, {label = "used only ]ly"})
table.insert(data.categories, "Afrikaans predicative-only adjectives")
else
local infl_parts = {label = "]", attr}
if attr2 then
table.insert(infl_parts, attr2)
end
table.insert(data.inflections, infl_parts)
end
-- Comparative and superlative forms
if comp == "-" then
table.insert(data.inflections, {label = "not ]"})
else
-- Comparative
local infl_parts = {label = "]", comp}
if comp2 then
table.insert(infl_parts, comp2)
end
table.insert(data.inflections, infl_parts)
-- Superlative
infl_parts = {label = "]", sup}
if sup2 then
table.insert(infl_parts, sup2)
end
table.insert(data.inflections, infl_parts)
end
end
}
-- List of irregular verbs. See further down.
local irregular_verbs = {}
-- Display additional inflection information for a adverb
pos_functions = {
params = {
= {list = "pres", default = ""},
= {list = "past", default = ""},
= {},
},
func = function(args, data)
local past_part = args
local sep = args
local stem = PAGENAME
-- If separable, remove the prefix to create the stem
if sep then
stem = PAGENAME:gsub("^" .. sep, "")
table.insert(data.categories, "Afrikaans separable verbs")
end
local forms = {}
-- Is this the stem of an irregular verb?
-- If so, delegate all the work to its function.
if irregular_verbs then
irregular_verbs(forms)
table.insert(data.categories, "Afrikaans irregular verbs")
else
forms = {stem}
forms = args; if forms == "" then forms = stem .. "ende" end
forms = args; if forms == "" then forms = "ge" .. stem end
end
for key, form in pairs(forms) do
form.accel = {form = key}
end
-- Add the forms to the list
if forms then
if sep then
forms.accel = nil
for i, form in ipairs(forms) do
forms = "] ]"
end
end
forms.label = "present"
table.insert(data.inflections, forms)
end
if forms then
if sep then
for i, form in ipairs(forms) do
forms = sep .. form
end
end
forms.label = "present participle"
table.insert(data.inflections, forms)
end
if forms then
forms.accel = nil
if sep then
for i, form in ipairs(forms) do
forms = "] ]"
end
end
forms.label = "past"
table.insert(data.inflections, forms)
end
if forms then
if sep then
for i, form in ipairs(forms) do
forms = sep .. form
end
end
forms.label = "past participle"
table.insert(data.inflections, forms)
end
end
}
irregular_verbs = function(forms)
forms = {"dink"}
forms = {"denkende"}
forms = {"dag", "dog"}
forms = {"gedag", "gedog", "gedink"}
end
irregular_verbs = function(forms)
forms = {"het"}
forms = {"hebbende"}
forms = {"had"}
forms = {"gehad"}
end
irregular_verbs = function(forms)
forms = {"kan"}
forms = nil
forms = {"kon"}
forms = nil
end
irregular_verbs = function(forms)
forms = {"mag"}
forms = nil
forms = {"mog"}
forms = nil
end
irregular_verbs = function(forms)
forms = {"moet"}
forms = nil
forms = {"moes"}
forms = nil
end
irregular_verbs = function(forms)
forms = {"sal"}
forms = nil
forms = {"sou"}
forms = nil
end
irregular_verbs = function(forms)
forms = {"is"}
forms = {"synde"}
forms = {"was"}
forms = {"gewees"}
end
irregular_verbs = function(forms)
forms = {"weet"}
forms = {"wetende"}
forms = {"wis"}
forms = {"geweet"}
end
irregular_verbs = function(forms)
forms = {"wil"}
forms = nil
forms = {"wou"}
forms = {"gewil"}
end
irregular_verbs = function(forms)
forms = {"beter"}
forms = nil
forms = nil
forms = nil
end
return export