Skip to content

Instantly share code, notes, and snippets.

@ostephens
ostephens / gist:7639249
Created November 25, 2013 10:16
Basic SPARQL query using a literal II
SELECT *
WHERE {
?subject ?predicate "Austen, Jane, 1775-1817"
}
LIMIT 10
@ostephens
ostephens / gist:7639241
Created November 25, 2013 10:15
Basic SPARQL Query using a literal I
SELECT *
WHERE {
?subject ?predicate "Austen, Jane"
}
LIMIT 10
@ostephens
ostephens / gist:7633907
Created November 24, 2013 23:27
SPARQL query to find titles of books authored by person identified by http://viaf.org/viaf/102333412 (Jane Austen)
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT ?title
WHERE {
?person owl:sameAs <http://viaf.org/viaf/102333412> .
?book dct:creator ?person .
?book dct:title ?title
}
LIMIT 10
@ostephens
ostephens / gist:7633750
Created November 24, 2013 23:13
Find all people that BNB believes to have the same year of birth as Jane Austen (based on her VIAF URI)
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX bio: <http://purl.org/vocab/bio/0.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name
WHERE {
?person owl:sameAs <http://viaf.org/viaf/102333412> .
?person bio:event ?event .
?event rdf:type bio:Birth .
@ostephens
ostephens / gist:7633608
Created November 24, 2013 22:57
SPARQL Query with 2 patterns - finds titles for books where Jane Austen is the dc:creator
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?title
WHERE {
?book dct:creator <http://bnb.data.bl.uk/id/person/AustenJane1775-1817> .
?book dct:title ?title
}
LIMIT 10
@ostephens
ostephens / gist:7633423
Created November 24, 2013 22:40
Simplest SPARQL query using single letter variables
SELECT *
WHERE {
?s ?p ?o
}
LIMIT 10
@ostephens
ostephens / gist:7633297
Created November 24, 2013 22:28
Example of using PREFIX of 'banana': Find 10 URIs where the BNB URI for Jane Austen is the subject and the predicate is banana:creator
PREFIX banana: <http://purl.org/dc/terms/>
SELECT *
WHERE {
?subject banana:creator <http://bnb.data.bl.uk/id/person/AustenJane1775-1817>
}
LIMIT 10
@ostephens
ostephens / gist:7633289
Created November 24, 2013 22:27
Example of using PREFIX of 'dct': Find 10 URIs where the BNB URI for Jane Austen is the subject and the predicate is dct:creator
PREFIX dct: <http://purl.org/dc/terms/>
SELECT *
WHERE {
?subject dct:creator <http://bnb.data.bl.uk/id/person/AustenJane1775-1817>
}
LIMIT 10
@ostephens
ostephens / gist:7633258
Last active December 29, 2015 06:59
Find 10 URIs where the BNB URI for Jane Austen is the subject and the predicate is dc:creator
SELECT *
WHERE {
?book <http://purl.org/dc/terms/creator> <http://bnb.data.bl.uk/id/person/AustenJane1775-1817>
}
LIMIT 10
@ostephens
ostephens / gist:7633236
Created November 24, 2013 22:24
Find triples where the BNB URI for Jane Austen is the Object
SELECT *
WHERE {
?subject ?predicate <http://bnb.data.bl.uk/id/person/AustenJane1775-1817>
}
LIMIT 10