Module:qhv-headword: Difference between revisions

No edit summary
No edit summary
Line 36: Line 36:


local lang = require("Module:languages").getByCode("qhv")
local lang = require("Module:languages").getByCode("qhv")
local m_decl = require("Module:qhv-noun")
local m_data = require("Module:qhv-noun/data")
local m_data = require("Module:qhv-noun/data")


Line 52: Line 51:
end
end


local function generate_genitive(word, args)
local function generate_genitive(word, args, data, decl_type)
return m_data[word](args) and m_data[word](args)
return m_data[word] and m_data[word](args, data) or m_data[decl_type](args, data)
end
end


Line 63: Line 62:
local head = args["head"]; if head == "" then head = nil end
local head = args["head"]; if head == "" then head = nil end
local pass = {forms = {}, categories = {}}
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local class = frame.args[2]; if class == "" then class = nil end
local class = frame.args[2]; if class == "" then class = nil end
Line 82: Line 81:
[3] = {list = "pl"},
[3] = {list = "pl"},
[4] = {list = "dim"},
[4] = {list = "dim"},
["number"] = {},
["class"] = {},
["head"] = {default = PAGENAME},
["head"] = {default = PAGENAME},
["m"] = {list = true},
["m"] = {list = true},
Line 89: Line 90:
local args = require("Module:parameters").process(args, params)
local args = require("Module:parameters").process(args, params)
data.heads = {args["head"]}
data.heads = {args["head"]}
local decl_type = require("Module:qhv-noun").detect_decl(table.concat(data.heads), args["number"], args["class"])
-- Gender
-- Gender
Line 105: Line 107:
-- Genitive
-- Genitive
if not args[2][1] then
if not args[2][1] then
table.insert(args[2], generate_genitive(data.heads, args))
table.insert(args[2], generate_genitive(data.heads, args, data))
end
end