Jump to content

Module:User:Wikispeedier/bn-splitverb

From Wiktionary, the free dictionary

Passed All tests passed.

Name Expected Actual
Passed test_split

local export = {}

function export.split(verb)
	for _, ending in pairs({"েওয়া", "ওয়া", "য়া", "া", "েওয়ানো", "ওয়ানো", "য়ানো", "ানো", "োনো", "নো"}) do
		local split_point = -mw.ustring.len(ending)
		if mw.ustring.find(verb, ending, split_point) then
			return {
				stem = mw.ustring.sub(verb, 1, split_point - 1),
				ending = ending
			}
		end
	end
	error('invalid verb "' .. verb .. '" (verbs must end in "া" or "নো")')
end

function export.split_tr(verb_tr)
	for _, ending_tr in pairs({"eẇa", "ẇa", "a", "eẇano", "ẇano", "ano", "ono", "no"}) do
		local split_point = -mw.ustring.len(ending_tr)
		if mw.ustring.find(verb_tr, ending_tr, split_point) then
			return {
				stem_tr = mw.ustring.sub(verb_tr, 1, split_point - 1),
				ending_tr = ending_tr
			}
		end
	end
	error('invalid verb "' .. verb_tr .. '" (verbs must end in "a" or "no")')
end

return export