Jump to content

Module:accel/eo

Wiktionary වෙතින්

This module contains new entry creation rules for එස්පෙරාන්තො; see WT:ACCEL for an overview, and Module:accel for information on creating new rules.


return {generate = function (params, entry)
	local index = params.origin:find(" de ")
	-- Get word before " de "
	local usub = mw.ustring.sub
	local word = index and params.origin:sub(1, index - 1) or params.origin
	local stem = usub(word, 1, -2)
	local ending = usub(word, -1)
	
	if ending == "j" then
		stem = "original=" .. params.origin .. "|"
		ending = usub(word, -2, -2)
	end
	
	if index then
		stem = "original=" .. params.origin .. "|"
	end
	
	if not ("aio"):find(ending) then
		return error("The Esperanto word \"" .. params.origin .. "\" does not end in -o or -a or -i or -oj or -aj (index = " .. index .. ", word = " .. word .. ", stem = " .. stem .. ", ending = " .. ending .. ").")
	end

	if ending == "i" then
		ending = ""
	end
	
	local formparam = {
		["acc"]   = "n|unc=yes",
		["p"]     = "j" .. (params.pos == "proper noun" and "-proper" or ""),
		["acc|s"] = "n" .. (params.pos == "proper noun" and "-properpl" or ""),
		["acc|p"] = "jn" .. (params.pos == "proper noun" and "-properpl" or ""),
		["pres"]  = "as",
		["past"]  = "is",
		["futr"]  = "os",
		["cond"]  = "us",
		["voli"]  = "u",
	}
	
	local inflection = formparam[params.form] or params.form
	
	if params.pos ~= "proper noun" then
		entry.head = "{{eo-head}}"
	end
	
	local participle_ending = inflection:match("[aio]n?t([aeo]j?n?)$")
	if participle_ending then
		-- Two or three letters long.
		-- Alternative: participle_ending:match("[ao](j?n?)$") ~= ""
		if #participle_ending >= 2 then
			entry.head = "{{eo-part}}"
		else -- One letter long.
			if participle_ending == "a" then
				entry.pos_header = "Adjective"
			elseif participle_ending == "e" then
				entry.pos_header = "Adverb"
			elseif participle_ending == "o" then
				entry.pos_header = "Noun"
			end
		end
	end
	
	entry.def = "{{eo-form of|" .. stem .. "|" .. ending .. inflection .. "}}"
end}
"https://si.wiktionary.org/w/index.php?title=Module:accel/eo&oldid=34005" වෙතින් සම්ප්‍රවේශනය කෙරිණි