Message Boards Message Boards

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

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.

Attachments:
POSTED BY: Seth Chandler

enter image description here - Congratulations! This post is now featured in our Staff Pick column as distinguished by a badge on your profile of a Featured Contributor! Thank you, keep it coming, and consider contributing your work to the The Notebook Archive!

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract