SPARQL

SPARQL

Querying Semantic Data

SPARQL (pronounced “sparkle”, a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language, that is, a query language for databases, able to retrieve and manipulate data stored in Resource Description Framework format. RDF is commonly used for modeling information in the web of linked data.

It was made a standard by the RDF Data Access Working Group (DAWG) of the World Wide Web Consortium, and is considered as one of the key technologies of the semantic web. On 15 January 2008, SPARQL 1.0 became an official W3C Recommendation.

Querying WordLift’s Data with SPARQL – a Cheat Sheet

Here we have listed few queries in SPARQL created to extract metadata being shared as linked data by semantic websites that use WordLift.

1. What are the most recurring concepts used on the site to mark up the articles?

PREFIX dct: <http://purl.org/dc/terms/>
SELECT * WHERE {
SELECT ?o (COUNT() as ?count) WHERE { [] dct:references ?o }
GROUP BY ?o
} ORDER BY DESC(?count) LIMIT 10

2. What are the most recurring concepts taking into account the relationships created among concepts?

PREFIX dct: <http://purl.org/dc/terms/>
SELECT * WHERE {
SELECT ?o (COUNT() as ?count) WHERE { [] dct:relation ?o }
GROUP BY ?o
} ORDER BY DESC(?count) LIMIT 10

3. What are the most recurring concepts combining the relationships with articles and the relationships among entities?

PREFIX dct: <http://purl.org/dc/terms/>
SELECT * WHERE {
SELECT ?o (COUNT() as ?count) WHERE { { [] dct:references ?o } UNION { [] dct:relation ?o } }
GROUP BY ?o
} ORDER BY DESC(?count) LIMIT 10

4. How many triples have been created on the site?

SELECT (COUNT() AS ?no) { ?s ?p ?o }

5. How many entities have been created on the site?

SELECT (COUNT(distinct ?s) AS ?no) { ?s a [] }

6. How many articles have been annotated with WordLift?

SELECT (COUNT(distinct ?s) AS ?no) WHERE {?s a <http://schema.org/BlogPosting> . }