local export = {}
local links = require("Module:links")
local lang = require("Module:languages").getByCode("pi")
local m_parameters = require("Module:parameters")
local m_noun = require("Module:pi-decl/noun")
local m_scripts = require("Module:scripts")
local to_script = require("Module:pi-Latn-translit").tr
local debug_outer = ''
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local sub = mw.ustring.sub
local asub = string.sub -- quicker for ASCII, but works on bytes.
local ti = table.insert
-- require "Module:log globals" -- Check for abuse of globals. Only require for testing!
local function dc(x) -- Use this to make marks legible. The name 'dc' means 'drop carrier'.
return gsub(x, "", "") -- These are the letter ka in the 10 supported Indic scripts.
end
local endings = {
-- pa endings
= "ati", = "ati", = "ati", = "ati",
= "ati", = "ati",
= "ati", = "ati", = "ati", = "ati",
= "ati",
= "ayati", = "ayati", = "ayati", = "ayati",
= "ayati", = "ayati", = "ayati", = "ayati",
= "ayati", = "ayati", = "ayati", = "ayati",
= "ayati", = "ayati", = "ayati",
= "āti", = "āti", = "āti", = "āti",
= "āti", = "āti", = "āti", = "āti",
= "āti", = "āti", = "āti", = "āti",
= "āti",
= "eti", = "eti", = "eti",
= "eti", = "eti",
= "eti", = "eti", = "eti", = "eti",
= "oti", = "oti", = "oti",
= "oti", = "oti", = "oti", = "oti",
= "oti", = "oti", = "oti", = "oti",
-- pm endings
= "ate", = "ate", = "ate", = "ate",
= "ate", = "ate",
= "ate", = "ate", = "ate", = "ate",
= "ate",
= "ayate", = "ayate", = "ayate", = "ayate",
= "ayate", = "ayate", = "ayate", = "ayate",
= "ayate", = "ayate", = "ayate", = "ayate",
= "ayate", = "ayate", = "ayate",
= "āte", = "āte", = "āte", = "āte",
= "āte", = "āte", = "āte", = "āte",
= "āte", = "āte", = "āte", = "āte",
= "āte",
= "ete", = "ete", = "ete",
= "ete", = "ete",
= "ete", = "ete", = "ete", = "ete",
= "ute", = "ute", = "ute", = "ute",
= "ute", = "ute",
= "ute", = "ute", = "ute", = "ute",
= "ute",
-- optative endings
= "eyya", = "eyya", = "eyya", = "eyya",
= "eyya", = "eyya", = "eyya", = "eyya",
= "eyya", = "eyya", = "eyya", = "eyya",
= "eyya", = "eyya", = "eyya",
= "ā", = "ā", = "ā", = "ā",
= "ā", = "ā", = "ā", = "ā",
= "ā", = "ā", = "ā", = "ā",
= "ā",
= "etha", = "etha", = "etha", = "etha",
= "etha", = "etha", = "etha", = "etha",
= "etha", = "etha", = "etha", = "etha",
= "etha",
-- imperfect endings
= "attha", = "attha", = "attha", = "attha",
= "attha", = "attha", = "attha", = "attha",
= "attha", = "attha", = "attha", = "attha",
= "attha",
= "a", = "a", = "a", -- Only good for alphabets!
}
local aorist_endings = {
-- aorist endings. Only active seems predictable enough.
= "i", = "i", = "i", = "i",
= "i", = "i",
= "i", = "i", = "i", = "i",
= "i",
= "esi", = "esi", = "esi", = "esi",
= "esi", = "esi",
= "esi", = "esi", = "esi", = "esi",
= "esi",
= "āsi", = "āsi", = "āsi", = "āsi",
= "āsi", = "āsi", = "āsi", = "āsi",
= "āsi", = "āsi", = "āsi", = "āsi",
= "āsi",
-- Purpose of "osi" is to bleed "āsi" when the vowel is written as two characters in from NFC
= "osi", = "osi", = "osi", = "osi",
= "ayi", = "ayi", = "ayi", = "ayi",
= "ayi", = "ayi", = "ayi", = "ayi", = "ayi",
= "ayi", = "ayi", = "ayi", = "ayi", = "ayi",
= "ayi",
}
local future_endings = {
-- fa endings
= "ati", = "ati", = "ati", = "ati",
= "ati", = "ati",
= "ati", = "ati", = "ati", = "ati",
= "ati",
= "iti", ="iti", ="iti", ="iti",
="iti", ="iti",
="iti", ="iti", ="iti", ="iti",
="iti",
= "heti", = "heti", = "heti", = "heti",
= "heti", = "heti",
= "heti", = "heti", = "heti", = "heti",
= "heti",
= "kāhiti", = "kāhiti", = "kāhiti", = "kāhiti",
= "kāhiti", = "kāhiti",
= "kāhiti", = "kāhiti", = "kāhiti", = "kāhiti",
= "kāhiti",
-- fm endings
= "ate", = "ate", = "ate", = "ate",
= "ate", = "ate",
= "ate", = "ate", = "ate", = "ate",
= "ate",
-- ca ending.
= "ā", = "ā", = "ā", = "ā",
= "ā", = "ā", = "ā", = "ā",
= "ā", = "ā", = "ā", = "ā",
= "ā",
= "a",
-- cm ending
= "atha", = "atha", = "atha", = "atha",
= "atha", = "atha", = "atha", = "atha",
= "atha", = "atha", = "atha", = "atha",
= "atha",
}
local cons = "^"
local detectEndingFromList = function(cite3s, endings, latinise, flags)
if latinise then
local cfin = cite3s -- In general, this logic would need the
cite3s = (lang:transliterate(cfin, latinise)) -- trwo() function from the transliterator.
end
local len
local ending
local wordEnd
for len = 5, 1, -1 do
wordEnd = sub(cite3s, -len)
ending = endings
if not ending then
-- Try again
elseif wordEnd == "ติ" then
if match(cite3s, 'เ.ติ$') then
return "eti"
elseif match(cite3s, 'โ.ติ$') then
return "oti"
elseif match(cite3s, dc('เ.กฺ.ติ$')) then
return "eti"
elseif match(cite3s, dc('โ.กฺ.ติ$')) then
return "oti"
else
return ending
end
elseif wordEnd == "เต" then
if match(cite3s, 'เ.เต$') then
return "ete"
elseif match(cite3s, dc('เ.กฺ.เต$')) then
return "ete"
else
return ending
end
elseif wordEnd == "ຕິ" then
if match(cite3s, 'ເ.ຕິ$') then
return "eti"
elseif match(cite3s, 'ໂ.ຕິ$') then
return "oti"
elseif match(cite3s, dc('ເ.ກ຺.ຕິ$')) then
return "eti"
elseif match(cite3s, dc('ໂ.ກ຺.ຕິ$')) then
return "oti"
else
return ending
end
elseif wordEnd == "ເຕ" then
if match(cite3s, 'ເ.ເຕ$') then
return "ete"
elseif match(cite3s, dc('ເ.ກ຺.ເຕ$')) then
return "ete"
else
return ending
end
elseif wordEnd == "สิ" then
if match(cite3s, 'เ.สิ$') then
return "esi"
elseif match(cite3s, dc('เ.กฺ.สิ$')) then
return "esi"
else
-- Try again
end
elseif wordEnd == "ສິ" then
if match(cite3s, 'ເ.ສິ$') then
return "esi"
elseif match(cite3s, dc('ເ.ກ຺.ສິ$')) then
return "esi"
else
-- Try again
end
elseif ending == 'ayati' and len == 3 then
if match(sub(cite3s,-4,-4), cons) then
return ending
else
return "ati"
end
elseif ending == 'ayate' and len == 3 then
if match(sub(cite3s,-4,-4), cons) then
return ending
else
return "ate"
end
elseif ending == 'ayi' and len == 2 then
if match(sub(cite3s,-3,-3), cons) then
return ending
else
return "i"
end
elseif ending == 'āsi' and flags then
if flags.aasi == '1' then
return ending
else
-- Try again
end
elseif ending == 'osi' then
return "i" -- Avoid misrecognising as 'āsi' in Burmese and similar.
else
-- if ending == "i" and not allowi then
-- ending = "ati" -- For brūti and similar
-- end
-- debug_outer = debug_outer..'\n'..cite3s..'='..ending..'\n'
return ending
end
end
if match(sub(cite3s, -1, -1), cons) then
-- debug_outer = debug_outer..'\n'..cite3s..'='.."a"..'\n'
return "a"
else
-- debug_outer = debug_outer..'\n'..cite3s..'='.."ati"..'\n'
return "ati"
end
end
export.detectEnding = function(cite3s, latinise)
return detectEndingFromList(cite3s, endings, latinise)
end
export.detectAoristEnding = function(cite3s, latinise, flags)
return detectEndingFromList(cite3s, aorist_endings, latinise, flags)
end
local active_optative = {
{"⌫⌫⌫eyyāmi", "⌫⌫⌫eyyaṃ", "⌫⌫⌫e"}, {"⌫⌫⌫eyyāma"},
{"⌫⌫⌫eyyāsi", "⌫⌫⌫e"}, {"⌫⌫⌫eyyātha"},
{"⌫⌫⌫eyya", "⌫⌫⌫e"}, {"⌫⌫⌫eyyuṃ"}
}
local active_optative_ati = mw.clone(active_optative)
local active_optative_aati = mw.clone(active_optative)
active_optative_aati = {"⌫⌫⌫eyyāmi", "⌫⌫⌫eyyaṃ"}
active_optative_aati = {"⌫⌫⌫eyyāsi"}
local active_optative_eti = mw.clone(active_optative_aati)
active_optative_eti = {"⌫⌫⌫eyya"}
local active_optative_oti = mw.clone(active_optative_eti)
local active_optative_ute = mw.clone(active_optative_eti)
local middle_optative = {
{"⌫⌫⌫eyyaṃ"}, {"⌫⌫⌫eyyāmhe"},
{"⌫⌫⌫etho"}, {"⌫⌫⌫eyyavho"},
{"⌫⌫⌫etha"}, {"⌫⌫⌫eraṃ"}
}
local middle_optative_ati = mw.clone(middle_optative)
local middle_optative_aati = mw.clone(middle_optative)
local middle_optative_eti = mw.clone(middle_optative)
local middle_optative_oti = mw.clone(middle_optative)
local middle_optative_ute = mw.clone(middle_optative)
local empty = {{}, {}, {}, {}, {}, {}}
local pattern = {
= {
{"⌫⌫⌫āmi"}, {"⌫⌫⌫āma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫nti"},
mid = "ate",
imperfect = {
{"⌫⌫", "⌫⌫ṃ"}, {"⌫⌫mhā"},
{"⌫⌫⌫o"}, {"⌫tha"},
{"⌫⌫", "⌫⌫⌫ā"}, {"⌫⌫⌫u", "⌫⌫⌫ū"},
},
imperative = {
{"⌫⌫⌫āmi"}, {"⌫⌫⌫āma"}, {"⌫⌫", "⌫⌫⌫āhi"}, {"⌫ha"}, {"⌫u"}, {"⌫⌫ntu"}
},
optative_active = active_optative_ati,
optative_middle = middle_optative_ati,
participle = {{"⌫⌫nt"}},
},
= {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫⌫anti"},
mid = "āte",
imperfect = {
{"⌫⌫⌫a", "⌫⌫⌫aṃ"}, {"⌫⌫⌫amhā"},
{"⌫⌫⌫o"}, {"⌫⌫⌫attha"},
{"⌫⌫⌫a", "⌫⌫"}, {"⌫⌫⌫u", "⌫⌫⌫ū"},
},
imperative = {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫", "⌫⌫hi"}, {"⌫ha"}, {"⌫u"}, {"⌫⌫⌫antu"},
},
optative_active = active_optative_aati,
optative_middle = middle_optative_aati,
participle = {{"⌫⌫⌫ant"}},
},
= {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫nti"},
mid = nil, -- "ete",
imperfect = empty,
imperative = {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫hi"}, {"⌫ha"}, {"⌫u"}, {"⌫⌫ntu"},
},
optative_active = active_optative_eti,
optative_middle = middle_optative_eti,
participle = {{"⌫⌫nt"}},
},
= {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫nti"},
mid = "oti_ute",
imperfect = empty,
imperative = {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫hi"}, {"⌫ha"}, {"⌫u"}, {"⌫⌫ntu"},
},
optative_active = active_optative_oti,
optative_middle = middle_optative_oti,
participle = {{"⌫⌫nt"}},
},
= { -- Also services "ati"
{"⌫⌫⌫e"}, {"⌫⌫⌫āmhe"}, {"⌫⌫se"}, {"⌫⌫vhe"}, {"⌫e"}, {"⌫⌫nte", "⌫⌫re"},
mid = "ate",
imperfect = {
{"⌫⌫⌫iṃ"}, {"⌫⌫⌫āmhase", "⌫⌫mhase"},
{"⌫⌫se"}, {"⌫⌫vhaṃ"},
{"⌫tha"}, {"⌫thuṃ"},
},
imperative = {
{"⌫⌫⌫e"}, {"⌫⌫⌫āmase"}, {"⌫⌫ssu"}, {"⌫⌫vho"}, {"⌫aṃ"}, {"⌫⌫ntaṃ"},
},
optative_active = active_optative_ati,
optative_middle = middle_optative_ati,
participle = {{"⌫⌫māna"}},
},
= { -- Also services "āti"
{"⌫⌫⌫e"}, {"⌫⌫mhe"},
{"⌫⌫se"}, {"⌫⌫⌫avhe"},
{"⌫e"}, {"⌫⌫⌫ante", "⌫⌫re"},
mid = "āte",
imperfect = empty,
optative_active = active_optative_aati,
optative_middle = middle_optative_aati,
participle = {{"⌫⌫⌫amāna"}},
},
= { -- Also services "eti"
{"⌫⌫⌫aye"}, {"⌫⌫⌫ayāmhe"},
{"⌫⌫⌫ayase"}, {"⌫⌫⌫ayavhe"},
{"⌫⌫⌫ayate"}, {"⌫⌫⌫ayante", "⌫⌫⌫ayare"},
mid = "ete",
imperfect = empty,
imperative = {
{"⌫⌫⌫aye"}, {"⌫⌫⌫ayāmase"},
{"⌫⌫⌫ayassu"}, {"⌫⌫⌫ayavho"},
{}, -- {"⌫⌫⌫ayataṃ", "⌫aṃ"}, -- 3s needs review
{"⌫⌫⌫ayantaṃ"}
},
optative_active = active_optative_eti,
optative_middle = middle_optative_eti,
participle = {{"⌫⌫⌫ayamāna"}},
},
= { -- Actual ending is "oti" when copied to "oti_ute".
{"⌫⌫⌫ve"}, {"⌫⌫⌫umhe"},
{"⌫⌫⌫use"}, {"⌫⌫⌫uvhe"},
{"⌫⌫⌫ute"}, {"⌫⌫⌫unte", "⌫⌫⌫ure"},
mid = "ute",
imperfect = empty,
imperative = {
{"⌫⌫⌫ve"}, {"⌫⌫⌫vāmase"},
{"⌫⌫⌫ussu"}, {"⌫⌫⌫uvho"},
{"⌫⌫⌫utaṃ"}, {"⌫⌫⌫untaṃ"}
-- 1s, 1pl and 3pl will often need manual repair.
},
optative_active = active_optative_ute,
optative_middle = middle_optative_ute,
},
= {
optative_active = { -- '-e' is not included!
{"⌫āmi", "⌫aṃ"}, {"⌫āma"},
{"⌫āsi"}, {"⌫ātha"},
{""}, {"⌫uṃ"}
},
optative_middle = {
{"ṃ"}, {"⌫āmhe"},
{"⌫⌫⌫tho"}, {"vho"},
{"⌫⌫⌫tha"}, {"⌫⌫⌫raṃ"}
},
},
= {
optative_active = {
{"mi"}, {"ma"}, {"si"}, {"tha"}, {""}, {"⌫uṃ"}
}
},
= {
mid = "etha",
optative_middle = {
{"⌫⌫⌫yyaṃ"}, {"⌫⌫⌫yyāmhe"},
{"⌫o"}, {"⌫⌫⌫yyavho"},
{""}, {"⌫⌫⌫raṃ"}
},
},
= {
mid="a_attha",
imperfect = {
{"", "ṃ"}, {"mhā"},
{"⌫o"}, {"ttha"},
{"", "⌫ā"}, {"⌫u", "⌫ū"},
}
},
= { -- imperfect form
mid="ā_attha",
imperfect = {
{"⌫a", "⌫aṃ"}, {"⌫amhā"},
{"⌫o"}, {"⌫attha"},
{"⌫a", ""}, {"⌫u", "⌫ū"},
}
},
= {
mid = "attha",
imperfect = {
{"⌫⌫⌫⌫⌫iṃ"}, {"⌫⌫⌫⌫⌫āmhase", "⌫⌫⌫⌫mhase"},
{"⌫⌫⌫⌫se"}, {"⌫⌫⌫⌫vhaṃ"}, {""}, {"⌫uṃ"}
}
},
= {
mid = "a_attha",
imperfect = {
{"⌫iṃ"}, {"⌫āmhase", "mhase"},
{"se"}, {"vhaṃ"}, {"ttha"}, {"tthuṃ"}
}
},
= {
mid = "ā_attha",
imperfect = {
{"⌫iṃ"}, {"mhase", "⌫amhase"},
{"⌫ase"}, {"⌫avhaṃ"}, {"⌫attha"}, {"⌫atthuṃ"}
}
},
= {
mid = nil,
aorist = {{"ṃ"}, {"mha"}, {""}, {"ttha"}, {""}, {"ṃsu"}} -- 3p might be wrong too often
-- However, -ayi seems to consistently yield -ayiṃsu rather than ayuṃ.
},
= {
mid = nil,
aorist = {{"ṃ"}, {}, {""}, {}, {""}, {"⌫uṃ"}} -- 3p might be wrong too often
},
= { -- A common mix of sigmatic and thematic aorists!
mid = nil,
aorist = {{"ṃ"}, {"⌫⌫⌫amha", "⌫⌫⌫amhā"}, {""}, {"⌫⌫⌫attha"}, {""}, {"⌫⌫⌫aṃsu"}}
},
}
-- -oti is too different from -ute in some scripts.
pattern.oti_ute = mw.clone(pattern.ute)
pattern.oti_ute.mid = "oti_ute"
pattern.ayati = mw.clone(pattern.ati)
pattern.ayati.mid = "ayate"
-- Lose some of the shorter forms.
pattern.ayati.imperative = {"⌫⌫⌫āhi"}
pattern.ayati.optative_active = {"⌫⌫⌫eyyāmi", "⌫⌫⌫eyyaṃ"}
pattern.ayati.optative_active = {"⌫⌫⌫eyyāsi"}
pattern.ayate = mw.clone(pattern.ate)
pattern.ayate.mid = "ayate"
pattern.ayate.imperative = {} -- {"⌫aṃ", "⌫⌫⌫⌫⌫etaṃ"} -- 3s needs review
pattern.ayate.optative_active = pattern.ayati.optative_active
pattern.ayi = mw.clone(pattern.i)
pattern.ayi.aorist = mw.clone(pattern.i.aorist)
pattern.ayi.aorist = {"ṃsu"}
-- convert Latin script inflections to another script
-- Ⓓ deletes last preposed vowel (for Thai and Lao)
-- Ⓣ toggles last preposed vowel between 'e' and 'o' (for Thai and Lao)
local convert_suffixes = function(stem, nstrip, suffixes, sc, impl, yopt)
local form, pre, stem_pre
local yung, yaa
local xlitend = {}
local strip = string.rep("⌫", nstrip)
local altstem, as1
local option = {impl = impl}
if sc == 'Thai' or sc == 'Laoo' then
altstem = to_script(stem, sc)
stem_pre = match(altstem, "^")
as1 = sub(altstem, 1, 1)
if yopt and sc == 'Laoo' then
if yopt == 'yung' or yopt == 'ຍ' then
yung = 1
elseif yopt == 'yaa' or yopt == 'ຢ' then
yaa = 1
elseif yopt == 'both' then
yung = 1 yaa = 1
else
error('Parameter yaa has invalid value "'..yopt..'"')
end
end
end
for k = 1, #suffixes do
xlitend = {}
form = export.joinSuffix('Latn', stem, suffixes)
local altforms = {}
for ia, va in pairs(form) do
altform = to_script(va, sc, option)
if yung or yaa then
local y1, y2
if yung then y1 = gsub(altform, 'ຢ', 'ຍ') end
if yaa then y2 = gsub(altform, 'ຍ', 'ຢ') end
if y1 then
table.insert(altforms, y1)
if y2 then
if y1 ~= y2 then table.insert(altforms, y2) end
end
else
table.insert(altforms, y2)
end
else
table.insert(altforms, altform)
end
end
local ib = 1 -- Conversion is not one-to-one!
for ia, altform in pairs(altforms) do
local ibin = ib
-- Special handling is needed for a preposed vowel.
pre = match(altform, "^")
if pre then
if stem_pre then
if sub(altform, 1, 1) == as1 then
xlitend = sub(strip, 2) .. sub(altform, 3)
ib = ib + 1
else
-- mw.addWarning("Cannot abstract derivation "..altstem.." > "..altform)
xlitend.voi = true
xlitend = sub(strip, 2) .. 'Ⓣ' .. sub(altform, 3)
ib = ib + 1
end -- Don't generate gibberish
else
xlitend = strip .. "↶" .. pre .. sub(altform, 3)
ib = ib + 1
end
else
if stem_pre then
xlitend.voi = true
xlitend = sub(strip, 2) .. 'Ⓓ' .. sub(altform, 2)
ib = ib + 1
else
xlitend = strip .. sub(altform, 2)
ib = ib + 1
end
end
-- Add alternative Thai/Lao endings
-- A lot of data is needed to decide whether the disabled logic is needed.
-- Any dead code here must be kept around in case facts later show that it is
-- needed for some spelling variant.
if (sc == 'Thai' or sc == 'Laoo') and impl == 'yes' and ib > ibin then
local altend
if impl=='yes' then
altend = gsub(xlitend, dc("()()()"), "%2%1%3")
else
xlitend = gsub(xlitend, "ัว", "ะว") -- TBC!
altend = gsub(xlitend, dc("()()()"), "%2%1%3")
end
if altend ~= xlitend then
xlitend = xlitend
xlitend = altend
ib = ib + 1
end
end
end
end
return xlitend
end
function export.getSuffixes(sc, ending, tense, option)
local impl = option and option.impl or 'yes'
local yopt = option and option.y
local pat
if not pattern then
error('No verb pattern for ending "'..ending..'".')
end
if tense then
pat = pattern
else
pat = pattern
end
if 'Latn' == sc then
return pat
elseif not pat then
return nil
elseif pat then
return pat
else
local olen = {Mymr = 2, Lana = 2} -- Assume NFC
local attha_len = {Latn = 5, Sinh = 4}
eyya_len = {Mymr = 3, Sinh = 5}
local alen
if impl == 'no' and (sc == 'Thai' or sc == 'Laoo') then
alen = 1
else
alen = 0
end
local way = {
= {pseudostem = "kati", ndel = 2 + alen},
= {pseudostem = "kayati", ndel = 3 + 2 * alen},
= {pseudostem = "kāti", ndel = 3},
= {pseudostem = "keti", ndel = 3},
= {pseudostem = "soti", ndel = 2 + (olen or 1)},
= {pseudostem = "soti", ndel = 2 + (olen or 1)},
= {pseudostem = "kate", ndel = 2 + alen},
= {pseudostem = "kayate", ndel = 3 + 2 * alen},
= {pseudostem = "kāte", ndel = 3},
= {pseudostem = "kete", ndel = 3},
= {pseudostem = "sute", ndel = 3},
= {pseudostem = "keyya", ndel = eyya_len or 4},
= {pseudostem = "kā", ndel = 1},
= {pseudostem = "kā", ndel = 1},
= {pseudostem = "ka", ndel = alen},
= {pseudostem = "ka", ndel = alen},
= {pseudostem = "kā", ndel = 1},
= {pseudostem = "ketha", ndel = 2 + alen},
= {pseudostem = "kattha", ndel = (attha_len or 3) + alen},
= {pseudostem = "ki", ndel = 1},
= {pseudostem = "kesi", ndel = 3},
= {pseudostem = "kāsi", ndel = 3},
= {pseudostem = "kayi", ndel = 2 + alen},
}
way = way
if way then
pat = convert_suffixes(way.pseudostem, way.ndel, pat, sc,
impl, yopt)
if ending == 'etha' then
debug_outer=debug_outer..'tr:'..pat
end
else
error('Cannot convert derivations from suffix '..ending..' for '..sc)
end
return pat
end
end
local function dump_table(name, futargs) -- For debugging only!
for k, v in pairs(futargs) do
local t = type(v)
if t == 'string' then
mw.addWarning(name..'.'..k..'='..v)
elseif t == 'table' then
mw.addWarning(name..'.'..k..' is a table of '..#v)
else
mw.addWarning(name..'.'..k..' is a '..type(v))
end
end
end
local function define_overrides(params, prefix, mod_default)
for _, pn in pairs({"1s", "2s", "3s", "1p", "2p", "3p"}) do
params = {list = true}
params = {list = true}
params = {default = mod_default}
params = {default = mod_default}
end
end
local function addFutureParams(params, mod_default) -- i.e. future specific
params.cond = {list = true} -- Only forms including augment
params.cond_midl = {list = true} -- Only forms including augment
params.cond_voice = {} -- defaults to (corrected) value of voice
params.fap_mod = {default = mod_default}
params.fap = {list = true}
params.fmp_mod = {default = mod_default}
params.fmp = {list = true}
define_overrides(params, 'cond_', mod_default)
end
function export.parse(args)
local mod_default = 'after'
if args.impf_midl and not args.midl then
error("Argument impf_midl may only be used if argument midl is.")
end
local params = {
= {}, -- Just ignore
cite = {list = true},
midl = {list = true},
label = {},
impl = {},
y = {},
aa = {},
showtr = {},
subst = {},
sc = {},
voice = {default = 'both'}, -- Overridden by cite and midl
impf_voice = {default = 'none'},
augment = {default = 'both_made'},
impf = {list = true}, -- Only forms including augment
impf_midl = {list = true}, -- Only forms including augment
impr_voice = {}, -- defaults to (corrected) value of voice
opta_voice = {}, -- defaults to (corrected) value of voice
opta_mod = {default = mod_default},
opta = {list = true},
opta_midl = {list = true},
aori = {list = true},
aor2 = {list = true},
aori_voice = {default = 'act'}, -- paradigms only generate active forms!
aori_augment = {}, -- No default!
aasi = {}, -- Set to 1 to recognise "āsi" as a special ending.
perf = {list = true},
perf_voice = {default = 'both'},
part_voice = {}, -- defaults to (corrected) value of voice
pap_mod = {default = mod_default},
pap = {list = true},
pmp_mod = {default = mod_default},
pmp = {list = true},
-- Options for future system:
futu = {list = true},
futu_midl = {list = true},
futu_voice = {},
cond_augment = {},
futu_part_voice = {},
}
addFutureParams(params, mod_default)
define_overrides(params, '', mod_default)
define_overrides(params, 'impf_', mod_default)
define_overrides(params, 'impr_', mod_default)
define_overrides(params, 'opta_', mod_default)
define_overrides(params, 'aori_', mod_default)
define_overrides(params, 'perf_', mod_default)
-- Options for future system:
define_overrides(params, 'futu_', mod_default)
define_overrides(params, 'cond_', mod_default)
return m_parameters.process(args, params)
end
function export.futureParse(args, subset)
local mod_default = 'after'
if args.cond_midl and not args.midl then
error("Argument cond_midl may only be used if argument midl is.")
end
local params = {
= {}, -- Just ignore
cite = {list = true},
midl = {list = true},
label = {},
impl = {},
y = {},
aa = {},
showtr = {},
subst = {},
sc = {},
voice = {default = 'both'}, -- Overridden by cite and midl
augment = {default = 'with_made'},
part_voice = {} -- defaults to (corrected) value of voice
}
addFutureParams(params, mod_default)
define_overrides(params, '', mod_default)
if subset then -- Lists have already been formed.
define_overrides(params, 'futu_', mod_default)
local futargs = {}
local replaced = {
= 1, cite = 1, midl = 1, voice = 1, augment = 1, part_voice = 1
}
for k, v in pairs(args) do
if params and not replaced then
if type(k) ~= 'string' then
-- Weird! Just skip.
elseif match(k, '^futu_') then
futargs = args
elseif match(k, '^') then
-- Don't copy
else
futargs = args
end
end
end
futargs.cite = args.futu
futargs.midl = args.futu_midl
futargs.voice = args.futu_voice or 'both'
futargs.augment = args.cond_augment or
match(args.augment, '^with') and args.augment or 'with_made'
futargs.part_voice = args.futu_part_voice or args.part_voice
-- dump_table('futargs', futargs)
return futargs
else
return m_parameters.process(args, params)
end
end
local arrcat_nodup = m_noun.arrcat_nodup
local function kill_final_vole(stem)
return gsub(stem, "()(*)$", "%2")
end
local function toggle_vo(stem)
local toggle = {="โ", ="เ", ="ໂ", ="ເ"}
local function f_toggle(m1, m2) return toggle..m2 end
return gsub(stem, "()(*)$", f_toggle)
end
function export.joinSuffix(sc, base, pattern, option)
if pattern.voi then
local res = {}
for _,v in ipairs(pattern) do
local forms, rest
local base2 = nil
if match(v, '⌫⌫⌫⌫⌫Ⓓ') then
base2 = kill_final_vole(sub(base, 1, -6))
rest = sub(v,7)
elseif match(v, '⌫⌫⌫⌫Ⓓ') then
base2 = kill_final_vole(sub(base, 1, -5))
rest = sub(v,6)
elseif match(v, '⌫⌫⌫Ⓓ') then
base2 = kill_final_vole(sub(base, 1, -4))
rest = sub(v,5)
elseif match(v, '⌫⌫Ⓓ') then
base2 = kill_final_vole(sub(base, 1, -3))
rest = sub(v,4)
elseif match(v, '⌫Ⓓ') then
base2 = kill_final_vole(sub(base, 1, -2))
rest = sub(v,3)
elseif match(v, 'Ⓓ') then
base2 = kill_final_vole(sub(base, 1, -1))
rest = sub(v,2)
elseif match(v, '⌫⌫⌫⌫⌫Ⓣ') then
base2 = toggle_vo(sub(base, 1, -6))
rest = sub(v,7)
elseif match(v, '⌫⌫⌫⌫Ⓣ') then
base2 = toggle_vo(sub(base, 1, -5))
rest = sub(v,6)
elseif match(v, '⌫⌫⌫Ⓣ') then
base2 = toggle_vo(sub(base, 1, -4))
rest = sub(v,5)
elseif match(v, '⌫⌫Ⓣ') then
base2 = toggle_vo(sub(base, 1, -3))
rest = sub(v,4)
elseif match(v, '⌫Ⓣ') then
base2 = toggle_vo(sub(base, 1, -2))
rest = sub(v,3)
elseif match(v, 'Ⓣ') then
base2 = toggle_vo(sub(base, 1, -1))
rest = sub(v,2)
end
if base2 then
forms = m_noun.joinSuffix(sc, base2, {rest})
else
forms = m_noun.joinSuffix(sc, base, {v})
end
res = arrcat_nodup(res, forms)
end
return res
elseif pattern.kill_final_preposed then
return m_noun.joinSuffix(sc, kill_final_vole(base), pattern, option)
else
return m_noun.joinSuffix(sc, base, pattern, option)
end
end
function export.joinSuffixes(scriptCode, stem, pattern, option)
local forms = {}
for i = 1, 6 do
forms = export.joinSuffix(scriptCode, stem, pattern, option)
end
return forms
end
function export.modify_voice(forms, prefix, args)
-- Only null action is implemented.
for i, pn in pairs({"1s", "1p", "2s", "2p", "3s", "3p"}) do
local flag = pn..'_mod'
if #args > 0 then
if args == 'after' then
forms = arrcat_nodup(forms, args)
forms.isnil = false
elseif args == 'replace' then
forms = args
forms.isnil = false
elseif args == 'before' then
forms = arrcat_nodup(args, forms)
forms.isnil = false
elseif args == 'blank' then
forms = {}
else
error('Argument '..prefix..pn..' has invalid value '..args)
end
elseif args == 'blank' then
forms = {}
end
end
end
function export.modify_voice(forms, prefix, args)
for i, pn in pairs({"1s", "1p", "2s", "2p", "3s", "3p"}) do
local flag = pn..'_mod'
local added = nil;
if args and #args > 0 then
added = true;
if args == 'after' then
forms = arrcat_nodup(forms, args)
forms.isnil = false
elseif args == 'replace' then
forms = args
forms.isnil = false
elseif args == 'before' then
forms = arrcat_nodup(args, forms)
forms.isnil = false
elseif args == 'blank' then
forms = {}
added = nil;
else
error('Argument '..prefix..pn..' has invalid value '..args)
end
if added and (i == 2) then forms.add1p = true end
elseif args == 'blank' then
forms = {}
end
end
end
function export.present(cite, tense, formsa, formsm)
local rows = {"1st", "2nd", "3rd"}
local forms1
local output = {}
ti(output, '<div class="NavFrame" style="min-width:30%">'..
'<div class="NavHead" style="background:#d9ebff">'..tense..
' forms of "' .. cite .. '"' ..'</div><div class="NavContent">')
ti(output,
'<table class="inflection-table" style="background:#F9F9F9;'..
'text-align:center;width:100%">')
if formsa and formsm then
ti(output, '<tr style="background:#eff7ff"><th></th><th colspan=2>Active</th><th colspan=2>Middle</th></tr>')
ti(output, '<tr style="background:#eff7ff"><th></th><th>Singular</th><th>Plural</th><th>Singular</th><th>Plural</th></tr>')
for i,v in ipairs(rows) do
if #formsa > 0 or #formsa > 0 or #formsm > 0 or #formsm > 0 then
ti(output, "<tr><th style=\"background-color:#eff7ff;\">" .. v .. "</th>")
ti(output, "<td>" .. m_noun.orJoin(currentScript, formsa) .. "</td>")
ti(output, "<td>" .. m_noun.orJoin(currentScript, formsa) .. "</td>")
ti(output, "<td>" .. m_noun.orJoin(currentScript, formsm) .. "</td>")
ti(output, "<td>" .. m_noun.orJoin(currentScript, formsm) .. "</td>")
ti(output, "</tr>")
end
end
else
if formsa then
forms1 = formsa
else
forms1 = formsm
end
ti(output, '<tr style="background:#eff7ff"><th></th><th>Singular</th><th>Plural</th></tr>')
for i,v in ipairs(rows) do
if #forms1 > 0 or #forms1 > 0 then
ti(output, "<tr><td style=\"background-color:#eff7ff;\">" .. v .. "</td>")
ti(output, "<td>" .. m_noun.orJoin(currentScript, forms1) .. "</td>")
ti(output, "<td>" .. m_noun.orJoin(currentScript, forms1) .. "</td>")
ti(output, "</tr>")
end
end
end
ti(output, "</table></div></div>")
return table.concat(output)
end
-- Basic form of augment:
local augment = {
Latn="a",
Thai="อ",
Deva="अ",
Beng="অ",
Mymr="အ",
Lana="ᩋ",
Khmr="អ",
Sinh="අ",
Brah="𑀅",
Laoo="ອ",
Cakm="𑄃",
}
local augment_alph= {
Thai = "อะ",
Laoo = "ອະ"
}
local enda3s = {
Latn="ti",
Thai="ติ",
Deva="ति",
Beng="তি",
Mymr="တိ",
Lana="ᨲᩥ",
Khmr="តិ",
Sinh="ති",
Brah="𑀢𑀺",
Laoo="ຕິ",
Cakm="𑄖𑄨",
}
local function select_args(old, prefix) -- prefix must be in ASCII
local new = {}
local pattern = '^'..prefix
local follow = string.len(pattern)
for i, v in pairs(old) do
if string.match(i,pattern) then
new = v
end
end
return new
end
function export.modify(formsa, formsm, prefix, args)
local subprefix
if not formsa then formsa = {{}, {}, {}, {}, {}, {}, isnil=true} end
subprefix = prefix..'a'
export.modify_voice(formsa, subprefix, select_args(args,subprefix))
if formsa.isnil then formsa = nil end
if not formsm then formsm = {{}, {}, {}, {}, {}, {}, isnil=true} end
subprefix = prefix..'m'
export.modify_voice(formsm, subprefix, select_args(args,subprefix))
if formsm.isnil then formsm = nil end
return formsa, formsm
end
local hike = true -- Whether heading for voices and numbers should be in common for tables.
local function rows2v(currentScript, tense, formsa, formsm, x0)
local rows = {"1st", "2nd", "3rd"}
local output = {}
formsa = formsa or empty
formsm = formsm or empty
ti(output, '<tr style="background:#d9ebff"><th colspan=5>'..tense..'</th></tr>')
if not hike then
ti(output, '<tr style="background:#eff7ff"><th></th><th colspan=2>Active</th><th colspan=2>Middle</th></tr>')
ti(output, '<tr style="background:#eff7ff"><th></th><th>Singular</th><th>Plural</th><th>Singular</th><th>Plural</th></tr>')
end
for i,v in ipairs(rows) do
if #formsa > 0 or #formsa > 0 or #formsm > 0 or #formsm > 0 then
ti(output, "<tr><th style=\"background-color:#eff7ff;\">" .. v .. "</th>")
ti(output, "<td>")
ti(output, m_noun.orJoin(currentScript, formsa, x0))
ti(output, "</td>")
ti(output, "<td>")
ti(output, m_noun.orJoin(currentScript, formsa, x0))
ti(output, "</td>")
ti(output, "<td>")
ti(output, m_noun.orJoin(currentScript, formsm, x0))
ti(output, "</td>")
ti(output, "<td>")
ti(output, m_noun.orJoin(currentScript, formsm, x0))
ti(output, "</td>")
ti(output, "</tr>")
end
end
return table.concat(output)
end
local function rows1v(currentScript, tense, formsa, formsm, xo)
local rows = {"1st", "2nd", "3rd"}
local output = {}
local forms1 = formsa or formsm or empty
ti(output, '<tr style="background:#d9ebff"><th colspan=3>'..tense..'</th></tr>')
if not hike then
ti(output, '<tr style="background:#eff7ff"><th></th><th>Singular</th><th>Plural</th></tr>')
end
for i,v in ipairs(rows) do
if #forms1 > 0 or #forms1 > 0 then
ti(output, "<tr><td style=\"background-color:#eff7ff;\">")
ti(output, v)
ti(output, "</td>")
ti(output, "<td>")
ti(output, m_noun.orJoin(currentScript, forms1, xo))
ti(output, "</td>")
ti(output, "<td>")
ti(output, m_noun.orJoin(currentScript, forms1, xo))
ti(output, "</td>")
ti(output, "</tr>")
end
end
return table.concat(output)
end
function export.present_conj(label, currentScript, parts, xo)
local output = {}
parts.cat = parts.cat or {}
local havea = parts.presa or parts.impra or parts.impfa or parts.optaa
local havea = havea or parts.aoria or parts.futua or parts.conda or parts.perfa
local havem = parts.presm or parts.imprm or parts.impfm or parts.optam
havem = havem or parts.aorim or parts.futum or parts.condm or parts.perfa
local have2 = parts.presa and parts.presm or parts.impra and parts.imprm or
parts.impfa and parts.impfm or parts.optaa and parts.optam or
parts.aoria and parts.aorim or parts.futua and parts.futum or
parts.conda and parts.condm or parts.perfa and parts.perfm
ti(output, '<div class="NavFrame" style="min-width:30%">'..
'<div class="NavHead" style="background:#d9ebff">'..
'Conjugation of "' .. label .. '"</div><div class="NavContent">')
ti(output, '<table class="inflection-table" style="background:#F9F9F9;'..
'text-align:center;width:100%">')
if have2 then
if hike then
ti(output, '<tr style="background:#eff7ff"><th></th><th colspan=2>Active</th><th colspan=2>Middle</th></tr>')
ti(output, '<tr style="background:#eff7ff"><th></th><th>Singular</th><th>Plural</th><th>Singular</th><th>Plural</th></tr>')
end
if parts.presa or parts.presm then
ti(output, rows2v(currentScript, 'Present', parts.presa, parts.presm, xo))
end
if parts.impfa or parts.impfm then
ti(output, rows2v(currentScript, 'Imperfect', parts.impfa, parts.impfm, xo))
end
if parts.impra or parts.imprm then
ti(output, rows2v(currentScript, 'Imperative', parts.impra, parts.imprm, xo))
end
if parts.optaa or parts.optam then
ti(output, rows2v(currentScript, 'Optative', parts.optaa, parts.optam, xo))
end
if parts.aoria or parts.aorim then
ti(output, rows2v(currentScript, 'Aorist', parts.aoria, parts.aorim, xo))
end
if parts.futua or parts.futum then
ti(output, rows2v(currentScript, 'Future', parts.futua, parts.futum, xo))
end
if parts.conda or parts.condm then
ti(output, rows2v(currentScript, 'Conditional', parts.conda, parts.condm, xo))
end
if parts.perfa or parts.perfm then
ti(output, rows2v(currentScript, 'Perfect', parts.perfa, parts.perfm, xo))
end
else
if hike then
ti(output, '<tr style="background:#eff7ff"><th></th><th>Singular</th><th>Plural</th></tr>')
end
if parts.presa or parts.presm then
ti(output, rows1v(currentScript, 'Present', parts.presa, parts.presm, xo))
end
if parts.impfa or parts.impfm then
ti(output, rows1v(currentScript, 'Imperfect', parts.impfa, parts.impfm, xo))
end
if parts.impra or parts.imprm then
ti(output, rows1v(currentScript, 'Imperative', parts.impra, parts.imprm, xo))
end
if parts.optaa or parts.optam then
ti(output, rows1v(currentScript, 'Optative', parts.optaa, parts.optam, xo))
end
if parts.aoria or parts.aorim then
ti(output, rows1v(currentScript, 'Aorist', parts.aoria, parts.aorim, xo))
end
if parts.futua or parts.futum then
ti(output, rows1v(currentScript, 'Future', parts.futua, parts.futum, xo))
end
if parts.conda or parts.condm then
ti(output, rows1v(currentScript, 'Conditional', parts.conda, parts.condm, xo))
end
if parts.perfa or parts.perfm then
ti(output, rows1v(currentScript, 'Perfect', parts.perfa, parts.perfm, xo))
end
end
if parts.conda or parts.condm then
ti(parts.cat, "]")
if parts.conda and parts.conda.add1p then
ti(parts.cat, "]")
end
end
ti(output, "</table></div></div>")
if parts.pap and #parts.pap > 0 then
table.insert(output, '\n* Present active participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.pap, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.pmp and #parts.pmp > 0 then
table.insert(output, '\n* Present middle participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.pmp, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.fap and #parts.fap > 0 then
table.insert(output, '\n* Future active participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.fap, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.fmp and #parts.fmp > 0 then
table.insert(output, '\n* Future middle participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.fmp, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.debug then table.insert(output, parts.debug) end
if parts.cat then ti(output, table.concat(parts.cat)) end
return table.concat(output)
end
function export.present_special_oldway(label, currentScript, parts, xo)
output = {}
parts.cat = parts.cat or {}
if parts.presa or parts.presm then
table.insert(output, export.present(label, 'Present', parts.presa, parts.presm, xo))
end
if parts.impfa or parts.impfm then
table.insert(output, export.present(label, 'Imperfect', parts.impfa, parts.impfm, xo))
end
if parts.impra or parts.imprm then
table.insert(output, export.present(label, 'Imperative', parts.impra, parts.imprm, xo))
end
if parts.optaa or parts.optam then
table.insert(output, export.present(label, 'Optative', parts.optaa, parts.optam, xo))
end
if parts.futua or parts.futum then
ti(output, export.present(label, 'Future', parts.futua, parts.futum, xo))
end
if parts.conda or parts.condm then
ti(output, export.present(label, 'Conditional', parts.conda, parts.condm, xo))
ti(parts.cat, "]")
if parts.conda and parts.conda.add1p then
ti(parts.cat, "]")
end
end
if parts.pap and #parts.pap > 0 then
table.insert(output, '\n* Present active participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.pap, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.pmp and #parts.pmp > 0 then
table.insert(output, '\n* Present middle participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.pmp, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.fap and #parts.fap > 0 then
table.insert(output, '\n* Future active participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.fap, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.fmp and #parts.fmp > 0 then
table.insert(output, '\n* Future middle participle: ')
table.insert(output, m_noun.orJoin(currentScript, parts.fmp, xo))
table.insert(output, ', which see for forms and usage')
end
if parts.debug then table.insert(output, parts.debug) end
if parts.cat then ti(output, table.concat(parts.cat)) end
return table.concat(output)
end
function export.present_future(label, currentScript, parts, xo)
if true then -- Newer table format
return export.present_conj(label, currentScript, parts, xo)
else
return export.present_special_oldway(label, currentScript, parts, xo)
end
end
function export.present_special(label, currentScript, parts, xo)
if true then -- Newer table format
return export.present_conj(label, currentScript, parts, xo)
else
return export.present_special_oldway(label, currentScript, parts, xo)
end
end
function export.special_forms(cite, args)
local currentScript = lang:findBestScript(cite)
local scriptCode = currentScript:getCode()
local latinise = nil
if scriptCode == "None" and args.sc then -- Resort to sc
scriptCode = args
currentScript = m_scripts.getByCode(scriptCode, "No such script as ".. scriptCode .. ".")
latinise = currentScript
augment = to_script("a", scriptCode)
end
args = export.parse(args)
args.cite = arrcat_nodup({cite}, args.cite)
local debug = '\n\nAt (1), args.cite = '..table.concat(args.cite, ' ')
local patpa, patpm, basepa, basepm
local parts = {}
local option = {}
option.aa = args.aa
-- Handle present tense. This forms a base for others.
local ending = export.detectEnding(cite, latinise)
-- mw.addWarning('ending='..ending)
patpa = export.getSuffixes(scriptCode, ending, nil, args)
basepa = cite
local mset = nil
local forBoth = false
local aset = args.cite
local voice = "both"
if 'e' == asub(ending, -1) then -- No active inflection
patpm = patpa
patpa = nil
basepm = cite
aset = nil
mset = args.cite
voice = "midl"
elseif args.midl and args.midl then
basepm = args.midl
mset = args.midl
local midend = export.detectEnding(basepm, latinise)
patpm = pattern.mid and
export.getSuffixes(scriptCode, pattern.mid, nil, args)
elseif args.voice == 'act' then
patpm = nil
voice = "act"
else
patpm = pattern.mid and
export.getSuffixes(scriptCode, pattern.mid, nil, args)
basepm = cite
forBoth = true
mset = args.cite
end
local formsa = nil
local formsm = nil
if patpa then
formsa = export.joinSuffixes(scriptCode, basepa, patpa, option)
for k = 2, #aset do
basepa = aset
patpa = export.getSuffixes(
scriptCode, export.detectEnding(basepa, latinise), nil, args)
local extras = export.joinSuffixes(scriptCode, basepa, patpa, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
end
end
if patpm or forBoth then
if patpm then
formsm = export.joinSuffixes(scriptCode, basepm, patpm, option)
else
formsm = {{}, {}, {}, {}, {}, {}}
end
for k = 2, #mset do
basepm = mset
local kend = export.detectEnding(basepm, latinise)
kend = pattern.mid
if kend then
patpm = export.getSuffixes(scriptCode, kend, nil, args)
local extras = export.joinSuffixes(scriptCode, basepm, patpm, option)
for ip = 1, 6 do
formsm = arrcat_nodup(formsm, extras)
end
end
end
end
if args.voice == "act" or args.voice == "both" then
-- handled already
elseif args.voice == "none" then
formsa = nil
formsm = nil
voice = "none"
elseif args.voice then
error('Argument voice has bad value "'..args.voice..'.')
end
formsa, formsm = export.modify(formsa, formsm, '', args)
parts.presa = formsa
parts.presm = formsm
-- Form imperative from present
formsa = nil
formsm = nil
local imperativeVoice = args.impr_voice or voice
if imperativeVoice == 'act' or imperativeVoice == 'both' then
local patma, kend
formsa = {{}, {}, {}, {}, {}, {}}
for k = 1, #aset do
kend = export.detectEnding(aset, latinise)
patma = export.getSuffixes(scriptCode, kend, 'imperative', args)
if patma then
local extras = export.joinSuffixes(scriptCode, aset, patma, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
end
end
end
if imperativeVoice == 'midl' or imperativeVoice == 'both' then
local patmm
formsm = {{}, {}, {}, {}, {}, {}}
local nstem, form3s
if forBoth then
nstem = #aset
else
nstem = #mset
end
for k = 1, nstem do
form3s = mset
local kend = export.detectEnding(form3s, latinise)
if pattern.mid then
kend = pattern.mid
elseif kend == "eti" then
kend = nil
else
error('No middle endings for ending "'..kend..'".')
kend = nil
end
patmm = kend and export.getSuffixes(scriptCode, kend, 'imperative', args)
if patmm then
local extras = export.joinSuffixes(scriptCode, form3s, patmm, option)
for ip = 1, 6 do
formsm = arrcat_nodup(formsm, extras)
end
end
end
end
debug = debug..'\n\nAt (8), formsa='..tostring(formsa)
formsa, formsm = export.modify(formsa, formsm, 'impr_', args)
if formsa then
debug = debug..'\n\nAt (9), formsa='..tostring(formsa)..
' formsa.isnil='..tostring(formsa.isnil)
else
debug = debug..'\n\nAt (9), formsa='..tostring(formsa)
end
parts.impra = formsa
parts.imprm = formsm
-- Form imperfect from present. Existence defaults to false for both voices.
local aug
if args == 'no' then
aug = augment_alph or augment
else
aug = augment
end
-- error("impl="..tostring(args).." aug="..aug)
local impf = {}
if (args.impf_voice ~= 'none') then
if args.augment == 'without' then
impf = aset or {}
elseif args.augment == 'with_made' then
if aset then
for k = 1, #aset do
impf = aug .. aset
end
end
elseif args.augment == 'with_given' then
impf = args.impf
elseif args.augment == 'both_made' then
if aset then
for k = 1, #aset do
impf = aug .. aset
end
for k = 1, #aset do
impf = aset
end
end
elseif args.augment == 'both_given' then
impf = arrcat_nodup(args.impf or {}, aset or {})
else
error('Argument augment has bad value "'..args.augment..'".')
end
end
if (args.impf_voice == 'both' or args.impf_voice == 'act')
-- and (voice == 'both' or voice == 'act')
then
formsa = {{}, {}, {}, {}, {}, {}}
for k = 1, #impf do
kend = export.detectEnding(impf, latinise)
if kend == "ā" then kend = "ā2" end
patma = export.getSuffixes(scriptCode, kend, 'imperfect', args)
if true then -- Make false for debugging.
elseif patma == nil or patma == nil or patma == nil then
mw.addWarning('impf='..impf..' kend='..kend..' patma=nil')
else
mw.addWarning('impf='..impf..' kend='..kend..' patma='..patma)
end
if patma then
local extras = export.joinSuffixes(scriptCode, impf, patma, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
end
end
elseif (args.impf_voice == 'none' or args.impf_voice == 'midl') then
formsa = nil
else
error('Argument impf_voice has bad value "'..args.impf_voice..'".')
end
if (args.impf_voice == 'both' or args.impf_voice == 'midl')
-- and (voice == 'both' or voice == 'midl')
then
formsm = {{}, {}, {}, {}, {}, {}}
if not forBoth then
impf = {}
if args.augment == 'without' then
impf = mset
elseif args.augment == 'with_made' then
for k = 1, #mset do
impf = aug .. mset
end
elseif args.augment == 'with_given' then
impf = args.midl and args.midl and args.impf_midl or args.midl
elseif args.augment == 'both_made' then
for k = 1, #mset do
impf = aug .. mset
end
for k = 1, #mset do
impf = mset
end
elseif args.augment == 'both_given' then
impf = arrcat_nodup(
args.midl and args.midl and (args.impf_midl or {}) or
args.impf or {},
mset or {})
else
error('Argument augment has bad value "'..args.augment..'".')
end
end
for k = 1, #impf do
kend = export.detectEnding(impf, latinise)
debug=debug..'\n\nAt (7) impf='..impf
if kend == "ā" then kend = "ā2" end
if forBoth then
if pattern.mid then
kend = pattern.mid
elseif kend == "eti" then
kend = nil
else
error('No middle endings for ending "'..kend..'".')
kend = nil
end
end
local pat = kend and export.getSuffixes(scriptCode, kend, 'imperfect', args)
if not kend then
-- nothng to do
elseif pat then
local extras = export.joinSuffixes(scriptCode, impf, pat, option)
for ip = 1, 6 do
formsm = arrcat_nodup(formsm, extras)
end
else
mw.addWarning('No imperfect middle suffixes for '..impf..
' ('..kend..')')
end
end
else
formsm = nil
end
formsa, formsm = export.modify(formsa, formsm, 'impf_', args)
parts.impfa = formsa
parts.impfm = formsm
-- Form optative from present citation forms.
args.opta_voice = args.opta_voice or voice
debug = debug .. '\n\nAt (2), args.cite = '..table.concat(args.cite, ' ')
local opta = args.cite
debug = debug .. '\n\nAt (3), opta = '..table.concat(opta, ' ')
if args.opta then
debug = debug..'\n\nAt (4), args.opta='..table.concat(args.opta)..', args.opta_mod='..args.opta_mod
if args.opta_mod == 'replace' then
opta = args.opta
elseif args.opta_mod == 'after' then
opta = arrcat_nodup(opta, args.opta)
elseif args.opta_mod == 'before' then
opta = arrcat_nodup(args.opta, opta)
elseif args.opta_mod == 'blank' then
args.opta_voice = 'none'
else
error('Argument opta_mod has bad value "'..args.opta_mode..'".')
end
end
debug = debug .. '\n\nAt (5), opta = '..table.concat(opta, ' ')..
', args.opta_voice='..args.opta_voice
if args.opta_voice == 'both' or args.opta_voice == 'act' then
formsa = {{}, {}, {}, {}, {}, {}}
local kend, patma
for k = 1, #opta do
kend = export.detectEnding(opta, latinise)
patma = export.getSuffixes(scriptCode, kend, 'optative_active', args)
if true then -- Make false for debugging.
elseif patma == nil or patma == nil or patma == nil then
mw.addWarning('opta='..opta..' kend='..kend..' patma=nil')
else
mw.addWarning('opta='..opta..' kend='..kend..' patma='..patma)
end
if patma then
local extras = export.joinSuffixes(scriptCode, opta, patma, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
end
end
elseif args.opta_voice == 'midl' or args.opta_voice == 'none' then
formsa = nil
else
error('Argument opta_voice has bad value "'..args.opta_voice..'".')
end
if #args.opta_midl > 0 then opta = args.opta_midl end
formsm = nil
if args.opta_voice == 'both' or args.opta_voice == 'midl' then
formsm = {{}, {}, {}, {}, {}, {}}
local kend, patma
debug=debug..'\n\nAt (6), opta='..table.concat(opta)
for k = 1, #opta do
kend = export.detectEnding(opta, latinise)
patma = export.getSuffixes(scriptCode, kend, 'optative_middle', args)
if patma then
local extras = export.joinSuffixes(scriptCode, opta, patma, option)
for ip = 1, 6 do
formsm = arrcat_nodup(formsm, extras)
end
else
debug = debug.."\n\nNo "..kend..".optative_middle"
end
end
else
formsm = nil
end
formsa, formsm = export.modify(formsa, formsm, 'opta_', args)
parts.optaa = formsa
parts.optam = formsm
-- Generate aorist forms - currently only from aorist specific parameters.
formsa = nil
formsm = nil
if args.aori and #args.aori > 0 or args.aor2 and #args.aor2 > 0 then
local flags = {}
flags.aasi = args.aasi
formsa = { {}, {}, {}, {}, {}, {} }
local aori = {} -- List of *aorist* 3s. Cannnot tell -ati from -i!
for k = 1, #(args.aor2 or {}) do
aori = aug .. args.aor2
end
aori = arrcat_nodup(aori, args.aor2 or {})
aori = arrcat_nodup(aori, args.aori)
for k = 1, #aori do
local kend = export.detectAoristEnding(aori, latinise, flags)
if kend == "āsi" then
parts.cat = parts.cat or {}
ti(parts.cat, "]")
end
local patma = export.getSuffixes(scriptCode, kend, 'aorist', args)
if patma then
local extras = export.joinSuffixes(scriptCode, aori, patma, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
else
debug = debug.."\n\nNo "..kend..".aorist"
end
end
if #formsa == 0 and #formsa == 0 and #formsa == 0 and
#formsa == 0 and #formsa == 0 and #formsa == 0 then
formsa = nil
end
end
parts.aoria, parts.aorim = export.modify(formsa, formsm, 'aori_', args)
-- Generate perfect tense by write in
formsa = nil
formsm = nil
parts.perfa, parts.perfm = export.modify(formsa, formsm, 'perf_', args)
-- List present participles.
local pap, pmp = {}, {}
args.part_voice = args.part_voice or voice
if args.part_voice == 'both' or args.part_voice == 'act' then
if voice == 'both' or voice == 'act' then
for k = 1, aset and #aset or 0 do
local kend = export.detectEnding(aset, latinise)
local pat = kend and export.getSuffixes(scriptCode, kend, "participle", args)
if pat then
local extra = export.joinSuffix(scriptCode, aset, pat)
pap = arrcat_nodup(pap, extra)
end
end
end
if args.pap_mod == 'blank' then
pap = {}
elseif args.pap_mod == 'after' then
pap = arrcat_nodup(pap, args.pap)
elseif args.pap_mod == 'before' then
pap = arrcat_nodup(args.pap, pap)
elseif args.pap_mod == 'replace' then
pap = args.pap
else
error('Argument pap_mod has invalid value '..args.pap_mod)
end
parts.pap = pap
elseif args.part_voice == 'midl' or args.part_voice == 'none' then
-- permissible
else
error('Argument part_voice has invalid value '..args.part_voice)
end
if args.part_voice == 'both' or args.part_voice == 'midl' then
local list
local from_active = forBoth or voice == 'act'
if from_active then
list = aset
else
list = mset
end
for k = 1, list and #list or 0 do
local kend = export.detectEnding(list, latinise)
if from_active then kend = pattern.mid end
local pat = kend and export.getSuffixes(scriptCode, kend, "participle", args)
if pat then
local extra = export.joinSuffix(scriptCode, list, pat)
pmp = arrcat_nodup(pmp, extra)
end
end
if args.pmp_mod == 'blank' then
pmp = {}
elseif args.pmp_mod == 'after' then
pmp = arrcat_nodup(pmp, args.pmp)
elseif args.pmp_mod == 'before' then
pmp = arrcat_nodup(args.pmp, pmp)
elseif args.pmp_mod == 'replace' then
pmp = args.pmp
else
error('Argument pmp_mod has invalid value '..args.pmp_mod)
end
parts.pmp = pmp
end
-- parts.debug = debug..'\n\n'..debug_outer
return parts
end
function export.show(frame)
local args = mw.clone(frame:getParent().args)
local cite = args or args or mw.title.getCurrentTitle().text
local currentScript = lang:findBestScript(cite)
local xo = {impl = args.impl, y = args.y, showtr = args.showtr, subst = args.subst}
local parts = export.special_forms(cite, args)
parts.cat = parts.cat or {}
if args.futu then
local fuparts = export.future_forms(args.futu, args, true)
fuparts.cat = fuparts.cat or {}
for k, v in pairs(fuparts) do
if k == 'cat' then
parts.cat = arrcat_nodup(parts.cat, fuparts.cat)
else
parts = fuparts
end
end
-- dump_table('parts', parts)
end
local label = args.label or cite
return export.present_special(label, currentScript, parts, xo)
end
function export.detectFutureEnding(cite3s, latinise)
if latinise then
local cfin = cite3s
cite3s = (lang:transliterate(cfin, latinise))
end
local len, wordEnd
local ending
for len = 6, 1, -1 do
wordEnd = sub(cite3s, -len)
ending = future_endings
if not ending then
-- Try again
else
-- debug_outer = debug_outer..'\n'..cite3s..'='..ending..'\n'
return ending
end
end
-- debug_outer = debug_outer..'\n'..cite3s..'='.."a"..'\n'
return "a"
end
local future_pattern = {
= {
{"⌫⌫⌫āmi"}, {"⌫⌫⌫āma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫nti"},
mid = "ate",
conditional = {
{"⌫⌫ṃ"}, -- Collins also has 1s {"⌫⌫⌫āmi"}
{}, -- Kaccayano, Aggavamsa and Duroiselle have -amhā
-- while Warder and Collins have -āma.
-- {"⌫⌫mhā", "⌫⌫⌫āma"}, -- We need to gather evidence and then decide.
{"⌫⌫", "⌫⌫⌫i"}, {"⌫ha"}, -- Duroiselle also has 2s "⌫⌫⌫e", which Collins says is middle.
{"⌫⌫⌫ā", "⌫⌫"}, {"⌫⌫ṃsu"}, -- Duroiselle also has 3s as in future.
},
participle = {{"⌫⌫nt"}},
},
= { -- Also services "ati"
{"⌫⌫ṃ"}, {"⌫⌫⌫āmhe"}, {"⌫⌫se"}, {"⌫⌫vhe"}, {"⌫e"}, {"⌫⌫nte"},
conditional = {
{"⌫⌫ṃ"}, {"⌫⌫⌫āmhase"},
{"⌫⌫⌫e", "⌫⌫se"}, {"⌫⌫vhe"}, -- Duroiselle has first 2s as active.
{"⌫ha"}, {"⌫⌫⌫iṃsu"},
},
participle = {{"⌫⌫māna", "⌫⌫⌫āna"}},
mid = "ate"
},
= {
conditional = {
{"⌫aṃ"}, -- Collins also has 1s {"mi"}
{}, -- {"⌫amhā", "ma"}, -- See above for controversy.
{"⌫a", "⌫i"}, {"⌫atha"}, -- Duroiselle also has 2s "⌫⌫⌫e", which Collins says is middle.
{"", "⌫a"}, {"⌫aṃsu"}, -- Duroiselle also has 3s as in future.
},
mid = "atha_for_aa",
},
= {
conditional = {
{"ṃ"}, -- Collins also has 1s {"āmi"}
{}, -- {"mhā", "⌫āma"}, -- See above for controversy.
{"", "⌫i"}, {"tha"}, -- Duroiselle also has 2s "⌫⌫⌫e", which Collins says is middle.
{"⌫ā", ""}, {"ṃsu"}, -- Duroiselle also has 3s as in future.
},
mid = "atha_for_a",
},
= {
conditional = {
{"⌫⌫⌫ṃ"}, {"⌫⌫⌫⌫āmhase"},
{"⌫⌫⌫⌫e", "⌫⌫⌫se"}, {"⌫⌫⌫vhe"}, -- Duroiselle has first 2s as active.
{""}, {"⌫⌫⌫⌫iṃsu"},
},
mid = "atha"
},
= {
conditional = {
{"ṃ"}, {"⌫āmhase"},
{"⌫e", "se"}, {"vhe"}, -- Duroiselle has first 2s as active.
{"tha"}, {"⌫iṃsu"},
},
mid = "atha_for_a"
},
atha_for_aa = {
conditional = {
{"⌫aṃ"}, {"mhase"},
{"⌫e", "⌫ase"}, {"⌫avhe"}, -- Duroiselle has first 2s as active.
{"⌫atha"}, {"⌫iṃsu"},
},
mid = "atha_for_aa"
},
iti = {
{"⌫⌫⌫āmi"}, {"⌫⌫⌫āma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫nti"},
mid = "void"
},
heti = {
{"⌫⌫mi"}, {"⌫⌫ma"}, {"⌫⌫si"}, {"⌫ha"}, {""}, {"⌫⌫nti"},
mid = "void"
},
= {
{"⌫⌫⌫āmi"}, {"⌫⌫⌫āma"}, {"⌫⌫si"}, {}, {""}, {"⌫⌫nti"},
mid = "void"
},
void = { {}, {}, {}, {}, {}, {}, mid = "void"}
}
-- convert Latin script inflections to another script
-- ⒹⓉ
function export.getFutureSuffixes(sc, ending, tense, option)
local impl = option and option.impl or 'yes'
local yopt = option and option.y
local pat
if not future_pattern then
error('No verb pattern for ending "'..ending..'".')
end
if tense then
pat = future_pattern
else
pat = future_pattern
end
if 'Latn' == sc then
return pat
elseif not pat then
return nil
elseif pat then
return pat
else
local olen = {Mymr = 2, Lana = 2} -- Assume NFC
local attha_len = {Latn = 5, Sinh = 4}
eyya_len = {Mymr = 3, Sinh = 5}
local alen
if impl == 'no' and (sc == 'Thai' or sc == 'Laoo') then
alen = 1
else
alen = 0
end
local way = {
= {pseudostem = "kati", ndel = 2 + alen},
= {pseudostem = "heti", ndel = 3}, -- Tricky code
= {pseudostem = "kiti", ndel = 3},
= {pseudostem = "kate", ndel = 2 + alen},
= {pseudostem = "kā", ndel = 1},
= {pseudostem = "ka", ndel = alen},
= {pseudostem = "katha", ndel = 1 + 2 * alen},
atha_for_a = {pseudostem = "ka", ndel = alen},
atha_for_aa = {pseudostem = "kā", ndel = 1},
= {pseudostem = "kāhiti", ndel = 5}, --Tricky code
void = {pseudostem = "ku", ndel = 1}, -- rhubarb
}
way = way
if way then
pat = convert_suffixes(way.pseudostem, way.ndel, pat, sc,
impl, yopt)
else
error('Cannot convert derivations from suffix '..ending..' for '..sc)
end
return pat
end
end
function export.future_forms(cite, args, subset)
local currentScript = lang:findBestScript(cite)
local scriptCode = currentScript:getCode()
local latinise = nil
if scriptCode == "None" and args.sc then -- Resort to sc
scriptCode = args
currentScript = m_scripts.getByCode(scriptCode, "No such script as ".. scriptCode .. ".")
latinise = currentScript
augment = to_script("a", scriptCode)
end
if subset then args = export.parse(args) end
args = export.futureParse(args, subset)
args.cite = arrcat_nodup({cite}, args.cite)
local debug = '\n\nAt (1), args.cite = '..table.concat(args.cite, ' ')
local patpa, patpm, basepa, basepm
local parts = {}
local option = {}
option.aa = args.aa
-- Handle future tense. This forms a base for others.
local ending = export.detectFutureEnding(cite, latinise)
patpa = export.getFutureSuffixes(scriptCode, ending, nil, args)
basepa = cite
local mset = nil
local forBoth = false
local aset = args.cite
local voice = "both"
if 'e' == asub(ending, -1) then -- No active inflection
patpm = patpa
patpa = nil
basepm = cite
aset = nil
mset = args.cite
voice = "midl"
elseif args.midl and args.midl then
basepm = args.midl
mset = args.midl
local midend = export.detectFutureEnding(basepm, latinise)
patpm = future_pattern.mid and
export.getFutureSuffixes(scriptCode, future_pattern.mid, nil, args)
elseif args.voice == 'act' then
patpm = nil
voice = "act"
else
patpm = future_pattern.mid and
export.getFutureSuffixes(scriptCode, future_pattern.mid, nil, args)
basepm = cite
forBoth = true
mset = args.cite
end
local formsa = nil
local formsm = nil
if patpa then
formsa = export.joinSuffixes(scriptCode, basepa, patpa, option)
for k = 2, #aset do
basepa = aset
patpa = export.getFutureSuffixes(
scriptCode, export.detectFutureEnding(basepa, latinise), nil, args)
local extras = export.joinSuffixes(scriptCode, basepa, patpa, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
end
end
if patpm or forBoth then
if patpm then
formsm = export.joinSuffixes(scriptCode, basepm, patpm, option)
else
formsm = {{}, {}, {}, {}, {}, {}}
end
for k = 2, #mset do
basepm = mset
local kend = export.detectFutureEnding(basepm, latinise)
kend = future_pattern.mid
if kend then
patpm = export.getFutureSuffixes(scriptCode, kend, nil, args)
local extras = export.joinSuffixes(scriptCode, basepm, patpm, option)
for ip = 1, 6 do
formsm = arrcat_nodup(formsm, extras)
end
end
end
end
if args.voice == "act" or args.voice == "both" then
-- handled already
elseif args.voice == "none" then
formsa = nil
formsm = nil
voice = "none"
elseif args.voice then
error('Argument voice has bad value "'..args.voice..'.')
end
formsa, formsm = export.modify(formsa, formsm, '', args)
parts.futua = formsa
parts.futum = formsm
-- Form conditional from future.
local aug
if args == 'no' then
aug = augment_alph or augment
else
aug = augment
end
-- error("impl="..tostring(args).." aug="..aug)
-- error("impl="..tostring(args).." aug="..aug.." aset="..tostring(aset)..
-- " args.augment="..args.augment)
args.cond_voice = args.cond_voice or voice
-- error("args.cond_voice="..tostring(args.cond_voice))
local cond = {}
if (args.cond_voice ~= 'none') then
if args.augment == 'without' then
if aset then cond = aset end
elseif args.augment == 'with_made' then
if aset then
for k = 1, #aset do
cond = aug .. aset
end
end
elseif args.augment == 'with_given' then
cond = args.cond
elseif args.augment == 'both_made' then
if aset then
for k = 1, #aset do
cond = aug .. aset
end
for k = 1, #aset do
cond = aset
end
end
elseif args.augment == 'both_given' then
cond = arrcat_nodup(args.cond or {}, aset or {})
else
error('Argument augment has bad value "'..args.augment..'".')
end
end
-- mw.addWarning('args.cite='..args.cite..', args.cond_voice='..args.cond_voice)
if (args.cond_voice == 'both' or args.cond_voice == 'act')
then
formsa = {{}, {}, {}, {}, {}, {}}
for k = 1, #cond do
local kend = export.detectFutureEnding(cond, latinise)
local patma = export.getFutureSuffixes(scriptCode, kend, 'conditional', args)
if patma then
local extras = export.joinSuffixes(scriptCode, cond, patma, option)
for ip = 1, 6 do
formsa = arrcat_nodup(formsa, extras)
end
end
end
elseif (args.cond_voice == 'none' or args.cond_voice == 'midl') then
formsa = nil
else
error('Argument cond_voice has bad value "'..args.cond_voice..'".')
end
if (args.cond_voice == 'both' or args.cond_voice == 'midl')
then
formsm = {{}, {}, {}, {}, {}, {}}
if not forBoth then
cond = {}
if args.augment == 'without' then
cond = mset
elseif args.augment == 'with_made' then
for k = 1, #mset do
cond = aug .. mset
end
elseif args.augment == 'with_given' then
cond = args.midl and args.midl and args.cond_midl or args.cond
elseif args.augment == 'both_made' then
for k = 1, #mset do
cond = aug .. mset
end
for k = 1, #mset do
cond = mset
end
elseif args.augment == 'both_given' then
cond = arrcat_nodup(
args.midl and args.midl and (args.cond_midl or {}) or
args.cond or {},
mset or {})
else
error('Argument augment has bad value "'..args.augment..'".')
end
end
for k = 1, #cond do
local kend = export.detectFutureEnding(cond, latinise)
debug=debug..'\n\nAt (7) cond='..cond
if forBoth then
if future_pattern.mid then
kend = future_pattern.mid
elseif kend == "eti" then
kend = nil
else
mw.addWarning('No middle endings for ending "'..kend..'".')
kend = nil
end
end
local pat = kend and export.getFutureSuffixes(scriptCode, kend, 'conditional', args)
if not kend then
-- nothing to do
elseif pat then
local extras = export.joinSuffixes(scriptCode, cond, pat, option)
for ip = 1, 6 do
formsm = arrcat_nodup(formsm, extras)
end
else
mw.addWarning('No conditional middle suffixes for '..cond..
' ('..kend..')')
end
end
else
formsm = nil
end
formsa, formsm = export.modify(formsa, formsm, 'cond_', args)
parts.conda = formsa
parts.condm = formsm
-- List present participles.
local pap, pmp = {}, {}
args.part_voice = args.part_voice or voice
if args.part_voice == 'both' or args.part_voice == 'act' then
if voice == 'both' or voice == 'act' then
for k = 1, aset and #aset or 0 do
local kend = export.detectFutureEnding(aset, latinise)
local pat = kend and export.getFutureSuffixes(scriptCode, kend, "participle", args)
if pat then
local extra = export.joinSuffix(scriptCode, aset, pat)
pap = arrcat_nodup(pap, extra)
end
end
end
if args.fap_mod == 'blank' then
pap = {}
elseif args.fap_mod == 'after' then
pap = arrcat_nodup(pap, args.fap)
elseif args.fap_mod == 'before' then
pap = arrcat_nodup(args.fap, pap)
elseif args.fap_mod == 'replace' then
pap = args.fap
else
error('Argument fap_mod has invalid value '..args.fap_mod)
end
parts.fap = pap
elseif args.part_voice == 'midl' or args.part_voice == 'none' then
-- permissible
else
error('Argument part_voice has invalid value '..tostring(args.part_voice))
end
if args.part_voice == 'both' or args.part_voice == 'midl' then
local list
local from_active = forBoth or voice == 'act'
if from_active then
list = aset
else
list = mset
end
for k = 1, list and #list or 0 do
local kend = export.detectFutureEnding(list, latinise)
if from_active then kend = future_pattern.mid end
local pat = kend and export.getFutureSuffixes(scriptCode, kend, "participle", args)
if pat then
-- if 2 == k then
-- error("k="..k.."list="..list)
-- end
local extra = export.joinSuffix(scriptCode, list, pat)
pmp = arrcat_nodup(pmp, extra)
end
end
if args.fmp_mod == 'blank' then
pmp = {}
elseif args.fmp_mod == 'after' then
pmp = arrcat_nodup(pmp, args.fmp)
elseif args.fmp_mod == 'before' then
pmp = arrcat_nodup(args.fmp, pmp)
elseif args.fmp_mod == 'replace' then
pmp = args.fmp
else
error('Argument fmp_mod has invalid value '..args.fmp_mod)
end
parts.fmp = pmp
end
-- parts.debug = debug..'\n\n'..debug_outer
return parts
end
function export.show_future(frame)
local args = mw.clone(frame:getParent().args)
local cite = args or args -- or mw.title.getCurrentTitle().text
local xo = {impl = args.impl, y = args.y, showtr = args.showtr, subst = args.subst}
local parts = export.future_forms(cite, args, false)
local label = args.label or cite
local currentScript = lang:findBestScript(cite)
return export.present_future(label, currentScript, parts, xo)
end
return export