Module:pl-nouns-decl
Documentation for this module may be created at Module:pl-nouns-decl/τεκμηρίωση
p = {}
--σταθερές
bgcolor = 'd9ebff'
titlesbgcolor = '#d9ebff'
ptoseisbgcolor = '#eff7ff'
bordercolor = '#AAAACC'
kataliksicolor = 'DeepPink'
--τοπικές συναρτησεις
errorhere = function(errstring)
return '<div class="error">' .. errstring .. '</div>[[Κατηγορία:Σελίδες με σφάλματα στο πρότυπο κλίσης]]'
end
_xk = function(kataliksi)
return '<font style="color:' .. kataliksicolor ..';">' .. kataliksi .. '</font>'
end
xintable = function(thevalue,thetable)
for k,v in pairs(thetable) do
if v == thevalue then return true end
end
return false
end
maintable = function (args)
local ostr = ''
local ostrpl = ''
local dstr = ''
local dstrpl = ''
local cstr = ''
local cstrpl = ''
local bstr = ''
local bstrpl = ''
local nstr = ''
local nstrpl = ''
local mstr = ''
local mstrpl = ''
local wstr = ''
local wstrpl = ''
local paratirisi = ''
local hassingular = true --(args['εν'] ~= nil)
if args['μόνο'] == "πλ" then hassingular = false end
local hasplural = true -- (args['πλ'] ~= nil)
if args['μόνο'] == "εν" then hasplural = false end
if not (args['παρατήρηση'] == nil or mw.ustring.len(args['παρατήρηση']) < 1) then
--mw.log('para')
paratirisi = '|-' .. "\n" .. [=[| colspan="4" align="left" style="background:]=] .. titlesbgcolor .. [=[; font-size: 90%; font-style: italic;" | ]=]
paratirisi = paratirisi .. args['παρατήρηση'] .. "\n"
end
-- if paratirisi == nil then paratirisi =
if hassingular then
stitlestr = [=[! bgcolor="]=] .. titlesbgcolor .. [=[" colspan="1" align="center"| '''''[[ενικός]]''''']=] .. "\n"
ostr = [=[| align="left" | ]=] .. args['οε'] .. "\n"
dstr = [=[| align="left" | ]=] .. args['γε'] .. "\n"
cstr = [=[| align="left" | ]=] .. args['δε'] .. "\n"
bstr = [=[| align="left" | ]=] .. args['αε'] .. "\n"
nstr = [=[| align="left" | ]=] .. args['ρε'] .. "\n"
mstr = [=[| align="left" | ]=] .. args['τε'] .. "\n"
wstr = [=[| align="left" | ]=] .. args['κε'] .. "\n"
end
if hasplural then
ptitlestr = [=[! bgcolor="]=] .. titlesbgcolor .. [=[" colspan="1" align="center"| '''''[[πληθυντικός]]''''']=] .. "\n"
ostrpl = [=[| align="left" | ]=] .. args['οπ'] .. "\n"
dstrpl = [=[| align="left" | ]=] .. args['γπ'] .. "\n"
cstrpl = [=[| align="left" | ]=] .. args['δπ'] .. "\n"
bstrpl = [=[| align="left" | ]=] .. args['απ'] .. "\n"
nstrpl = [=[| align="left" | ]=] .. args['ρπ'] .. "\n"
mstrpl = [=[| align="left" | ]=] .. args['τπ'] .. "\n"
wstrpl = [=[| align="left" | ]=] .. args['κπ'] .. "\n"
end
return [=[{| 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="]=] .. titlesbgcolor .. [=[" | πτώση]=] .. "\n" .. stitlestr .. ptitlestr .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[ονομαστική]]''''' ('''''[[mianownik]]''''')]=] .. "\n" .. ostr .. ostrpl .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[γενική]]''''' ('''''[[dopełniacz]]''''')]=] .. "\n" .. dstr .. dstrpl .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[δοτική]]''''' ('''''[[celownik]]''''')]=] .. "\n" .. cstr .. cstrpl .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[αιτιατική]]''''' ('''''[[biernik]]''''')]=] .. "\n" .. bstr .. bstrpl .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[οργανική]]''''' ('''''[[narzędnik]]''''')]=] .. "\n" .. nstr .. nstrpl .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[τοπική]]''''' ('''''[[miejscownik]]''''')]=] .. "\n" .. mstr .. mstrpl .. [=[|-
| bgcolor="]=] .. ptoseisbgcolor .. [=[" | '''''[[κλητική]]''''' ('''''[[wołacz]]''''')]=] .. "\n" .. wstr .. wstrpl .. paratirisi .. [=[|}]=]
end
p.main = function (frame)
local args = frame.args
--get args passed from the article
local lemmaargs = frame:getParent().args
local pagename = mw.title.getCurrentTitle().text
--get template name
local templatename = frame:getParent():getTitle()
--get template name assuming all start the same
local protypoklisis = mw.ustring.sub(templatename, mw.ustring.len('Πρότυπο:pl-κλίσ-\'')+1,-2)
--find endings
local tableargs = p[protypoklisis](pagename, lemmaargs) or ''
--αν δεν βρει συνάρτηση για το πρότυπο
if tableargs == '' then return errorhere('Δεν βρέθηκε το πρότυπο!') end
--αν δεν επιστρέψει τουλάχιστον 14 (επειδή υπάρχει κάποιο άλλο πρόβλημα...)
if tableargs['οε'] == nil then return errorhere('Πρόβλημα με τις παραμέτρους!') end
--έχει μόνο πληθυντικό ή μόνο ενικό;
if lemmaargs['μόνο'] ~= nil then tableargs['μόνο'] = lemmaargs['μόνο'] end
--έχει παρατηρήσεις;
if lemmaargs['παρατήρηση'] ~= nil then tableargs['παρατήρηση'] = lemmaargs['παρατήρηση'] end
return frame:preprocess(maintable(tableargs))
end
--για ελέγχους στο αμμοδοχείο
p.check = function (frame)
local args = frame.args
--get args passed from the article
local lemmaargs = frame:getParent().args
local pagename = mw.title.getCurrentTitle().text
--get template name
local templatename = frame:getParent():getTitle()
--get template name assuming all start the same
local protypoklisis = args['προτυπο']--mw.ustring.sub(templatename, mw.ustring.len('Πρότυπο:pl-κλίσ-\'')+1,-2)
--find endings
local tableargs = p[protypoklisis](pagename, lemmaargs) or ''
--αν δεν βρει συνάρτηση για το πρότυπο
if tableargs == '' then return errorhere('Δεν βρέθηκε το πρότυπο!') end
--αν δεν επιστρέψει τουλάχιστον 14 (επειδή υπάρχει κάποιο άλλο πρόβλημα...)
if tableargs['οε'] == nil then return errorhere('Πρόβλημα με τις παραμέτρους!') end
--έχει μόνο πληθυντικό ή μόνο ενικό;
if lemmaargs['μόνο'] ~= nil then tableargs['μόνο'] = lemmaargs['μόνο'] end
--έχει παρατηρήσεις;
if lemmaargs['παρατήρηση'] ~= nil then tableargs['παρατήρηση'] = lemmaargs['παρατήρηση'] end
return frame:preprocess(maintable(tableargs))
end
p['dummy'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1, -3)
largs['οε'] = stem .. _xk('ek')
largs['γε'] = stem .. _xk('ka')
largs['δε'] = stem .. _xk('kowi')
largs['αε'] = stem .. _xk('ek')
largs['ρε'] = stem .. _xk('kiem')
largs['τε'] = stem .. _xk('ku')
largs['κε'] = stem .. _xk('ku')
largs['οπ'] = stem .. _xk('ki')
largs['γπ'] = stem .. _xk('ków')
largs['δπ'] = stem .. _xk('kom')
largs['απ'] = stem .. _xk('ki')
largs['ρπ'] = stem .. _xk('kami')
largs['τπ'] = stem .. _xk('kach')
largs['κπ'] = stem .. _xk('ki')
return largs
end
p['poeta'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1, -3)
largs['οε'] = stem .. _xk('ta')
largs['γε'] = stem .. _xk('ty')
largs['δε'] = stem .. _xk('cie')
largs['αε'] = stem .. _xk('tę')
largs['ρε'] = stem .. _xk('tą')
largs['τε'] = largs['δε']
largs['κε'] = stem .. _xk('to')
largs['οπ'] = stem .. _xk('ci')
largs['γπ'] = stem .. _xk('tów')
largs['δπ'] = stem .. _xk('tom')
largs['απ'] = largs['γπ']
largs['ρπ'] = stem .. _xk('tami')
largs['τπ'] = stem .. _xk('tach')
largs['κπ'] = largs['οπ']
return largs
end
p['artysta'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1, -4)
largs['οε'] = stem .. _xk('sta')
largs['γε'] = stem .. _xk('sty')
largs['δε'] = stem .. _xk('ście')
largs['αε'] = stem .. _xk('stę')
largs['ρε'] = stem .. _xk('stą')
largs['τε'] = largs['δε']
largs['κε'] = stem .. _xk('sto')
largs['οπ'] = stem .. _xk('ści')
largs['γπ'] = stem .. _xk('stów')
largs['δπ'] = stem .. _xk('stom')
largs['απ'] = largs['γπ']
largs['ρπ'] = stem .. _xk('stami')
largs['τπ'] = stem .. _xk('stach')
largs['κπ'] = largs['οπ']
return largs
end
p['lekarz'] = function (pagename, lemmaargs)
local largs = {}
largs['οε'] = pagename
largs['γε'] = pagename .. _xk('a')
largs['δε'] = pagename .. _xk('owi')
largs['αε'] = largs['γε']
largs['ρε'] = pagename .. _xk('em')
largs['τε'] = pagename .. _xk('u')
largs['κε'] = largs['τε']
largs['οπ'] = pagename .. _xk('e')
largs['γπ'] = pagename .. _xk('y')
largs['δπ'] = pagename .. _xk('om')
largs['απ'] = largs['γπ']
largs['ρπ'] = pagename .. _xk('ami')
largs['τπ'] = pagename .. _xk('ach')
largs['κπ'] = largs['οπ']
return largs
end
p['profesor'] = function (pagename, lemmaargs)
local largs = {}
largs['οε'] = pagename
largs['γε'] = pagename .. _xk('a')
largs['δε'] = pagename .. _xk('owi')
largs['αε'] = largs['γε']
largs['ρε'] = pagename .. _xk('em')
largs['τε'] = pagename .. _xk('ze')
largs['κε'] = largs['τε']
largs['οπ'] = pagename .. _xk('owie')
largs['γπ'] = pagename .. _xk('ów')
largs['δπ'] = pagename .. _xk('om')
largs['απ'] = largs['γπ']
largs['ρπ'] = pagename .. _xk('ami')
largs['τπ'] = pagename .. _xk('ach')
largs['κπ'] = largs['οπ']
return largs
end
p['kotek'] = function (pagename)
local largs = {}
local stem = mw.ustring.sub(pagename, 1,-3)
largs['οε'] = stem .. _xk('ek')
largs['γε'] = stem .. _xk('ka')
largs['δε'] = stem .. _xk('kowi')
largs['αε'] = args['οε']
largs['ρε'] = stem .. _xk('kiem')
largs['τε'] = stem .. _xk('ku')
largs['κε'] = largs['τε']
largs['οπ'] = stem .. _xk('ki')
largs['γπ'] = stem .. _xk('ków')
largs['δπ'] = stem .. _xk('kom')
largs['απ'] = largs['οπ']
largs['ρπ'] = stem .. _xk('kami')
largs['τπ'] = stem .. _xk('kach')
largs['κπ'] = largs['οπ']
return largs
end
--p.test1 = function (pagename, lemmaargs)
p['θ'] = function (pagename, lemmaargs)
local largs = {}
local lastletter = mw.ustring.sub(pagename,-1,-1)
--είναι a το τελευταίο;
if lastletter ~= 'a' then return largs end --largs=empty, which yields error
local doubles = {}
local doubles = {'ch', 'cz', 'dz', 'dż', 'rz', 'śk', 'sł', 'sm', 'sn', 'st', 'sz', 'zd', 'źk', 'zł', 'zm', 'zn'}
local singles = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'ł', 'm', 'n', 'p', 'r', 's', 't', 'w', 'z', 'ż'}
--βρες το προτελευταίο γράμμα
local inletter = mw.ustring.sub(pagename,-2,-2)
--largs['test'] = ''--inletter
-- βρες το τρίτο γράμμα από το τέλος
local thirdletter = mw.ustring.sub(pagename,-3,-3)
--αφαίρεσε τα 2 τελευταία γράμματα για να βρεις το θέμα
local stem = mw.ustring.sub(pagename, 1,-3)
--αν ο συνδυασμός των δύο προτελευταίων γραμμάτων υπάρχει...
--largs['test2'] = ''
--largs['test2a'] = stem
if xintable((thirdletter .. inletter),doubles) then
inletter = thirdletter .. inletter
--άλλαξε και το θέμα
stem = mw.ustring.sub(pagename, 1,-4)
largs['test3'] = inletter
else
--largs['test3'] = inletter
--αν δεν έχει κανένα από τα παραπάνω δίψηφα ούτε και κάποιο από τα παρακάτω μονά γράμματα...
--δεν υποστηρίζεται από αυτή τη συνάρτηση
if not (xintable(inletter,singles)) then
return largs --largs=empty, which yields error
end
end
--largs['test4'] = stem .. inletter
largs['οε'] = stem .. inletter .. _xk('a')
--largs['test4b'] = stem .. inletter .. _xk('a')
if xintable(inletter, {'g', 'j', 'k', 'l' }) then
largs['γε'] = stem .. inletter .. _xk('i')
else
largs['γε'] = stem .. inletter .. _xk('y')
end
if xintable(inletter , {'b', 'f', 'm', 'n', 'p', 's', 'w', 'z'}) then
largs['δε'] = stem .. inletter .. _xk('ie')
elseif xintable(inletter , {'c', 'cz', 'dz', 'dż', 'rz', 'sz', 'ż'}) then
largs['δε'] = stem .. inletter .. _xk('y')
elseif inletter == 'ch' then
largs['δε'] = stem .. _xk('sze')
elseif inletter == 'd' then
largs['δε'] = stem .. _xk('dzie')
elseif inletter == 'g' then
largs['δε'] = stem .. _xk('dze')
elseif inletter == 'h' then
largs['δε'] = stem .. _xk('że')
elseif inletter == 'j' then
largs['δε'] = stem .. _xk('ji')
elseif inletter == 'k' then
largs['δε'] = stem .. _xk('ce')
elseif inletter == 'l' then
largs['δε'] = stem .. _xk('li')
elseif inletter == 'ł' then
largs['δε'] = stem .. _xk('le')
elseif inletter == 'r' then
largs['δε'] = stem .. _xk('rze')
elseif inletter == 'sł' then
largs['δε'] = stem .. _xk('śle')
elseif inletter == 'sm' then
largs['δε'] = stem .. _xk('śmie')
elseif inletter == 'sn' then
largs['δε'] = stem .. _xk('śnie')
elseif inletter == 'st' then
largs['δε'] = stem .. _xk('ście')
elseif inletter == 't' then
largs['δε'] = stem .. _xk('cie')
elseif inletter == 'zd' then
largs['δε'] = stem .. _xk('ździe')
elseif inletter == 'zł' then
largs['δε'] = stem .. _xk('źle')
elseif inletter == 'zm' then
largs['δε'] = stem .. _xk('źmie')
elseif inletter == 'zn' then
largs['δε'] = stem .. _xk('źnie')
end
largs['αε'] = stem .. inletter .. _xk('ę')
largs['ρε'] = stem .. inletter .. _xk('ą')
largs['τε'] = largs['δε']
largs['κε'] = stem .. inletter .. _xk('o')
if xintable(inletter , {'g', 'k'}) then
largs['οπ'] = stem .. inletter .. _xk('i')
elseif xintable(inletter , {'c', 'cz', 'dz', 'dż', 'rz', 'sz', 'ż'}) then
largs['οπ'] = stem .. inletter .. _xk('e')
else
largs['οπ'] = stem .. inletter .. _xk('y')
end
--αν έχει δόσει τη γενική πληθυντικού...
if lemmaargs['γπ'] ~= nil then
largs['γπ'] = lemmaargs['γπ'] --πρόβλημα με την κατάληξη
else--αλλιώς...
if inletter == 'j' then
largs['γπ'] = stem .. inletter .. _xk('i') .. '/' .. stem .. _xk('yj')
elseif inletter == 'k' then
largs['γπ'] = stem .. _xk('ek')
else
largs['γπ'] = stem .. inletter
end
end
largs['δπ'] = stem .. inletter .. _xk('om')
largs['απ'] = largs['οπ']
largs['ρπ'] = stem .. inletter .. _xk('ami')
largs['τπ'] = stem .. inletter .. _xk('ach')
largs['κπ'] = largs['οπ']
return largs
end
p['dynia'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1 ,-4)
largs['οε'] = stem .. 'ni' .. _xk('a')
largs['γε'] = stem .. 'ni'
largs['δε'] = stem .. 'ni'
largs['αε'] = stem .. 'ni' .. _xk('ę')
largs['ρε'] = stem .. 'ni' .. _xk('ą')
largs['τε'] = stem .. 'ni'
largs['κε'] = stem .. 'ni' .. _xk('o')
largs['οπ'] = stem .. 'ni' .. _xk('e')
largs['γπ'] = stem .. 'ń'
largs['δπ'] = stem .. 'ni' .. _xk('om')
largs['απ'] = largs['οπ']
largs['ρπ'] = stem .. 'ni' .. _xk('ami')
largs['τπ'] = stem .. 'ni' .. _xk('ach')
largs['κπ'] = largs['οπ']
return largs
end
p['wartość'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1,-2)
largs['οε'] = stem .. _xk('ć')
largs['γε'] = stem .. _xk('ci')
largs['δε'] = largs['γε']
largs['αε'] = largs['οε']
largs['ρε'] = stem .. _xk('cią')
largs['τε'] = largs['γε']
largs['κε'] = largs['γε']
largs['οπ'] = largs['γε']
largs['γπ'] = largs['γε']
largs['δπ'] = stem .. _xk('ciom')
largs['απ'] = largs['γε']
largs['ρπ'] = stem .. _xk('ciami')
largs['τπ'] = stem .. _xk('ciach')
largs['κπ'] = largs['γε']
return largs
end
p['stadium'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1,-3)
largs['οε'] = stem .. _xk('um')
largs['γε'] = largs['οε']
largs['δε'] = largs['οε']
largs['αε'] = largs['οε']
largs['ρε'] = largs['οε']
largs['τε'] = largs['οε']
largs['κε'] = largs['οε']
largs['οπ'] = stem .. _xk('a')
largs['γπ'] = stem .. _xk('ów')
largs['δπ'] = stem .. _xk('om')
largs['απ'] = largs['οπ']
largs['ρπ'] = stem .. _xk('ami')
largs['τπ'] = stem .. _xk('ach')
largs['κπ'] = largs['οπ']
return largs
end
p['zdanie'] = function (pagename, lemmaargs)
local largs = {}
local stem = mw.ustring.sub(pagename, 1,-4)
largs['οε'] = stem .. 'ni' .. _xk('e')
largs['γε'] = stem .. 'ni' .. _xk('a')
largs['δε'] = stem .. 'ni' .. _xk('u')
largs['αε'] = largs['οε']
largs['ρε'] = stem .. 'ni' .. _xk('em')
largs['τε'] = largs['δε']
largs['κε'] = largs['οε']
largs['οπ'] = largs['γε']
largs['γπ'] = stem .. 'ń'
largs['δπ'] = stem .. 'ni' .. _xk('om')
largs['απ'] = largs['γε']
largs['ρπ'] = stem .. 'ni' .. _xk('ami')
largs['τπ'] = stem .. 'ni' .. _xk('ach')
largs['κπ'] = largs['γε']
return largs
end
--απλοϊκός έλεγχος στην κονσόλα
p.test2=function(pagename)
local protypoklisis = 'θ'
local lemmaargs = {}
local tableargs = p[protypoklisis](pagename, lemmaargs) or ''
local output = ''
for k,v in pairs(tableargs) do
output = output .. '\n' .. tableargs[k] .. '#' .. k
end
return output
--return maintable(tableargs) .. tableargs['test']
end
return p