モジュール:gem-headword
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:gem-headword/doc に作成できます
local export = {}
local lang = require("モジュール:languages").getByCode("gem-pro")
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local args = frame:getParent().args
SUBPAGENAME = mw.title.getCurrentTitle().subpageText
local head = args["head"]; if head == "" then head = nil end
-- The part of speech. This is also the name of the category that
-- entries go in. However, the two are separate (the "cat" parameter)
-- because you sometimes want something to behave as an adjective without
-- putting it in the adjectives category.
local poscat = frame.args[1] or error("品詞が指定されていません。パラメータ1をモジュールの呼び出しに渡して下さい。")
local postype = args["type"]; if postype == "" then postype = nil end
local genders = {}
local inflections = {}
local categories = {"ゲルマン祖語 " .. (postype and postype .. " " or "") .. poscat}
local ctemp = {}
if poscat == "形容詞" then
if SUBPAGENAME:find("^-") then
categories = {"ゲルマン祖語 接尾辞", "Proto-Germanic adjective-forming suffixes"}
end
inflections, ctemp = adjective(args)
for k,v in ipairs(ctemp) do table.insert(categories, v) end
elseif poscat == "副詞" then
if SUBPAGENAME:find("^-") then
categories = {"ゲルマン祖語 接尾辞", "Proto-Germanic adverb-forming suffixes"}
end
inflections, ctemp = adverb(args)
for k,v in ipairs(ctemp) do table.insert(categories, v) end
elseif poscat == "限定詞" then
inflections, ctemp = adjective(args)
for k,v in ipairs(ctemp) do table.insert(categories, v) end
elseif poscat == "名詞" then
if SUBPAGENAME:find("^-") then
categories = {"ゲルマン祖語 接尾辞", "Proto-Germanic noun-forming suffixes"}
end
genders, ctemp = noun_gender(args)
for k,v in ipairs(ctemp) do table.insert(categories, v) end
elseif poscat == "proper nouns" then
genders, ctemp = noun_gender(args)
for k,v in ipairs(ctemp) do table.insert(categories, v) end
elseif poscat == "verbs" then
if SUBPAGENAME:find("^-") then
categories = {"ゲルマン祖語 接尾辞", "Proto-Germanic verb-forming suffixes"}
end
end
return require("モジュール:headword").full_headword{
lang = lang,
heads = {head},
genders = genders,
inflections = inflections,
categories = categories,
}
end
-- Display information for a noun's gender
-- This is separate so that it can also be used for proper nouns
function noun_gender(args)
local categories = {}
local valid_genders = {
["m"] = true,
["f"] = true,
["n"] = true,
["m-p"] = true,
["f-p"] = true,
["n-p"] = true}
-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
local genders = {}
local g = args[1] or ""; if g == "" then g = "?" end
local i = 2
while g ~= "" do
if not valid_genders[g] then
g = "?"
end
-- If any of the specifications is a "?", add the entry
-- to a cleanup category.
if g == "?" then
table.insert(categories, "Proto-Germanic terms with incomplete gender")
elseif g == "m-p" or g == "f-p" or g == "n-p" then
table.insert(categories, "ゲルマン祖語 絶対複数")
end
table.insert(genders, g)
g = args["g" .. i] or ""
i = i + 1
end
return genders, categories
end
function adjective(args)
local inflections = {}
local categories = {}
local adverb = args["adv"]; if adverb == "" then adverb = nil end
local comparative = args[1]; if comparative == "" then comparative = nil end
local superlative = args[2]; if superlative == "" then superlative = nil end
if adverb then
table.insert(inflections, {label = "副詞", adverb})
end
if comparative then
table.insert(inflections, {label = "比較級", comparative})
end
if superlative then
table.insert(inflections, {label = "最上級", superlative})
end
return inflections, categories
end
function adverb(args)
local inflections = {}
local categories = {}
local adjective = args["adj"]; if adjective == "" then adjective = nil end
local comparative = args[1]; if comparative == "" then comparative = nil end
local superlative = args[2]; if superlative == "" then superlative = nil end
if adjective then
table.insert(inflections, {label = "形容詞", adjective})
end
if comparative then
table.insert(inflections, {label = "比較級", comparative})
end
if superlative then
table.insert(inflections, {label = "最上級", superlative})
end
return inflections, categories
end
return export