Module:siwa-headword: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
local export = {}
local export = {}
function format_pos(poscat)
if poscat == "noun" then
return "'''" .. args[1] .. "'''"
end
end


-- The main entry point.
-- The main entry point.
-- This is the only function that can be invoked from a template.
-- This is the only function that can be invoked from a template.
function export.show(frame)
function export.show(frame)
local args = frame:getParent().args
local PAGENAME = mw.title.getCurrentTitle().text
PAGENAME = mw.title.getCurrentTitle().subpageText
local params = {
[1] = { default = PAGENAME },
[2] = { required = true },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local head = args["head"]; if head == "" then head = nil end
local head = args[1]
if head == "" then
head = nil
end
-- The part of speech. This is also the name of the category that
local poscat = args[2]
-- entries go in. However, the two are separate (the "cat" parameter)
local data = {lang = lang, pos_category = (postype and postype .. " " or "") .. poscat, categories = {}, heads = {head}, genders = {}, inflections = {}}
-- because you sometimes want something to behave as an adjective without
-- putting it in the adjectives category.
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local data = {pos_category = poscat, categories = {}, heads = {head}, genders = {}, inflections = {}}
if poscat == "adjectives" then
if poscat == "adjectives" then
if PAGENAME:find("^-") then
if PAGENAME:find("^-") then
data.pos_category = "suffixes"
data.pos_category = "suffixes"
data.categories = {"Siwa adjective-forming suffixes"}
data.categories = {"Proto-Germanic adjective-forming suffixes"}
end
end
adjective(args, data)
adjective(args, data)
elseif poscat == "adverbs" then
elseif poscat == "adverbs" then
if PAGENAME:find("^-") then
if SUBPAGENAME:find("^-") then
data.pos_category = "suffixes"
data.pos_category = "suffixes"
data.categories = {"Siwa adverb-forming suffixes"}
data.categories = {"Proto-Germanic adverb-forming suffixes"}
end
end
adverb(args, data)
adverb(args, data)
elseif poscat == "determiners" then
elseif poscat == "determiners" then
Line 36: Line 42:
if PAGENAME:find("^-") then
if PAGENAME:find("^-") then
data.pos_category = "suffixes"
data.pos_category = "suffixes"
data.categories = {"Siwa noun-forming suffixes"}
data.categories = {"Proto-Germanic noun-forming suffixes"}
end
end
noun_gender(args, data)
noun_gender(args, data)
elseif poscat == "proper nouns" then
elseif poscat == "proper nouns" then
Line 45: Line 50:
if PAGENAME:find("^-") then
if PAGENAME:find("^-") then
data.pos_category = "suffixes"
data.pos_category = "suffixes"
data.categories = {"Siwa verb-forming suffixes"}
data.categories = {"Proto-Germanic verb-forming suffixes"}
end
end
end
end
return full_headword(data)
return format_pos(poscat)
end
end


Line 56: Line 61:
function noun_gender(args, data)
function noun_gender(args, data)
local valid_genders = {
local valid_genders = {
["in"] = true,
["m"] = true,
["an"] = true,
["f"] = true,
["in-p"] = true,
["n"] = true,
["an-p"] = true,
["m-p"] = true,
}
["f-p"] = true,
["n-p"] = true}
-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
Line 71: Line 77:
end
end
-- If any of the specifications is a "?", add the entry
-- to a cleanup category.
if g == "?" then
table.insert(data.categories, "Requests for gender in Proto-Germanic entries")
elseif g == "m-p" or g == "f-p" or g == "n-p" then
table.insert(data.categories, "Proto-Germanic pluralia tantum")
end
table.insert(data.genders, g)
table.insert(data.genders, g)
g = args["g" .. i] or ""
g = args["g" .. i] or ""
Line 112: Line 126:
end
end
end
end
return export

Navigation menu