Module:Chak-verbs: Difference between revisions

From The Languages of David J. Peterson
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
p = {}
p = {}


FORMS = {
require("Module:Chak-verbs/data")
{'1s','1st Singular'},
{'2s','2nd Singular'},
{'3s','3rd Singular'},
{'1p','1st Plural'},
{'2/3p','2nd/3rd Plural'},
{'rels','Rel. Singular'},
{'relp','Rel. Plural'},
{'inf','Infinitive'},
}
 
STD_UNDERIVED_SUF = {
["imp.1s"] = 'ii',
["perf.1s"] = 'ii',
["imp.2s"] = 'aash',
["perf.2s"] = 'asha',
["imp.3s"] = 'aaha',
["perf.3s"] = 'aha',
["imp.1p"] = 'iim',
["perf.1p"] = 'imi',
["imp.2/3p"] = 'aak',
["perf.2/3p"] = 'aka',
["imp.rels"] = 'aabit',
["perf.rels"] = 'abit',
["imp.relp"] = 'aabet',
["perf.relp"] = 'abet',
["imp.inf"] = 'a',
["perf.inf"] = 'aha',
["imp"] = 'a',
}
 
CAUS_UNDERIVED_SUF = {
["imp.1s"] = 'uuyi',
["perf.1s"] = 'uyi',
["imp.2s"] = 'uush',
["perf.2s"] = 'ushu',
["imp.3s"] = 'uuha',
["perf.3s"] = 'usha',
["imp.1p"] = 'uum',
["perf.1p"] = 'umu',
["imp.2/3p"] = 'uuk',
["perf.2/3p"] = 'uku',
["imp.rels"] = 'uubit',
["perf.rels"] = 'ubit',
["imp.relp"] = 'uubet',
["perf.relp"] = 'ubet',
["imp.inf"] = 'u',
["perf.inf"] = 'uvu',
["imp"] = 'u',
}
 
PASS_UNDERIVED_SUF = {
["imp.1s"] = 'aasii',
["perf.1s"] = 'asii',
["imp.2s"] = 'aasash',
["perf.2s"] = 'asash',
["imp.3s"] = 'aasha',
["perf.3s"] = 'asha',
["imp.1p"] = 'aasim',
["perf.1p"] = 'asim',
["imp.2/3p"] = 'aasak',
["perf.2/3p"] = 'asak',
["imp.rels"] = 'aasbit',
["perf.rels"] = 'asbit',
["imp.relp"] = 'aasbet',
["perf.relp"] = 'asbet',
["imp.inf"] = 'as',
["perf.inf"] = 'asa',
["imp"] = 'as',
}
 
STD_DERIVED_SUF = {
["imp.1s"] = 'ii',
["perf.1s"] = 'ii',
["imp.2s"] = 'ash',
["perf.2s"] = 'asha',
["imp.3s"] = 'aha',
["perf.3s"] = 'aha',
["imp.1p"] = 'im',
["perf.1p"] = 'imi',
["imp.2/3p"] = 'ak',
["perf.2/3p"] = 'aka',
["imp.rels"] = 'abit',
["perf.rels"] = 'abit',
["imp.relp"] = 'abet',
["perf.relp"] = 'abet',
["imp.inf"] = 'a',
["perf.inf"] = 'aha',
["imp"] = 'a',
}
 
CAUS_DERIVED_SUF = {
["imp.1s"] = 'ii',
["perf.1s"] = 'ii',
["imp.2s"] = 'ash',
["perf.2s"] = 'ash',
["imp.3s"] = 'aha',
["perf.3s"] = 'ha',
["imp.1p"] = 'im',
["perf.1p"] = 'im',
["imp.2/3p"] = 'ak',
["perf.2/3p"] = 'ak',
["imp.rels"] = 'abit',
["perf.rels"] = 'bit',
["imp.relp"] = 'abet',
["perf.relp"] = 'bet',
["imp.inf"] = '',
["perf.inf"] = 'u',
["imp"] = '',
}
 
