Module:User:Mofvanes/otw-verb

local export = {}

local lang = require("Module:languages").getByCode("otw") local m_string_utilities = require("Module:string utilities") local m_links = require("Module:links")

local vowels = {"a", "i", "o", "e", "ā", "ī", "ō"}

local vai_pers = {"1s", "2s", "3s", "3’", "X", "1p", "21", "2p", "3p"} local vai_accel = { ["pres"] = {"1|s", "2|s", "3|s", "3|obv", "impers", "1|excl|p", "1|incl|p", "2|p", "3|p"}, ["pres-neg"] = {"1|s", "2|s", "3|s", "3|obv", "impers", "1|excl|p", "1|incl|p", "2|p", "3|p"}, ["pret-neg"] = {"1|s", "2|s", "3|s", "3|obv", "impers", "1|excl|p", "1|incl|p", "2|p", "3|p"}, ["dubit"] = {"1|s", "2|s", "3|s", "3|obv", "impers", "1|excl|p", "1|incl|p", "2|p", "3|p"}, ["dubit-neg"] = {"1|s", "2|s", "3|s", "3|obv", "impers", "1|excl|p", "1|incl|p", "2|p", "3|p"} } local vai_pref = { ["C"] = {"ni", "gi", "",  "",    "", "ni",  "gi",  "gi", ""}, ["V"] = {"nid", "gid", "",  "",    "", "nid",  "gid",  "gid", ""} } local vai_suff = {"", "", "W", "W", "m", "mi", "mi", "m", "W"}

local vai_neg = { ["C"] = "sii", ["N"] = "zii" } local vai_pret = {"nāban", "nāban", "iban", "iban", "aban", "āban", "āban", "iban"} local vai_pret = {"nādig", "nādig", "idig", "idigen", "idig", "ādig", "ādig", "idigen"} local vai_3suf = { ["C"] = {"", "", "", "an", "", "", "", "", "ag"}, ["Y"] = {"", "", "", "iin", "", "", "", "", "iig"} }

local vai_table = [=[ ]=]

local vii_pers = {"0", "0’", "0p", "0’p"} local vii_accel = {"3|s", "3|s|obv", "3|p", "3|p|obv"}

local vii_verb_table = [=[ ]=]

local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local ulower = mw.ustring.lower local usub = mw.ustring.sub

local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end

local function get_index(str, list) if list == nil then return -1 end for i = 1, #list do if str == list[i] then return i end end return -1 end

local function in_set(str, list) if get_index(str, list) ~= -1 then return true else return false end end local function char_at(str, pos) return usub(str, pos, pos) end local function accent_vowels(str) return rsub(rsub(rsub(str, "aa", "ā"), "ii", "ī"), "oo", "ō") end local function double_vowels(str) return rsub(rsub(rsub(str, "ā", "aa"), "ī", "ii"), "ō", "oo") end

local function del_char(str, pos) local length = #str if pos > length or pos < 1 then error("invalid position") end if pos > 1 then first = usub(str, 1, pos-1) else first = "" end if pos ~= length then second = usub(str, pos+1, length) else second = "" end if in_set(char_at(first,#first), {"z", "h"}) and char_at(second,1) == "h" then return first .. "'" .. second end if char_at(first,#first) == "n" and in_set(char_at(second,1), {"s", "z", "y"}) then return first .. "'" .. second end return first .. second end

-- Algorithm as described in Valentine 2001 local function del_weak_vowels(stem) stem = accent_vowels(stem) vowels = {} weak_vowels = {} prev_vowel_weak = false for i = 1, #stem do		if in_set(char_at(stem,i), {"a", "i", "o"}) then table.insert(vowels, i)			if prev_vowel_weak then prev_vowel_weak = false else table.insert(weak_vowels ,i) prev_vowel_weak = true end elseif in_set(char_at(stem,i), {"e", "ā", "ī", "ō"}) then table.insert(vowels, i)			prev_vowel_weak = false else end end if vowels[#vowels] == weak_vowels[#weak_vowels] then table.remove(weak_vowels, #weak_vowels) end for i = #weak_vowels, 1, -1 do stem = del_char(stem, weak_vowels[i]) end return double_vowels(stem) end

local function phonotactics(stem) final_ch = char_at(stem,#stem) penul_ch = char_at(stem,#stem) if final_ch == "y" and final_ch == "n" then stem = usub(stem, 1, #stem-1) .. "h" end if final_ch == "w" or final_ch == "y" then stem = usub(stem, 1, #stem-1) end return stem end

local function build_vai_table(stem) forms = {} if in_set(char_at(stem,1),vowels) then prefix_class = "V" else prefix_class = "C" end for i = 1, #vai_pers do pref_stems = vai_prefix[prefix_class][i] .. stem end for i = 1, #vai_pers do word = pref_stems[i] .. vai_suf word = phonotactics(del_weak_vowels(word)) forms[vai_accel[i]] = word end for i = 1, #vai_pers do word = vai_prefix[prefix_class][i] .. stem word = phonotactics(del_weak_vowels(word)) forms[vai_accel[i]] = word end return m_string_utilities.format(vai_table, forms) end

function change_conjunct(stem) for i = 1, #stem do		if in_set(char_at(stem,i), vowels) then return "unfinished" end end end

function export.show(frame) PAGENAME = mw.title.getCurrentTitle.text text = frame.args[1] return "boodwe" end

return export