Module:Test

From Allocosm
Revision as of 02:56, 11 February 2024 by Vaxjedi (talk | contribs)

Documentation for this module may be created at Module:Test/doc

require('Module:Test/data')

export = {}

function export.get_forms(root,mod,manual)
	mod = mod or ''
	
	local forms = {}
	local patterns = {}
	
	local head = ""
	local vowel = ""
	
	local root = m_cu.parse_root(root..mod,true)
	
	local tail =  mw.text.split(root[#root],"-")
	
	if #root == 1 then
		--TBD
	elseif #root == 2 then
		vowel = root[1]
	else
		table.remove(root,#root)
		vowel = root[#root]
		table.remove(root,#root)
		head = table.concat(root)
	end
	
	if #tail == 1 then
		patterns = NOMOD_PATTERNS
	elseif #tail == 2 then
		patterns = ONEMOD_PATTERNS
	elseif #tail == 3 then
		patterns = TWOMOD_PATTERNS
	end
	
	for k,v in pairs(patterns) do
		forms[k] = string.gsub(v,"C",head)
		forms[k] = string.gsub(forms[k],"V",vowel)
		forms[k] = string.gsub(forms[k],"1",tail[1])
		forms[k] = string.gsub(forms[k],"2",tail[2] or '')
		forms[k] = string.gsub(forms[k],"3",tail[3] or '')
	end

	for k,v in pairs(forms) do
		forms[k] = m_cu.assimilate(v)
	end
	
	for k,v in pairs(manual) do
		forms[k] = v
	end

	mw.logObject(forms)
	return forms
end

return export