These exercises develop some useful Lisp functions for accessing knowledge graphs from two services:

Both services are accessed via HTTPS. That doen't work with the portable version of the AllegroServe HTTP client, so use Drakma. Install it with Quicklisp.

Google Knowledge Graph

To access GKG, you need to get an API key. Note the restrictions on querying.

Define two packages:

You should do (in-package :gkg-tests) before any testing.

The results returned from GKG are in a string using JSON-LD syntax and the ontology. Use the CL-JSON parser to translate JSON strings into CLOS objects.


Test cases: gkg-tests.lisp

GKG-1: Basic query

Function names: search-freebase, set-default-key

Global variable names: *default-api-key*

Define (search-freebase query [keys...] to query the Google knowledge graph and return the results as a nested alist.

The function should allow any keywords to be passed in, and assemble them all into the URL to send to GKG. The expected keywords are those listed in the standard API.

If no :api-key is given, it should default to the value in *default-api-key*. The default key is the empty string. Set it to the API key you get from Google.


It's easy to get an entity in WikiData if you know its ID, but to do a complex search, e.g., for cities with female mayors, you need to construct a SPARQL query object.

Define two packages:

You should do (in-package :wikidata-tests) before any testing.

Faculty: Chris Riesbeck
Time: Monday, Wednesday, Friday: 11am - 11:50am
Location: Tech LR5


Important Links