Module:gl-reinteg-common

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


local export = {}

local romut_module = "Module:romance utilities"

local rsubn = mw.ustring.gsub
local rfind = mw.ustring.find
local rmatch = mw.ustring.match

local unaccented_vowel = "aeiouàAEIOUÀ"
local accented_vowel = "áéíóúýâêôÁÉÍÓÚÝÂÊÔ"
local maybe_accented_vowel = "ãõÃÕ"
local vowel = unaccented_vowel .. accented_vowel .. maybe_accented_vowel
local V = ""
export.V = V
local AV = ""
export.AV = AV
local NAV = ""
export.NAV = NAV
local C = ""
export.C = C
local remove_accent = {
	="a", ="e", ="i", ="o", ="u", ="y", ="a", ="e", ="o",
	="A", ="E", ="I", ="O", ="U", ="Y", ="A", ="E", ="O"
}
export.remove_accent = remove_accent

-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end

export.rsub = rsub

-- version of rsubn() that returns a 2nd argument boolean indicating whether
-- a substitution was made.
local function rsubb(term, foo, bar)
	local retval, nsubs = rsubn(term, foo, bar)
	return retval, nsubs > 0
end

export.rsubb = rsubb

-- apply rsub() repeatedly until no change
local function rsub_repeatedly(term, foo, bar)
	while true do
		local new_term = rsub(term, foo, bar)
		if new_term == term then
			return term
		end
		term = new_term
	end
end

export.rsub_repeatedly = rsub_repeatedly

function export.remove_final_accent(stem)
	return rsub(stem, "(" .. AV .. ")(" .. C .. "*)$", function(v, c) return (remove_accent or v) .. c end)
end

local prepositions = {
	-- a + optional article
	"a ",
	"às? ",
	"aos? ",
	-- com + optional article
	"com ",
	"coa?s? ",
	"d'",
	-- de + optional article
	"de ",
	"ds? ",
	"d'",
	-- en/em + optional article
	"em ",
	"ns? ",
	-- por + optional article
	"por ",
	"pols? ",
	-- others
	"para ",
	"at ",
	"com ",
	"entre ",
	"se ",
	"sob? ",
	"sobre ",
}

local function call_handle_multiword(term, special, make_fun, fun_name)
	local retval = require(romut_module).handle_multiword(term, special, make_fun, prepositions)
	if retval then
		if #retval ~= 1 then
			error("Internal error: Should have one return value for " .. fun_name .. ": " .. table.concat(retval, ","))
		end
		return retval
	end
	return nil
end

local function make_try(word)
	return function(from, to)
		local newval, changed = rsubb(word, from, to)
		if changed then
			return newval
		end
		return nil
	end
end

function export.make_plural(term, special)
	local retval = call_handle_multiword(term, special, export.make_plural, "make_plural")
	if retval then
		return retval
	end

	local try = make_try(term)
	-- This is ported from ] and based off of http://agal-gz.org/faq/doku.php?id=pt_agal:normas:norma_da_agal:morfologia:o_nome.
	return
		try("ão$", "ões") or
		try("aõ$", "oens") or
		try("(" .. AV .. ".*)l$", "%1eis") or -- final unstressed -el or -il
		try("el$", "éis") or -- final stressed -el
		try("il$", "is") or -- final stressed -il
		try("(" .. AV .. ".*)ol$", "%1ois") or -- final unstressed -ol
		try("ol$", "óis") or -- final stressed -ol
		try("(" .. V .. ")l$", "%1is") or -- any other vowel + -l
		try("m$", "ns") or -- final -m
		try("(" .. V .. ")$", "%1s") or -- final vowel
		try("()$", "%1s") or -- ordinal indicator
		try("(s)$", "%1es") or -- ] -> países
		try("(" .. AV .. ")s$", function(av) return (remove_accent or av) .. "ses" end) or -- final -ês, -ós etc.
		try("^(" .. NAV .. "*" .. C .. "s)$", "%1es") or -- final stressed -us or -is after consonant
		try("^(" .. NAV .. "*s)$", "%1es") or -- final stressed diphthong + -s e.g. ]
		try("()iz$", "%1ízes") or -- ] -> raízes
		try("()uz$", "%1úzes") or -- same for u; not sure if there are any examples
		try("()$", "%1es") or -- final -r, -z, -n: ], ], ], ], ]
		try("()$", "%1") or -- unstressed final -s, final cluster with -s or final -x: no change
		term .. "s"
end

function export.make_feminine(term, is_noun, special)
	local retval = call_handle_multiword(term, special, function(term) return export.make_feminine(term, is_noun) end,
		"make_feminine")
	if retval then
		return retval
	end

	local try = make_try(term)

	-- This is ported from ] and based off of http://agal-gz.org/faq/doku.php?id=pt_agal:normas:norma_da_agal:morfologia:o_nome.
	return
		-- Exceptions: ] (afegã), ] (alazã), ] (alemã), ] (anciã),
		--             ] (anglo-saxã), ] (beirã/beiroa), ] (bretã), ] (cã),
		--             ] (castelã/castelona/casteloa), ] (catalã), ] (chã),
		--             ] (cristã), ] (fodão since from ]), ] (grã), ] (lapoa),
		--             ] (letã), ] (meã), ] (órfã), ] (padrão), ] (pagã),
		--             ] (paleocristã), ] (parmesã), ] (romã), ] (sã),
		--             ] (saxã), ] (temporã), ] (teutona/teutã/teutoa), ] (vã),
		--             ] (varoa), ] (invariable), ] (vilã/viloa)
		try("ám$", "á") or
		try("ao$", "á") or
		try("om$", "ona") or
		try("ão$", "ona") or
		try("o$", "a") or
		-- ordinal indicator
		try("º$", "ª") or
		-- ], ], ], ] etc.
		try("ês$", "esa") or
		-- ], ], ], ] (archaic)
		try("ez$", "eza") or
		-- adjectives in:
		-- * ], ] (], ], etc.), ] (], etc.)
		-- * -tor (], ], ], etc.)
		-- * -sor (], ], ], etc.)
		-- but not:
		-- * ]/]/]/]/]/]
		-- * ]/]/]/etc., ], etc.
		try("(r)$", "%1a") or
		-- ], ], ], ], ], ], ], ],
		-- ], ], ]/], ], ], ],
		-- ]
		-- Exceptions: ] (judia), ] (sandia)
		try("eu$", "eia") or
		is_noun and try("e$", "a") or
		-- note: ] (espanhola), but this is the only case in ''-ol'' (vs. ], ] with no
		-- change in the feminine)
		term
end

function export.make_masculine(term, special)
	local retval = call_handle_multiword(term, special, export.make_masculine, "make_masculine")
	if retval then
		return retval
	end

	local try = make_try(term)

	return
		try("()ora$", "%1or") or
		try("a$", "o") or
		-- ordinal indicator
		try("ª$", "º") or
		term
end

return export