Module:see

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


local export = {}

local etymology_module = "Module:etymology"

local rsplit = mw.text.split


local function parse_args(args)
	local boolean = {type = "boolean"}
	local list_allow_holes = {list = true, allow_holes = true}
	args = require("Module:parameters").process(args, {
		 = {required = true, type = "language", default = "und"},
		 = list_allow_holes,
		 = list_allow_holes,
		 = {list = true, allow_holes = true, alias_of = "t"},
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		 = list_allow_holes,
		-- Note, lang1=, lang2=, ... are different from 1=; the former apply to
		-- individual arguments, while the latter applies to all arguments
		 = {type = "language", list = true, allow_holes = true, require_index = true},
		 = {type = "script"},
		-- Note, sc1=, sc2=, ... are different from sc=; the former apply to
		-- individual arguments when lang1=, lang2=, ... is specified, while
		-- the latter applies to all arguments where langN=... isn't specified
		 = {type = "script", list = "sc", allow_holes = true, require_index = true},
		 = boolean,
		 = boolean,
		 = boolean,
		 = true,
	})
	return args, args, args
end


local function get_parsed_part(args, i)
	local term_index = 2
	local term = args
	local alt = args
	local id = args
	local lang = args
	local sc = args
	
	local tr = args
	local ts = args
	local gloss = args
	local pos = args
	local lit = args
	local q = args
	local qq = args
	local g = args

	if not (term or alt or tr or ts) then
		require("Module:debug").track("see/no term or alt or tr")
		return nil
	else
		local termlang, actual_term
		if term then
			termlang, actual_term = term:match("^(+):(.*)$")
			if termlang then
				termlang = require("Module:languages").getByCode(termlang, nil, "allow etym") or nil
			end
			if not termlang then -- If not a valid language code, treat it as part of the term.
				actual_term = term
			end
		end
		if lang and termlang then
			error(("Both lang%s= and a language in %s= given; specify one or the other"):format(i, term_index + i - 1))
		end
		return { term = actual_term, alt = alt, id = id, lang = lang or termlang, sc = sc, tr = tr,
			ts = ts, gloss = gloss, pos = pos, lit = lit, q = q, qq = qq,
			genders = g and rsplit(g, ",") or {}
		}
	end
end


local function get_parsed_parts(args)
	local parts = {}

	-- Find the maximum index among any of the list parameters.
	local maxmaxindex = 0
	for _, v in pairs(args) do
		if type(v) == "table" and v.maxindex and v.maxindex > maxmaxindex then
			maxmaxindex = v.maxindex
		end
	end

	for index = 1, maxmaxindex do
		local part = get_parsed_part(args, index)
		parts = part
	end
	
	return parts
end


function export.see(frame)
	local args, lang, sc = parse_args(frame:getParent().args)

	local nocat = args
	local notext = args
	local text = not notext and frame.args
	local oftext = not notext and (frame.args or text and "of")
	local cat = not nocat and frame.args

	local parts = get_parsed_parts(args)

	if not next(parts) and mw.title.getCurrentTitle().nsText == "Template" then
		parts = { {term = "term"} }
	end

	local textparts = {}
	local function ins(text)
		table.insert(textparts, text)
	end
	if not args.noast then
		ins("* ")
	end
	ins("''")
	if args then
		ins("and ")
	end
	if args.compare then
		ins("compare with: ")
	else
		ins("see: ")
	end
	ins("''")

	local termparts = {}
	-- Make links out of all the parts
	for _, part in ipairs(parts) do
		local result
		if part.q then
			result = require("Module:qualifier").format_qualifier(part.q) .. " "
		else
			result = ""
		end
		part.sc = part.sc or sc
		if part.lang then
			result = result .. require(etymology_module).format_derived{
				terminfo = part,
				nocat = true,
				template_name = "see",
			}
		else
			part.lang = lang
			result = result .. require("Module:links").full_link(part, nil, false)
		end

		if part.qq then
			result = result .. " " .. require("Module:qualifier").format_qualifier(part.qq)
		end

		table.insert(termparts, result)
	end

	if #termparts == 1 then
		ins(termparts)
	else
		ins(require("Module:table").serialCommaJoin(termparts, {conj = "''and''"}))
	end

	if args.notes then
		ins(" ''")
		ins(args.notes)
		ins("''")
	end

	return table.concat(textparts)
end


return export