Module:User:Benwing2/sa-headword

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


local export = {}
local pos_functions = {}
local m_links = require("Module:links")

local lang = require("Module:languages").getByCode("sa")
local langname = lang:getCanonicalName()
local PAGENAME = mw.title.getCurrentTitle().text

local suffix_categories = {
	 = true,
	 = true,
	 = true,
	 = true,
}

local function track(page)
	require("Module:debug").track("sa-headword/" .. page)
	return true
end

local function glossary_link(entry, text)
	text = text or entry
	return "]"
end

function export.alt(frame)
	local args = frame:getParent().args
	local currentScript = require("Module:scripts").findBestScript(PAGENAME, lang)
	local currentScriptCode = currentScript:getCode()
	local availableScripts = lang:getScripts()
	local devaForm = currentScriptCode == "Deva" and PAGENAME or args or error("No Devanagari-script form detected.")
	local scriptCode
	local translit = require("Module:sa-convert").tr
	local m_labels = require("Module:labels")
	
	local terms
	local first
	local output = '<div class="NavFrame" style="max-width:40em"><div class="NavHead" style="background:#d9ebff">Alternative scripts</div><div class="NavContent" style="text-align:left"><ul>'
	for _,script in ipairs(availableScripts) do
		scriptCode = script:getCode()
		terms = { args, args, args }

		output = output .. "<li>"
		if scriptCode ~= "Deva" then
			if #terms == 0 then
				terms = translit(devaForm, scriptCode)
			elseif terms ~= translit(devaForm, scriptCode) then
				output = output .. "]"
			end
		end
		if terms ~= "" then
			first = true
			for _,term in ipairs(terms) do
				if term ~= nil and term ~= PAGENAME then
					if first then
						output = output .. m_links.full_link({lang = lang, sc = script, term = term, tr = "-"})
						first = false
					else
						output = output .. " or " .. m_links.full_link({lang = lang, sc = script, term = term, tr = "-"})
					end
				end
			end
			if scriptCode ~= currentScriptCode then
				output = output .. " " .. m_labels.show_labels({ script:getCategoryName() }, lang) .. "</li>"
			end
		end
	end
	output = output .. "</ul></div></div>"

	return output

end

-- The main entry point.
function export.show(frame)
	local tracking_categories = {}
	
	local poscat = frame.args
		or error("Plural part of speech e.g. 'nouns' has not been specified. Please pass parameter 1 to the module invocation.")
	
	local params = {
		 = {list = true},
		 = {list = true, allow_holes = true},
		 = {},
		 = {},
		 = {},
		 = {type = "boolean"},
	}

	if pos_functions then
		for key, val in pairs(pos_functions.params) do
			params = val
		end
	end
	
    local parargs = frame:getParent().args
	local args = require("Module:parameters").process(parargs, params)
	local data = {
		lang = lang,
		sc = args or currentScript,
		pos_category = poscat,
		categories = {},
		heads = args,
		translits = args,
		genders = {},
		inflections = {},
		id = args,
		sort_key = args,
		categories = {},
		sccat = true,
	}
	
	if args then
		data.pos_category = "suffixes"
		
		if suffix_categories then
			local singular_poscat = poscat:gsub("s$", "")
			table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
		else
			error("No category exists for suffixes forming " .. poscat .. ".")
		end
	end
	
	if pos_functions then
		pos_functions.func(args, data, tracking_categories)
	end
	
	return require("Module:headword").full_headword(data)
		.. require("Module:utilities").format_categories(tracking_categories, lang)
end

