モジュール:fro-headword
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:fro-headword/doc に作成できます
local m_fro_utilities = require("モジュール:fro-utilities")
local export = {}
local lang = require("モジュール:languages").getByCode("fro")
function export.noun(frame)
local args = frame:getParent().args
PAGENAME = mw.title.getCurrentTitle().text
local head = args["head"]; if head == "" then head = nil end
local op = args["op"] or args[2]; if op == "" then op = nil end
local ns = args["ns"] or args[3]; if ns == "" then ns = nil end
local np = args["np"] or args[4]; if np == "" then np = nil end
local genders = {}
local inflections = {}
local categories = {"古フランス語 名詞"}
-- Process the genders
local valid_genders = {
["m"] = true,
["f"] = true,
["m-p"] = true,
["f-p"] = true}
local g = args[1]
if valid_genders[g] then
genders = {g}
if g == "m" or g == "m-p" then
table.insert(categories, "古フランス語 男性名詞")
else
table.insert(categories, "古フランス語 女性名詞")
end
elseif g == "mf" then
genders = {"m", "f"}
table.insert(categories, "古フランス語 男性名詞")
table.insert(categories, "古フランス語 女性名詞")
else
genders = {"?"}
table.insert(categories, "Old French terms with incomplete gender")
end
-- Generate default plural forms by adding -s.
-- Note that these are also used for the nominative singular of masculine nouns.
local plurals = m_fro_utilities.pluralize(PAGENAME)
-- Insert PART, either a string or array, into TAB. If PART is a string,
-- split on commas.
local function insert_part(tab, part)
if type(part) == "table" then
for _, form in ipairs(part) do
table.insert(tab, form)
end
else
local forms = mw.text.split(part, ",")
for _, form in ipairs(forms) do
table.insert(tab, form)
end
end
end
-- Oblique plurals are the same for both genders
local op_parts = {label = "複数斜格"}
insert_part(op_parts, op or plurals)
-- Nominative forms differ between the genders
-- If masculine, the singular gets the -s
-- If feminine, the plural gets the -s
local ns_parts = {label = "単数主格"}
local np_parts = {label = "複数主格"}
if genders[1] == "m" or genders[1] == "m-p" then
insert_part(np_parts, np or PAGENAME)
insert_part(ns_parts, ns or plurals)
else
insert_part(ns_parts, ns or PAGENAME)
insert_part(np_parts, np or plurals)
end
-- Add the inflections
if op == "-" or genders[1] == "m-p" or genders[1] == "f-p" then
table.insert(inflections, ns_parts)
table.insert(categories, "古フランス語 不可算名詞")
else
table.insert(inflections, op_parts)
table.insert(inflections, ns_parts)
table.insert(inflections, np_parts)
end
return require("モジュール:headword").full_headword(lang, nil, head, nil, genders, inflections, categories, nil)
end
return export