モジュール:sv-headword
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:sv-headword/doc に作成できます
local export = {}
local pos_functions = {}
local lang = require("モジュール:languages").getByCode("sv")
local PAGENAME
local g_to_genders = {
["c"] = {"c"},
["n"] = {"n"},
["cp"] = {"c-p"},
["c-p"] = {"c-p"},
["np"] = {"n-p"},
["n-p"] = {"n-p"},
["cn"] = {"c", "n"},
["c-n"] = {"c", "n"},
["nc"] = {"c", "n"},
["n-c"] = {"c", "n"},
}
pos_functions["形容詞"] = function(args, data)
local alt = args["alt"] or ""
if args[1] == "-" or args[1] == "abs" then
table.insert(data.inflections, {label = "比較形なし"})
elseif args[1] == "peri" or args[1] == "mermest" then
table.insert(data.inflections, {label = "比較級", "[[mer#スウェーデン語|mer]] " .. PAGENAME})
table.insert(data.inflections, {label = "最上級", "[[mest#スウェーデン語|mest]] " .. PAGENAME})
else
local comparative
local superative
if args[2] and args[2] ~= "" then
-- 比較級・最上級が個別に指定されている場合
comparative = args[1] or PAGENAME
superative = args[2] or PAGENAME
else
-- 語幹のみが指定されている、または指定無しの場合
if args[1] and args[1] ~= "" then
comparative = args[1] .. "re"
superative = args[1] .. "st"
else
comparative = PAGENAME .. alt .. "are"
superative = PAGENAME .. alt .. "ast"
end
end
table.insert(data.inflections, {label = "比較級", comparative})
table.insert(data.inflections, {label = "最上級", superative})
end
end
pos_functions["副詞"] = function(args, data)
if args[1] == "peri" or args[1] == "mermest" then
table.insert(data.inflections, {label = "比較級", "[[mer#スウェーデン語|mer]] " .. PAGENAME})
table.insert(data.inflections, {label = "最上級", "[[mest#スウェーデン語|mest]] " .. PAGENAME})
elseif args[1] == "-" or args[1] == "abs" then
table.insert(data.inflections, {label = "比較形なし"})
else
local comparative
local superative
if (not args[2]) or args[2] == "" or args[2] == "are" then
comparative = (args[1] or PAGENAME) .. "are"
superative = (args[1] or PAGENAME) .. "ast"
elseif args[2] == "re" then
comparative = (args[1] or PAGENAME) .. "re"
superative = (args[1] or PAGENAME) .. "st"
else
comparative = args[1]
superative = args[2]
end
table.insert(data.inflections, {label = "比較級", comparative})
table.insert(data.inflections, {label = "最上級", superative})
end
end
pos_functions["名詞"] = function(args, data)
local g = args["g"] or args[1] or ""
local g2 = args["g2"] or ""
local attr = (args[1] and args[2]) or (args["g"] and args[1]) or ""
-- 性が入力されるべき位置に不可算情報が入力された場合
if g == "-" or g == "uncountable" or g == "pluralonly" then
attr = g
g = ""
end
if g == "" then
table.insert(data.categories, "スウェーデン語 名詞 性別未入力")
else
if g_to_genders[g] then
data.genders = g_to_genders[g]
else
error("認識できない性が入力されました: " .. g)
end
end
if g2 ~= "" then
table.insert(data.genders, g2)
end
if attr == "-" or attr == "uncountable" then
table.insert(data.inflections, {label = "不可算名詞"})
table.insert(data.categories, "スウェーデン語 名詞 不可算")
elseif attr == "pluralonly" then
table.insert(data.inflections, {label = "絶対複数"})
table.insert(data.categories, "スウェーデン語 絶対複数")
end
end
pos_functions["固有名詞"] = function(args, data)
local g = args["g"] or args[1] or ""
local g2 = args["g2"] or ""
local gen = args[2] or args["gen"] or ""
local gen2 = args[3] or args["gen2"] or ""
local genitive_data = {label = "属格"}
if g ~= "" then
table.insert(data.genders, g)
end
if g2 ~= "" then
table.insert(data.genders, g2)
end
if gen == "" then
local last_char = mw.ustring.sub(PAGENAME, -1)
if last_char == "s" or last_char == "x" or last_char == "z" then
gen = PAGENAME
-- 以下は実在性がちゃんと分かってから有効化する。
if false then
gen2 = PAGENAME .. "'"
end
else
gen = PAGENAME .. "s"
end
end
if gen ~= "" then
table.insert(genitive_data, gen)
end
if gen2 ~= "" then
table.insert(genitive_data, gen2)
end
table.insert(data.inflections, genitive_data)
end
function export.show(frame)
local args = frame:getParent().args
PAGENAME = args["pagename"] or mw.title.getCurrentTitle().text
local poscat = frame.args[1] or error("品詞の入力が必要です。")
local head = args["head"] or PAGENAME
local sort_key = args["sort"] or ""
local data = {lang = lang, pos_category = poscat, genders = {}, categories = {}, heads = {head}, inflections = {}}
if pos_functions[poscat] then
pos_functions[poscat](args, data)
end
if sort_key ~= "" then
data.sort_key = sort_key
end
return require("Module:headword").full_headword(data)
end
return export