Module:siwa-noun: Difference between revisions

No edit summary
No edit summary
Line 115: Line 115:
end
end
if from_module then return g == "i" and data.forms["m"] or data.forms["m_sg"] -- for headword module
-- make the table
else return make_table(data) end -- make the table
return make_table(data)
end
 
function export.h(from_module)
local parent_args = frame:getParent().args
local numbers = {}
local decl = {}
local g = NAMESPACE == "Template" and "i" or parent_args[1]
local word = NAMESPACE == "Template" and "sivi" or parent_args["word"] or PAGENAME
local args = {}
local sv = NAMESPACE == "Template" and "i" or parent_args[2]
local decl_type = parent_args["decl"] or detect_decl(word, sv, g)
if g ~= "i" and g ~= "a" then error("Unknown gender: it must be either ‘i’ or ‘a’") end
if not m_data[word] then
if not decl_type then
error("Unknown declension '" .. decl_type .. "'")
end
args = require("Module:parameters").process(parent_args, m_data[decl_type].params, true)
if numbers then
for i, number in ipairs(numbers) do
args[i] = number
end
end
end
 
local data = {forms = {}, categories = {}}
data.head = parent_args["head"] or word
data.proper = parent_args["proper"] and true or false
data.nocat = parent_args["nocat"] and true or false
data.sv = sv or error("Parameter 2 must be the word's stressed vowel")
data.g = g
data.decl_type = decl_type
data.q = detect_quality(data.head, data.sv)
-- Generate the forms
if m_data[word] then
m_data[word](parent_args, data)
else
m_data[decl_type](args, data)
end
if g == "i" then
data.forms["m"][1] = parent_args["m"] or data.forms["m"][1]
else
for _, form in ipairs({"m_sg", "u_pl", "m_pl"}) do
data.forms[form][1] = parent_args[form] or data.forms[form][1]
end
end
return g == "i" and data.forms["m"] or data.forms["m_sg"] -- for headword module
end
end