Modul:sv-nouns

Üdvözlöm, Ön a Modul:sv-nouns szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:sv-nouns szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:sv-nouns szót egyes és többes számban mondani. Minden, amit a Modul:sv-nouns szóról tudni kell, itt található. A Modul:sv-nouns szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:sv-nouns és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:sv-nouns/doc lapon tudod dokumentálni

local m_utilities = require("Module:utilities")
local m_links = require("Module:links")

local export = {}

local lang = require("Module:languages").getByCode("sv")

-- Functions that do the actual inflecting by creating the forms of a basic term.
local inflections = {}

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local infl_type = frame.args or error("Inflection type has not been specified. Please pass parameter 1 to the module invocation")
	local args = frame:getParent().args
	
	if args then
		require("Module:debug").track("sv-nouns/base")
	end
	
	if args then
		require("Module:debug").track("sv-nouns/betydelser")
	end
	
	if args then
		require("Module:debug").track("sv-nouns/definitions")
	end
	
	if args then
		require("Module:debug").track("sv-nouns/gender")
	end
	
	if args then
		require("Module:debug").track("sv-nouns/genitive")
	end
	
	if not inflections then
		error("Unknown inflection type '" .. infl_type .. "'")
	end
	
	local data = {forms = {}, title = nil, categories = {}}
	
	-- Generate the forms
	inflections(args, data)
	
	-- Postprocess
	postprocess(args, data)
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end

--[=[
	Inflection functions
]=]--

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	local par2 = args; if par2 == "" then par2 = nil end
	local fv = args or ""
	
	par1 = par1 or mw.title.getCurrentTitle().text
	par2 = (par2 or par1) .. fv
	
	local s = "s"
	
	if mw.ustring.find(par1, "$") then
		s = ""
	end
	
	data.forms = {par1}
	data.forms = {par1 .. s}
	data.forms = {par2 .. "en"}
	data.forms = {par2 .. "ens"}
	
	data.forms = {par2 .. "ar"}
	data.forms = {par2 .. "ars"}
	data.forms = {par2 .. "arna"}
	data.forms = {par2 .. "arnas"}
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	local par2 = args; if par2 == "" then par2 = nil end
	local fv = args or ""
	local ien = (args or "") ~= ""
	
	local sg_nom_def = args; if sg_nom_def == "" then sg_nom_def = nil end
	local sg_gen_def = args; if sg_gen_def == "" then sg_gen_def = nil end
	
	if args or args then
		require("Module:debug").track("sv-nouns/manual")
	end
	
	par1 = par1 or mw.title.getCurrentTitle().text
	par2 = (par2 or par1) .. fv
	
	local s = "s"
	
	if mw.ustring.find(par1, "$") then
		s = ""
	end
	
	data.forms = {par1}
	data.forms = {par1 .. s}
	data.forms = {sg_nom_def or par2 .. "en"}
	data.forms = {sg_gen_def or par2 .. "ens"}
	
	data.forms = {par2 .. "er"}
	data.forms = {par2 .. "ers"}
	data.forms = {par2 .. "erna"}
	data.forms = {par2 .. "ernas"}
	
	if ien then
		table.insert(data.forms, 1, sg_nom_def or par2 .. "n")
		table.insert(data.forms, 1, sg_gen_def or par2 .. "ns")
	end
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	
	if not par1 and mw.title.getCurrentTitle().nsText == "Template" then
		par1 = "{{{1}}}"
	end
	
	data.forms = {par1 .. "a"}
	data.forms = {par1 .. "as"}
	data.forms = {par1 .. "an"}
	data.forms = {par1 .. "ans"}
	
	data.forms = {par1 .. "or"}
	data.forms = {par1 .. "ors"}
	data.forms = {par1 .. "orna"}
	data.forms = {par1 .. "ornas"}
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	local par2 = args; if par2 == "" then par2 = nil end
	local par3 = args; if par3 == "" then par3 = nil end
	
	par1 = par1 or mw.title.getCurrentTitle().text
	par2 = par2 or par1
	par3 = par3 or par2 or par1
	
	local s = "s"
	
	if mw.ustring.find(par1, "$") then
		s = ""
	end
	
	data.forms = {par1}
	data.forms = {par1 .. s}
	data.forms = {par2 .. "n"}
	data.forms = {par2 .. "ns"}
	
	data.forms = {par3 .. "r"}
	data.forms = {par3 .. "rs"}
	data.forms = {par3 .. "rna"}
	data.forms = {par3 .. "rnas"}
end

inflections = function(args, data)
	local stem = args; if stem == "" then stem = nil end
	local pluralstem = args; if pluralstem == "" then pluralstem = nil end
	
	if not args then
		require("Module:debug").track("sv-nouns/no stem")
	elseif stem .. "e" ~= mw.title.getCurrentTitle().text then
		require("Module:debug").track("sv-nouns/stem different")
	end
	
	if args then
		require("Module:debug").track("sv-nouns/pluralstem")
	end
	
	local s = "s"
	
	if mw.ustring.find(mw.title.getCurrentTitle().text, "$") then
		s = ""
	end
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. s}
	data.forms = {(stem or mw.title.getCurrentTitle().text) .. "en"}
	data.forms = {(stem or mw.title.getCurrentTitle().text) .. "ens"}
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. s}
	data.forms = {(pluralstem or stem or mw.title.getCurrentTitle().text) .. "na"}
	data.forms = {(pluralstem or stem or mw.title.getCurrentTitle().text) .. "nas"}
end