pos_functions = {
	params = {
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
	},
	func = function(args, data, tracking_categories)
		local function tooltip(mousetext, anchor, underline)
			return mw.getCurrentFrame():expandTemplate {
				title = "tooltip", args = {mousetext, anchor, und = underline and "1" or nil}
			}
		end
		local function type_to_text(typ)
			return (
				typ == "A" and {"ātmanepada"} or
				typ == "P" and {"parasmaipada"} or
				typ == "U" and {"ubhayapada"} or
				typ == "UP" and {"ubhayapada", "parasmaipada"} or
				typ == "UA" and {"ubhayapada", "ātmanepada"} or
				error("Unrecognized verb type: '" .. typ .. "'")
			)
		end
		local function type_to_tooltip(typ)
			local desc = table.concat(type_to_text(typ), " — ")
			return "type " .. tooltip(desc, typ, true)
		end
		local function mode_to_cat(mode)
			if mode == "present" or mode == "causative" or mode == "desiderative" or mode == "intensive" or
				mode == "denominative" then
				return mode .. " verbs"
			elseif mode == "frequentative" then
				return "intensive verbs"
			elseif mode == "nominal" then
				return "denominative verbs"
			elseif mode == "perfect" or mode == "imperfect" then
				return nil -- FIXME: What about these verbs?
			else
				error("Unrecognized verb mode: '" .. mode .. "'")
			end
		end

		if args then
			table.insert(data.inflections, {label = "root", args})
		end
		local function handle_class_type_mode(class, typ, mode, notfirst)
			if class then
				table.insert(data.inflections, {label = (notfirst and "or " or "") .. "class " .. class})
				table.insert(data.categories, langname .. " verbs of class " .. class)
			end
			if typ then
				table.insert(data.inflections, {label = "type " .. type_to_tooltip(typ)})
				for _, desc in ipairs(type_to_text(typ)) do
					table.insert(data.categories, langname .. " " .. desc .. " verbs")
				end
			end
			if mode then
				table.insert(data.inflections, {label = mode})
				local cat = mode_to_cat(mode)
				if cat then
					table.insert(data.categories, langname .. " " .. cat)
				end
			end
		end
		handle_class_type_mode(args, args, args)
		handle_class_type_mode(args, args, args, "notfirst")
	end,
}


pos_functions = {
	params = {
		 = {alias_of = "comparative"},
		 = {list = true}, --comparative(s)
		 = {alias_of = "superlative"},
		 = {list = true}, --superlative(s)
	},
	func = function(args, data, tracking_categories)
		if args.comparative == "-" then
			table.insert(data.inflections, {label = "not comparable"})
			table.insert(data.categories, langname .. " uncomparable adjectives")
		else
			if #args.comparative > 0 then
				args.comparative.label = glossary_link("comparative")
				args.comparative.accel = {form = "comparative"}
				table.insert(data.inflections, args.comparative)
			end
		
			if #args.superlative > 0 then
				args.superlative.label = glossary_link("superlative")
				args.superlative.accel = {form = "superlative"}
				table.insert(data.inflections, args.superlative)
			end
		end
	end
}

local noun_params = {
	 = {list = true}, --gender(s)
	 = {list = true}, --feminine form(s)
	 = {list = true}, --masculine form(s)
	 = {list = true}, --neuter form(s)
}

local allowed_genders = {
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
}

local function do_nouns(plpos, args, data, tracking_categories)
	local genders = {}
	for _, g in ipairs(args.g) do
		if not allowed_genders then
			error("Unrecognized gender: " .. g)
		end
		if g == "fm" then
			table.insert(genders, "f")
			table.insert(genders, "m")
		elseif g == "mn" then
			table.insert(genders, "m")
			table.insert(genders, "n")
		elseif g == "nm" then
			table.insert(genders, "n")
			table.insert(genders, "m")
		else
			-- mf, mfbysense handled internally by ]
			table.insert(genders, g)
		end
	end

	if #genders > 0 then
		data.genders = genders
	else
		data.genders = {"?"}
	end
	
	if #args.m > 0 then
		args.m.label = "masculine"
		table.insert(data.inflections, args.m)
	end

	if #args.f > 0 then
		args.f.label = "feminine"
		table.insert(data.inflections, args.f)
	end

	if #args.n > 0 then
		args.n.label = "neuter"
		table.insert(data.inflections, args.n)
	end
end

pos_functions = {
	params = noun_params,
	func = function(args, data, tracking_categories)
		return do_nouns("nouns", args, data, tracking_categories)
	end,
}

pos_functions = {
	params = noun_params,
	func = function(args, data, tracking_categories)
		return do_nouns("proper nouns", args, data, tracking_categories)
	end,
}

return export