Module:WordOfDay:check

Από Βικιλεξικό
Μετάβαση στην πλοήγηση Πήδηση στην αναζήτηση

Documentation for this module may be created at Module:WordOfDay:check/τεκμηρίωση

--για έλεγχο (με προεπισκόπηση σε κάποια προσωρινή σελίδα) των λέξεων της ημέρας
--(παλιών και νέων).
--Να μην χρησιμοποιηθεί σε σελίδα ή Πρότυπο
--παρά μόνο για προεπισκόπηση
--Βάζουμε σε μια προσωρινή σελίδα το 
--[=[{{#invoke:WordOfDay:check|export|νέαλέξη1
|νέαλέξη2
|νέαλέξη3
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη
|νέαλέξη31}}

]=]
p = {}
--TODO: αν είναι expensive να το βγάλω...
--αν και δεν παίζει μεγάλο ρόλο (υποθέτω) αφού δεν θα είναι σελίδα μεγάλης κίνησης...
local framehere = mw.getCurrentFrame()

function leksithshmeras (hmera)
    if hmera<1 or hmera>31 then return '' end
    local leksinum = 'ΛτΗ' .. hmera
    local titlosleksis = framehere:expandTemplate{ title = leksinum, args = { } }
    return titlosleksis
end 

function trimr(s)
	return s:find'^%s*$' and '' or s:match'^(.*%S)'
end

function denexeiorismo(lemmatitlehere)
    local thistitle = lemmatitlehere
    local lemmatext = mw.title.makeTitle("", thistitle):getContent()
    if lemmatext == nil then return true end --δεν υπάρχει το λήμμα
    local capstart, capend, captured = lemmatext:find('λείπει ο ορισμός', 1, true)
    return (capstart ~= nil)
end

function p.export(frame)
    local args = frame.args
    local output = ''
    for xcounter,lemmatitle in ipairs(args) do
        lemmatitletrimmed = trimr(lemmatitle)
        leksiprin = leksithshmeras(xcounter)
        --οι λέξεις του μήνα είναι οκ αν δεν υπάρχει το: λείπει ο ορισμός
        leksiprinok = not(denexeiorismo(leksiprin))
    	--οι νέες λέξεις είναι οκ αν έχουν το: λείπει ο ορισμός
        nealeksiok = denexeiorismo(lemmatitletrimmed)
        
        output = output .. tostring(xcounter) .. ' ' .. leksiprin   
        if leksiprinok then
            output = output  .. ' => '
        else
            output = output .. ' -Δεν αλλάχτηκε- '
        end
        output = output .. lemmatitletrimmed
        if not nealeksiok then
            output = output .. ' -λείπει το "δεν έχει ορισμό"- '
        end
        output = output .. '\n\n'
    end
    return output
end

--[=[function p.export2(frame)
	local args = frame.args
	return (args[1])
end

parentFrame = mw.getCurrentFrame():newChild{ args = { '' } }
frame = parentFrame:newChild{ args = { 'ένα','δύο','ξι','μεγάλος','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα','ένα' } }
=p.export(frame)

]=]

return p