Module:MathModDB: Difference between revisions

From MaRDI portal
No edit summary
No edit summary
Line 11: Line 11:
function p.getMathModDBStatistics()
function p.getMathModDBStatistics()


--  Q60231 refers to academic discipline  
-- Table to store statistics
-- Q6534265 refers to MathModDB community
local MathModDBStatistics = {}
  local sparqlQuery = [[
 
SELECT ?Research_Fields
----------------Research Fields---------------------------------------------
WHERE {
--  Q60231 refers to academic discipline  
    ?item wdt:P31  wd:Q60231;
-- Q6534265 refers to MathModDB community
          wdt:P1495 wd:Q6534265 .
local sparqlQuery = [[
}
SELECT ?Research_Fields
WHERE {
    ?item wdt:P31  wd:Q60231;
          wdt:P1495 wd:Q6534265 .
}
     ]]
     ]]
      
      
-- Executing the SPARQL query and retrieving results in JSON format
-- Executing the SPARQL query and retrieving results in JSON format
local jsonResults = sparql.runQuery(sparqlQuery)
local jsonResults = sparql.runQuery(sparqlQuery)
  -- Get the number of mathematical formulations
-- Get the number of research fields
local totalResearchFields = #jsonResults.results.bindings  + 1
local totalResearchFields = #jsonResults.results.bindings  + 1
-- Table to store statistics
    local statistics = {}
     -- Construct the Portal URL
     -- Construct the Portal URL
     local url = "https://portal.mardi4nfdi.de/wiki/MathModDB/Research_field"
     local url = "https://portal.mardi4nfdi.de/wiki/MathModDB/Research_field"
     local totalResearchFieldsWithUrl = string.format('[%s %s]', tostring(url), tostring(totalResearchFields))
     local totalResearchFieldsWithUrl = string.format('[%s %s]', tostring(url), tostring(totalResearchFields))
     table.insert(statistics, "| Research Fields: " .. totalResearchFieldsWithUrl)
     table.insert(MathModDBStatistics, "| Research Fields: " .. totalResearchFieldsWithUrl)
   
 
----------------Research Problems------------------------------------------- 
-- Q6032837 refers to research problem 
-- Q6534265 refers to MathModDB community
local sparqlQuery = [[
SELECT ?Research_Problems
WHERE {
?item wdt:P31 wd:Q6032837;
          wdt:P1495 wd:Q6534265 .
}
]]
 
-- Executing the SPARQL query and retrieving results in JSON format
jsonResults = sparql.runQuery(sparqlQuery)
-- Get the number of research problems
local totalResearchProblems = #jsonResults.results.bindings  + 1
    -- Construct the Portal URL
    url = "https://portal.mardi4nfdi.de/wiki/MathModDB/Research_problem"
    local totalResearchProblemsWithUrl = string.format('[%s %s]', tostring(url), tostring(totalResearchProblems))
    table.insert(MathModDBStatistics, "| Research Problems: " .. totalResearchProblemsWithUrl)
 
      
      
     -- Construct the Wikitext table
     -- Construct the Wikitext table

Revision as of 13:56, 23 May 2025

Documentation for this module may be created at Module:MathModDB/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 p.getMathModDBStatistics()

	-- Table to store statistics
	local MathModDBStatistics = {}

	----------------Research Fields---------------------------------------------
	--   Q60231 refers to academic discipline 
	-- Q6534265 refers to MathModDB community
	local sparqlQuery = [[
	SELECT ?Research_Fields
	WHERE {
    	?item wdt:P31   wd:Q60231;
        	  wdt:P1495 wd:Q6534265 .
	}
    ]]
    
	-- Executing the SPARQL query and retrieving results in JSON format
	local jsonResults = sparql.runQuery(sparqlQuery)
	-- Get the number of research fields
	local totalResearchFields = #jsonResults.results.bindings  + 1
	
    -- Construct the Portal URL
    local url = "https://portal.mardi4nfdi.de/wiki/MathModDB/Research_field"
    local totalResearchFieldsWithUrl = string.format('[%s %s]', tostring(url), tostring(totalResearchFields))
    table.insert(MathModDBStatistics, "| Research Fields: " .. totalResearchFieldsWithUrl)
    

	----------------Research Problems-------------------------------------------  
	-- Q6032837 refers to research problem   
	-- Q6534265 refers to MathModDB community 
	local sparqlQuery = [[
	SELECT ?Research_Problems
	WHERE {
		?item wdt:P31 wd:Q6032837;
        	  wdt:P1495 wd:Q6534265 .
	}
	]]

	-- Executing the SPARQL query and retrieving results in JSON format
	jsonResults = sparql.runQuery(sparqlQuery)
	-- Get the number of research problems
	local totalResearchProblems = #jsonResults.results.bindings  + 1
	
    -- Construct the Portal URL
    url = "https://portal.mardi4nfdi.de/wiki/MathModDB/Research_problem"
    local totalResearchProblemsWithUrl = string.format('[%s %s]', tostring(url), tostring(totalResearchProblems))
    table.insert(MathModDBStatistics, "| Research Problems: " .. totalResearchProblemsWithUrl)

    
    -- Construct the Wikitext table
    	local wikitextTable = [[
{| class="wikitable" style="table-layout: fixed; width: 1000px;"
]] .. table.concat(statistics, "\n|-\n") .. "\n|}"
    	return wikitextTable


end

return p