Icona de documentació de mòdul Documentació del mòdul[mostra] [modifica] [refresca]

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Mòdul de suport per la plantilla {{eo-entrada}}. Mostra l’entrada, sigui lema o forma, i la seva línia de flexió. Vegeu la documentació de la plantilla per a més informació.

local p = {}

local lang = {code = "eo", name = "esperanto", sc = "Latn"}
local pos_functions = {}

local function getPOS(word)
	-- delete anything after "de"
	word = string.gsub(word, " de .+$", "")
	
	if string.match(word,"^[aeiou]$") then
		-- Words with only one vowel are always irregular
		return nil
	elseif word:find("a$") then
		return "Adjectius"
	elseif word:find("aj$") or word:find("an$") or word:find("ajn$") then
		return "Formes d'adjectius"
	elseif word:find("e$") or word:find("en$") then
		return "Adverbis"
	elseif word:find("o$") then
		if mw.ustring.find(word, "^%u") then
			return "Noms propis"
		else
			return "Substantius"
		end
	elseif word:find("oj$") or word:find("on$") or word:find("ojn$") then
		if mw.ustring.find(word, "^%u") then
			return "Formes de noms propis"
		else
			return "Formes de substantius"
		end
	elseif word:find("i$") then
		return "Verbs"
	elseif word:find("[iaou]s$") or word:find("u$") then
		return "Formes verbals"
	else
		return nil
	end
end

-- The main entry point
function p.show(frame)
	local args = frame:getParent().args
	pagename = args.pagename
	if not pagename or pagename == "" then
		pagename = mw.title.getCurrentTitle().subpageText
	end
	
	local data = {lang = lang, heads = {}, inflections = {}, categories = {}}
	local lema = args.lema; if lema == "" then lema = nil end
	table.insert(data.heads, lema)
	
	local poscat = frame.args.cat or args.cat or getPOS(pagename)
	if not poscat then
		error("La categoria lèxica de \"" .. pagename .. "\" no es pot determinar automàticament.")
	elseif poscat == "Participis" and pagename:find("[jn]$") then
		poscat = "Formes de participis"
	end
	table.insert(data.categories, poscat .. " en " .. lang.name)

	if pos_functions[poscat] then
		pos_functions[poscat].func(args, data)
	end
	
	if args.bot then
		return require("Module:lema").make_bot_list(data.inflections)
	else
		return require("Module:lema").full_headword(data)
	end
end

pos_functions["Adjectius"] = {func = function(args, data)
	table.insert(data.inflections, {label = "plural", accel = "plural-form-of", pagename .. "j"})
	table.insert(data.inflections, {label = "acusatiu", accel = "acusativa-form-of", pagename .. "n"})
	table.insert(data.inflections, {label = "plural acusatiu", accel = "acusativa-plural-form-of", pagename .. "jn"})
	
	if not mw.title.new(pagename .. "j").exists or not mw.title.new(pagename .. "n").exists or not mw.title.new(pagename .. "jn").exists then
		table.insert(data.categories, "Termes en esperanto amb flexions a crear")
	end
end
}

pos_functions["Substantius"] = {func = function(args, data)
	-- Get the parameters
	local inflected_words_specified = false
	local inflected_words = {}
	local i = 1
	
	while args[i] do
		local word = args[i]; if word == "" or word == "+" or word == "-" then word = nil end
		
		if word then
			inflected_words[word] = true
			inflected_words_specified = true
		end
		
		i = i + 1
	end
	
	local pl = {}
	local acc = {}
	local acc_pl = {}
	
	-- Split multi-word terms
	for word in mw.text.gsplit(pagename, " ", true) do
		local pos = getPOS(word)
		
		-- Inflect each word separately
		if (not inflected_words_specified or inflected_words[word]) and (pos == "Adjectius" or pos == "Substantius") then
			table.insert(acc, word .. "n")
			table.insert(pl, word .. "j")
			table.insert(acc_pl, word .. "jn")
		else
			table.insert(acc, word)
			table.insert(pl, word)
			table.insert(acc_pl, word)
		end
	end
	
	-- Merge back together
	acc = table.concat(acc, " ")
	pl = table.concat(pl, " ")
	acc_pl = table.concat(acc_pl, " ")
	
	if args[1] == "-" then
		table.insert(data.inflections, {label = "incomptable"})
		table.insert(data.inflections, {label = "acusatiu", accel = "acusativa-incomptable-form-of", acc})
		if not mw.title.new(acc).exists then
			table.insert(data.categories, "Termes en esperanto amb flexions a crear")
		end
	else
		table.insert(data.inflections, {label = "acusatiu", accel = "acusativa-form-of", acc})
		table.insert(data.inflections, {label = "plural", accel = "plural-form-of", pl})
		table.insert(data.inflections, {label = "plural acusatiu", accel = "acusativa-plural-form-of", acc_pl})
		if not mw.title.new(acc).exists or not mw.title.new(pl).exists or not mw.title.new(acc_pl).exists then
			table.insert(data.categories, "Termes en esperanto amb flexions a crear")
		end
	end
end
}

