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 == "專有名詞" and "-proper" or ""),
["acc|s"] = "n" .. (params.pos == "專有名詞" and "-properpl" or ""),
["acc|p"] = "jn" .. (params.pos == "專有名詞" and "-properpl" or ""),
["pres"] = "as",
["past"] = "is",
["futr"] = "os",
["cond"] = "us",
["voli"] = "u",
}
local inflection = formparam[params.form] or params.form
if params.pos ~= "專有名詞" 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 = "形容詞"
elseif participle_ending == "e" then
entry.pos_header = "副詞"
elseif participle_ending == "o" then
entry.pos_header = "名詞"
end
end
end
entry.def = "{{eo-form of|" .. stem .. "|" .. ending .. inflection .. "}}"
end}