Zum Inhalt springen

„Modul:Wortbedeutungen“ – Versionsunterschied

aus AufEinWort, der freien Forschung
K wieder Reparatur
Markierung: Zurückgesetzt
KKeine Bearbeitungszusammenfassung
Markierung: Manuelle Zurücksetzung
 
Zeile 1: Zeile 1:
-- Modul:Wortbedeutungen
local p = {}


local p = {}
function p.zeig(frame)
    local modi = frame.args[1] or ""
    local num = frame.args[2] or ""
    local title = mw.title.getCurrentTitle()
    local content = title:getContent() or ""


-- Hilfsfunktion zum Extrahieren der Zielseite einer Sprachvorstufe
     local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
local function extrahiereZielseite(content, n)
     if not sprachvorstufe then
    -- Versuch mit [[n-Sprachvorstufe::Ziel|Anzeigetext]]
         sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
     local ziel = content:match(string.format("%[%[%d%-Sprachvorstufe::([^|%%]]+)|[^%%]]-%]%]", n))
     if not ziel then
         -- Versuch mit [[n-Sprachvorstufe::Ziel]]
        ziel = content:match(string.format("%[%[%d%-Sprachvorstufe::([^%%]]+)%]%]", n))
     end
     end
    return ziel
end


-- Hilfsfunktion zum Extrahieren der letzten Sprachstufe aus dem Inhalt
     if not sprachvorstufe or sprachvorstufe == "" then
local function extrahiereSprachstufe(content)
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
     local raw = content:match("%[%[Sprachstufe::([^%]]+)%]%]")
    end
    if not raw then return nil end
    return raw:match("([^.]+%.)%s*$")
end


-- Hilfsfunktion zum Sammeln aller Werte eines Properties
    local other = mw.title.new(sprachvorstufe)
local function sammleWerte(content, property)
     if not other then
     local werte = {}
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    for wert in content:gmatch("%[%[" .. property .. "::([^%]]+)%]%]") do
        table.insert(werte, wert)
     end
     end
    return werte
end


-- Kombinierte Anzeige
     local otherContent = other:getContent() or ""
function p.zeigNBD(frame)
     local sprachstufe = otherContent:match("%[%[Sprachstufe::([^%]]+)%]%]")
     local n = tonumber(frame.args[1]) or 1
     local lastLang = sprachstufe and sprachstufe:match("([a-z]+%.)%s*$") or sprachstufe or "[Sprachstufe nicht gefunden]"
     local title = mw.title.getCurrentTitle()
 
     local content = title:getContent() or ""
     local output = {}
     local ziel = extrahiereZielseite(content, n)
 
     if not ziel then return string.format("[Fehlende %d-Sprachvorstufe]", n) end
     if modi:find("N") then
        table.insert(output, lastLang .. " [[" .. sprachvorstufe .. "]]")
    end


     local zielTitel = mw.title.new(ziel)
     if modi:find("B") then
    if not zielTitel then return string.format("[Seite '%s' nicht gefunden]", ziel) end
        local bedeutungen = {}
        for bedeutung in otherContent:gmatch("%[%[Wortbedeutung::([^%]]+)%]%]") do
            table.insert(bedeutungen, bedeutung)
        end
        if #bedeutungen > 0 then
            table.insert(output, "'" .. table.concat(bedeutungen, ", ") .. "'")
        end
    end


     local zielContent = zielTitel:getContent() or ""
     if modi:find("D") then
    local stufe = extrahiereSprachstufe(zielContent) or "[Sprachstufe?]"
        local dingbedeutungen = {}
    local b = sammleWerte(zielContent, "Wortbedeutung")
        for bedeutung in otherContent:gmatch("%[%[Dingbedeutung::([^%]]+)%]%]") do
    local d = sammleWerte(zielContent, "Dingbedeutung")
            table.insert(dingbedeutungen, bedeutung)
        end
        if #dingbedeutungen > 0 then
            table.insert(output, "'" .. table.concat(dingbedeutungen, ", ") .. "'")
        end
    end


     local ergebnis = ziel
     return table.concat(output, " ")
    if #b > 0 then ergebnis = ergebnis .. " '" .. table.concat(b, ", ") .. "'" end
    if #d > 0 then ergebnis = ergebnis .. " '" .. table.concat(d, ", ") .. "'" end
    return stufe .. " " .. ergebnis
