-- Module:TurkishConjugation
local p = {} -- Table to hold our module's functions
-- Forward declarations for helper functions
local getVerbRoot
local conjugateVerb
local generateConjugationTable
-- Main function to be invoked by the template
function p.conjugate(frame)
local title = frame:getParent().args.title or mw.title.getCurrentTitle().text -- Get the current page title
local root, infinitive_suffix = getVerbRoot(title)
if not root then
return "Invalid verb form or unsupported verb."
end
return generateConjugationTable(root, infinitive_suffix)
end
-- Function to extract the root from the infinitive verb form
getVerbRoot = function(verb)
-- Remove the infinitive suffix '-mak' or '-mek'
if verb:match("mak$") then
return verb:sub(1, -4), "mak" -- Returns the root and the suffix
elseif verb:match("mek$") then
return verb:sub(1, -4), "mek"
else
return nil, nil -- Return nil if it's not a recognized verb form
end
end
-- Function to conjugate a Turkish verb
conjugateVerb = function(root, infinitive_suffix)
local suffixes = {
= { -- Suffixes for 'mak' ending verbs
= "ıyorum", -- I (first person singular)
= "ıyorsun", -- You (second person singular)
= "ıyor", -- He/She/It (third person singular)
= "ıyoruz", -- We (first person plural)
= "ıyorsunuz", -- You all (second person plural)
= "ıyorlar" -- They (third person plural)
},
= { -- Suffixes for 'mek' ending verbs
= "iyorum",
= "iyorsun",
= "iyor",
= "iyoruz",
= "iyorsunuz",
= "iyorlar"
}
}
-- Choose the appropriate suffixes based on the infinitive suffix
local conjugation_table = suffixes
if not conjugation_table then
return "Conjugation for this verb form is not supported."
end
-- Generate the conjugated forms
local conjugated_forms = {
= root .. conjugation_table,
= root .. conjugation_table,
= root .. conjugation_table,
= root .. conjugation_table,
= root .. conjugation_table,
= root .. conjugation_table
}
return conjugated_forms
end
-- Function to generate the HTML for the conjugation table
generateConjugationTable = function(root, infinitive_suffix)
local forms = conjugateVerb(root, infinitive_suffix)
-- Start the collapsible frame
local table_html = mw.html.create('div')
:addClass('NavFrame')
:css('width', '100%')
table_html:tag('div')
:addClass('NavHead')
:css('background', '#DFDFDF')
:wikitext("Conjugation of ''" .. root .. infinitive_suffix .. "''")
:done()
local conjugation_table = table_html:tag('div'):addClass('NavContent')
:tag('table')
:attr('border', '1')
:css('border-collapse', 'collapse')
:css('background', '#F9F9F9')
:css('text-align', 'center')
:css('width', '100%')
:addClass('inflection-table')
conjugation_table:tag('tr')
:tag('td'):css('background', '#f9f9f9'):attr('colspan', 9):wikitext('Note'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#dfdfdf'):attr('colspan', 9):wikitext('Positive declarative'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 3):wikitext('infinitive'):done()
:tag('td'):attr('colspan', 6):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('rowspan', 4, 'colspan', 1):wikitext('impersonal participle'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 2):wikitext('imperfective'):done()
:tag('td'):attr('colspan', 6):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 2):wikitext('perfective'):done()
:tag('td'):attr('colspan', 6):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 2):wikitext('prospective'):done()
:tag('td'):attr('colspan', 6):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('rowspan', 3):attr('colspan', 1):wikitext('personal participle'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 2):wikitext('non-prospective'):done()
:tag('td'):wikitext('{{{1}}}'):wikitext('{{{1}}}'):wikitext('{{{1}}}'):wikitext('{{{1}}}'):wikitext('{{{1}}}'):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 2):wikitext('prospective'):done()
:tag('td'):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 3):wikitext('verbal noun'):done()
:tag('td'):attr('colspan', 6):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):css('background', '#eeeeee'):attr('colspan', 3):wikitext('way of doing'):done()
:tag('td'):attr('colspan', 6):wikitext('{{{1}}}'):done()
conjugation_table:tag('tr')
:tag('th'):attr('colspan', 3):wikitext(''):done()
:tag('th'):css('background', '#dfdfdf'):attr('colspan', 3):wikitext('singular'):done()
:tag('th'):css('background', '#dfdfdf'):attr('colspan', 3):wikitext('plural'):done()
conjugation_table:tag('tr')
:tag('th'):attr('colspan', 3):wikitext(''):done()
:tag('td'):wikitext('{{{1}}}'):done()
:tag('td'):wikitext('{{{2}}}'):done()
:tag('td'):wikitext('{{{3}}}'):done()
:tag('td'):wikitext('{{{4}}}'):done()
:tag('td'):wikitext('{{{5}}}'):done()
:tag('td'):wikitext('{{{6}}}'):done()
conjugation_table:done()
return tostring(table_html)
end
return p -- Return the table containing the functions