local export = {}
local m_str_utils = require("Module:string utilities")
local m_ryu = require("Module:ryu")
local hiragana = m_ryu.kata_to_hira
local katakana = m_ryu.romaji_to_kata
local map = {
-- Key: Fundamental stem / Nonpast negative (negative, etc.)
-- Column 1: Continuative stem / Headword ending (indicative, etc.)
-- Column 2: Onbin stem / Gerund (conjunctive, past)
= { "ch", "ch" },
= { "s" , "ch" },
= { "ch", "cch" },
= { "n" , "j" },
= { "m" , "d" },
= { "i" , "t" },
= { "i" , "t" },
= { "i" , "ch" },
= { "i" , "tch" },
= { "i" , "tt" },
= { "i" , "tt" },
= { "j" , "j" },
= { "j" , "t" },
= { "j" , "ch" },
= { "b" , "d" },
= { "i" , "t" },
= { "", "" },
};
function check_stem(col) if map == nil then error("Invalid stem. See documentation.") end end
function export.continuative_stem(stem, col) check_stem(col); return stem .. map end
function export.onbin_stem(stem, col)
check_stem(col)
if col == "r5" or col == "r6" then
return stem:sub(1, -3) .. map
end
return stem .. map
end
function export.fundamental_stem(stem, col) check_stem(col); return stem .. col:gsub("", ""):gsub("rn", "r") end
function export.format_ryu_kata(text) return katakana(m_str_utils.gsub(text, "", {
= "aー",
= "iー",
= "uー",
= "eー",
= "oー",
})):gsub(" ", ""):gsub("'", "ッ"):gsub('%.', ''):gsub("ウォ", "ヲ") .. '' end
function export.format_ryu(text) return hiragana(export.format_ryu_kata(text))
:gsub("うぃ", "ゐ")
:gsub("うぇ", "ゑ")
:gsub("うぅ", "をぅ") .. ''
end
function export.format_ryu_no_glottal(text) return text
:gsub("っゐ", "ゐ"):gsub("ゐ", "うぃ")
:gsub("っゑ", "ゑ"):gsub("ゑ", "うぇ")
:gsub("っを", "を"):gsub("をぅ", "うぅ")
:gsub("っや", "や"):gsub("や", "ぃや") .. ''
end
function export.format_ryu_extras(text) return text
:gsub("si", "shi")
:gsub("aa", "ā")
:gsub("ii", "ī")
:gsub("uu", "ū")
:gsub("ee", "ē")
:gsub("oo", "ō") .. ''
end
function export.format_ryu_split_vowel(text) return text
:gsub("ā", "aa")
:gsub("ī", "ii")
:gsub("ū", "uu")
:gsub("ē", "ee")
:gsub("ō", "oo") .. ''
end
function export.format_ryu_broken_vowel(text, stem)
if stem:sub(-1) == text:sub(#stem + 1, #stem + 1) and stem == text:sub(1, #stem) and stem:sub(-1):gsub("", "") == "" then
return stem .. "." .. text:sub(#stem + 1)
else
return text
end
end
function conj_template(p)
p.i_infix = p.i_infix == nil and p.infix or p.i_infix
p.p_infix = p.p_infix == nil and p.infix or p.p_infix
p.n_infix = p.n_infix == nil and p.infix or p.n_infix
p.p_stem = p.p_stem == nil and p.stem or p.p_stem
p.n_stem = p.n_stem == nil and p.stem or p.n_stem
return {
p_im = { p.stem .. p.i_infix .. "n" },
a_im = { p.stem .. p.i_infix .. "ru" },
p_pf = { p.p_stem .. p.p_infix .. "an" },
a_pf = { p.p_stem .. p.p_infix .. "aru" },
ineg = { p.n_stem .. p.n_infix .. "an" },
pneg = { p.n_stem .. p.n_infix .. "antan" },
};
end
function export.conj_irregulars(p)
local conj = {}
if p.stem == "ッめんせーん" or p.stem == "ぃめんせーん" or p.stem == "ッめんせえん" or p.stem == "ぃめんせえん"
or p.stem == "めんせーん" or p.stem == "めんせえん" or p.stem == "めんしえーん" or p.stem == "ッめんしえーん"
or p.stem == "ぃめんしえーん" or p.stem == "ッメンセーン" or p.stem == "ッメンシェーン" or p.stem == "ぃ召候ん" then
local s = "'mens"
if p.row == "ind" then
p.stem = "'mens"
p.i_infix = "ē"
p.p_infix = "ō"
p.n_infix = "ō"
end
conj = conj_template(p)
end
return conj
end
return export