Documentation for this module may be created at Module:κλίση/en/ουσιαστικό/τεκμηρίωση

export = {}

getstem = function (lemma,suffixnum)
    return mw.ustring.sub(lemma, 1, -1-suffixnum)
end

--Χρησιμοποιώ στατικά το "ενικός" και "πληθυντικός"
--Ίσως χρειάζεται όμως το frame για να προστεθούν από τα πρότυπα
tabletop = [=[{| style="float:right;border:1px solid #AAAACC;margin-left:0.5em;margin-bottom:0.5em;text-align:right;" rules="all" cellpadding="3" cellspacing="0"
! bgcolor="#A1BDEA" colspan="1" align = 'center' width = '50%' | ενικός
! bgcolor="#A1BDEA" colspan="1" align = 'center' width = '50%' | πληθυντικός
|-
]=]

tablenotes = function(notesfromlemma)
    local notes =''
    if notesfromlemma then
        note = '|-' .. "\n" .. [=[| colspan="4" align="left" style="background:#d9ebff; font-size: 90%; font-style: italic;" | ]=] 
        note = note .. notesfromlemma
    end
    return notes
end

tablebottom = [=[
|}]=]

--"notesforlemma" always come here. Either empty string or with content.
general = function (frame,lemma,notesfromlemma,plletters) 
    output = tabletop .. [=[
|-
| align = 'center' | [[]=] .. lemma .. [=[]]
| align = 'center' | [[]=] .. lemma .. plletters .. [=[]]
|}]=] .. tablenotes(notesfromlemma) .. tablebottom
    return output
end


--άραγε Θέλουμε το frame για την εμφάνιση άλλων στοιχείων;
export['e'] = function (frame, lemma, notesfromlemma)
    return general(frame, lemma, notesfromlemma or '','e') --unprocessed
end

export['s'] = function (frame, lemma, notesfromlemma)
    return general(frame, lemma, notesfromlemma or '','s') --unprocessed
end

export['es'] = function (frame, lemma, notesfromlemma)
    return general(frame, lemma, notesfromlemma or '','es') --unprocessed
end

--fly, spy etc.
export['ies'] = function (frame, lemma, notesfromlemma)
    notestoshow = tablenotes(notes or '')
    stemtouse = getstem(lemma,1)
    output = tabletop .. [=[
|-
| align = 'center' | [[]=] .. lemma .. [=[]]
| align = 'center' | [[]=] .. stemtouse .. 'ies' ..  [=[]]
|}]=] .. tablenotes(notesfromlemma) .. tablebottom
    
    return output --unprocessed
end

--man, woman, spiderman etc.
export['men'] = function (frame, lemma, notesfromlemma)
    notestoshow = tablenotes(notes or '')
    stemtouse = getstem(lemma,2)
    output = tabletop .. [=[
|-
| align = 'center' | [[]=] .. lemma .. [=[]]
| align = 'center' | [[]=] .. stemtouse .. 'en' ..  [=[]]
|}]=] .. tablenotes(notesfromlemma) .. tablebottom
    
    return output --unprocessed

end

return export