AIML [Artificial Intelligence Markup Language] is a derivative of XML [Extensible Markup Language] that enables pattern-based content analysis and implements stimulus-response knowledge mechanisms. AIML was designed to be easy to use and also allows rapid extension of the basic language representation. It ensures interoperability with XML derivatives such as XHTML. The AIML interpreter is the system that implements the information parsing mechanism and makes it available to third parties.
Categories
Categories are the fundamental units of a knowledge structure in AIML. A category is made up of at least two elements: the pattern and the template. Here is an example of a category:
<category> <pattern>WHAT IS YOUR NAME</pattern> <template>My name is Alex.</template> </category>
When this category is loaded, to the question “What is your name?” the system will answer “My name is Alex.“.
Pattern
A pattern is a string of characters that represents one or more user inputs. A typical pattern is WHAT IS YOUR NAME, which, however, allows only a single input, namely: “what is your name”. Patterns can also contain wildcards, which can substitute one or more words. A pattern such as WHAT IS YOUR * will allow an infinite number of inputs, such as “what is your name”, “what is your favorite color”, “what is your occupation” etc. Pattern syntax is very simple and less complex than regular expressions.
Template
A template indicates the response to a pattern. A template can contain literal text, such as My name is Alex, but it can also use variables, such as
My name is <nome name="nome"/>
which substitutes the generalized name in the sentence identified by the system as Alex, or
You told me you are <get name="anni-utente"/> years old.
which substitutes the user’s age in the sentence (if known). Template elements include
- basic text formatting,
- conditional responses
- random responses
- redirection to other patterns
In the case of redirection the <srai> tag is used, which can be used to implement synonyms, as in the following example:
<category>
<pattern>WHAT IS YOUR NAME</pattern>
<template>
My name is <nome name="nome"/>
</template>
</category>
<category>
<pattern>WHAT DO YOU CALL YOURSELF</pattern>
<template>
<srai>what is your name</srai>
</template>
</category>
The first category responds to the input “what is your name” by providing the name. The second category instead specifies that the input “what do you call yourself” should be redirected to the category that deals with the input “what is your name” because the two phrases are equivalent.
List of AIML tags
Below is a list of documented and undocumented tags that might be used in the implementation of a bot.
<star index=”N”/> – replaced with the value corresponding to * in the pattern
<that index=”M,N”/> – replaced with the corresponding value from the bot’s previous response
<input index=”N”/> – replaced with the corresponding value of the user’s input
<thatstar index=”N”/> – replaced with the value of * in the “that”
<topicstar index=”N”/> – replaced with the value of * in the topic
<get name=”XXX”/> – replaced by the value of the specific conversation variable
<bot name=”XXX”/> – replaced by the value of the specific bot variable
<sr/> – abbreviation for <srai><star/> </srai> (replaced with the response to the value of * from the pattern)
<person2/> – converts the text (or <star />) between 1st and 2nd person (I <-> he, etc.)
<person/> – converts the text (or <star />) between 1st and 3rd person (I <-> you, etc.)
<gender/> – converts the text (or <star />) between male and female (he <-> she)
<date/> – replaced with the current date and time, a “format” attribute is also supported
<size/> – replaced with the size of the bot’s memory
<version/> – replaced with the AI engine version
<uppercase> – converts the text to uppercase
<lowercase> – converts the text to lowercase
<formal> – converts all words in the text to uppercase
<sentence> – capitalizes the first word in the text
<condition name=”X” value=”Y”> – defines an “if” condition based on comparing a variable’s value to a pattern
<condition name=”X”> – case statement
<condition> – multi-value if / else statement
<random> – selects one of the nested <li> values at random <li name = “X” value = “Y”> – used in the random and condition tags
<li value=”Y”> – used in the random and condition tags
<set name=”XXX”> – sets the value of a variable
<gossip> – logs the text
<srai> – recursively evaluates the text and replaces it with the response
<learn> – loads an external AIML file, currently not allowed
<system> – executes an OS command, currently not allowed
<javascript> – executes JavaScript code

Comments