Module:sv-adjectives

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

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 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 par3 = args; if par3 == "" then par3 = nil end
	
	local alt = args; if alt == "" then alt = nil end
	local n = args; if n == "" then n = nil end
	
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par2 or n or (par1 or mw.title.getCurrentTitle().text) .. "t"}
	data.forms   = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e"}
	data.forms  = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a"}
	
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "are"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "are"}
	data.forms   = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "are"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "are"}
	data.forms  = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "are"}
	
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "ast"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "ast"}
	data.forms   = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "ast"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "aste"}
	data.forms  = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "aste"}
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 alt = args; if alt == "" then alt = nil end
	local n = args; if n == "" then n = nil end
	
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par2 or n or (par1 or mw.title.getCurrentTitle().text) .. "t"}
	data.forms   = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e"}
	data.forms  = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a"}
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 alt = args; if alt == "" then alt = nil end
	local n = args; if n == "" then n = nil end
	
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par2 or n or (par1 or mw.title.getCurrentTitle().text) .. "t"}
	data.forms   = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e"}
	data.forms = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e"}
	data.forms  = {(par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a"}
	
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms = {"] " .. (par2 or n or (par1 or mw.title.getCurrentTitle().text) .. "t")}
	data.forms   = {"] " .. ((par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a")}
	data.forms = {"] " .. ((par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e")}
	data.forms  = {"] " .. ((par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a")}
	
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms = {"] " .. (par2 or n or (par1 or mw.title.getCurrentTitle().text) .. "t")}
	data.forms   = {"] " .. ((par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a")}
	data.forms = {"] " .. ((par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "e")}
	data.forms  = {"] " .. ((par3 or alt or par1 or mw.title.getCurrentTitle().text) .. "a")}
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms   = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms  = {par1 or mw.title.getCurrentTitle().text}
	
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms   = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms  = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms   = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
	data.forms  = {"] " .. (par1 or mw.title.getCurrentTitle().text)}
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 par4 = args; if par4 == "" then par4 = nil end
	local par5 = args; if par5 == "" then par5 = nil end
	local par6 = args; if par6 == "" then par6 = nil end
	local par7 = args; if par7 == "" then par7 = nil end
	local par8 = args; if par8 == "" then par8 = nil end
	local par9 = args; if par9 == "" then par9 = nil end
	local par10 = args; if par10 == "" then par10 = nil end
	
	if par9 ~= par8 then
		require("Module:debug").track("sv-adjectives/98")
	end
	
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par2}
	data.forms   = {par5}
	data.forms = {par5}
	data.forms = {par3}
	data.forms  = {par4}
	
	data.forms = {par6}
	data.forms = {par6}
	data.forms   = {par6}
	data.forms = {par6}
	data.forms  = {par6}
	
	data.forms = {par10}
	data.forms = {par10}
	data.forms   = {par10}
	data.forms = {par7}
	data.forms  = {par8}
end

inflections = function(args, data)
	local par1 = args; if par1 == "" then par1 = nil end
	
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms   = {par1 or mw.title.getCurrentTitle().text}
	data.forms   = {par1 or mw.title.getCurrentTitle().text}
	data.forms = {par1 or mw.title.getCurrentTitle().text}
	data.forms  = {par1 or mw.title.getCurrentTitle().text}
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 par4 = args; if par4 == "" then par4 = nil end
	local par5 = args; if par5 == "" then par5 = nil end
	
	local enstem = args; if enstem == "" then enstem = nil end
	
	data.forms = {(enstem and enstem .. "en") or par1 or mw.title.getCurrentTitle().text}
	data.forms = {(enstem and enstem .. "et") or par2}
	data.forms   = {(enstem and enstem .. "na") or par5 or par4 or par3 or ((par1 or mw.title.getCurrentTitle().text) .. "e")}
	data.forms = {(enstem and enstem .. "ne") or par3 or ((par1 or mw.title.getCurrentTitle().text) .. "e")}
	data.forms = {(enstem and enstem .. "ne") or par3 or ((par1 or mw.title.getCurrentTitle().text) .. "e")}
	data.forms  = {(enstem and enstem .. "na") or par4 or par3 or ((par1 or mw.title.getCurrentTitle().text) .. "e")}
end


-- Helper functions

function postprocess(args, data)
	-- Check if the lemma form matches the page name
	if not appendix and (lang:makeEntryName(data.forms)) ~= mw.title.getCurrentTitle().text then
		table.insert(data.categories, "Swedish 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, term = 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 = mw.getCurrentFrame():expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = 'Inflection of {{{lemma}}}{{{info}}}',
			palette = 'indigo',  -- to match {{sv-decl-noun}}
			tall = 'yes'  -- collapsible
		}
	}
	wikicode = wikicode .. [=[
! class="outer" | Indefinite
! positive
! comparative
! superlative<sup>1</sup>
|-
! common singular
| {{{pos_indf_c_sg}}}
| {{{comp_indf_c_sg}}}
| {{{sup_indf_c_sg}}}
|-
! neuter singular
| {{{pos_indf_n_sg}}}
| {{{comp_indf_n_sg}}}
| {{{sup_indf_n_sg}}}
|- 
! plural
| {{{pos_indf_pl}}}
| {{{comp_indf_pl}}}
| {{{sup_indf_pl}}}
|- 
! masculine plural<sup>2</sup>
| {{{pos_indf_m_pl}}}
| {{{comp_indf_pl}}}
| {{{sup_indf_pl}}}
|- 
! colspan="999" class="separator" |
|-
! class="outer" | Definite
! positive
! comparative
! superlative
|-
! masculine singular<sup>3</sup>
| {{{pos_defn_m_sg}}}
| {{{comp_defn_m_sg}}}
| {{{sup_defn_m_sg}}}
|- 
! all
| {{{pos_defn_all}}}
| {{{comp_defn_all}}}
| {{{sup_defn_all}}}
]=]
	wikicode = wikicode .. mw.getCurrentFrame():expandTemplate{
		title = 'inflection-table-bottom',
		args = {
			notes = 
				'<sup>1</sup> The indefinite superlative forms are only used in the predicative.<br>' ..
				'<sup>2</sup> Dated or archaic.<br>' ..
				'<sup>3</sup> Only used, optionally, to refer to things whose natural gender is masculine.'
		}
	}
	return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)
end

return export