Module:Chak-verbs: Difference between revisions

From The Languages of David J. Peterson
Jump to navigation Jump to search
(Created page with "-- WORK-IN-PROGRESS -- p = {} FORMS = { {'1s','1st Singular'}, {'2s','2nd Singular'}, {'3s','3rd Singular'}, {'1p','1st Plural'}, {'2/3p','2nd/3rd Plural'}, {'r...")
 
No edit summary
Tag: Manual revert
 
(135 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
 
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


CAUS_UNDERIVED_SUF = {
mw.logObject(forms)
["imp.1s"] = 'uuyi',
return forms
["perf.1s"] = 'uyi',
end
["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 = {
function export.get_stems(root_str)
["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 = {
if root_str == nil then
["imp.1s"] = 'ii',
error("Root is required")
["perf.1s"] = 'ii',
end
["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 = {
root_str = string.gsub(root_str,"-","")
["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 = {
local stems = {}
["imp.1s"] = 'asii',
local tail = {}
["perf.1s"] = 'asii',
local vowel = ''
["imp.2s"] = 'asash',
["perf.2s"] = 'asash',
local root = m_cu.parse_root(root_str,true)
["imp.3s"] = 'asha',
["perf.3s"] = 'asha',
if not root or #root == 0 then
["imp.1p"] = 'asim',
error ("No root provided.")
["perf.1p"] = 'asim',
elseif #root == 1 and string.find(root[1],"["..VOWELS.."]") then
["imp.2/3p"] = 'asak',
error ("Invalid root: "..root_str)
["perf.2/3p"] = 'asak',
elseif #root == 1 and string.find(root[1],"[^"..VOWELS.."]") then
["imp.rels"] = 'asbit',
tail = mw.text.split(root[1],"-")
["perf.rels"] = 'asbit',
if #tail == 2 then
["imp.relp"] = 'asbet',
stems[1] = tail[1].."a"..tail[2]
["perf.relp"] = 'asbet',
stems[2] = tail[1].."a"..m_cu.geminate_char(tail[2])
["imp.inf"] = 'as',
elseif #tail == 3 then
["perf.inf"] = 'asa',
stems[1] = 'a'..tail[1]..tail[2]..'aa'..tail[3]
["imp"] = 'as',
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)


function p.getBaseStems (root1, root2)
local forms = {}
tail = mod or ''
local stems = export.get_stems(root..tail)
local stems = {}
--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
if root1 == nil then
for k,v in pairs(other_manual) do
error("First root is required")
if UNMOD_SUFFIXES[k] ~= nil then
forms[k] = v
end
end
end
return forms
end
function export.get_infinitives(root,mod,manual_stems,other_manual)


if root2 == nil then
--local stems = get_stems(root,mod)
stems[1] = root1
tail = mod or ''
stems[2] = root1..string.sub(root1,-1)
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
else
stems[1] = root1..'aa'..root2
infinitives["std.ipfv.inf"] = stems[5]..MOD_SUFFIXES["std.ipfv.inf"]
stems[2] = root1..root2
infinitives["std.pfv.inf"] = stems[2]..MOD_SUFFIXES["std.pfv.inf"]
stems[3] = root1..string.sub(root1,-1).."uu"..root2
infinitives["caus.ipfv.inf"] = stems[3]..MOD_SUFFIXES["caus.ipfv.inf"]
stems[4] = root1..string.sub(root1,-1).."u"..root2
infinitives["caus.pfv.inf"] = stems[4]..MOD_SUFFIXES["caus.pfv.inf"]
stems[5] = root1..'a'..root2
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
end


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


function p.getForms(root1,root2,manual_stems)
return infinitives
end


local std_stems = {}
function link(word)
local caus_stems = {}
local data = {
local pass_stems = {}
["term"] = word,
["lang"] = lang
}
return require("Module:Links").full_link(data,nil,false)
baseStems = p.getBaseStems(root1,root2)
end
 
function export.show_conjugations(root,mod,others)
 
local forms = {}


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


if root2 == nil then
return m_stru.format(new_conj_table,forms)
-- Standard Stems
std_stems["imp.1s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.1s"]
std_stems["perf.1s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.1s"]
std_stems["imp.2s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.2s"]
std_stems["perf.2s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.2s"]
std_stems["imp.3s"] = baseStems[1]..STD_UNDERIVED_SUF["imp.3s"]
std_stems["perf.3s"] = baseStems[2]..STD_UNDERIVED_SUF["perf.3s"]
std_stems["imp.1p"] = baseStems[1]..STD_UNDERIVED_SUF["imp.1p"]
std_stems["perf.1p"] = baseStems[2]..STD_UNDERIVED_SUF["perf.1p"]
std_stems["imp.2/3p"] = baseStems[1]..STD_UNDERIVED_SUF["imp.2/3p"]
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
-- 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_UNDERIVED_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[5]..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 std_stems, caus_stems, pass_stems
end
end


function p.showConjugations()
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 std_forms = {}
local frame_args = frame:getParent().args
local caus_forms = {}
local args,others = m_params.process(frame_args,params,true)
local pass_forms = {}
std_forms, caus_forms, pass_forms = p.getForms('shun',nil)
local stems = {}
for i=1,5 do
stems[i] = args["stem"][i]
end
local output = {}
return export.show_conjugations(args["root"],args["mod"],others)
table.insert(output,'{| class="wikitable\n ! !! colspan=2 | Standard !! colspan=2 | Causative !! colspan=2 | Passive\n')  
end
table.insert(output,"|-\n! Form !! Imperfect !! Perfect !! Imperfect !! Perfect !! Imperfect !! Perfect\n")
 
for _,v in ipairs(FORMS) do
function export.headword(frame)
table.insert(output,"|-\n")
 
table.insert(output,"| "..v[2].." || ".. std_forms["imp."..v[1]] .. " || " .. std_forms["perf."..v[1]].." ")
local params = {
table.insert(output,"|| ".. caus_forms["imp."..v[1]] .. " || " .. caus_forms["perf."..v[1]].." ")
[1] = {alias_of = "root"},
table.insert(output,"|| ".. pass_forms["imp."..v[1]] .. " || " .. pass_forms["perf."..v[1]].."\n")
[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
end
table.insert(output,"|-\n")
table.insert(output,"| Imperative || ".. std_forms["imp"] .. " || ")
table.insert(output,"|| ".. caus_forms["imp"] .. " || " )
table.insert(output,"|| ".. pass_forms["imp"] .. " ||  \n")
table.insert(output,"|}")
return table.concat(output)
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