end
end


-- Einzelne Anzeigen
function p.zeigN(frame)
function p.zeig(frame)
     local num = frame.args[1] or ""
     local n = tonumber(frame.args[1]) or 1
     local title = mw.title.getCurrentTitle()
     local title = mw.title.getCurrentTitle()
     local content = title:getContent() or ""
     local content = title:getContent() or ""
    local ziel = extrahiereZielseite(content, n)
    if not ziel then return string.format("[Fehlende %d-Sprachvorstufe]", n) end


     local zielTitel = mw.title.new(ziel)
     local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
     if not zielTitel then return string.format("[Seite '%s' nicht gefunden]", ziel) end
     if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end


     local zielContent = zielTitel:getContent() or ""
    if not sprachvorstufe or sprachvorstufe == "" then
     local stufe = extrahiereSprachstufe(zielContent) or "[Sprachstufe?]"
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
     return stufe .. " " .. ziel
    end
 
    local other = mw.title.new(sprachvorstufe)
    if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end
 
     local otherContent = other:getContent() or ""
     local sprachstufe = otherContent:match("%[%[Sprachstufe::([^%]]+)%]%]")
 
     if sprachstufe and sprachstufe ~= "" then
        local lastLang = sprachstufe:match("([a-z]+%.)%s*$") or sprachstufe
        return lastLang .. " [[" .. sprachvorstufe .. "]]"
    else
        return "[Sprachstufe nicht gefunden in " .. sprachvorstufe .. "]"
    end
end
end


function p.zeigB(frame)
function p.zeigB(frame)
     local n = tonumber(frame.args[1]) or 1
     local num = frame.args[1] or ""
     local title = mw.title.getCurrentTitle()
     local title = mw.title.getCurrentTitle()
     local content = title:getContent() or ""
     local content = title:getContent() or ""
    local ziel = extrahiereZielseite(content, n)
    if not ziel then return string.format("[Fehlende %d-Sprachvorstufe]", n) end


     local zielTitel = mw.title.new(ziel)
     local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
     if not zielTitel then return string.format("[Seite '%s' nicht gefunden]", ziel) end
    if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end
 
    if not sprachvorstufe or sprachvorstufe == "" then
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
    end
 
    local other = mw.title.new(sprachvorstufe)
     if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end
 
    local otherContent = other:getContent() or ""
 
    local bedeutungen = {}
    for bedeutung in otherContent:gmatch("%[%[Wortbedeutung::([^%]]+)%]%]") do
        table.insert(bedeutungen, bedeutung)
    end


     local zielContent = zielTitel:getContent() or ""
     if #bedeutungen == 0 then
    local b = sammleWerte(zielContent, "Wortbedeutung")
         return "[Keine Wortbedeutung gefunden in " .. sprachvorstufe .. "]"
    if #b > 0 then
         return table.concat(b, ", ")
     else
     else
         return string.format("[Keine Wortbedeutung gefunden in %s]", ziel)
         return table.concat(bedeutungen, ", ")
     end
     end
end
end


function p.zeigD(frame)
function p.zeigD(frame)
     local n = tonumber(frame.args[1]) or 1
     local num = frame.args[1] or ""
     local title = mw.title.getCurrentTitle()
     local title = mw.title.getCurrentTitle()
     local content = title:getContent() or ""
     local content = title:getContent() or ""
    local ziel = extrahiereZielseite(content, n)
    if not ziel then return string.format("[Fehlende %d-Sprachvorstufe]", n) end


     local zielTitel = mw.title.new(ziel)
     local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
     if not zielTitel then return string.format("[Seite '%s' nicht gefunden]", ziel) end
    if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end
 
    if not sprachvorstufe or sprachvorstufe == "" then
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
    end
 
    local other = mw.title.new(sprachvorstufe)
     if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end
 
    local otherContent = other:getContent() or ""
 
    local dingbedeutungen = {}
    for bedeutung in otherContent:gmatch("%[%[Dingbedeutung::([^%]]+)%]%]") do
        table.insert(dingbedeutungen, bedeutung)
    end


     local zielContent = zielTitel:getContent() or ""
     if #dingbedeutungen == 0 then
    local d = sammleWerte(zielContent, "Dingbedeutung")
         return "[Keine Dingbedeutung gefunden in " .. sprachvorstufe .. "]"
    if #d > 0 then
         return table.concat(d, ", ")
     else
     else
         return string.format("[Keine Dingbedeutung gefunden in %s]", ziel)
         return table.concat(dingbedeutungen, ", ")
     end
     end
