Module:User:Mårtensås/sv-nouns-obs

Hello, you have come here looking for the meaning of the word Module:User:Mårtensås/sv-nouns-obs. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Mårtensås/sv-nouns-obs, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Mårtensås/sv-nouns-obs in singular and plural. Everything you need to know about the word Module:User:Mårtensås/sv-nouns-obs you have here. The definition of the word Module:User:Mårtensås/sv-nouns-obs will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Mårtensås/sv-nouns-obs, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Lua error at line 20: attempt to call field 'isPositiveInteger' (a nil value) Lua error at line 20: attempt to call field 'isPositiveInteger' (a nil value) Lua error at line 20: attempt to call field 'isPositiveInteger' (a nil value)


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

local export = {}

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

local current_title = mw.title.getCurrentTitle()
local namespace = current_title.nsText

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

-- Shifts down all integer arguments, removing argument 1, even when there are
-- gaps. For instance, { 1, nil, 3 } will become { nil, 3 }.
-- An improved version of table.remove(args, 1).
local function remove_arg_1(args)
	local new_args = {}
	for k, v in pairs(args) do
		if require("Module:table").isPositiveInteger(k) then
			if k > 1 then
				new_args = v
			end
		else
			new_args = v
		end
	end
	return new_args
end

-- 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
	if current_title.text == "Module:User:Mårtensås/sv-nouns-obs"
	or current_title.text == "Module:User:Mårtensås/sv-nouns-obs/documentation" then
		args = frame:getParent().args
	else
		args = remove_arg_1(frame.args)
	end
	
	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 current_title.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
	
	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
	local obs = args; if obs == "" then obs = nil end
	data = obs
	
	if not par1 then
		if namespace == "Template" or namespace == "Module" then
			par1 = "{{{1}}}"
		else
			error("parameter 1 is required")
		end
	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"}
	
	if obs then	
		--Obsolete forms
		data.forms = {par1 .. "os"}
		data.forms = {par1 .. "o"}
		data.forms = {par1 .. "o"}
		data.forms = {par1 .. "ones"}
		data.forms = {par1 .. "ona"}
		data.forms = {par1 .. "one"}
		
		data.forms = {par1 .. "or"}
		data.forms = {par1 .. "om"}
		data.forms = {par1 .. "orna"}
		data.forms = {par1 .. "omen"}
	end
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 current_title.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" ~= current_title.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(current_title.text, "$") then
		s = ""
	end
	
	data.forms = {current_title.text}
	data.forms = {current_title.text .. s}
	data.forms = {(stem or current_title.text) .. "en"}
	data.forms = {(stem or current_title.text) .. "ens"}
	
	data.forms = {current_title.text}
	data.forms = {current_title.text .. s}
	data.forms = {(pluralstem or stem or current_title.text) .. "na"}
	data.forms = {(pluralstem or stem or current_title.text) .. "nas"}
end

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

inflections = function(args, data)
	if not mw.ustring.find(current_title.text, "nde$") then
		error("The noun must end in -nde.")
	end
	
	data.forms = {current_title.text}
	data.forms = {current_title.text .. "s"}
	data.forms = {current_title.text .. "n"}
	data.forms = {current_title.text .. "ns"}
	
	data.forms = {current_title.text}
	data.forms = {current_title.text .. "s"}
	data.forms = {current_title.text .. "na"}
	data.forms = {current_title.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
	local obs = args; if obs == "" then obs = nil end
	data = obs
	
	par1 = par1 or current_title.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"}
	
	if obs then	
		--Obsolete forms
		data.forms = {par1}
		data.forms = {par1 .. s .. "ens"}
		data.forms = {par2 .. "no"}
		
		data.forms = {par1 .. "om"}
		data.forms = {par1 .. "omen"}
	end
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 current_title.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(current_title.text, "$") then
		s = ""
	end
	
	data.forms = {current_title.text}
	data.forms = {current_title.text .. s}
	data.forms = {(stem or current_title.text) .. "et"}
	data.forms = {(stem or current_title.text) .. "ets"}
	
	data.forms = {current_title.text}
	data.forms = {current_title.text .. s}
	data.forms = {(stem or current_title.text) .. "en"}
	data.forms = {(stem or current_title.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) ~= current_title.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 = current_title.text}, "term")
		elseif param == "info" then
			return data.title and " (" .. data.title .. ")" or ""
		elseif param:find "_obs$" then
			-- There shouldn't be multiple obsolete forms, because it'd look
			-- weird to have multiple lines with a dagger on the last line only.
			if data.forms then
				assert(#data.forms <= 1)
				return ", " .. show_form(data.forms) .. "<sup>]</sup>"
			else
				return ""
			end
		else
			return show_form(data.forms)
		end
	end
	local wikicode
	if data then 
		--Showing obsolete forms
		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}}}{{{indf_gen_sg_obs}}}
| {{{defn_gen_sg}}}{{{defn_gen_sg_obs}}}
| {{{indf_gen_pl}}}
| {{{defn_gen_pl}}}
|- class="vsHide" style="background: #FFF2F2;"
! style="background: #FFE6E6;" | Accusative<sup>]</sup>
| {{{indf_acc_sg}}}
| {{{defn_acc_sg}}}
| {{{indf_acc_pl}}}
| {{{defn_acc_pl}}}
|- class="vsHide" style="background: #FFF2F2;"
! style="background: #FFE6E6;" | Dative<sup>]</sup>
| {{{indf_dat_sg}}}
| {{{defn_dat_sg}}}
| {{{indf_dat_pl}}}
| {{{defn_dat_pl}}}
|}]=]
	else
		--Not showing obsolete forms
		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}}}
|}]=]
	end
	return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)
end

return export