Skip to content
Keith Sterling edited this page Aug 11, 2017 · 15 revisions

Resource Descriptor Framework (RDF) Support

This is probably one of the most poorly understood parts of any AIML chat bot. Added by Pandora bots and visible in the Alice2 AIML set, there is little or no documentation on the tags available to support RDF, but is one of the most powerful features once you get your head around it.

AIML implements RDF support in the form of triples, and Alice2 shops with a files triples.txt as part of the overall substitution files. It also shops with a number of aiml grammars that make use of the triples.txt and associated aiml tags addtriple, deletetriple, select, tuple and uniq.

This section of the Wiki is initially my notes on trying to decypher how it works, and also once implemented how you can make use of it.

Rant

PandoraBots have not done anyone any favours, the AIML 2.0 spec is little more than a suggestion, and AIML 2.0 onwards has fragmented with Pandora bots implementing a wide range of tags with little or no thought to the guidance and stewardship of AIML.....

What is RDF

Resource Descriptor Framework or RDF is a W3C standard for representing information on the web. For details of the spec see RDF Concepts And Abstract Syntax

An RDF entity consists of 3 elements, usually referred to as a Triple. Each triple represents a statement of a relationship between the things denoted by the nodes that it links. Each triple has three parts:

  • a subject,
  • an object, and
  • a predicate (also called a property) that denotes a relationship.

AIML Triples File

AIML allows the user to store RDF data in the form of triples. Triple is a single line of text, containing the Subject, Predicate and Object seperated by colon ':'. e.g

AIRPLANE:hasPurpose:to transport us through the air
AIRPLANE:hasSize:9
AIRPLANE:hasSpeed:12
AIRPLANE:hasSyllables:1
AIRPLANE:isa:Aircraft
AIRPLANE:isa:Transportation
AIRPLANE:lifeArea:Physical

In this example, we see the RDF definition of an airplane, which has a number of properties (predicates), each of which has a value (object)

In this format, we can create a body of knowledge about any entity for which we can identify a range of properties and their values

See config\triples.txt for many more examples of the format and content of the data

AIML RDF Tags

AIML2 introduces a number of tags that support the creation, deletion and querying of RDF data

  • addtriple
  • deletetriple
  • select
  • tuple
  • uniq
  • get

Loading Data

As described above Program-Y uses the triples file

brain:
    files:
        triples: $BOT_ROOT/config/triples.txt

Creating Data

<addtriple>
  <subj></subj><pred></pred><obj></obj>
</addtriple>

Deleting Data

<deletetriple>
  <subj></subj><pred></pred><obj></obj>
</deletetriple>

Querying Data

Simple Query

<select>
    <vars>?x ?y .... </vars>
    <q><subj></subj><pred></pred><obj></obj></q>
    <notq><subj></subj><pred></pred><obj></obj></notq>
</select>

Simple Query with Vars

<select>
    <vars>?x ?y .... </vars>
    <q><subj></subj><pred></pred><obj></obj></q>
</select>

Complex Queries

<select>
    <vars>?x ?y .... </vars>
    <q><subj></subj><pred></pred><obj></obj></q>
    <notq><subj></subj><pred></pred><obj></obj></notq>
</select>

Fetching Data

<set var="tuples>
    <select>
        <vars>?x ?y .... </vars>
        <q><subj></subj><pred></pred><obj></obj></q>
    </select>
</set>

<get var="?x">
    <tuple>
        <first><get var="tuples" /></first>
    </tuple>
</get>

Sources of RDF Data

There are lots of sources of RDF data on the web, the following are a few links that I have found. The data is in many different raw formats, but the intention is to provide a suite of tools to convert them into subject:predicate:object file format to load into Program-Y

Most of these are index pages which references lots of different rdf files of data.

Clone this wiki locally