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
Tag: Manual revert
 
(133 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- WORK-IN-PROGRESS
export = {}
--


p = {}
require("Module:Chak-verbs/format")
require("Module:Chak-verbs/new format")
require("Module:Chak-verbs/data")
require("Module:Chak-verbs/new data")
m_params = require("Module:Parameters")
m_vars = require("Module:Variables")
m_cu = require("Module:Chak-utilities")
m_stru = require("Module:String utilities")


FORMS = {
local lang = require("Module:Languages").getByCode("chak")
{'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 = {
function export.get_forms(root,mod,manual)
["imp.1s"] = 'ii',
mod = mod or ''
["perf.1s"] = 'ii',
["imp.2s"] = 'aash',
local forms = {}
["perf.2s"] = 'asha',
local patterns = {}
["imp.3s"] = 'aaha',
["perf.3s"] = 'aha',
local head = ""
["imp.1p"] = 'iim',
local vowel = ""
["perf.1p"] = 'imi',
local vowel2 = ""
["imp.2/3p"] = 'aak',
["perf.2/3p"] = 'aka',
local root = m_cu.parse_root(root..mod,true)
["imp.rels"] = 'aabit',
["perf.rels"] = 'abit',
local tail =  mw.text.split(root[#root],"-")
["imp.relp"] = 'aabet',
["perf.relp"] = 'abet',
if #root == 1 then
["imp.inf"] = 'a',
head = tail[1]
["perf.inf"] = 'aha',
vowel = 'a'
["imp"] = 'a',
table.remove(tail,1)
}
if #tail == 1 then
vowel2 = vowel
end
elseif #root == 2 then
vowel2 = root[1]
vowel = m_cu.degeminate_char(root[1])
else
table.remove(root,#root)
vowel2 = root[#root]
vowel = m_cu.degeminate_char(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],"E",vowel2)
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


CAUS_UNDERIVED_SUF = {
for k,v in pairs(forms) do
["imp.1s"] = 'uuyi',
forms[k] = m_cu.assimilate(v)
["perf.1s"] = 'uyi',
forms[k] = m_cu.prothetic(forms[k])
["imp.2s"] = 'uush',
end
["perf.2s"] = 'ushu',
["imp.3s"] = 'uuha',
for k,v in pairs(manual) do
["perf.3s"] = 'usha',
forms[k] = v
["imp.1p"] = 'uum',
end
["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 = {
mw.logObject(forms)
["imp.1s"] = 'aasii',
return forms
["perf.1s"] = 'asii',
end
["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 = {
function export.get_stems(root_str)
["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 = {
if root_str == nil then
["imp.1s"] = 'ii',
error("Root is required")
["perf.1s"] = 'ii',
end
["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 = {
root_str = string.gsub(root_str,"-","")
["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',
}


 
local stems = {}
 
local tail = {}
function p.getBaseStems (root1, root2)
local vowel = ''
local stems = {}
local root = m_cu.parse_root(root_str,true)
if root1 == nil then
if not root or #root == 0 then
error("First root is required")
error ("No root provided.")
end
elseif #root == 1 and string.find(root[1],"["..VOWELS.."]") then
error ("Invalid root: "..root_str)
elseif #root == 1 and string.find(root[1],"[^"..VOWELS.."]") then
tail =  mw.text.split(root[1],"-")
if #tail == 2 then
stems[1] = tail[1].."a"..tail[2]
stems[2] = tail[1].."a"..m_cu.geminate_char(tail[2])
elseif #tail == 3 then
stems[1] = 'a'..tail[1]..tail[2]..'aa'..tail[3]
stems[2] = tail[1]..'a'..tail[2]..tail[3]
stems[3] = tail[1]..'a'..m_cu.geminate_char(tail[2])..'uu'..tail[3]
stems[4] = tail[1]..'a'..m_cu.geminate_char(tail[2])..'u'..tail[3]
stems[5] = 'a'..tail[1]..tail[2]..'a'..tail[3]
elseif #tail == 4 then


if root2 == nil then
end
stems[1] = root1
stems[2] = root1..string.sub(root1,-1)
else
else
stems[1] = root1..'aa'..root2
local tail_str = root[#root]
stems[2] = root1..root2
tail = mw.text.split(tail_str,"-")
stems[3] = root1..string.sub(root1,-1).."uu"..root2
table.remove(root,#root)
stems[4] = root1..string.sub(root1,-1).."u"..root2
vowel = root[#root]
stems[5] = root1..'a'..root2
cond_vowel = m_cu.degeminate_char(m_cu.condense_vowels(vowel))
table.remove(root,#root)
concat_root = table.concat(root)
if #tail == 1 then
stems[1] = concat_root..vowel..tail[1]
stems[2] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])
elseif #tail == 2 then
stems[1] = concat_root..vowel..tail[1]..'aa'..tail[2]
stems[2] = concat_root..cond_vowel..tail[1]..tail[2]
stems[3] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'uu'..tail[2]
stems[4] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'u'..tail[2]
stems[5] = concat_root..vowel..tail[1]..'a'..tail[2]
elseif #tail == 3 then
stems[1] = concat_root..vowel..tail[1]..'aa'..tail[2]..'a'..tail[3]
stems[2] = concat_root..cond_vowel..tail[1]..tail[2]..'a'..tail[3]
stems[3] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'uu'..tail[2]..'u'..tail[3]
stems[4] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'u'..tail[2]..'u'..tail[3]
stems[5] = concat_root..vowel..tail[1]..'a'..tail[2]..'a'..tail[3]
end
if m_cu.is_geminate(root[1]) then
for i in ipairs(stems) do
stems[i] = vowel..stems[i]
end
end
end
end
 
return stems
return stems
end
end


function p.getForms(root1,root2,manual_stems)
function export.old_get_forms(root,mod,manual_stems,other_manual)


local std_stems = {}
local forms = {}
local caus_stems = {}
tail = mod or ''
local pass_stems = {}
baseStems = p.getBaseStems(root1,root2)
local stems = export.get_stems(root..tail)
--Overwrite stems with any specified
for i=1,5 do
if manual_stems[i] ~= nil then
stems[i] = manual_stems[i]
end
end


local full_form = ''


if root2 == nil then
if mod == nil or mod == '' then
-- Standard Stems
for _,form in ipairs(FORMS) do
std_stems["imp.1s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.1s"]
full_form = 'std.ipfv.'..form[1]
std_stems["perf.1s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.1s"]
forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
std_stems["imp.2s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.2s"]
full_form = 'std.pfv.'..form[1]
std_stems["perf.2s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.2s"]
forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
std_stems["imp.3s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.3s"]
full_form = 'caus.ipfv.'..form[1]
std_stems["perf.3s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.3s"]
forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
std_stems["imp.1p"] = baseStems[1]..STD_UNDERIVED_SUF["imp.1p"]
full_form = 'caus.pfv.'..form[1]
std_stems["perf.1p"] = baseStems[2]..STD_UNDERIVED_SUF["perf.1p"]
forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
std_stems["imp.2/3p"] = baseStems[1]..STD_UNDERIVED_SUF["imp.2/3p"]
full_form = 'pass.ipfv.'..form[1]
std_stems["perf.2/3p"] = baseStems[2]..STD_UNDERIVED_SUF["perf.2/3p"]
forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
std_stems["imp.rels"] = baseStems[1]..STD_UNDERIVED_SUF["imp.rels"]
full_form = 'pass.pfv.'..form[1]
std_stems["perf.rels"] = baseStems[2]..STD_UNDERIVED_SUF["perf.rels"]
forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
std_stems["imp.relp"] = baseStems[1]..STD_UNDERIVED_SUF["imp.relp"]
end
std_stems["perf.relp"] = baseStems[2]..STD_UNDERIVED_SUF["perf.relp"]
full_form = "std.imp"
std_stems["imp.inf"] = baseStems[1]..STD_UNDERIVED_SUF["imp.inf"]
forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
std_stems["perf.inf"] = baseStems[2]..STD_UNDERIVED_SUF["perf.inf"]
full_form = "caus.imp"
std_stems["imp"] = baseStems[1]..STD_UNDERIVED_SUF["imp"]
forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
-- Causative Stems
full_form = "pass.imp"
caus_stems["imp.1s"] = baseStems[1]..CAUS_UNDERIVED_SUF["imp.1s"]
forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
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
for _,form in ipairs(FORMS) do
std_stems["imp.1s"] = baseStems[1]..STD_DERIVED_SUF["imp.1s"]
full_form = 'std.ipfv.'..form[1]
std_stems["perf.1s"] = baseStems[2]..STD_DERIVED_SUF["perf.1s"]
forms[full_form] = stems[1]..MOD_SUFFIXES[full_form]
std_stems["imp.2s"] = baseStems[1]..STD_DERIVED_SUF["imp.2s"]
full_form = 'std.pfv.'..form[1]
std_stems["perf.2s"] = baseStems[2]..STD_DERIVED_SUF["perf.2s"]
forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
std_stems["imp.3s"] = baseStems[1]..STD_DERIVED_SUF["imp.3s"]
full_form = 'caus.ipfv.'..form[1]
std_stems["perf.3s"] = baseStems[2]..STD_DERIVED_SUF["perf.3s"]
forms[full_form] = stems[3]..MOD_SUFFIXES[full_form]
std_stems["imp.1p"] = baseStems[1]..STD_DERIVED_SUF["imp.1p"]
full_form = 'caus.pfv.'..form[1]
std_stems["perf.1p"] = baseStems[2]..STD_DERIVED_SUF["perf.1p"]
forms[full_form] = stems[4]..MOD_SUFFIXES[full_form]
std_stems["imp.2/3p"] = baseStems[1]..STD_DERIVED_SUF["imp.2/3p"]
full_form = 'pass.ipfv.'..form[1]
std_stems["perf.2/3p"] = baseStems[2]..STD_DERIVED_SUF["perf.2/3p"]
forms[full_form] = stems[1]..MOD_SUFFIXES[full_form]
std_stems["imp.rels"] = baseStems[1]..STD_DERIVED_SUF["imp.rels"]
full_form = 'pass.pfv.'..form[1]
std_stems["perf.rels"] = baseStems[2]..STD_DERIVED_SUF["perf.rels"]
forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
std_stems["imp.relp"] = baseStems[1]..STD_DERIVED_SUF["imp.relp"]
end
std_stems["perf.relp"] = baseStems[2]..STD_DERIVED_SUF["perf.relp"]
full_form = "std.imp"
std_stems["imp.inf"] = baseStems[5]..STD_DERIVED_SUF["imp.inf"]
forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
std_stems["perf.inf"] = baseStems[2]..STD_DERIVED_SUF["perf.inf"]
full_form = "caus.imp"
std_stems["imp"] = baseStems[2]..STD_DERIVED_SUF["imp"]
forms[full_form] = stems[4]..MOD_SUFFIXES[full_form]
-- Causative Stems
full_form = "pass.imp"
caus_stems["imp.1s"] = baseStems[3]..CAUS_DERIVED_SUF["imp.1s"]
forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
caus_stems["perf.1s"] = baseStems[4]..CAUS_DERIVED_SUF["perf.1s"]
caus_stems["imp.2s"] = baseStems[3]..CAUS_DERIVED_SUF["imp.2s"]
-- Overwriting standard and passive infinitives since they don't fit the patter,
caus_stems["perf.2s"] = baseStems[4]..CAUS_DERIVED_SUF["perf.2s"]
-- Bit of a hack I know.
caus_stems["imp.3s"] = baseStems[3]..CAUS_DERIVED_SUF["imp.3s"]
full_form = "std.ipfv.inf"
caus_stems["perf.3s"] = baseStems[4]..CAUS_DERIVED_SUF["perf.3s"]
forms[full_form] = stems[5]..MOD_SUFFIXES[full_form]
caus_stems["imp.1p"] = baseStems[3]..CAUS_DERIVED_SUF["imp.1p"]
full_form = "pass.ipfv.inf"
caus_stems["perf.1p"] = baseStems[4]..CAUS_DERIVED_SUF["perf.1p"]
forms[full_form] = stems[5]..MOD_SUFFIXES[full_form]
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
end
return std_stems, caus_stems, pass_stems
for k,v in pairs(forms) do
forms[k] = m_cu.assimilate(v)
end
for k,v in pairs(other_manual) do
if UNMOD_SUFFIXES[k] ~= nil then
forms[k] = v
end
end
return forms
end
end


function p.showConjugations(root1,root2)
function export.get_infinitives(root,mod,manual_stems,other_manual)


local std_forms = {}
--local stems = get_stems(root,mod)
local caus_forms = {}
tail = mod or ''
local pass_forms = {}
std_forms, caus_forms, pass_forms = p.getForms(root1,root2)
local stems = export.get_stems(root..tail)
for i=1,5 do
if manual_stems[i] ~= nil then
stems[i] = manual_stems[i]
end
end
local output = {}
local infinitives={}
table.insert(output,'{| class="wikitable\n ! !! colspan=2 | Standard !! colspan=2 | Causative !! colspan=2 | Passive\n')
if mod == nil then
table.insert(output,"|-\n! Form !! Imperfect !! Perfect !! Imperfect !! Perfect !! Imperfect !! Perfect\n")
infinitives["std.ipfv.inf"] = stems[1]..UNMOD_SUFFIXES["std.ipfv.inf"]
for _,v in ipairs(FORMS) do
infinitives["std.pfv.inf"] = stems[2]..UNMOD_SUFFIXES["std.pfv.inf"]
table.insert(output,"|-\n")
infinitives["caus.ipfv.inf"] = stems[2]..UNMOD_SUFFIXES["caus.ipfv.inf"]
table.insert(output,"| "..v[2].." || ".. std_forms["imp."..v[1]] .. " || " .. std_forms["perf."..v[1]].." ")
infinitives["caus.pfv.inf"] = stems[2]..UNMOD_SUFFIXES["caus.pfv.inf"]
table.insert(output,"|| ".. caus_forms["imp."..v[1]] .. " || " .. caus_forms["perf."..v[1]].." ")
infinitives["pass.ipfv.inf"] = stems[1]..UNMOD_SUFFIXES["pass.ipfv.inf"]
table.insert(output,"|| ".. pass_forms["imp."..v[1]] .. " || " .. pass_forms["perf."..v[1]].."\n")
infinitives["pass.pfv.inf"] = stems[2]..UNMOD_SUFFIXES["pass.pfv.inf"]
else
infinitives["std.ipfv.inf"] = stems[5]..MOD_SUFFIXES["std.ipfv.inf"]
infinitives["std.pfv.inf"] = stems[2]..MOD_SUFFIXES["std.pfv.inf"]
infinitives["caus.ipfv.inf"] = stems[3]..MOD_SUFFIXES["caus.ipfv.inf"]
infinitives["caus.pfv.inf"] = stems[4]..MOD_SUFFIXES["caus.pfv.inf"]
infinitives["pass.ipfv.inf"] = stems[5]..MOD_SUFFIXES["pass.ipfv.inf"]
infinitives["pass.pfv.inf"] = stems[2]..MOD_SUFFIXES["pass.pfv.inf"]
end
 
for k,v in pairs(infinitives) do
infinitives[k] = m_cu.assimilate(v)
end
 
for k,v in pairs(other_manual) do
if UNMOD_SUFFIXES[k] ~= nil then
infinitives[k] = v
end
end
end
table.insert(output,"|-\n")
 
table.insert(output,"| Imperative || ".. std_forms["imp"] .. " || ")
return infinitives
table.insert(output,"|| ".. caus_forms["imp"] .. " || " )
end
table.insert(output,"|| ".. pass_forms["imp"] .. " ||  \n")
 
table.insert(output,"|}")
function link(word)
local data = {
["term"] = word,
["lang"] = lang
}
return require("Module:Links").full_link(data,nil,false)
return table.concat(output)
end
 
function export.show_conjugations(root,mod,others)
 
local forms = {}
 
forms = export.get_forms(root,mod,others)
 
return m_stru.format(new_conj_table,forms)
end
end


function p.test1()
function export.conjugations(frame)
return p.showConjugations("shun",nil)
 
local params = {
[1] = {alias_of = "root"},
[2] = {alias_of = "mod"},
["root"] = { default = m_vars.var('chak-root') },
["mod"] = { default = m_vars.var('chak-mod') },
["stem"] = {list = true, require_index = true, allow_holes = true},
}
 
local frame_args = frame:getParent().args
local args,others = m_params.process(frame_args,params,true)
local stems = {}
for i=1,5 do
stems[i] = args["stem"][i]
end
return export.show_conjugations(args["root"],args["mod"],others)
end
end


function p.test2()
function export.headword(frame)
return p.showConjugations("nak","l")
 
local params = {
[1] = {alias_of = "root"},
[2] = {alias_of = "mod"},
["root"] = { default = m_vars.var('chak-root') },
["mod"] = { default = m_vars.var('chak-mod') },
}
 
local frame_args = frame:getParent().args
local args,others = m_params.process(frame_args,params,true)
 
if args["mod"] == '' then
args["mod"] = nil
end
infinitives = export.get_infinitives(args["root"],args["mod"],{},others)
 
local output = ""
output = output.."''(perfect infinitive'' "..link(infinitives["std.pfv.inf"])
output = output..", ''causative infinitives'' "..link(infinitives["caus.ipfv.inf"]).." / "..link(infinitives["caus.pfv.inf"])
    output = output..", ''passive infinitives'' "..link(infinitives["pass.ipfv.inf"]).." / "..link(infinitives["pass.pfv.inf"])
output = output.."'')''"
return output
end
end
 
return export
return p

Latest revision as of 14:48, 21 July 2024

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

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


export = {} 

require("Module:Chak-verbs/format")
require("Module:Chak-verbs/new format")
require("Module:Chak-verbs/data")
require("Module:Chak-verbs/new data")
m_params = require("Module:Parameters")
m_vars = require("Module:Variables")
m_cu = require("Module:Chak-utilities")
m_stru = require("Module:String utilities")

local lang = require("Module:Languages").getByCode("chak")

function export.get_forms(root,mod,manual)
	mod = mod or ''
	
	local forms = {}
	local patterns = {}
	
	local head = ""
	local vowel = ""
	local vowel2 = ""
	
	local root = m_cu.parse_root(root..mod,true)
	
	local tail =  mw.text.split(root[#root],"-")
	
	if #root == 1 then
		head = tail[1]
		vowel = 'a'
		table.remove(tail,1)
		if #tail == 1 then
			vowel2 = vowel
		end
		
	elseif #root == 2 then
		vowel2 = root[1]
		vowel = m_cu.degeminate_char(root[1])
	else
		table.remove(root,#root)
		vowel2 = root[#root]
		vowel = m_cu.degeminate_char(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],"E",vowel2)
		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)
		forms[k] = m_cu.prothetic(forms[k])
	end
	
	for k,v in pairs(manual) do
		forms[k] = v
	end

	mw.logObject(forms)
	return forms
end

function export.get_stems(root_str)

	if root_str == nil then
		error("Root is required")
	end

	root_str = string.gsub(root_str,"-","")

	local stems = {}
	local tail = {}
	local vowel = ''
	
	local root = m_cu.parse_root(root_str,true)
	
	if not root or #root == 0 then
		error ("No root provided.")
	elseif #root == 1 and string.find(root[1],"["..VOWELS.."]") then
		error ("Invalid root: "..root_str)
	elseif #root == 1 and string.find(root[1],"[^"..VOWELS.."]") then
		tail =  mw.text.split(root[1],"-")
		if #tail == 2 then
			stems[1] = tail[1].."a"..tail[2]
			stems[2] = tail[1].."a"..m_cu.geminate_char(tail[2])
		elseif #tail == 3 then
			stems[1] = 'a'..tail[1]..tail[2]..'aa'..tail[3]
			stems[2] = tail[1]..'a'..tail[2]..tail[3]
			stems[3] = tail[1]..'a'..m_cu.geminate_char(tail[2])..'uu'..tail[3]
			stems[4] = tail[1]..'a'..m_cu.geminate_char(tail[2])..'u'..tail[3]
			stems[5] = 'a'..tail[1]..tail[2]..'a'..tail[3]
		elseif #tail == 4 then

		end
	else
		local tail_str = root[#root]
		tail = mw.text.split(tail_str,"-")
		table.remove(root,#root)
		vowel = root[#root]
		cond_vowel = m_cu.degeminate_char(m_cu.condense_vowels(vowel))
		table.remove(root,#root)
		concat_root = table.concat(root)
	
		if #tail == 1 then
			stems[1] = concat_root..vowel..tail[1]
			stems[2] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])
		elseif #tail == 2 then
			stems[1] = concat_root..vowel..tail[1]..'aa'..tail[2]
			stems[2] = concat_root..cond_vowel..tail[1]..tail[2]
			stems[3] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'uu'..tail[2]
			stems[4] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'u'..tail[2]
			stems[5] = concat_root..vowel..tail[1]..'a'..tail[2]
		elseif #tail == 3 then
			stems[1] = concat_root..vowel..tail[1]..'aa'..tail[2]..'a'..tail[3]
			stems[2] = concat_root..cond_vowel..tail[1]..tail[2]..'a'..tail[3]
			stems[3] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'uu'..tail[2]..'u'..tail[3]
			stems[4] = concat_root..cond_vowel..m_cu.geminate_char(tail[1])..'u'..tail[2]..'u'..tail[3]
			stems[5] = concat_root..vowel..tail[1]..'a'..tail[2]..'a'..tail[3]
		end
		
		if m_cu.is_geminate(root[1]) then
			for i in ipairs(stems) do
				stems[i] = vowel..stems[i]
			end
		end
	end
	
	return stems
	
end

function export.old_get_forms(root,mod,manual_stems,other_manual)

	local forms = {}
	tail = mod or ''
	
	
	local stems = export.get_stems(root..tail)
	
	--Overwrite stems with any specified
	for i=1,5 do
		if manual_stems[i] ~= nil then
			stems[i] = manual_stems[i]
		end
	end

	local full_form = ''

	if mod == nil or mod == '' then
			for _,form in ipairs(FORMS) do
					full_form = 'std.ipfv.'..form[1]
					forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
					full_form = 'std.pfv.'..form[1]
					forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
					full_form = 'caus.ipfv.'..form[1]
					forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
					full_form = 'caus.pfv.'..form[1]
					forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
					full_form = 'pass.ipfv.'..form[1]
					forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
					full_form = 'pass.pfv.'..form[1]
					forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
			end
			full_form = "std.imp"
			forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
			full_form = "caus.imp"
			forms[full_form] = stems[2]..UNMOD_SUFFIXES[full_form]
			full_form = "pass.imp"
			forms[full_form] = stems[1]..UNMOD_SUFFIXES[full_form]
	else
			for _,form in ipairs(FORMS) do
					full_form = 'std.ipfv.'..form[1]
					forms[full_form] = stems[1]..MOD_SUFFIXES[full_form]
					full_form = 'std.pfv.'..form[1]
					forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
					full_form = 'caus.ipfv.'..form[1]
					forms[full_form] = stems[3]..MOD_SUFFIXES[full_form]
					full_form = 'caus.pfv.'..form[1]
					forms[full_form] = stems[4]..MOD_SUFFIXES[full_form]
					full_form = 'pass.ipfv.'..form[1]
					forms[full_form] = stems[1]..MOD_SUFFIXES[full_form]
					full_form = 'pass.pfv.'..form[1]
					forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
			end
			full_form = "std.imp"
			forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
			full_form = "caus.imp"
			forms[full_form] = stems[4]..MOD_SUFFIXES[full_form]
			full_form = "pass.imp"
			forms[full_form] = stems[2]..MOD_SUFFIXES[full_form]
			
			-- Overwriting standard and passive infinitives since they don't fit the patter,
			-- Bit of a hack I know.
			full_form = "std.ipfv.inf"
			forms[full_form] = stems[5]..MOD_SUFFIXES[full_form]
			full_form = "pass.ipfv.inf"
			forms[full_form] = stems[5]..MOD_SUFFIXES[full_form]
	end
	
	for k,v in pairs(forms) do
		forms[k] = m_cu.assimilate(v)
	end
	
	for k,v in pairs(other_manual) do
		if UNMOD_SUFFIXES[k] ~= nil then
			forms[k] = v
		end		
	end
	return forms
end

function export.get_infinitives(root,mod,manual_stems,other_manual)

	--local stems = get_stems(root,mod)
	tail = mod or ''
	
	local stems = export.get_stems(root..tail)
	for i=1,5 do
		if manual_stems[i] ~= nil then
			stems[i] = manual_stems[i]
		end
	end
	
	local infinitives={}
	
	if mod == nil then
		infinitives["std.ipfv.inf"] = stems[1]..UNMOD_SUFFIXES["std.ipfv.inf"]
		infinitives["std.pfv.inf"] = stems[2]..UNMOD_SUFFIXES["std.pfv.inf"]
		infinitives["caus.ipfv.inf"] = stems[2]..UNMOD_SUFFIXES["caus.ipfv.inf"]
		infinitives["caus.pfv.inf"] = stems[2]..UNMOD_SUFFIXES["caus.pfv.inf"]
		infinitives["pass.ipfv.inf"] = stems[1]..UNMOD_SUFFIXES["pass.ipfv.inf"]
		infinitives["pass.pfv.inf"] = stems[2]..UNMOD_SUFFIXES["pass.pfv.inf"]
	else
		infinitives["std.ipfv.inf"] = stems[5]..MOD_SUFFIXES["std.ipfv.inf"]
		infinitives["std.pfv.inf"] = stems[2]..MOD_SUFFIXES["std.pfv.inf"]
		infinitives["caus.ipfv.inf"] = stems[3]..MOD_SUFFIXES["caus.ipfv.inf"]
		infinitives["caus.pfv.inf"] = stems[4]..MOD_SUFFIXES["caus.pfv.inf"]
		infinitives["pass.ipfv.inf"] = stems[5]..MOD_SUFFIXES["pass.ipfv.inf"]
		infinitives["pass.pfv.inf"] = stems[2]..MOD_SUFFIXES["pass.pfv.inf"]
	end

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

	for k,v in pairs(other_manual) do
		if UNMOD_SUFFIXES[k] ~= nil then
			infinitives[k] = v
		end		
	end

	return infinitives
end

function link(word)
	local data = {
		["term"] = word,
		["lang"] = lang
	}
	return require("Module:Links").full_link(data,nil,false)
	
end

function export.show_conjugations(root,mod,others)

	local forms = {}

	forms = export.get_forms(root,mod,others)

	return m_stru.format(new_conj_table,forms)
	
end

function export.conjugations(frame)

	local params = {
		[1] = {alias_of = "root"},
		[2] = {alias_of = "mod"},
		["root"] = { default = m_vars.var('chak-root') },
		["mod"] = { default = m_vars.var('chak-mod') },
		["stem"] = {list = true, require_index = true, allow_holes = true},
	}

	local frame_args = frame:getParent().args
	local args,others = m_params.process(frame_args,params,true)
	
	local stems = {}
	for i=1,5 do
		stems[i] = args["stem"][i]
	end
	
	return export.show_conjugations(args["root"],args["mod"],others)
	
end

function export.headword(frame)

	local params = {
		[1] = {alias_of = "root"},
		[2] = {alias_of = "mod"},
		["root"] = { default = m_vars.var('chak-root') },
		["mod"] = { default = m_vars.var('chak-mod') },
	}

	local frame_args = frame:getParent().args
	local args,others = m_params.process(frame_args,params,true)

	if args["mod"] == '' then
		args["mod"] = nil
	end
	
	infinitives = export.get_infinitives(args["root"],args["mod"],{},others)

	local output = ""
	output = output.."''(perfect infinitive'' "..link(infinitives["std.pfv.inf"])
	output = output..", ''causative infinitives'' "..link(infinitives["caus.ipfv.inf"]).." / "..link(infinitives["caus.pfv.inf"])
    output = output..", ''passive infinitives'' "..link(infinitives["pass.ipfv.inf"]).." / "..link(infinitives["pass.pfv.inf"])
	output = output.."'')''"
	
	return output
end
return export