local export = {}
local lang = require("Module:languages").getByCode("moh")
local m_string_utilities = require("Module:string utilities")
local m_links = require("Module:links")
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 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 find_indices(text, str)
indices = {}
_, next_ind = rfind(text, str, 0)
while next_ind ~= nil do
table.insert(indices, next_ind)
next_ind = next_ind + 1
_, next_ind = rfind(text,str,next_ind)
end
return indices
end
local function arr_to_str(array)
str = ""
for i = 1, #array do str = str .. array .. " " end
return str
end
local function char_at(str, pos)
return usub(str, pos, pos)
end
local function replace_char(text, pos, ch)
local length = #text
local first = ""
local second = ""
if pos > length or pos < 1 then error("invalid position") end
if pos > 1 then first = usub(text, 1, pos-1) end
if pos ~= length then second = usub(text, pos+1, length) end
return first .. ch .. second
end
local function insert_str(text, pos, ch)
local length = #text
local first = ""
local second = ""
if pos > length or pos < 1 then error("invalid position") end
if pos > 1 then first = usub(text, 1, pos) end
if pos ~= length then second = usub(text, pos+1, length) end
return first .. ch .. second
end
local function preprocessing(form)
form = rsub(form, "i()", "y%1")
form = rsub(form, "en()", "v%1")
form = rsub(form, "on()", "u%1")
return form
end
local function postprocessing(form)
local substitutions = { = "on", = "ón", = "òn", = "en", = "én", = "èn", = "i", = "e", = "a"}
for i, j in pairs(substitutions) do stem = rsub(form, i, j) end
return form
end
local function acute_accent(form, pos)
local ch = char_at(form, pos)
local substitutions = { = "á", = "é", = "ó", = "í", = "ú", = "ǘ"}
for i, j in pairs(substitutions) do
if ch == i then return replace_char(form, pos, j) end
end
return form
end
local function grave_accent(form, pos)
local ch = char_at(form, pos)
local substitutions = { = "à", = "è", = "ò", = "ì", = "ù", = "ǜ"}
for i, j in pairs(substitutions) do
if ch == i then return replace_char(form, pos, j) end
end
return form
end
local oneida_order = {"C", "A", "E", "O", "I"}
local oneida_prefixes = {
-- agent
= {"k", "ka", "k", "k", "k"},
}
local function assign_stress(stem)
local vowels = ""
local vowels = find_indices(stem, vowels)
local penult = vowels
local penult_plus1 = usub(stem, penult+1, penult+1)
local penult_plus2 = usub(stem, penult+2, penult+2)
if penult_plus1 == "h" then
if in_set(penult_plus2, {"n", "r"}) then
stem = grave_accent(stem,penult)
stem = replace_char(stem,penult+1, ":") end
elseif penult_plus1 == "’" then
stem = grave_accent(stem,penult)
stem = replace_char(stem,penult+1, ":")
end
return stem
end
function export.show(frame)
text = frame.args or "Kahnawa’ke"
text = assign_stress(text)
return text
end
return export