local export = {}
-- Abau Manner Prefixes (Table 33, p.127)
local manner_prefixes = {
{ prefix = "nak", gloss = "acc (accompaniment)" },
{ prefix = "hiy", gloss = "caus (causative)" },
{ prefix = "non", gloss = "du (dual accompaniment)" },
{ prefix = "saw", gloss = "spd (speed, urgency)" },
{ prefix = "kor", gloss = "lim (limitation)" },
{ prefix = "kiy", gloss = "act (actuality)" },
{ prefix = "nuw", gloss = "int (intensity)" },
{ prefix = "ma", gloss = "rpt (repetitive)" }
}
-- Abau Directional Prefixes (Table 34, p.128)
local directional_prefixes = {
{ prefix = "a", gloss = "at some distance" },
{ prefix = "amor", gloss = "right there" },
{ prefix = "am", gloss = "near" },
{ prefix = "ka", gloss = "side" },
{ prefix = "kay", gloss = "across" },
{ prefix = "lay", gloss = "straight forward (horizontally)" },
{ prefix = "lak", gloss = "towards the river" },
{ prefix = "lam", gloss = "away from the river" },
{ prefix = "lik", gloss = "alongside the river, downstream" },
{ prefix = "lim", gloss = "alongside the river, upstream" },
{ prefix = "kyor", gloss = "downward (vertically)" },
{ prefix = "ar", gloss = "upward (vertically)" }
}
-- Helper function to apply diacritic for aspect
local function apply_aspect_marker(verb_stem, aspect_marker)
local vowels = { = true, = true, = true, = true, = true }
local marked_vowels = {
= { = "â", = "ê", = "î", = "ô", = "û" },
= { = "à", = "è", = "ì", = "ò", = "ù" }
}
local last_vowel_pos
for i = mw.ustring.len(verb_stem), 1, -1 do
local char = mw.ustring.sub(verb_stem, i, i)
if vowels then
last_vowel_pos = i
break
end
end
if last_vowel_pos then
local vowel_to_mark = mw.ustring.sub(verb_stem, last_vowel_pos, last_vowel_pos)
local marked_vowel_char = marked_vowels and marked_vowels
if marked_vowel_char then
return mw.ustring.sub(verb_stem, 1, last_vowel_pos - 1) ..
marked_vowel_char .. mw.ustring.sub(verb_stem, last_vowel_pos + 1)
end
end
return verb_stem -- Return original if no vowel found
end
-- Function to apply l-deletion and prefixation
local function apply_prefix_to_verb(prefix_data, base_verb_stem)
local prefix = prefix_data.prefix
local prefixed_stem
local l_deleted_stem = base_verb_stem
-- Check for l-deletion (Rule A, p.24)
-- "the verb is prefixed by a verbal prefix ending in a consonant or high vocoid (includes semi-vowels y and w.)"
local last_char_of_prefix = mw.ustring.sub(prefix, -2, -2) -- Get character before hyphen
local prefix_ends_in_cons_or_high_vocoid = false
-- Check for consonants (not vowels or hyphen) or y/w
if not mw.ustring.find(last_char_of_prefix, "") or mw.ustring.find(last_char_of_prefix, "") then
prefix_ends_in_cons_or_high_vocoid = true
end
-- Special case from grammar Table 9: l is NOT deleted after prefix ending in central vowel a (e.g. ma-ley, ka-liwak)
if mw.ustring.sub(base_verb_stem, 1, 1) == "l" then
if prefix_ends_in_cons_or_high_vocoid then
l_deleted_stem = mw.ustring.sub(base_verb_stem, 2) -- Remove initial 'l'
elseif mw.ustring.sub(prefix, -2, -2) == "a" then
-- l is NOT deleted, keep original stem starting with 'l'
l_deleted_stem = base_verb_stem
else
-- Should handle prefixes ending in other vowels (e,i,o,u) which are not high vocoids y/w.
-- The grammar mentions "non-high central vowel a" specifically for non-deletion.
-- For other vowels, assume deletion based on Rule A's high vocoid inclusion, implying other vowels might also cause deletion?
-- Or does Rule A only apply to prefixes ending in C, y, w? "ending in a consonant or high vocoid".
-- Let's stick strictly to the rule A and the exception for 'a'.
-- If prefix ends in vowel other than 'a', and not y/w, does deletion happen? Grammar isn't perfectly explicit here.
-- Based on "ending in a consonant or high vocoid", vowels (a, e, i, o, u) that are *not* y/w should *not* cause deletion.
-- Re-evaluate prefix_ends_in_cons_or_high_vocoid logic.
local last_char_no_hyphen = mw.ustring.sub(prefix, -2, -2)
if not vowels then -- Is a consonant
prefix_ends_in_cons_or_high_vocoid = true
elseif last_char_no_hyphen == 'y' or last_char_no_hyphen == 'w' then -- Is a high vocoid/semi-vowel
prefix_ends_in_cons_or_high_vocoid = true
else -- Is another vowel (a, e, i, o, u)
prefix_ends_in_cons_or_high_vocoid = false -- Deletion does NOT happen per Rule A
end
if prefix_ends_in_cons_or_high_vocoid then
l_deleted_stem = mw.ustring.sub(base_verb_stem, 2) -- Remove initial 'l'
else
-- Rule A doesn't apply, but there's an exception for 'a'.
-- So if it's another vowel (e, i, o, u), deletion also does *not* happen.
l_deleted_stem = base_verb_stem
end
end
end
prefixed_stem = prefix .. l_deleted_stem
local imperfective_form = apply_aspect_marker(prefixed_stem, "ipftv")
local perfective_form = apply_aspect_marker(prefixed_stem, "pftv")
return imperfective_form, perfective_form
end
function export.show(frame)
local parent_args = frame:getParent().args
local args = {}
if parent_args then
args.stem = parent_args.stem
args.meaning = parent_args.meaning
end
local pagename = mw.title.getCurrentTitle().text
local base_verb_stem = args.stem or pagename
-- Content *inside* the inflection-table template
local conj_table_content = {}
-- Add the main table header rows (without the title/intro stuff)
table.insert(conj_table_content, "{| class=\"wikitable\" style=\"text-align:center;\"")
-- Header for aspect columns - Adjusted colspan as gloss column is removed
table.insert(conj_table_content, "! !! colspan=\"1\" | imperfective !! colspan=\"1\" | perfective")
table.insert(conj_table_content, "|-")
-- Base Form Row
local base_ipftv = apply_aspect_marker(base_verb_stem, "ipftv")
local base_pftv = apply_aspect_marker(base_verb_stem, "pftv")
table.insert(conj_table_content, "|-\n! ∅")
table.insert(conj_table_content, "| " .. base_ipftv)
table.insert(conj_table_content, "| " .. base_pftv)
-- Manner Prefixes
if #manner_prefixes > 0 then
-- Adjusted colspan for section header
table.insert(conj_table_content, "|-\n! colspan=\"3\" | '''manner prefixes'''")
for _, p_data in ipairs(manner_prefixes) do
local ipftv_form, pftv_form = apply_prefix_to_verb(p_data, base_verb_stem)
table.insert(conj_table_content, "|-\n! " .. p_data.prefix .. "<br/><small>(" .. p_data.gloss .. ")</small>")
table.insert(conj_table_content, "| " .. ipftv_form)
table.insert(conj_table_content, "| " .. pftv_form)
end
end
-- Directional Prefixes
if #directional_prefixes > 0 then
-- Adjusted colspan for section header
table.insert(conj_table_content, "|-\n! colspan=\"3\" | '''directional prefixes'''")
for _, p_data in ipairs(directional_prefixes) do
local ipftv_form, pftv_form = apply_prefix_to_verb(p_data, base_verb_stem)
table.insert(conj_table_content, "|-\n! " .. p_data.prefix .. "<br/><small>(" .. p_data.gloss .. ")</small>")
table.insert(conj_table_content, "| " .. ipftv_form)
table.insert(conj_table_content, "| " .. pftv_form)
end
end
table.insert(conj_table_content, "|}")
-- Now wrap the table content within the inflection-table template calls
local final_output = {}
-- Add the title "Conjugation of " using inflection-table-top
table.insert(final_output, frame:expandTemplate {
title = 'inflection-table-top',
args = {
title = "Conjugation of ''" .. base_verb_stem .. "''",
palette = 'blue', -- Or another color if preferred,
tall = "yes"
}
})
-- Add the table content itself
table.insert(final_output, table.concat(conj_table_content, "\n"))
-- Add the closing inflection-table-bottom template
table.insert(final_output, frame:expandTemplate { title = 'inflection-table-bottom' })
return table.concat(final_output, "\n")
end
return export