Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
SPARQL about van Gogh -- on CoCalc!
We are going to use some the DBPedia SPARQL endpoint to do some queries related to Vincent van Gogh.
First we define the endpoint and the preferred language for labels
Now let's find out the entity URI for van Gogh in DBPedia. We search entities that are persons and whose label contains van Gogh
(case insensitive).
Note that the DBPedia endpoint has a set of predefined namespace prefixes that we can use without the need to define them in the query, such as rdfs:
or foaf:
so we could remove them from the query without problem.
It is clear from the result that we want the http://dbpedia.org/resource/Vincent_van_Gogh DBPedia entity (we can click on the link for confirmation, and it will lead us to a DBPedia web page describing the resource).
Fact finding
Now that we found his URI, let's search for places, dates and people related with van Gogh.
In this query we also set the table to show the data type for each result
Find a painting
Now we search for a van Gogh painting whose title contains "night"
Just to show another possibility, we repeat the same query but indicating raw
display format
Describe a painting
Now we find out all that DBPedia knows about one of those paintings, Starry Night Over the Rhone
Similar data could be obtained by asking the endpoint to DESCRIBE
the resource. Let's do this, but for a twist let's ask the kernel to draw a graph with the results (for this to work, Graphviz should be installed in the system).
We generate a PNG here. Note that svg
is a much better format than png
, if the browser supports it (better quality, and hyperlinked nodes).
Locate paintings
Finally, to print out a slightly more complex graph, we will construct one with all of van Gogh's paintings, together with their location and the country they are in.
This one we render as SVG; this has the said advantage of better quality (being a vector format). Plus nodes and edges can contain hyperlinks, so when they are URIs they point to the full URL (note that, unless the withliterals
option is used, all represented nodes will be URIs)
Author: Paulo Villegas