PASS_DERIVED_SUF = {
["imp.1s"] = 'asii',
["perf.1s"] = 'asii',
["imp.2s"] = 'asash',
["perf.2s"] = 'asash',
["imp.3s"] = 'asha',
["perf.3s"] = 'asha',
["imp.1p"] = 'asim',
["perf.1p"] = 'asim',
["imp.2/3p"] = 'asak',
["perf.2/3p"] = 'asak',
["imp.rels"] = 'asbit',
["perf.rels"] = 'asbit',
["imp.relp"] = 'asbet',
["perf.relp"] = 'asbet',
["imp.inf"] = 'as',
["perf.inf"] = 'asa',
["imp"] = 'as',
}
 
 


function p.getBaseStems (root1, root2)
function p.getBaseStems (root1, root2)
Line 161: Line 30:
function p.getForms(root1,root2,manual_stems)
function p.getForms(root1,root2,manual_stems)


local std_stems = {}
local forms = {}
local caus_stems = {}
local pass_stems = {}
baseStems = p.getBaseStems(root1,root2)
local baseStems = p.getBaseStems(root1,root2)


local full_form = ''


if root2 == nil then
if root2 == nil then
-- Standard Stems
for _,conj in ipairs(CONJUGATIONS) do
std_stems["imp.1s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.1s"]
for _,form in ipairs(FORMS) do
std_stems["perf.1s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.1s"]
full_form = conj[1]..'.ipfv.'..form[1]
std_stems["imp.2s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.2s"]
forms[full_form] = baseStems[1]..UNMOD_SUFFIXES[full_form]
std_stems["perf.2s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.2s"]
full_form = conj[1]..'.pfv.'..form[1]
std_stems["imp.3s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.3s"]
forms[full_form] = baseStems[2]..UNMOD_SUFFIXES[full_form]
std_stems["perf.3s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.3s"]
end
std_stems["imp.1p"] = baseStems[1]..STD_UNDERIVED_SUF["imp.1p"]
full_form = conj[1]..".imp"
std_stems["perf.1p"] = baseStems[2]..STD_UNDERIVED_SUF["perf.1p"]
forms[full_form] = baseStems[1]..UNMOD_SUFFIXES[full_form]
std_stems["imp.2/3p"] = baseStems[1]..STD_UNDERIVED_SUF["imp.2/3p"]
end
std_stems["perf.2/3p"] = baseStems[2]..STD_UNDERIVED_SUF["perf.2/3p"]
std_stems["imp.rels"] = baseStems[1]..STD_UNDERIVED_SUF["imp.rels"]
std_stems["perf.rels"] = baseStems[2]..STD_UNDERIVED_SUF["perf.rels"]
std_stems["imp.relp"] = baseStems[1]..STD_UNDERIVED_SUF["imp.relp"]
std_stems["perf.relp"] = baseStems[2]..STD_UNDERIVED_SUF["perf.relp"]
std_stems["imp.inf"] = baseStems[1]..STD_UNDERIVED_SUF["imp.inf"]
std_stems["perf.inf"] = baseStems[2]..STD_UNDERIVED_SUF["perf.inf"]
std_stems["imp"] = baseStems[1]..STD_UNDERIVED_SUF["imp"]
-- Causative Stems
caus_stems["imp.1s"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.1s"]
caus_stems["perf.1s"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.1s"]
caus_stems["imp.2s"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.2s"]
caus_stems["perf.2s"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.2s"]
caus_stems["imp.3s"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.3s"]
caus_stems["perf.3s"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.3s"]
caus_stems["imp.1p"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.1p"]
caus_stems["perf.1p"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.1p"]
caus_stems["imp.2/3p"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.2/3p"]
caus_stems["perf.2/3p"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.2/3p"]
caus_stems["imp.rels"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.rels"]
caus_stems["perf.rels"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.rels"]
caus_stems["imp.relp"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.relp"]
caus_stems["perf.relp"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.relp"]
caus_stems["imp.inf"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.inf"]
caus_stems["perf.inf"] = baseStems[2]..CAUS_UNDERIVED_SUF["perf.inf"]
caus_stems["imp"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp"]
-- Passive Stems
pass_stems["imp.1s"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.1s"]
pass_stems["perf.1s"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.1s"]
pass_stems["imp.2s"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.2s"]
pass_stems["perf.2s"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.2s"]
pass_stems["imp.3s"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.3s"]
pass_stems["perf.3s"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.3s"]
pass_stems["imp.1p"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.1p"]
pass_stems["perf.1p"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.1p"]
pass_stems["imp.2/3p"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.2/3p"]
pass_stems["perf.2/3p"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.2/3p"]
pass_stems["imp.rels"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.rels"]
pass_stems["perf.rels"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.rels"]
pass_stems["imp.relp"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.relp"]
pass_stems["perf.relp"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.relp"]
pass_stems["imp.inf"] = baseStems[1]..PASS_UNDERIVED_SUF["imp.inf"]
pass_stems["perf.inf"] = baseStems[2]..PASS_UNDERIVED_SUF["perf.inf"]
pass_stems["imp"] = baseStems[1]..PASS_UNDERIVED_SUF["imp"]
else
else
-- Standard stems
-- Standard stems
Line 280: Line 104:
end
end
return std_stems, caus_stems, pass_stems
return forms
end
end


function p.showConjugations(root1,root2)
function p.showConjugations(root1,root2)


local forms = {}
local std_forms = {}
local std_forms = {}
local caus_forms = {}
local caus_forms = {}
local pass_forms = {}
local pass_forms = {}
std_forms, caus_forms, pass_forms = p.getForms(root1,root2)
forms = p.getForms(root1,root2)
local output = {}
local output = {}
Line 297: Line 122:
for _,v in ipairs(FORMS) do
for _,v in ipairs(FORMS) do
table.insert(output,"|-\n")
table.insert(output,"|-\n")
table.insert(output,"| "..v[2].." || ".. std_forms["imp."..v[1]] .. " || " .. std_forms["perf."..v[1]].." ")
table.insert(output,"| "..v[2].." || ".. forms["std.ipfv."..v[1]] .. " || " .. forms["std.pfv."..v[1]].." ")
table.insert(output,"|| ".. caus_forms["imp."..v[1]] .. " || " .. caus_forms["perf."..v[1]].." ")
table.insert(output,"|| ".. forms["caus.ipfv."..v[1]] .. " || " .. forms["caus.pfv."..v[1]].." ")
table.insert(output,"|| ".. pass_forms["imp."..v[1]] .. " || " .. pass_forms["perf."..v[1]].."\n")
table.insert(output,"|| ".. forms["pass.ipfv."..v[1]] .. " || " .. forms["pass.pfv."..v[1]].."\n")
end
end
table.insert(output,"|-\n")
table.insert(output,"|-\n")
table.insert(output,"| Imperative || ".. std_forms["imp"] .. " || ")
table.insert(output,"| Imperative || ".. forms["std.imp"] .. " || ")
table.insert(output,"|| ".. caus_forms["imp"] .. " || " )
table.insert(output,"|| ".. forms["caus.imp"] .. " || " )
table.insert(output,"|| ".. pass_forms["imp"] .. " ||  \n")
table.insert(output,"|| ".. forms["pass.imp"] .. " ||  \n")
table.insert(output,"|}")
table.insert(output,"|}")

Revision as of 09:55, 16 October 2023

Implements {{chak-verb}} and {{chak-conj}}

Note: Formatting for tables is defined in Module:Chak-verbs/format.


-- WORK-IN-PROGRESS
--

p = {}

require("Module:Chak-verbs/data")

function p.getBaseStems (root1, root2)
	
	local stems = {}
	
	if root1 == nil then
		error("First root is required")
	end

	if root2 == nil then
		stems[1] = root1
		stems[2] = root1..string.sub(root1,-1)
	else
		stems[1] = root1..'aa'..root2
		stems[2] = root1..root2
		stems[3] = root1..string.sub(root1,-1).."uu"..root2
		stems[4] = root1..string.sub(root1,-1).."u"..root2
		stems[5] = root1..'a'..root2
	end

	return stems
end	

function p.getForms(root1,root2,manual_stems)

	local forms = {}
	
	local baseStems = p.getBaseStems(root1,root2)

	local full_form = ''

	if root2 == nil then
		for _,conj in ipairs(CONJUGATIONS) do
			for _,form in ipairs(FORMS) do
					full_form = conj[1]..'.ipfv.'..form[1]
					forms[full_form] = baseStems[1]..UNMOD_SUFFIXES[full_form]
					full_form = conj[1]..'.pfv.'..form[1]
					forms[full_form] = baseStems[2]..UNMOD_SUFFIXES[full_form]
			end
			full_form = conj[1]..".imp"
			forms[full_form] = baseStems[1]..UNMOD_SUFFIXES[full_form]
		end
	else
		-- Standard stems
		std_stems["imp.1s"] = baseStems[1]..STD_DERIVED_SUF["imp.1s"]
		std_stems["perf.1s"] = baseStems[2]..STD_DERIVED_SUF["perf.1s"]
		std_stems["imp.2s"] = baseStems[1]..STD_DERIVED_SUF["imp.2s"]
		std_stems["perf.2s"] = baseStems[2]..STD_DERIVED_SUF["perf.2s"]
		std_stems["imp.3s"] = baseStems[1]..STD_DERIVED_SUF["imp.3s"]
		std_stems["perf.3s"] = baseStems[2]..STD_DERIVED_SUF["perf.3s"]
		std_stems["imp.1p"] = baseStems[1]..STD_DERIVED_SUF["imp.1p"]
		std_stems["perf.1p"] = baseStems[2]..STD_DERIVED_SUF["perf.1p"]
		std_stems["imp.2/3p"] = baseStems[1]..STD_DERIVED_SUF["imp.2/3p"]
		std_stems["perf.2/3p"] = baseStems[2]..STD_DERIVED_SUF["perf.2/3p"]
		std_stems["imp.rels"] = baseStems[1]..STD_DERIVED_SUF["imp.rels"]
		std_stems["perf.rels"] = baseStems[2]..STD_DERIVED_SUF["perf.rels"]
		std_stems["imp.relp"] = baseStems[1]..STD_DERIVED_SUF["imp.relp"]
		std_stems["perf.relp"] = baseStems[2]..STD_DERIVED_SUF["perf.relp"]
		std_stems["imp.inf"] = baseStems[5]..STD_DERIVED_SUF["imp.inf"]
		std_stems["perf.inf"] = baseStems[2]..STD_DERIVED_SUF["perf.inf"]
		std_stems["imp"] = baseStems[2]..STD_DERIVED_SUF["imp"]
		-- Causative Stems
		caus_stems["imp.1s"] = baseStems[3]..CAUS_DERIVED_SUF["imp.1s"]
		caus_stems["perf.1s"] = baseStems[4]..CAUS_DERIVED_SUF["perf.1s"]
		caus_stems["imp.2s"] = baseStems[3]..CAUS_DERIVED_SUF["imp.2s"]
		caus_stems["perf.2s"] = baseStems[4]..CAUS_DERIVED_SUF["perf.2s"]
		caus_stems["imp.3s"] = baseStems[3]..CAUS_DERIVED_SUF["imp.3s"]
		caus_stems["perf.3s"] = baseStems[4]..CAUS_DERIVED_SUF["perf.3s"]
		caus_stems["imp.1p"] = baseStems[3]..CAUS_DERIVED_SUF["imp.1p"]
		caus_stems["perf.1p"] = baseStems[4]..CAUS_DERIVED_SUF["perf.1p"]
		caus_stems["imp.2/3p"] = baseStems[3]..CAUS_DERIVED_SUF["imp.2/3p"]
		caus_stems["perf.2/3p"] = baseStems[4]..CAUS_DERIVED_SUF["perf.2/3p"]
		caus_stems["imp.rels"] = baseStems[3]..CAUS_DERIVED_SUF["imp.rels"]
		caus_stems["perf.rels"] = baseStems[4]..CAUS_DERIVED_SUF["perf.rels"]
		caus_stems["imp.relp"] = baseStems[3]..CAUS_DERIVED_SUF["imp.relp"]
		caus_stems["perf.relp"] = baseStems[4]..CAUS_DERIVED_SUF["perf.relp"]
		caus_stems["imp.inf"] = baseStems[3]..CAUS_DERIVED_SUF["imp.inf"]
		caus_stems["perf.inf"] = baseStems[4]..CAUS_DERIVED_SUF["perf.inf"]
		caus_stems["imp"] = baseStems[4]..CAUS_DERIVED_SUF["imp"]
		-- Passive Stems
		pass_stems["imp.1s"] = baseStems[1]..PASS_DERIVED_SUF["imp.1s"]
		pass_stems["perf.1s"] = baseStems[2]..PASS_DERIVED_SUF["perf.1s"]
		pass_stems["imp.2s"] = baseStems[1]..PASS_DERIVED_SUF["imp.2s"]
		pass_stems["perf.2s"] = baseStems[2]..PASS_DERIVED_SUF["perf.2s"]
		pass_stems["imp.3s"] = baseStems[1]..PASS_DERIVED_SUF["imp.3s"]
		pass_stems["perf.3s"] = baseStems[2]..PASS_DERIVED_SUF["perf.3s"]
		pass_stems["imp.1p"] = baseStems[1]..PASS_DERIVED_SUF["imp.1p"]
		pass_stems["perf.1p"] = baseStems[2]..PASS_DERIVED_SUF["perf.1p"]
		pass_stems["imp.2/3p"] = baseStems[1]..PASS_DERIVED_SUF["imp.2/3p"]
		pass_stems["perf.2/3p"] = baseStems[2]..PASS_DERIVED_SUF["perf.2/3p"]
		pass_stems["imp.rels"] = baseStems[1]..PASS_DERIVED_SUF["imp.rels"]
		pass_stems["perf.rels"] = baseStems[2]..PASS_DERIVED_SUF["perf.rels"]
		pass_stems["imp.relp"] = baseStems[1]..PASS_DERIVED_SUF["imp.relp"]
		pass_stems["perf.relp"] = baseStems[2]..PASS_DERIVED_SUF["perf.relp"]
		pass_stems["imp.inf"] = baseStems[5]..PASS_DERIVED_SUF["imp.inf"]
		pass_stems["perf.inf"] = baseStems[2]..PASS_DERIVED_SUF["perf.inf"]
		pass_stems["imp"] = baseStems[2]..PASS_DERIVED_SUF["imp"]
	end
	
	return forms
end

function p.showConjugations(root1,root2)

	local forms = {}
	local std_forms = {}
	local caus_forms = {}
	local pass_forms = {}
	
	forms = p.getForms(root1,root2)
	
	local output = {}
	
	table.insert(output,'{| class="wikitable\n ! !! colspan=2 | Standard !! colspan=2 | Causative !! colspan=2 | Passive\n') 
	table.insert(output,"|-\n! Form !! Imperfect !! Perfect !! Imperfect !! Perfect !! Imperfect !! Perfect\n")
	for _,v in ipairs(FORMS) do
		table.insert(output,"|-\n")
		table.insert(output,"| "..v[2].." || ".. forms["std.ipfv."..v[1]] .. " || " .. forms["std.pfv."..v[1]].." ")
		table.insert(output,"|| ".. forms["caus.ipfv."..v[1]] .. " || " .. forms["caus.pfv."..v[1]].." ")
		table.insert(output,"|| ".. forms["pass.ipfv."..v[1]] .. " || " .. forms["pass.pfv."..v[1]].."\n")
	end
		table.insert(output,"|-\n")
		table.insert(output,"| Imperative || ".. forms["std.imp"] .. " || ")
		table.insert(output,"|| ".. forms["caus.imp"] .. " || " )
		table.insert(output,"|| ".. forms["pass.imp"] .. " ||  \n")
	table.insert(output,"|}")
	
	return table.concat(output)
	
end

function p.test1()
	return p.showConjugations("shun",nil)
end

function p.test2()
	return p.showConjugations("nak","l")
end

return p