pos_functions["Noms propis"] = {func = function(args, data)
	-- Get the parameters
	local inflected_words_specified = false
	local inflected_words = {}
	local i = 1
	
	while args[i] do
		local word = args[i]; if word == "" or word == "+" or word == "-" then word = nil end
		
		if word then
			inflected_words[word] = true
			inflected_words_specified = true
		end
		
		i = i + 1
	end
	
	local acc = {}
	local pl = {}
	local acc_pl = {}
	
	-- Split multi-word terms
	for word in mw.text.gsplit(pagename, " ", true) do
		local pos = getPOS(mw.ustring.lower(word))
		
		-- Inflect each word separately
		if (not inflected_words_specified or inflected_words[word]) and (pos == "Adjectius" or pos == "Substantius") then
			table.insert(acc, word .. "n")
			table.insert(pl, word .. "j")
			table.insert(acc_pl, word .. "jn")
		else
			table.insert(acc, word)
			table.insert(pl, word)
			table.insert(acc_pl, word)
		end
	end
	
	-- Merge back together
	acc = table.concat(acc, " ")
	pl = table.concat(pl, " ")
	acc_pl = table.concat(acc_pl, " ")
	
	if args[1] == "+" then
		table.insert(data.inflections, {label = "acusatiu", accel = "acusativa-form-of", acc})
		table.insert(data.inflections, {label = "plural", accel = "plural-form-of", pl})
		table.insert(data.inflections, {label = "plural acusatiu", accel = "acusativa-plural-form-of", acc_pl})
		if not mw.title.new(acc).exists or not mw.title.new(pl).exists or not mw.title.new(acc_pl).exists then
			table.insert(data.categories, "Termes en esperanto amb flexions a crear")
		end
	else
		table.insert(data.inflections, {label = "acusatiu", accel = "acusativa-incomptable-form-of", acc})
		if not mw.title.new(acc).exists then
			table.insert(data.categories, "Termes en esperanto amb flexions a crear")
		end
	end
end
}

pos_functions["Verbs"] = {func = function(args, data)
	local stem = pagename:sub(1, -2)
	
	table.insert(data.inflections, {label = "present", accel = "present-form-of", stem .. "as"})
	table.insert(data.inflections, {label = "passat", accel = "passat-form-of", stem .. "is"})
	table.insert(data.inflections, {label = "futur", accel = "futur-form-of", stem .. "os"})
	table.insert(data.inflections, {label = "condicional", accel = "condicional-form-of", stem .. "us"})
	table.insert(data.inflections, {label = "volitiu", accel = "imperatiu-form-of", stem .. "u"})
	
	if not mw.title.new(stem .. "as").exists or not mw.title.new(stem .. "is").exists or not mw.title.new(stem .. "os").exists
	or not mw.title.new(stem .. "us").exists or not mw.title.new(stem .. "u").exists then
		table.insert(data.categories, "Termes en esperanto amb flexions a crear")
	end
end
}

pos_functions["Participis"] = {
	func = function(args, data)
		local ending = mw.ustring.match(pagename, "..([aio]n?t[aeo]j?n?)$")
		if ending then
			local vowel, consonant = ending:match("([aoe])(j?n?)$")
			if consonant == "" then
				if vowel == "a" or vowel == "o" then
					table.insert(data.inflections, {label = "plural", accel = "plural-form-of", pagename .. "j"})
					table.insert(data.inflections, {label = "acusatiu", accel = "acusativa-form-of", pagename .. "n"})
					table.insert(data.inflections, {label = "plural acusatiu", accel = "acusativa-plural-form-of", pagename .. "jn"})
				end
			end
		end
	end
}

return p