Module:Formula

From MaRDI portal
Revision as of 15:47, 14 May 2025 by TA4Shehu (talk | contribs) (Created page with "-- Required modules for SPARQL queries and HTML table generation -- Module for executing SPARQL queries local sparql = require('SPARQL') -- MediaWiki library for logging and utilities local mw = require('mw') local json = require("mw.text") -- Main table to hold all functions local p = {} -- function to check whether the item has the MathModDB community tag function p.hasMathModDB(frame) local entity = mw.wikibase.getEntity() if not entity then return false en...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

-- Required modules for SPARQL queries and HTML table generation
-- Module for executing SPARQL queries
local sparql = require('SPARQL')
-- MediaWiki library for logging and utilities
local mw = require('mw')
local json = require("mw.text") 

-- Main table to hold all functions
local p = {}

-- function to check whether the item has the MathModDB community tag
function p.hasMathModDB(frame)
    local entity = mw.wikibase.getEntity()
    if not entity then return false end

    local statements = entity.claims and entity.claims['P1495']
    if not statements then return false end

    for _, statement in ipairs(statements) do
        local val = statement.mainsnak
            and statement.mainsnak.datavalue
            and statement.mainsnak.datavalue.value

        if val == "MathModDB" then
            return true
        elseif type(val) == "table" and val.id == "Q6534265" then -- if it's an item reference
            return true
        end
    end

    return false
end



return p