Module:TA4TK:myTest
From MaRDI portal
Documentation for this module may be created at Module:TA4TK:myTest/doc
-- Main table to hold all functions
local sparql = require('SPARQL') -- Load the SPARQL binding
local p = {}
function p.hello()
local str = "Hello World!"
return str
end
function p.renderFormula()
local formula = "\\sin x" -- LaTeX formula
end
function p.querySPARQL()
-- Define the SPARQL endpoint
local endpoint = "https://query.wikidata.org/"
-- Define the SPARQL query
local sparqlQuery = [[
SELECT ?item ?itemLabel WHERE {
?item wdt:P31 wd:Q5;
rdfs:label "Albert Einstein"@en.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} LIMIT 1
]]
local queryResults = sparql.runQuery(sparqlQuery) -- Use the runQuery method
-- nil is returned if Blazegraph did not return a valid response
if queryResults == nil then
return "No results found."
end
--return queryResults['results']
return queryResults[0]
end
return p