Module:qlu-nouns: Difference between revisions
Lëtzelúcia (talk | contribs) No edit summary |
Lëtzelúcia (talk | contribs) No edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 20: | Line 20: | ||
data.forms["dat-pl"] = r .. "evo" | data.forms["dat-pl"] = r .. "evo" | ||
data.forms["acc-sg"] = r .. "a" | data.forms["acc-sg"] = r .. "a" | ||
data.forms["acc-pl"] = r .. " | data.forms["acc-pl"] = r .. "e" | ||
end }) | end }) | ||
| Line 36: | Line 36: | ||
data.forms["dat-pl"] = r .. "evo" | data.forms["dat-pl"] = r .. "evo" | ||
data.forms["acc-sg"] = r .. "o" | data.forms["acc-sg"] = r .. "o" | ||
data.forms["acc-pl"] = r .. " | data.forms["acc-pl"] = r .. "i" | ||
end }) | end }) | ||
| Line 68: | Line 68: | ||
data.forms["dat-pl"] = r .. "evo" | data.forms["dat-pl"] = r .. "evo" | ||
data.forms["acc-sg"] = r .. "e" | data.forms["acc-sg"] = r .. "e" | ||
data.forms["acc-pl"] = r .. " | data.forms["acc-pl"] = r .. "i" | ||
end }) | end }) | ||
| Line 126: | Line 126: | ||
local r = args[1] | local r = args[1] | ||
data.forms["nom-sg"] = r .. "u" | data.forms["nom-sg"] = r .. "u" | ||
data.forms["nom-pl"] = r .. " | data.forms["nom-pl"] = r .. "ui" | ||
data.forms["gen-sg"] = r .. " | data.forms["gen-sg"] = r .. "aui" | ||
data.forms["gen-pl"] = r .. " | data.forms["gen-pl"] = r .. "ove" | ||
data.forms["dat-sg"] = r .. "au" | data.forms["dat-sg"] = r .. "au" | ||
data.forms["dat-pl"] = r .. " | data.forms["dat-pl"] = r .. "ovo" | ||
data.forms["acc-sg"] = r .. "u" | data.forms["acc-sg"] = r .. "u" | ||
data.forms["acc-pl"] = r .. " | data.forms["acc-pl"] = r .. "ui" | ||
end }) | end }) | ||
| Line 143: | Line 143: | ||
data.forms["nom-sg"] = r .. "u" | data.forms["nom-sg"] = r .. "u" | ||
data.forms["nom-pl"] = r .. "ua" | data.forms["nom-pl"] = r .. "ua" | ||
data.forms["gen-sg"] = r .. " | data.forms["gen-sg"] = r .. "aui" | ||
data.forms["gen-pl"] = r .. " | data.forms["gen-pl"] = r .. "ove" | ||
data.forms["dat-sg"] = r .. "au" | data.forms["dat-sg"] = r .. "au" | ||
data.forms["dat-pl"] = r .. " | data.forms["dat-pl"] = r .. "ovo" | ||
data.forms["acc-sg"] = r .. "u" | data.forms["acc-sg"] = r .. "u" | ||
data.forms["acc-pl"] = r .. "ua" | data.forms["acc-pl"] = r .. "ua" | ||
| Line 153: | Line 153: | ||
-- Display metadata | -- Display metadata | ||
local cases = { | local cases = { | ||
["nominative"] = { short_form = "nom", link = "''[[nominative case|nominative]]''" }, | ["nominative"] = { short_form = "nom", link = "''[[w:nominative case|nominative]]''" }, | ||
["accusative"] = { short_form = "acc", link = "''[[accusative case|accusative]]''" }, | ["accusative"] = { short_form = "acc", link = "''[[w:accusative case|accusative]]''" }, | ||
["genitive"] = { short_form = "gen", link = "''[[genitive case|genitive]]''" }, | ["genitive"] = { short_form = "gen", link = "''[[w:genitive case|genitive]]''" }, | ||
["dative"] = { short_form = "dat", link = "''[[dative case|dative]]''" }, | ["dative"] = { short_form = "dat", link = "''[[w:dative case|dative]]''" }, | ||
} | } | ||
-- Main output function | -- Main output function | ||
function export.show(frame) | function export.show(frame) | ||
local args = frame | local args = frame.args | ||
local root = args[1] or error("No root provided.") | local root = args[1] or error("No root provided.") | ||
local decltype = args["type"] or error("No declension type provided.") | local decltype = args["type"] or error("No declension type provided.") | ||
| Line 176: | Line 176: | ||
local key = cases[case].short_form .. "-" .. number | local key = cases[case].short_form .. "-" .. number | ||
return data.forms[key] or "—" | return data.forms[key] or "—" | ||
end | |||
local function small(text) | |||
return frame:preprocess("{{small|" .. text .. "}}") | |||
end | end | ||
local out = {} | local out = {} | ||
table.insert(out, '{| class="wikitable" | table.insert(out, '{| class="wikitable" style="text-align:center;"') | ||
table.insert(out, '|-') | |||
table.insert(out, '! Number !! Case !! Declension') | |||
-- Singular rows | |||
table.insert(out, '|-') | |||
table.insert(out, '! rowspan=4 | Singular') | |||
table.insert(out, '! ' .. small("nom.")) | |||
table.insert(out, '| ' .. showForm("nominative", "sg")) | |||
table.insert(out, '|-') | |||
table.insert(out, '! ' .. small("acc.")) | |||
table.insert(out, '| ' .. showForm("accusative", "sg")) | |||
table.insert(out, '|-') | |||
table.insert(out, '! ' .. small("dat.")) | |||
table.insert(out, '| ' .. showForm("dative", "sg")) | |||
table.insert(out, '|-') | |||
table.insert(out, '! ' .. small("gen.")) | |||
table.insert(out, '| ' .. showForm("genitive", "sg")) | |||
-- Plural rows | |||
table.insert(out, '|-') | |||
table.insert(out, '! rowspan=4 | Plural') | |||
table.insert(out, '! ' .. small("nom.")) | |||
table.insert(out, '| ' .. showForm("nominative", "pl")) | |||
table.insert(out, '|-') | |||
table.insert(out, '! ' .. small("acc.")) | |||
table.insert(out, '| ' .. showForm("accusative", "pl")) | |||
table.insert(out, '|-') | |||
table.insert(out, '! ' .. small("dat.")) | |||
table.insert(out, '| ' .. showForm("dative", "pl")) | |||
table.insert(out, '|-') | |||
table.insert(out, '! ' .. small("gen.")) | |||
table.insert(out, '| ' .. showForm("genitive", "pl")) | |||
table.insert(out, '|}') | table.insert(out, '|}') | ||
Latest revision as of 20:05, 29 June 2025
Documentation for this module may be created at Module:qlu-nouns/doc
local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("qlu")
local export = {}
local decls = {}
-- a-stem
decls["a"] = {
params = { [1] = {} },
}
setmetatable(decls["a"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "a"
data.forms["nom-pl"] = r .. "e"
data.forms["gen-sg"] = r .. "e"
data.forms["gen-pl"] = r .. "aro"
data.forms["dat-sg"] = r .. "a"
data.forms["dat-pl"] = r .. "evo"
data.forms["acc-sg"] = r .. "a"
data.forms["acc-pl"] = r .. "e"
end })
-- o-stem
decls["o"] = {
params = { [1] = {} },
}
setmetatable(decls["o"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "u"
data.forms["nom-pl"] = r .. "i"
data.forms["gen-sg"] = r .. "i"
data.forms["gen-pl"] = r .. "oro"
data.forms["dat-sg"] = r .. "a"
data.forms["dat-pl"] = r .. "evo"
data.forms["acc-sg"] = r .. "o"
data.forms["acc-pl"] = r .. "i"
end })
-- o-stem neuter
decls["o-N"] = {
params = { [1] = {} },
}
setmetatable(decls["o-N"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "o"
data.forms["nom-pl"] = r .. "a"
data.forms["gen-sg"] = r .. "i"
data.forms["gen-pl"] = r .. "oro"
data.forms["dat-sg"] = r .. "a"
data.forms["dat-pl"] = r .. "evo"
data.forms["acc-sg"] = r .. "o"
data.forms["acc-pl"] = r .. "a"
end })
-- i-stem
decls["i"] = {
params = { [1] = {} },
}
setmetatable(decls["i"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "e"
data.forms["nom-pl"] = r .. "i"
data.forms["gen-sg"] = r .. "i"
data.forms["gen-pl"] = r .. "e"
data.forms["dat-sg"] = r .. "i"
data.forms["dat-pl"] = r .. "evo"
data.forms["acc-sg"] = r .. "e"
data.forms["acc-pl"] = r .. "i"
end })
-- r-stem (updated)
decls["r"] = {
params = { [1] = {} },
}
setmetatable(decls["r"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "ar"
data.forms["nom-pl"] = r .. "aiu"
data.forms["gen-sg"] = r .. "eri"
data.forms["gen-pl"] = r .. "are"
data.forms["dat-sg"] = r .. "er"
data.forms["dat-pl"] = r .. "arevo"
data.forms["acc-sg"] = r .. "ar"
data.forms["acc-pl"] = r .. "aru"
end })
-- d1-stem
decls["d1"] = {
params = { [1] = {} },
}
setmetatable(decls["d1"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "ê"
data.forms["nom-pl"] = r .. "edi"
data.forms["gen-sg"] = r .. "edi"
data.forms["gen-pl"] = r .. "ede"
data.forms["dat-sg"] = r .. "edi"
data.forms["dat-pl"] = r .. "edevo"
data.forms["acc-sg"] = r .. "ede"
data.forms["acc-pl"] = r .. "edi"
end })
-- d2-stem
decls["d2"] = {
params = { [1] = {} },
}
setmetatable(decls["d2"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "â"
data.forms["nom-pl"] = r .. "adi"
data.forms["gen-sg"] = r .. "adi"
data.forms["gen-pl"] = r .. "ade"
data.forms["dat-sg"] = r .. "adi"
data.forms["dat-pl"] = r .. "adevo"
data.forms["acc-sg"] = r .. "ade"
data.forms["acc-pl"] = r .. "adi"
end })
-- u-stem
decls["u"] = {
params = { [1] = {} },
}
setmetatable(decls["u"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "u"
data.forms["nom-pl"] = r .. "ui"
data.forms["gen-sg"] = r .. "aui"
data.forms["gen-pl"] = r .. "ove"
data.forms["dat-sg"] = r .. "au"
data.forms["dat-pl"] = r .. "ovo"
data.forms["acc-sg"] = r .. "u"
data.forms["acc-pl"] = r .. "ui"
end })
-- u-stem neuter
decls["u-N"] = {
params = { [1] = {} },
}
setmetatable(decls["u-N"], { __call = function(self, args, data)
local r = args[1]
data.forms["nom-sg"] = r .. "u"
data.forms["nom-pl"] = r .. "ua"
data.forms["gen-sg"] = r .. "aui"
data.forms["gen-pl"] = r .. "ove"
data.forms["dat-sg"] = r .. "au"
data.forms["dat-pl"] = r .. "ovo"
data.forms["acc-sg"] = r .. "u"
data.forms["acc-pl"] = r .. "ua"
end })
-- Display metadata
local cases = {
["nominative"] = { short_form = "nom", link = "''[[w:nominative case|nominative]]''" },
["accusative"] = { short_form = "acc", link = "''[[w:accusative case|accusative]]''" },
["genitive"] = { short_form = "gen", link = "''[[w:genitive case|genitive]]''" },
["dative"] = { short_form = "dat", link = "''[[w:dative case|dative]]''" },
}
-- Main output function
function export.show(frame)
local args = frame.args
local root = args[1] or error("No root provided.")
local decltype = args["type"] or error("No declension type provided.")
local decl = decls[decltype]
if not decl then
error("Unknown declension type: " .. decltype)
end
local data = { forms = {} }
decl({ root }, data)
local function showForm(case, number)
local key = cases[case].short_form .. "-" .. number
return data.forms[key] or "—"
end
local function small(text)
return frame:preprocess("{{small|" .. text .. "}}")
end
local out = {}
table.insert(out, '{| class="wikitable" style="text-align:center;"')
table.insert(out, '|-')
table.insert(out, '! Number !! Case !! Declension')
-- Singular rows
table.insert(out, '|-')
table.insert(out, '! rowspan=4 | Singular')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "sg"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "sg"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "sg"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "sg"))
-- Plural rows
table.insert(out, '|-')
table.insert(out, '! rowspan=4 | Plural')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "pl"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "pl"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "pl"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "pl"))
table.insert(out, '|}')
return table.concat(out, '\n')
end
return export