end
end


return p
return p

Aktuelle Version vom 17. April 2025, 13:40 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Wortbedeutungen/Doku erstellt werden

local p = {}

function p.zeig(frame)
    local modi = frame.args[1] or ""
    local num = frame.args[2] or ""
    local title = mw.title.getCurrentTitle()
    local content = title:getContent() or ""

    local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
    if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end

    if not sprachvorstufe or sprachvorstufe == "" then
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local other = mw.title.new(sprachvorstufe)
    if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local otherContent = other:getContent() or ""
    local sprachstufe = otherContent:match("%[%[Sprachstufe::([^%]]+)%]%]")
    local lastLang = sprachstufe and sprachstufe:match("([a-z]+%.)%s*$") or sprachstufe or "[Sprachstufe nicht gefunden]"

    local output = {}

    if modi:find("N") then
        table.insert(output, lastLang .. " [[" .. sprachvorstufe .. "]]")
    end

    if modi:find("B") then
        local bedeutungen = {}
        for bedeutung in otherContent:gmatch("%[%[Wortbedeutung::([^%]]+)%]%]") do
            table.insert(bedeutungen, bedeutung)
        end
        if #bedeutungen > 0 then
            table.insert(output, "'" .. table.concat(bedeutungen, ", ") .. "'")
        end
    end

    if modi:find("D") then
        local dingbedeutungen = {}
        for bedeutung in otherContent:gmatch("%[%[Dingbedeutung::([^%]]+)%]%]") do
            table.insert(dingbedeutungen, bedeutung)
        end
        if #dingbedeutungen > 0 then
            table.insert(output, "'" .. table.concat(dingbedeutungen, ", ") .. "'")
        end
    end

    return table.concat(output, " ")
end

function p.zeigN(frame)
    local num = frame.args[1] or ""
    local title = mw.title.getCurrentTitle()
    local content = title:getContent() or ""

    local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
    if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end

    if not sprachvorstufe or sprachvorstufe == "" then
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local other = mw.title.new(sprachvorstufe)
    if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local otherContent = other:getContent() or ""
    local sprachstufe = otherContent:match("%[%[Sprachstufe::([^%]]+)%]%]")

    if sprachstufe and sprachstufe ~= "" then
        local lastLang = sprachstufe:match("([a-z]+%.)%s*$") or sprachstufe
        return lastLang .. " [[" .. sprachvorstufe .. "]]"
    else
        return "[Sprachstufe nicht gefunden in " .. sprachvorstufe .. "]"
    end
end

function p.zeigB(frame)
    local num = frame.args[1] or ""
    local title = mw.title.getCurrentTitle()
    local content = title:getContent() or ""

    local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
    if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end

    if not sprachvorstufe or sprachvorstufe == "" then
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local other = mw.title.new(sprachvorstufe)
    if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local otherContent = other:getContent() or ""

    local bedeutungen = {}
    for bedeutung in otherContent:gmatch("%[%[Wortbedeutung::([^%]]+)%]%]") do
        table.insert(bedeutungen, bedeutung)
    end

    if #bedeutungen == 0 then
        return "[Keine Wortbedeutung gefunden in " .. sprachvorstufe .. "]"
    else
        return table.concat(bedeutungen, ", ")
    end
end

function p.zeigD(frame)
    local num = frame.args[1] or ""
    local title = mw.title.getCurrentTitle()
    local content = title:getContent() or ""

    local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
    if not sprachvorstufe then
        sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
    end

    if not sprachvorstufe or sprachvorstufe == "" then
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local other = mw.title.new(sprachvorstufe)
    if not other then
        return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
    end

    local otherContent = other:getContent() or ""

    local dingbedeutungen = {}
    for bedeutung in otherContent:gmatch("%[%[Dingbedeutung::([^%]]+)%]%]") do
        table.insert(dingbedeutungen, bedeutung)
    end

    if #dingbedeutungen == 0 then
        return "[Keine Dingbedeutung gefunden in " .. sprachvorstufe .. "]"
    else
        return table.concat(dingbedeutungen, ", ")
    end
end

return p