Module:User:Sarri.greek/recognizeaffix

From Wiktionary, the free dictionary
Jump to navigation Jump to search

-- [[wikt:en:User:Erutuon]] wrote this, in 2019, for our use at el.wikt. Thank you!!
-- 2024.03.12. [[wikt:en:User:Sarri.greek]]
-- [[Template:User:Sarri.greek/recognizeaffix]]
-- Used at [[Template:R:el:Reverse]]
-- it cuts off the first character, if at 1 i put {{PAGENAME}}  I added ...or PAGENAME

local p = {}

function p.affix(frame)
	local term = frame.args[1] or frame:getParent().args[1] -- {{#invoke:recognizeaffix|affix|<a word>}}

	PAGENAME = mw.title.getCurrentTitle().text
	
	-- (1, 1) start at 1st character, stop at 1st character
	-- when param 1 is empty, see PAGENAME
	if term:sub(1, 1) == '-' or PAGENAME:sub(1, 1) == "-" then
		
		-- (-1) is the last letter (1st from the end)
		if term:sub(-1) == '-' then
			return 'infix'
		else
			return 'suffix'
		end
	elseif term:sub(-1) == '-' then
		return 'prefix'
	else
		return 'combining form'
	end
end

return p