HowTo: SPARQL Query for crawling Tweets

Here is a query that can be used to sponge tweets. For instance, a variation of this query (just change the target named graph in the query body) could be used to sponge tweets following Turtle Doc generation from the social media activity tracking spreadsheet.

This query also demonstrates Virtuoso’s unique ability (at the current time re RDF DBMS engines) to de-reference URI-variables as part of its SPARQL solution construction pipeline.

DEFINE get:soft "soft"
DEFINE input:grab-var "url" 

PREFIX schema: <http://schema.org/> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dcterms: <http://purl.org/dc/terms/> 

SELECT DISTINCT ?url ?post ?postTitle ?postComment ?date

WHERE {
         GRAPH <https://github.com/OpenLinkSoftware/lod-refine-showcases/raw/master/Week-Ending-2019-05-03.ttl> {
                    # ?s foaf:topic ?topic.
                    ?topic schema:url ?url .}

         GRAPH ?g {
                    ?url schema:mainEntity ?post . 
                         ?post rdfs:label ?postTitle ;
                         rdfs:comment ?postComment ;
                         dcterms:created ?date . 
                  }

      } 

Query Results Screenshot

Live Query Results Example – Runs longer since sponger pragmas are enabled

Live Query Results Example – Runs quicker since pragmas are disabled