(See category). AIML categories in AIML are the fundamental unit of knowledge. A category consists of at least two further elements: the pattern and template elements. Here is a simple category:
<category> <pattern>WHAT IS YOUR NAME</pattern> <template>My name is John.</template> </category>
When this category is loaded, an AIML bot will respond to the input “What is your name” with the response “My name is John.”
Each AIML namespace, representing a particular bot or other set of free AIML files (such as a set of utilities) corresponds to a Project on Google code.
A Project is a large container that holds a collection of repositories. Each repository in a Project basically represents a version of a pandorabot. In particular, an individual repository in a Project is a collection of code and downloads associated with a particular release or version of a pandorabot.
You can find an AIML project on Google code by using the namespace identifier in the URL:
aiml-en-us-foundation-alice.googlecode.com or code.google.com/p/aiml-en-us-foundation-alice (alternative format) aiml-en-us-ovrp-emma.googlecode.com aiml-en-uk-squarebear-utils.googlecode.com
A Pandorabots AIML project includes:
The basic unit of knowledge in AIML is called a category. In its simplest form, the category consists of an input-side expression called the pattern and an output side expression called the template. Here is an example category:
<category> <pattern>WHAT IS YOUR NAME</pattern> <template>My name is John. What is your name?</template> </category>
When this category is loaded, an AIML bot will respond to the input “What is your name” with the response “My name is John. What is your name?” As this example shows, the <category> maps one input sentence to possibly more than one output sentences.
.. topic:: application API The application API ------------------- <...> See also :topic:`this section <application API>`.
(Of course, the element following the topic directive needn’t be a section.)
In the context of Restructured Text, a directive defines specific markup. Directives can have arguments, options and content.
Arguments are given directly after the double colon following the directive’s name. Each directive decides whether it can have arguments, and how many.
Options are given after the arguments, in form of a field lists.
A common gotcha with directives is that the first line of the content must be indented to the same level as the options are.
Restructured Text also provides facilities to extend markup functionality by allowing you to define your own directives. Typically directives are formed beginning with two periods followed by a space ”.. ” followed by a directive type and two colons. The text string ”.. directive type::” is referred to as the directory marker. The directory block immediately follows the directive marker and includes all subsequent indented lines. Sphinx uses this directive for images. Follow this link to peruse the complete RestructuredText syntax details. Here is a simple example:
.. name:: content -- where name is the directive name, and content is what it points to
For example, we can insert an image using this directive:
.. image:: \_static\docicons-behindscenes.png
:fieldname: Field content
In common ordinary usage an input sentence would simply mean a sentence you offer the bot. However, more than one sentence might be offered to the bot, and so in the context of AIML we call the one or more input sentences submitted together, a request.
The request consists of a sequence of input sentences. Each of these sentences is called an input in AIML and is denoted by the <input> tag. The request “Hello. Are you busy? I have a question.” consists of three inputs “Hello”, “Are you busy” and “I have a question.”
Pandorabots extends AIML with a <learn>/<eval> tag pair that makes it possible for the clients to train the bot through conversation. The purpose of <learn> is to store a new AIML category in the bot’s memory. The following example illustrates the use of <learn>/<eval>:
<category> <pattern>REMEMBER * LOVES *</pattern> <template>Ok I will remember it. <learn> <category> <pattern>WHO DOES <eval><star/></eval>LOVE</pattern> <template> <eval> <star index="2"/></eval>. </template> </category> </learn> </template> </category>
Generates the dialog:
Human: Remember John loves Jane.
Bot: OK, I will remember it.
Human: Who does John love?
For each input request, the output of the bot may consist of one or more sentences. The totality of this paragraph is called the response and is denoted by the <response> tag. Although the <request> and <response> tags are rarely used in AIML, one example is a category to display a record of the recent conversation. This example illustrates printing the last 3 interactions:
<category> <pattern>DIALOG HISTORY</pattern> <template> Human: <request index="3"/> Robot: <response index="3"/> Human: <request index="2"/> Robot: <response index="2"/> Human: <request index="1"/> Robot: <response index="1"/> </template> </category>
Sphinx uses a specially defined text-strings, called a roles, to determine how to insert markup into documents. References to roles are used to generate cross references. Writing :role:`target`, generates a link to the target of the type indicated by role. The links’s text will be the same as target.
There are some additional facilities, however, that make cross-referencing roles more versatile:
In HTML output, the link’s title attribute (that is e.g. shown as a tool-tip on mouse-hover) will always be the full target name.
The <srai> tag gives AIML the ability to link a template to other responses recursively. The srai tag is used to link together synonyms, to rewrite sentences into canonical forms, and to divide inputs and combine the responses together.
Perhaps the most common use of <srai> is to link the same response to many different ways of saying the same thing. The following categories make it possible for the bot to respond the same way to different variations of “What is your name?”
<category> <pattern>NAME</pattern> <template>ALICE.</template> </category> <category> <pattern>WHAT IS YOUR NAME</pattern> <template> <srai>NAME</srai> </template> </category> <category> <pattern>WHO ARE YOU</pattern> <template> <srai>NAME</srai> </template> </category> <category> <pattern>IDENTIFY YOURSELF</pattern> <template> <srai>NAME</srai> </template> </category>
In AIML the term <that> refers to the robot’s previous utterance. This is based on the common English usage of “that” as in “That makes sense” or “I understand that.” Each element of the <response> is a <that>. The <that> provides rudimentary context mainly in question answering. For example, if you say “Yes” to me, I better remember what I asked you that made you say “Yes”, in order to form a coherent reply.
The following example illustrates the use of <that>:
Bot: What is your name?
Bot: Nice to meet you, Jane.
This dialog may be achieved with the category:
<category> <pattern>*</pattern> <that>WHAT IS YOUR NAME</that> <template>Nice to meet you, <set name="name"><star/></set>. </template> </category>
The <topic> tag provides an additional level of context in AIML, so that many categories can be grouped together under common topics such as “Humor”, “Sales”, “Chit Chat” etc.
The <topic> tag may be used to group categories so that when the predicate value “topic” matches the topic name in the tag, those categories may be activated:
<topic name="CARS"> <category>...</category> ... <category>....</category> </topic> <topic name="TRAINS"> <category>....</category> ... <category>....</category> </topic>
The category with the pattern <pattern>*</pattern> i.e. just the wild card‘s * by itself, is called the ultimate default category because it means that no other more specific matching pattern exists. Essentially when an input matches this category, the bot has no idea what was said. A good strategy with this category is to write a list of non-sequitors that the bot may draw upon randomly, in order to get the conversation back onto something it knows about. We sometimes call this list of random choices pickup lines.
It is also a good strategy when creating a bot, to write the ultimate default category first.
<category> <pattern>*</pattern> <template> <random> <li>What's your favorite movie?</li> <li>Do you like ice cream?</li> <li>I didn't understand that. Can you rephrase it?</li> ... </random> </template> </category>
Wild cards are special characters in AIML input patterns that can match one or more words. AIML has two wild cards: _ and *. Each matches one or more words. The difference between them is that _ has the highest priority in matching. Individual words have the next highest priority, and * has the lowest priority.
Suppose we have 3 categories with the patterns:
A. <pattern>_ MOTHER</pattern> B. <pattern>WHO IS YOUR MOTHER</pattern> C. <pattern>* MOTHER</pattern>
(and for the purpose of this example, assume there are no other categories in the bot). If the input ends in the word “MOTHER” then category A will match, no matter what, even if the input is exactly the phrase “Who is your mother”. The reason is, the wildcard _ has highest priority in matching, even higher than exact matching words. If we eliminated category A, the input “Who is your mother” would match B, and “Tell me about your mother”, “Do you have a mother” etc. would match C.
Introductory Documents for Pandorabots, Inc.
Pandorabots, Inc. <http://www.pandorabots.com/>
© 2014 by Pandorabots, Inc.