inflections = function(args, data)
	if not mw.ustring.find(mw.title.getCurrentTitle().text, "are$") then
		error("The noun must end in -are.")
	end
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. "s"}
	data.forms = {mw.title.getCurrentTitle().text .. "n"}
	data.forms = {mw.title.getCurrentTitle().text .. "ns"}
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. "s"}
	data.forms = {mw.ustring.sub(mw.title.getCurrentTitle().text, 1, -2) .. "na"}
	data.forms = {mw.ustring.sub(mw.title.getCurrentTitle().text, 1, -2) .. "nas"}
end

inflections = function(args, data)
	if not mw.ustring.find(mw.title.getCurrentTitle().text, "nde$") then
		error("The noun must end in -nde.")
	end
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. "s"}
	data.forms = {mw.title.getCurrentTitle().text .. "n"}
	data.forms = {mw.title.getCurrentTitle().text .. "ns"}
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. "s"}
	data.forms = {mw.title.getCurrentTitle().text .. "na"}
	data.forms = {mw.title.getCurrentTitle().text .. "nas"}
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	local par2 = args; if par2 == "" then par2 = nil end
	local par3 = args; if par3 == "" then par3 = nil end
	
	par1 = par1 or mw.title.getCurrentTitle().text
	par2 = par2 or par1
	par3 = par3 or par2 or par1
	
	local s = "s"
	
	if mw.ustring.find(par1, "$") then
		s = ""
	end
	
	data.forms = {par1}
	data.forms = {par1 .. s}
	data.forms = {par2 .. "t"}
	data.forms = {par2 .. "ts"}
	
	data.forms = {par3 .. "n"}
	data.forms = {par3 .. "ns"}
	data.forms = {par3 .. "na"}
	data.forms = {par3 .. "nas"}
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	local par2 = args; if par2 == "" then par2 = nil end
	
	par1 = par1 or mw.title.getCurrentTitle().text
	par2 = par2 or par1
	
	local s = "s"
	
	if mw.ustring.find(par1, "$") then
		s = ""
	end
	
	data.forms = {par1}
	data.forms = {par1 .. s}
	data.forms = {par2 .. "t"}
	data.forms = {par2 .. "ts"}
	
	data.forms = {par2 .. "r"}
	data.forms = {par2 .. "rs"}
	data.forms = {par2 .. "rna"}
	data.forms = {par2 .. "rnas"}
end

inflections = function(args, data)
	local stem = args; if stem == "" then stem = nil end
	
	local s = "s"
	
	if mw.ustring.find(mw.title.getCurrentTitle().text, "$") then
		s = ""
	end
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. s}
	data.forms = {(stem or mw.title.getCurrentTitle().text) .. "et"}
	data.forms = {(stem or mw.title.getCurrentTitle().text) .. "ets"}
	
	data.forms = {mw.title.getCurrentTitle().text}
	data.forms = {mw.title.getCurrentTitle().text .. s}
	data.forms = {(stem or mw.title.getCurrentTitle().text) .. "en"}
	data.forms = {(stem or mw.title.getCurrentTitle().text) .. "ens"}
end

-- Helper functions

function postprocess(args, data)
	local n = args; if n == "" then n = nil end
	
	if n == "pl" then
		table.insert(data.categories, lang:getCanonicalName() .. " pluralia tantum")
	end
	
	if n == "sg" then
		table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
	end
	
	for key, form in pairs(data.forms) do
		-- Do not show singular or plural forms for nominals that don't have them
		if (n == "pl" and key:find("_sg$")) or (n == "sg" and key:find("_pl$")) then
			form = nil
		end
		
		data.forms = form
	end
	
	-- Check if the lemma form matches the page name
	if lang:makeEntryName(data.forms) ~= mw.title.getCurrentTitle().text then
		table.insert(data.categories, lang:getCanonicalName() .. " entries with inflection not matching pagename")
	end
end


-- Make the table
function make_table(data)
	local function show_form(form)
		if not form then
			return "—"
		elseif type(form) ~= "table" then
			error("a non-table value was given in the list of inflected forms.")
		elseif #form == 0 then
			return "—"
		end
		
		local ret = {}
		
		for key, subform in ipairs(form) do
			table.insert(ret, m_links.full_link({lang = lang, term = subform}))
		end
		
		return table.concat(ret, "<br/>")
	end
	
	local function repl(param)
		if param == "lemma" then
			return m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
		elseif param == "info" then
			return data.title and " (" .. data.title .. ")" or ""
		else
			return show_form(data.forms)
		end
	end
	
	local wikicode = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="border: solid 1px #CCCCFF; text-align:left;" cellspacing="1" cellpadding="2"
|- style="background: #CCCCFF; vertical-align: top;"
! class="vsToggleElement" colspan="5" | Declension of {{{lemma}}}{{{info}}}&nbsp;
|- class="vsHide" style="background: #CCCCFF;"
! rowspan="2" style="min-width: 12em;" |
! colspan="2" | Singular
! colspan="2" | Plural
|- class="vsHide" style="background: #CCCCFF;"
! style="min-width: 12em;" | Indefinite
! style="min-width: 12em;" | Definite
! style="min-width: 12em;" | Indefinite
! style="min-width: 12em;" | Definite
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #E6E6FF;" | Nominative
| {{{indf_nom_sg}}}
| {{{defn_nom_sg}}}
| {{{indf_nom_pl}}}
| {{{defn_nom_pl}}}
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #E6E6FF;" | Genitive
| {{{indf_gen_sg}}}
| {{{defn_gen_sg}}}
| {{{indf_gen_pl}}}
| {{{defn_gen_pl}}}
|}]=]
	return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)
end

return export