Mòdul:eu-nom
A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]
Mòdul de suport per les plantilles {{eu-nom-decl}} i {{eu-nom propi-decl}} que genera la taula de declinació d’un nom comú o nom propi.
local p = {}
local m_link = require("Module:enllaç")
local lang = {code = "eu", name = "basc", sc = "Latn"}
local pagename
local decl_type = {}
local function make_link(declension, case)
local ret = '-'
if declension[case] ~= nil and declension[case] ~= "-" then
if pagename:find("r$") and declension[case]:find("^" .. pagename .. "r") then
root = pagename .. "r"
elseif declension[case]:find("^" .. pagename) then
root = pagename
elseif pagename:find("a$") and declension[case]:find("^" .. pagename:gsub("a$", "")) then
root = pagename:gsub("a$", "")
else
root = declension[case]
end
ending = declension[case]:gsub("^" .. root, "")
if ending ~= "" then
ending = "'''" .. ending .. "'''"
end
ret = m_link.full_link({term = declension[case], alt = root .. ending, lang = lang}, nil, false)
end
return ret
end
local function make_table(declension, number)
local case_order = {
"Absolutiu", "Ergatiu", "Datiu", "Genitiu", "Comitatiu",
"Benefactiu", "Instrumental", "Partitiu", "Prolatiu", "Causal",
"Inessiu", "Ablatiu", "Al·latiu", "Terminatiu", "Al·l. direcional", "Gen. locatiu"
}
if number == nil then number = "" end
local ret = {}
if declension.title then
if number == "i" or number == "s" or number == "p" then
table.insert(ret, '\n{| width="20%" style="margin-left: 0.5em; float: left; font-size: 90%;"')
else
table.insert(ret, '\n{| width="40%" style="margin-left: 0.5em; float: left; font-size: 90%;"')
end
table.insert(ret, '\n|-')
table.insert(ret, '\n|<div class="NavFrame">')
table.insert(ret, '\n<div class="NavHead" style="color: #202122; background-color: #ccccff; text-align:center;">' .. declension.title .. '</div>')
table.insert(ret, '\n<div class="NavContent">')
table.insert(ret, '\n{| class="wikitable" style="width:100%; text-align:left; margin-top: -0.1em;"')
table.insert(ret, '\n|-')
table.insert(ret, '\n! style="font-style: italic; text-align: left; font-weight: normal;" | Cas')
if number ~= "s" and number ~= "p" then
table.insert(ret, '\n! style="font-style:italic; font-weight: normal;" | Indefinit')
end
if number ~= "i" and number ~= "p" then
table.insert(ret, '\n! style="font-style:italic; font-weight: normal;" | Singular')
end
if number ~= "i" and number ~= "s" then
table.insert(ret, '\n! style="font-style:italic; font-weight: normal;" | Plural')
end
for n = 1, 10 do
if declension["case" .. n .. "i"] ~= nil or declension["case" .. n .. "s"] ~= nil or declension["case" .. n .. "p"] ~= nil then
table.insert(ret, '\n|-')
table.insert(ret, '\n! style="font-style:italic; text-align: left; font-weight: normal;" | ' .. case_order[n])
if number ~= "s" and number ~= "p" then
table.insert(ret, '\n| ' .. make_link(declension, "case" .. n .. "i"))
end
if number ~= "i" and number ~= "p" then
table.insert(ret, '\n| ' .. make_link(declension, "case" .. n .. "s"))
end
if number ~= "i" and number ~= "s" then
table.insert(ret, '\n| ' .. make_link(declension, "case" .. n .. "p"))
end
end
end
if number ~= "s" then
table.insert(ret, '\n|-')
if number == "i" or number == "p" then
table.insert(ret, '\n! colspan="2" style="font-style:italic; font-weight: normal;" | Locatius')
else
table.insert(ret, '\n! colspan="4" style="font-style:italic; font-weight: normal;" | Locatius')
end
for n = 11, 16 do
if declension["case" .. n .. "i"] ~= nil or declension["case" .. n .. "s"] ~= nil or declension["case" .. n .. "p"] ~= nil then
table.insert(ret, '\n|-')
table.insert(ret, '\n! style="font-style:italic; font-weight: normal; text-align: left;" | ' .. case_order[n])
if number ~= "s" and number ~= "p" then
table.insert(ret, '\n| ' .. make_link(declension, "case" .. n .. "i"))
end
if number ~= "i" and number ~= "p" then
table.insert(ret, '\n| ' .. make_link(declension, "case" .. n .. "s"))
end
if number ~= "i" and number ~= "s" then
table.insert(ret, '\n| ' .. make_link(declension, "case" .. n .. "p"))
end
end
end
end
table.insert(ret, '\n|}')
table.insert(ret, '\n</div></div>')
table.insert(ret, '\n|}')
table.insert(ret, '<br clear="all">')
end
return table.concat(ret)
end
function p.show(frame)
local args = frame:getParent().args
pagename = args.pagename or mw.title.getCurrentTitle().subpageText
local noun_type = frame.args[1] or "nc" -- nc/np: noun common/proper
if noun_type == "np" and mw.ustring.find(pagename, "[^ ]+ [^ ]+") then -- currently not supported
return
end
local attested = args.atest == nil
-- Series of suffixes, typified at http://www.euskaltzaindia.net/dok/euskera/50606.pdf
local suffix = {}
suffix[1] = {"", "k", "ri", "ren", "rekin", "rentzat", "z", "rik", "tzat", "rengatik"} -- no locatius indefinit vocal
suffix[2] = {"", "ek", "i", "en", "ekin", "entzat", "ez", "ik", "tzat", "engatik"} -- no locatius indefinit consonant
suffix[3] = {"ak", "ek", "ei", "en", "ekin", "entzat", "ez", "-", "-", "engatik"} -- no locatius plural
suffix[4] = {"n", "tik", "ra", "raino", "rantz", "ko"} -- part locatius inanimat
suffix[5] = {"an", "tik", "ra", "raino", "rantz", "ko"} -- part locatius singular inanimat
suffix[6] = {"gan", "gandik", "gana", "ganaino", "ganantz", "ganako"} -- part locatius animat
local cases_def = {"1", "2", "3", "4", "5", "6", "7", "10"} -- casos no locatius definits
local ending
if pagename:find("a$") then
ending = "a" -- a organic
elseif pagename:find("au$") then
ending = "c"
elseif pagename:find("[eiou]$") then
ending = "v" -- vowel
else
ending = "c" -- consonant
end
local animacy = mw.text.split(args[1] or "", "/")
local ret = ''
for _, anim in ipairs(animacy) do
local a_n = mw.text.split(anim or "", "-")
local ai = a_n[1] -- an, in
local number = a_n[2] -- i, s, p
if number == nil and noun_type == "np" then
number = "i"
end
local declension, categories = {}, {}
if decl_type[noun_type .. ai .. ending] then
decl_type[noun_type .. ai .. ending].func(declension, suffix, cases_def)
end
-- local args or defective by number
for i = 1, 16 do
if number == "i" then
declension["case" .. i .. "i"] = args["cas" .. i .. "i"] or declension["case" .. i .. "i"]
declension["case" .. i .. "s"] = nil
declension["case" .. i .. "p"] = nil
elseif number == "s" then
declension["case" .. i .. "i"] = nil
if i > 10 then
declension["case" .. i .. "s"] = nil
else
declension["case" .. i .. "s"] = args["cas" .. i .. "s"] or declension["case" .. i .. "s"]
end
declension["case" .. i .. "p"] = nil
elseif number == "p" then
declension["case" .. i .. "i"] = nil
declension["case" .. i .. "s"] = nil
declension["case" .. i .. "p"] = args["cas" .. i .. "p"] or declension["case" .. i .. "p"]
else
declension["case" .. i .. "i"] = args["cas" .. i .. "i"] or declension["case" .. i .. "i"]
declension["case" .. i .. "s"] = args["cas" .. i .. "s"] or declension["case" .. i .. "s"]
declension["case" .. i .. "p"] = args["cas" .. i .. "p"] or declension["case" .. i .. "p"]
end
end
-- Check red links
if attested then
for k, v in pairs(declension) do
if k ~= "title" and v ~= "-" then
if not mw.title.new(v).exists then
table.insert(categories, "Termes en basc amb flexions a crear")
break
end
end
end
end
if args.bot then
ret = ret .. require('Module:lema').make_bot_list(declension)
else
ret = ret .. make_table(declension, number)
if #categories > 0 then
ret = ret .. require("Module:utilitats").format_categories(categories, lang)
end
end
end
return ret
end
-- Declension types: nc/np + an/in + a/v/c
decl_type["ncina"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom comú inanimat -a orgànica"
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. suffix[1][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. "ta" .. suffix[4][i-10]
declension["case" .. i .. "s"] = pagename .. suffix[4][i-10]
declension["case" .. i .. "p"] = pagename:gsub("a$", "") .. "eta" .. suffix[4][i-10]
end
for _, i in ipairs(cases_def) do -- 1-7 + 10
declension["case" .. i .. "s"] = pagename .. suffix[1][tonumber(i)]
declension["case" .. i .. "p"] = pagename:gsub("a$", "") .. suffix[3][tonumber(i)]
end
return
end
}
decl_type["ncinv"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom comú inanimat en vocal"
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. suffix[1][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. "ta" .. suffix[4][i-10]
declension["case" .. i .. "s"] = pagename .. suffix[5][i-10]
declension["case" .. i .. "p"] = pagename .. "eta" .. suffix[4][i-10]
end
for _, i in ipairs(cases_def) do
declension["case" .. i .. "s"] = pagename .. "a" .. suffix[1][tonumber(i)]
declension["case" .. i .. "p"] = pagename .. suffix[3][tonumber(i)]
end
return
end
}
decl_type["ncinc"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom comú inanimat en consonant"
local doubleRs = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}
local doubleR = ""
if pagename:find("r$") and pagename ~= "ur" then
doubleRs = {"", "r", "r", "r", "r", "r", "r", "r", "", "r", "r", "r", "r", "r", "r", "r"}
doubleR = "r"
end
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. suffix[2][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. "eta" .. suffix[4][i-10]
declension["case" .. i .. "s"] = pagename .. doubleR .. "e" .. suffix[5][i-10]
declension["case" .. i .. "p"] = pagename .. doubleR .. "eta" .. suffix[4][i-10]
end
for _, i in ipairs(cases_def) do
declension["case" .. i .. "s"] = pagename .. doubleR .. "a" .. suffix[1][tonumber(i)]
declension["case" .. i .. "p"] = pagename .. doubleR .. suffix[3][tonumber(i)]
end
return
end
}
decl_type["ncana"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom comú animat -a orgànica"
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. suffix[1][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. "ren" .. suffix[6][i-10]
declension["case" .. i .. "s"] = pagename .. "ren" .. suffix[6][i-10]
declension["case" .. i .. "p"] = pagename:gsub("a$", "") .. "en" .. suffix[6][i-10]
end
for _, i in ipairs(cases_def) do
declension["case" .. i .. "s"] = pagename .. suffix[1][tonumber(i)]
declension["case" .. i .. "p"] = pagename:gsub("a$", "") .. suffix[3][tonumber(i)]
end
return
end
}
decl_type["ncanv"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom comú animat en vocal"
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. suffix[1][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. "ren" .. suffix[6][i-10]
declension["case" .. i .. "s"] = pagename .. "aren" .. suffix[6][i-10]
declension["case" .. i .. "p"] = pagename .. "en" .. suffix[6][i-10]
end
for _, i in ipairs(cases_def) do
declension["case" .. i .. "s"] = pagename .. "a" .. suffix[1][tonumber(i)]
declension["case" .. i .. "p"] = pagename .. suffix[3][tonumber(i)]
end
return
end
}
decl_type["ncanc"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom comú animat en consonant"
local doubleRs = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}
local doubleR = ""
if pagename:find("r$") then
doubleRs = {"", "r", "r", "r", "r", "r", "r", "r", "", "r", "r", "r", "r", "r", "r", "r"}
doubleR = "r"
end
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. suffix[2][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. "en" .. suffix[6][i-10]
declension["case" .. i .. "s"] = pagename .. doubleR .. "aren" .. suffix[6][i-10]
declension["case" .. i .. "p"] = pagename .. doubleR .. "en" .. suffix[6][i-10]
end
for _, i in ipairs(cases_def) do
declension["case" .. i .. "s"] = pagename .. doubleR .. "a" .. suffix[1][tonumber(i)]
declension["case" .. i .. "p"] = pagename .. doubleR .. suffix[3][tonumber(i)]
end
return
end
}
decl_type["npina"] = {func = function(declension, suffix, cases_def)
decl_type["npinv"].func(declension, suffix, cases_def)
return
end
}
decl_type["npinv"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom propi inanimat en vocal"
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. suffix[1][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. suffix[4][i-10]
end
return
end
}
decl_type["npinc"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom propi inanimat en consonant"
local doubleRs = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}
if pagename:find("r$") then
doubleRs = {"", "r", "r", "r", "r", "r", "r", "r", "", "r", "r", "r", "r", "r", "r", "r"}
end
for i = 1, 10 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. suffix[2][i]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. "e" .. suffix[4][i-10]
end
return
end
}
decl_type["npana"] = {func = function(declension, suffix, cases_def)
decl_type["npanv"].func(declension, suffix, cases_def)
return
end
}
decl_type["npanv"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom propi animat en vocal"
for _, i in ipairs(cases_def) do
declension["case" .. i .. "i"] = pagename .. suffix[1][tonumber(i)]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. "ren" .. suffix[6][i-10]
end
return
end
}
decl_type["npanc"] = {func = function(declension, suffix, cases_def)
declension.title = "Nom propi animat en consonant"
local doubleRs = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}
if pagename:find("r$") then
doubleRs = {"", "r", "r", "r", "r", "r", "r", "r", "", "r", "r", "r", "r", "r", "r", "r"}
end
for _, i in ipairs(cases_def) do
declension["case" .. i .. "i"] = pagename .. doubleRs[tonumber(i)] .. suffix[2][tonumber(i)]
end
for i = 11, 16 do
declension["case" .. i .. "i"] = pagename .. doubleRs[i] .. "en" .. suffix[6][i-10]
end
return
end
}
return p