Module:RootFinder

From The Seven Sages of Rome
Revision as of 14:35, 25 March 2025 by Noeth (talk | contribs)

Documentation for this module may be created at Module:RootFinder/doc

local p = {}
local mw = require('mw')

function p.getVariety(frame)
    local page = frame.args[1]  -- Extract the first argument from the frame
    
    if not page or page == "" then
        return "Error: No page name provided."
    end
    
    -- Query Semantic MediaWiki for the property "Is Variety Of"
    local result = mw.smw.ask{"[[" .. page .. "]] |?Is Variety Of"}
    
    if result then
        for _, data in pairs(result) do
            if data["Is Variety Of"] then
                return "Is Variety Of: " .. data["Is Variety Of"]
            end
        end
    end
    
    return "No 'Is Variety Of' property found for " .. page
end

return p