Message Boards Message Boards

GROUPS:

Using SPARQL to construct a timeline of the Supreme Court Chief Justices

Posted 10 months ago
2086 Views
|
1 Reply
|
4 Total Likes
|

The intent of this post is to show those inexpert in SPARQL but curious about capabilities how much can be done with it within the Wolfram Language. My specific quest is to generate a timeline of chief justices of the United States Supreme Court but, in the course of doing so, to share some learning about SPARQL and Wikidata.

The main insight is to exploit the many examples of SPARQL code at the Wikidata query site, find one that is relevant, and then use ImportString[#,"SPARQLQuery"]& to generate symbolic SPARQL within the Wolfram Language. Once that's done, we can use core Wolfram Language tools to modify the code for the specific task at hand and then run it against the Wikidata "endpoint." Once the results come back from Wikidata, some basic Wolfram Language code generates a nice timeline with relative ease.

The notebook finishes with a little section on how to run Python from within a Wolfram notebook and get the same kind of results. Again, one doesn't need to know much about Python to do this (trust me!). Wikidata actually itself provides the basic code. And, as version 12.1 and beyond permit the Wolfram ecosystem to expand its capabilities with other languages, it may be possible to use Wikidata's fluency in multiple computer languages (Ruby, JavaScript, etc.) to diversify the set of tools with which to attack Wikidata while remaining in the comfortable and powerful Wolfram system.