Some SPARQL queries for Noordergraf¶

This uses the SPARQL kernel for Jupyter Notebook

In [1]:
%lsmagics
Available magics:
%auth %display %endpoint %format %graph %header %http_header %lang %load %log %lsmagics %method %outfile %prefix %qparam %show

%auth (basic|digest|none) <username> <passwd> : send HTTP authentication (use env:<var> to get values from environment variables)
%display raw | table [withtypes] | diagram [svg|png] [withliterals] : set display format
%endpoint <url> : set SPARQL endpoint. **REQUIRED**
%format JSON | N3 | XML | default | any | none : set requested result format
%graph <uri> : set default graph for the queries
%header <string> | OFF : add a persistent SPARQL header line before all queries, or delete all defined headers
%http_header <name> [<value>] : add (or delete) an arbitrary HTTP header to all queries
%lang <lang> [...] | default | all : language(s) preferred for labels
%load <filename> : load a file with magic lines and process them
%log critical | error | warning | info | debug : set logging level
%lsmagics : list all magics
%method get | post : set HTTP method
%outfile <filename> | off : save raw output to a file (use "%d" in name to add cell number, "off" to cancel saving)
%prefix <name> [<uri>] : set (or delete) a persistent URI prefix for all queries
%qparam <name> [<value>] : add (or delete) a persistent custom parameter to all queries
%show <n> | all : maximum number of shown results

We set a few default options via those magics.

In [2]:
# Modify output format
# Don't show more than 80 results (event if more are fetched)
%show 80

# Request whatever format is appropriate for the query type
%format default

# Activate table output
%display table
Result maximum size: 80
Request format: DEFAULT
Display: table

Set the endpoint to Noordergraf

In [3]:
%endpoint https://noordergraf.rug.nl:10036/repositories/noordergraf
Endpoint set to: https://noordergraf.rug.nl:10036/repositories/noordergraf
In [4]:
%prefix : <https://noordergraf.rug.nl/ns#>
Prefix set: : = <https://noordergraf.rug.nl/ns#>

Search for famous people. These are people with a link to an external site, such as wikidata.

In [5]:
SELECT ?person ?name ?sameas {
  ?person :sameAs ?sameas .
  ?person :name / :fullName ?name .
  ?item :subject ?person .
  FILTER fn:not(STRSTARTS(xsd:string(?sameas), "https://noordergraf"))
} ORDER BY ?name
person name sameas
https://noordergraf.rug.nl/item/P00002#P1 Théodore van Gogh http://www.wikidata.org/entity/Q317188
https://noordergraf.rug.nl/item/P00001#P1 Vincent van Gogh http://www.wikidata.org/entity/Q5582
Total: 2, Shown: 2