local export = {}
local m_para = require("Module:parameters")
local initial_pattern = "^?"
local function mutate(text)
text = text:gsub("qu", "qw") -- temporarily encode qu
local initial = mw.ustring.match(text, initial_pattern):gsub("qw", "qu")
local corr = {
-- = { "lenited", "nasalised" }
= { "ph", "b" },
= { "h", "d" },
= { "h", "dh" },
= { "h", "j" },
= { "ch", "g" },
= { "ch", "g" },
= { "wh", "gu" },
= { "b", "b" },
= { "w", "mw" },
= { "gh", "d" },
= { "gh", "dh" },
= { "gh", "n" },
= { "gh", "g" },
= { "v", "m" },
= { "w", "mw" },
= { "", "v" },
= { "wh", "w" },
= { "h", "s" },
= { "l", "sl" },
= { "n", "sn" },
= { "h", "sh" },
}
return {
initial, -- radical
corr, -- lenited
corr, -- nasalised
}
end
function export.show(frame)
local args = m_para.process(frame:getParent().args, {
= { default = mw.loadData("Module:headword/data").page.pagename } , -- root
= true, -- stem
= true, -- participle
= { default = "?" } , -- verbal noun; ideally this should always be provided
})
local condition = {
-- some conditions that get reused a lot below
has_final_ee = args:find("ee$"),
ends_in_vowel = args:find("$"),
starts_in_f_fr = args:find("^fr?"),
}
if not args then
-- try to generate the stem
if condition.has_final_ee then
args = args:gsub("ee$", "")
elseif args:find("e?$") then
args = args:gsub("()e?$", "%1%1")
else
args = args
end
end
if args.vn == "?" then
require("Module:debug/track")("gv-conj/no verbal noun provided")
end
local mutated = mutate(args)
local root = args:gsub(initial_pattern, "")
local stem = args:gsub(initial_pattern, "")
local data = {
B = mutated,
L = mutated,
N = mutated,
root = root,
stem = stem,
pp = args.pp or args .. "it",
vn = args.vn,
past = (condition.starts_in_f_fr and "d" or mutated) .. root,
fut_ind = (condition.has_final_ee and args or args) .. ((condition.ends_in_vowel and not condition.has_final_ee) and "-" or "") .. "ee",
fut_rel = mutated .. (condition.has_final_ee and root or stem) .. (condition.ends_in_vowel and "-" or "") .. "ys",
fut_1s_ind = (condition.has_final_ee and args or args) .. (condition.ends_in_vowel and "-" or "") .. "ym",
fut_1s_dep = mutated .. (condition.has_final_ee and root or stem) .. (condition.ends_in_vowel and "-" or "") .. "ym",
fut_1s_rel = mutated .. (condition.has_final_ee and root or stem) .. (condition.ends_in_vowel and "-" or "") .. "ym",
}
return (([[
! colspan="2" class="outer" |
! class="outer" | Independent
! class="outer" | Dependent
! class="outer" | Relative
|-
! colspan="2" class="outer" | Past
| {{{past}}}
| {{{N}}}{{{root}}}
| {{{past}}}
|-
! rowspan="3" class="outer" | Future
! General
| {{{fut_ind}}}
| {{{N}}}{{{root}}}
| {{{fut_rel}}}
|-
! First singular
| {{{fut_1s_ind}}}
| {{{fut_1s_dep}}}
| {{{fut_1s_rel}}}
|-
! First plural
| {{{B}}}{{{root}}}-maid
| {{{N}}}{{{root}}}-maid
| {{{L}}}{{{stem}}}ys-maid
|-
! rowspan="2" class="outer" | Conditional
! General
| {{{L}}}{{{stem}}}agh
| {{{N}}}{{{stem}}}agh
| {{{L}}}{{{stem}}}agh
|-
! First singular
| {{{L}}}{{{stem}}}in
| {{{N}}}{{{stem}}}in
| {{{L}}}{{{stem}}}in
|-
! rowspan="2" class="outer" | Imperative
! General
| colspan="3" | {{{B}}}{{{root}}}
|-
! Second plural
| colspan="3" | {{{B}}}{{{root}}}-jee
|-
! colspan="2" class="outer" | Participle
| colspan="3" | {{{pp}}}
|-
! colspan="2" class="outer" | Verbal noun
| colspan="3" | {{{vn}}}
]])
:gsub("{{{(-)}}}", data))
end
return export