Module:nn-verb-table

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local p = {}
local classes = require('Module:nn-verb-classes')
local class = {v1 = classes.v1, v2 = classes.v2,
    v3 = classes.v3, v4 = classes.v4}


function p.section(forms, number, type)
    numbers = {'first', 'second', 'third'}
    text = [=[ 
|-
! rowspan="7" style="background:#DFDFDF" |]=] .. numbers[number] .. ' inflection (' .. type .. [=[) 
|-
! colspan="6" style="background:#DFDFDF" | <span style="color:Green">Inflection in time</span>
|-
! style="background:#DFDFDF" | present tense
! style="background:#DFDFDF" | past tense
! style="background:#DFDFDF" | supine
! style="background:#DFDFDF" | passive infinitive
! style="background:#DFDFDF" | present participle
! style="background:#DFDFDF" | imperative
|-
| ]=] .. forms['present tense'] .. '\n| ' .. forms['past tense'] ..
'\n| ' .. forms['past participle'] .. '\n| ' .. forms['passive infinitive'] .. 
'\n| ' .. forms['present participle'] .. '\n| ' .. forms['imperative'] .. [=[ 
|-
! colspan="3" style="background:#DFDFDF" | <span style="color:Green">Inflection of the past participle</span> || style="background:#DFDFDF" rowspan="3" colspan = "3"| &nbsp;
|-
! style="background:#DFDFDF" | masculine and feminine
! style="background:#DFDFDF" | neuter
! style="background:#DFDFDF" | definite singular and plural
|-
| ]=] .. forms['adj f and m'] .. '\n| ' .. forms['adj n'] ..
'\n| ' .. forms['adj def sg and pl']
    return text
end

function p.main(frame)
    PAGENAME = mw.title.getCurrentTitle().text
    
    class1 = frame.args[1]
    class2 = frame.args[2]
    class3 = frame.args[3]
    
    forms1 = class[class1](PAGENAME)
    
    length = PAGENAME:len()
    template = [=[ <div class="NavFrame" style="width:78em">
<div class="NavHead" style="" >&nbsp; &nbsp; Complete inflection of <small>'']=] .. PAGENAME .. [=[''</small></div>
<div class="NavContent">
 
{| style="background:#F9F9F9;text-align:center;width:70em" class="inflection-table2"]=]
    
    template = template .. p.section(forms1, 1, class1)
    if class2 and class2 ~= '' then
        forms2 = class[class2](PAGENAME)
        template = template .. p.section(forms2, 2, class2)
    else
        template = template:gsub('first inflection', 'inflection')
    end
    if class3 and class3 ~= '' then
        forms3 = class[class3](PAGENAME)
        template = template .. p.section(forms3, 3, class3)
    end

    template = template .. [=[ 
|- 
! colspan = "2" style="background:#DFDFDF"| <span style="color:Green">Derivations</span> || style="background:#DFDFDF" rowspan="3" colspan = "5"| &nbsp; 
|-
! style="background:#DFDFDF" | Verbal noun
| ]=] .. forms1['verbal noun'] .. [=[ 
|-
! style="background:#DFDFDF" | Agent noun 
| ]=] .. forms1['agent noun'] .. '\n|}\n</div></div>'
    return template
end

return p