Zum Inhalt springen

„Modul:Wortbedeutungen“ – Versionsunterschied

aus AufEinWort, der freien Forschung
Die Seite wurde neu angelegt: „-- Modul:1_Sprachvorstufe_Wortbedeutung local p = {} -- Gibt die Wortbedeutungen der 1. Sprachvorstufe als kommaseparierte Liste zurück function p.anzeige(frame) local title = mw.title.getCurrentTitle() local query = '#show: ' .. title.prefixedText .. '|?1_Sprachvorstufe=' local result = mw.smw and mw.smw.ask and mw.smw.ask(query) if not result or not result[1] or not result[1]["1_Sprachvorstufe"] then return "[keine 1_Sprachvo…“
 
KKeine Bearbeitungszusammenfassung
Markierung: Manuelle Zurücksetzung
 
(89 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
-- Modul:1_Sprachvorstufe_Wortbedeutung
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 p = {}
    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


-- Gibt die Wortbedeutungen der 1. Sprachvorstufe als kommaseparierte Liste zurück
function p.zeigB(frame)
function p.anzeige(frame)
    local num = frame.args[1] or ""
     local title = mw.title.getCurrentTitle()
     local title = mw.title.getCurrentTitle()
     local query = '#show: ' .. title.prefixedText .. '|?1_Sprachvorstufe='
     local content = title:getContent() or ""
    local result = mw.smw and mw.smw.ask and mw.smw.ask(query)


     if not result or not result[1] or not result[1]["1_Sprachvorstufe"] then
     local sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^|%]]+)")
         return "[keine 1_Sprachvorstufe gefunden]"
    if not sprachvorstufe then
         sprachvorstufe = content:match("%[%[" .. num .. "%-Sprachvorstufe::([^%]]+)%]%]")
     end
     end


     local zielseite = result[1]["1_Sprachvorstufe"]
     if not sprachvorstufe or sprachvorstufe == "" then
    local wb_query = '#show: ' .. zielseite ..
        return "[" .. num .. "-Sprachvorstufe nicht gefunden]"
        '|?Wortbedeutung 1|?Wortbedeutung 2|?Wortbedeutung 3|?Wortbedeutung 4|?Wortbedeutung 5'
    end
        .. '|?Wortbedeutung 6|?Wortbedeutung 7|?Wortbedeutung 8|?Wortbedeutung 9|?Wortbedeutung 10'


     local bedeutungsergebnisse = mw.smw.ask(wb_query)
     local other = mw.title.new(sprachvorstufe)
     if not bedeutungsergebnisse or not bedeutungsergebnisse[1] then
     if not other then
         return "[keine Wortbedeutungen gefunden]"
         return "[Seite der " .. num .. "-Sprachvorstufe nicht gefunden]"
     end
     end
    local otherContent = other:getContent() or ""


     local bedeutungen = {}
     local bedeutungen = {}
     for i = 1, 10 do
     for bedeutung in otherContent:gmatch("%[%[Wortbedeutung::([^%]]+)%]%]") do
        local eintrag = bedeutungsergebnisse[1]["Wortbedeutung " .. i]
        table.insert(bedeutungen, bedeutung)
         if eintrag then
    end
            table.insert(bedeutungen, eintrag)
 
        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
     end


     return table.concat(bedeutungen, ", ")
     if #dingbedeutungen == 0 then
        return "[Keine Dingbedeutung gefunden in " .. sprachvorstufe .. "]"
    else
        return table.concat(dingbedeutungen, ", ")
    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