Introduction: About AllegroGraph Cloud

AllegroGraph Cloud (also called Hosted AllegroGraph) is a web-based platform that simplifies the process of setting up AllegroGraph servers, allowing you to do so with just a few clicks.

See https://allegrograph.cloud for more information and registration instructions.

Chomsky examples are preloaded in AllegroGraph.cloud

The Chomsky chatbot and the Chomsky chatbot with memory examples are for the most part already set up in AllegroGraph.cloud (the chomsky data is loaded in the chomsky repo and the chomsky-vec repo has been created), saving users the trouble of downloading large files and creating a vector store. In some other AllegroGraph documentation, the names of the Chomsky database are chomsky47 and chomsky47-vec. The data is the same regardless of what name is used.

Natural language to SPARQL queries

AllegroGraph supports translating a natural language query to a SPARQL query. This feature is described in the Natural Language SPARQL Queries document. That document uses the kennedy repository supplied with the AllegroGraph distribution and discussed in the AllegroGraph Quick Start document. This repository is not, however, preloaded in the AllegroGraph Cloud.

The olympics repository, which contains information about the Olympic Games, is preloaded and in this section we will show how to set that repo up for natural language queries and show a couple of examples. A feature of this tool is the query is converted to SPARQL allowing users to examine the SPARQL produced. The SPARQL can be used as a template for other similar queries.

To enable natural language querying you must first specify an embedder and create a vector database associated with the repo. This has already been done for the olympics repo using the OpenAI embedder. In order to use it, you must supply an OpenAI key. See OpenAI GPT. Once you have a key, specify it to the olympics vector repo. Display all repos by opening WebView and clicking on AllegroGraph in the upper left. All repos will be displayed, with ordinary repos above and vector repos below, as shown in the illustration:

Available repos and vector repos

The various vector repos are set up to accept an OpenAI key. Click on the button indicated by the red arrow. A dialog will appear allowing you to enter your key:

Dialog for specifying an OpenAI key

Once the key has been entered, the system is ready for natural language queries which will be used to generate SPARQL queries.

Open the olympics repo and click on Query from the Repository menu to the left. On that page click on the down arrow next to the New Query button and choose Natural Langauge (NL) to SPARQL.

Query selection menu

There is a box where you enter the query. It will be translated to SPARQL in the field below.

Query results

In our example, we ask Name swimmer gold medalist. Click the button RUN NL QUERY. The natural langauge query is translated to SPARQL. In our example, this is the translation:

PREFIX o: <http://franz.com/olympics/>  
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>  
 
SELECT DISTINCT ?athleteName  
WHERE {  
  ?athleteEvent o:medal ?medal ;  
                o:sportingEvent ?sportingEvent .  
  ?sportingEvent o:sportingEventName ?sportName .  
  FILTER (CONTAINS(?sportName, "Swimming"))  
  ?medal o:medalName "Gold" .  
  ?athlete o:athleteName ?athleteName ;  
          o:athleteEvent ?athleteEvent .  
} 

Then the SPARQL query is executed and the results displayed, as shown in the illustration.

Out next query is What were the events in the 1984 games?, with this result:

What were the events query results

One of the events is Men's Shot Put. Who won the bronze? We ask:

Men's shot put bronze medalist