Modulis:fr-headword
Šī moduļa dokumentāciju var izveidot Modulis:fr-headword/doc lapā
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("fr")
-- 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
PAGENAME = mw.title.getCurrentTitle().text
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("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local genders = {}
local inflections = {}
local categories = {"Franču valodas " .. poscat}
if pos_functions[poscat] then
pos_functions[poscat](args, genders, inflections, categories)
end
return require("Module:headword").full_headword(lang, nil, head, nil, genders, inflections, categories, nil)
end
pos_functions["lietvārdi"] = function(args, genders, inflections, categories)
-- Gather genders
local gender = args[1]; if gender == "" then gender = nil end
local gender2 = args["g2"]; if gender2 == "" then gender2 = nil end
if gender == "mf" then
table.insert(genders, "m")
table.insert(genders, "f")
else
table.insert(genders, gender)
table.insert(genders, gender2)
end
-- Gather all the plural parameters from the numbered parameters.
local plurals = {}
local p = args[2]; if p == "" then p = nil end
local i = 3
while p do
table.insert(plurals, p)
p = args[i]; if p == "" then p = nil end
i = i + 1
end
-- Gather all the feminine parameters
local feminines = {}
local p = args["f"]; if p == "" then p = nil end
local i = 2
while p do
table.insert(feminines, p)
p = args["f" .. i]; if p == "" then p = nil end
i = i + 1
end
-- Gather all the masculine parameters
local masculines = {}
local p = args["m"]; if p == "" then p = nil end
local i = 2
while p do
table.insert(masculines, p)
p = args["m" .. i]; if p == "" then p = nil end
i = i + 1
end
-- Add categories for genders
if #genders == 0 then
table.insert(genders, "?")
end
local mode = nil
for _, g in ipairs(genders) do
if g == "m-p" or g == "f-p" then
mode = "p"
end
if g == "m" then
table.insert(categories, "Franču valodas vīriešu dzimtes lietvārdi")
elseif g == "f" then
table.insert(categories, "Franču valodas sieviešu dzimtes lietvārdi")
end
end
-- Decide how to show the plurals
mode = mode or plurals[1]
-- Plural is unknown
if mode == "?" then
table.insert(inflections, "<small><sup>???</sup> lūdzu sniedz daudskaitli!</small>")
table.insert(categories, "French nouns needing inflection")
-- Plural is not attested
elseif mode == "!" then
table.insert(inflections, {label = "daudzskaitlis nav pārbaudīts"})
table.insert(categories, "Franču valodas lietvārdi ar nepārbaudītu daudzskaitli")
-- Plural-only noun, doesn't have a plural
elseif mode == "p" then
table.insert(inflections, {label = "plural only"})
table.insert(categories, "French pluralia tantum")
else
-- Uncountable noun; may occasionally have a plural
if mode == "-" then
table.remove(plurals, 1) -- Remove the mode parameter
table.insert(categories, "Franču valodas neskaitāmie lietvārdi")
-- If plural forms were given explicitly, then show "countable" as well
if #plurals > 0 then
table.insert(inflections, {label = "skaitāms vai neskaitāms"})
table.insert(categories, "Franču valodas skaitāmie lietvārdi")
else
table.insert(inflections, {label = "neskaitāms"})
end
-- The default, always has a plural
else
table.insert(categories, "Franču valodas skaitāmie lietvārdi")
-- If no plural was given, add a default one now
if #plurals == 0 then
plurals = {"s"}
end
end
if #plurals > 0 then
-- Process the plural forms
for i, pl in ipairs(plurals) do
if pl == "s" then
plurals[i] = PAGENAME .. "s"
elseif pl == "x" then
plurals[i] = PAGENAME .. "x"
end
end
-- Add the plural forms
plurals.label = "plural"
plurals.accel = "plural-form-of"
table.insert(inflections, plurals)
end
end
-- Add the feminine forms
if #feminines > 0 then
feminines.label = "feminine"
table.insert(inflections, feminines)
end
-- Add the masculine forms
if #masculines > 0 then
masculines.label = "masculine"
table.insert(inflections, masculines)
end
end
return export