Example SPARQL queries in Wolfram Language: Difference between revisions

(Created page with "SPARQL")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
SPARQL
This code transforms the string SPARQL query into  a Wolfram Language SPARQLQuery.<syntaxhighlight lang="mathematica">
ImportString[
"SELECT?subject?predicate?object
WHERE {?subject ?predicate ?object .}",
"SPARQLQuery"]
</syntaxhighlight>The query below is the Wolfram Language representation of the query above,<syntaxhighlight lang="mathematica">
query = SPARQLQuery[
  SPARQLSelect[{RDFTriple[SPARQLVariable["subject"],
      SPARQLVariable["predicate"], SPARQLVariable["object"]]}]/*
  SPARQLProject[{"subject", "predicate", "object"}]]
</syntaxhighlight>This code executes the query above agains the semiWiki RDFStore created in [[Import SMW .jsonld as RDFStore in Wolfram Language]]<syntaxhighlight lang="mathematica">
SPARQLExecute[semiWiki, query]
</syntaxhighlight>

Latest revision as of 16:30, 13 November 2022

This code transforms the string SPARQL query into a Wolfram Language SPARQLQuery.

ImportString[
 "SELECT?subject?predicate?object
WHERE {?subject ?predicate ?object .}",
 "SPARQLQuery"]

The query below is the Wolfram Language representation of the query above,

query = SPARQLQuery[
  SPARQLSelect[{RDFTriple[SPARQLVariable["subject"], 
      SPARQLVariable["predicate"], SPARQLVariable["object"]]}]/*
   SPARQLProject[{"subject", "predicate", "object"}]]

This code executes the query above agains the semiWiki RDFStore created in Import SMW .jsonld as RDFStore in Wolfram Language

SPARQLExecute[semiWiki, query]