Module:qlu-nouns: Difference between revisions

From Linguifex
Jump to navigation Jump to search
incomplete
 
No edit summary
 
(30 intermediate revisions by the same user not shown)
Line 4: Line 4:


local export = {}
local export = {}
local decl_names = {
["a"] = "a-stem",
["o"] = "o-stem",
["o-N"] = "o-stem neuter",
["i"] = "i-stem",
["r"] = "r-stem"
}


local decls = {}
local decls = {}


-- a-stem
decls["a"] = {
decls["a"] = {
params = {
params = { [1] = {} },
[1] = {},
},
}
}
setmetatable(decls["a"], {__call = function(self, args, data)
setmetatable(decls["a"], { __call = function(self, args, data)
data.forms["nom-sg"] = args[1] .. "a"
local r = args[1]
data.forms["nom-pl"] = args[1] .. "e"
data.forms["nom-sg"] = r .. "a"
data.forms["nom-pl"] = r .. "e"
data.forms["gen-sg"] = args[1] .. "e"
data.forms["gen-sg"] = r .. "e"
data.forms["gen-pl"] = args[1] .. "aro"
data.forms["gen-pl"] = r .. "aro"
data.forms["dat-sg"] = r .. "a"
data.forms["dat-sg"] = args[1] .. "a"
data.forms["dat-pl"] = r .. "evo"
data.forms["dat-pl"] = args[1] .. "evo"
data.forms["acc-sg"] = r .. "a"
data.forms["acc-pl"] = r .. "e"
data.forms["acc-sg"] = args[1] .. "a"
end })
data.forms["acc-pl"] = args[1] .. "as"
end
})


-- o-stem
decls["o"] = {
decls["o"] = {
params = {
params = { [1] = {} },
[1] = {},
},
}
}
setmetatable(decls["o"], {__call = function(self, args, data)
setmetatable(decls["o"], { __call = function(self, args, data)
data.forms["nom-sg"] = args[1] .. "u"
local r = args[1]
data.forms["nom-pl"] = args[1] .. "i"
data.forms["nom-sg"] = r .. "u"
data.forms["nom-pl"] = r .. "i"
data.forms["gen-sg"] = args[1] .. "i"
data.forms["gen-sg"] = r .. "i"
data.forms["gen-pl"] = args[1] .. "oro"
data.forms["gen-pl"] = r .. "oro"
data.forms["dat-sg"] = r .. "a"
data.forms["dat-sg"] = args[1] .. "a"
data.forms["dat-pl"] = r .. "evo"
data.forms["dat-pl"] = args[1] .. "evo"
data.forms["acc-sg"] = r .. "o"
data.forms["acc-pl"] = r .. "i"
data.forms["acc-sg"] = args[1] .. "o"
end })
data.forms["acc-pl"] = args[1] .. "os"
end
})


-- o-stem neuter
decls["o-N"] = {
decls["o-N"] = {
params = {
params = { [1] = {} },
[1] = {},
},
}
}
setmetatable(decls["o-N"], {__call = function(self, args, data)
setmetatable(decls["o-N"], { __call = function(self, args, data)
data.forms["nom-sg"] = args[1] .. "o"
local r = args[1]
data.forms["nom-pl"] = args[1] .. "a"
data.forms["nom-sg"] = r .. "o"
data.forms["nom-pl"] = r .. "a"
data.forms["gen-sg"] = args[1] .. "i"
data.forms["gen-sg"] = r .. "i"
data.forms["gen-pl"] = args[1] .. "oro"
data.forms["gen-pl"] = r .. "oro"
data.forms["dat-sg"] = r .. "a"
data.forms["dat-sg"] = args[1] .. "a"
data.forms["dat-pl"] = r .. "evo"
data.forms["dat-pl"] = args[1] .. "evo"
data.forms["acc-sg"] = r .. "o"
data.forms["acc-pl"] = r .. "a"
data.forms["acc-sg"] = args[1] .. "o"
end })
data.forms["acc-pl"] = args[1] .. "a"
end
})


-- i-stem
decls["i"] = {
decls["i"] = {
params = {
params = { [1] = {} },
[1] = {},
},
}
}
setmetatable(decls["i"], {__call = function(self, args, data)
setmetatable(decls["i"], { __call = function(self, args, data)
data.forms["nom-sg"] = args[1] .. "e"
local r = args[1]
data.forms["nom-pl"] = args[1] .. "i"
data.forms["nom-sg"] = r .. "e"
data.forms["nom-pl"] = r .. "i"
data.forms["gen-sg"] = args[1] .. "i"
data.forms["gen-sg"] = r .. "i"
data.forms["gen-pl"] = args[1] .. "e"
data.forms["gen-pl"] = r .. "e"
data.forms["dat-sg"] = r .. "i"
data.forms["dat-sg"] = args[1] .. "i"
data.forms["dat-pl"] = r .. "evo"
data.forms["dat-pl"] = args[1] .. "evo"
data.forms["acc-sg"] = r .. "e"
data.forms["acc-pl"] = r .. "i"
data.forms["acc-sg"] = args[1] .. "e"
end })
data.forms["acc-pl"] = args[1] .. "es"
end
})


-- r-stem (updated)
decls["r"] = {
decls["r"] = {
params = {
params = { [1] = {} },
[1] = {},
}
[2] = {},
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]]''" },
}
}
setmetatable(decls["r"], {__call = function(self, args, data)
 
data.forms["nom-sg"] = args[1]
-- Main output function
data.forms["nom-pl"] = args[2] .. "i"
function export.show(frame)
local args = frame.args
data.forms["gen-sg"] = args[2] .. "i"
local root = args[1] or error("No root provided.")
data.forms["gen-pl"] = args[2] .. "e"
local decltype = args["type"] or error("No declension type provided.")
 
data.forms["dat-sg"] = args[2] .. "i"
local decl = decls[decltype]
data.forms["dat-pl"] = args[2] .. "evo"
if not decl then
error("Unknown declension type: " .. decltype)
data.forms["acc-sg"] = args[2] .. "e"
end
data.forms["acc-pl"] = args[2] .. "es"
 
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
end
})
 
return export

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