###### ###### ##
# ## # ##
## ##
## ##
## #### ######
## #####
## ## ##
## ##
## ## ## ##
## ##
## ## ## ## ##
#### ######
#### ###
AIML Implementation
Reference
Version 1.00
By P.E.Colla (LU7DID) (c) 2000,2001
AIML is
(c) the AI Foundation 2000, this document uses the AIML 1.0 standard,
for a
full description of the tagset refer to the original AIML specification.
All
experimental tags implemented by TBot doesn't have support from the
AI
Foundation nor there is any guarantee it would ever be supported, use
them at
your own risk.
Standard AIML Tags and Predicates
<condition> Conditional Execution
<get> Retrieve the value of a Variable
<id> Address of Connected client
<input> Retrieve the last user Input
<javascript> Execute Script Statements
<lowercase> Lowercase a String
<sentence> Formalize a Sentence
<size/> Current Bot Memory (Categories)
<sr> Recurse Star Part of the Pattern
<system> Execute System Command Shell
<template> Define a Template for the response.
<uppercase> Uppercase a String
<version/> Current Bot Version
Non-Standard AIML Tags and Predicates
<define> Define a Custom Tag Structure
<tag> Define a new Custom Predicate
<mapped> Define the resolution of a new Predicate.
<replace> String Replacement Structure
<subst> String Replacement Predicate
<pp> External Pattern Processor
<trimleft> Trim left side of the string
<trimright> Trim right side of the string
<botsaid> Stack of previous responses from the bot
<now> Currently Evaluated Pattern String
<clientsaid> Stack of previous inputs from the user
<new> Define a new Macro Predicate
<definition> Define the resolution of a new macro.
Secondary Brain AIML non-standard extensions
<train> Train the Inference Engine
<srai> Recurse the Pattern to the Secondary Brain
<srai> Recurse a Pattern to a Remote Bot
<learn> Dynamic Creation of AIML
Standard Non-Primitive AIML Tags and Predicates
Irregular Tags (Bot Properties)
<beforethat>,<justthat>,<justbeforethat>
TBot
implements AIML thru the combination of
*
AIML 0.9 Tagset.
* AIML 1.0 Tagset.
* non-Standard AIML experimental tags.
The
following supported tags are part of the standard AIML set.
Format:
<aiml></aiml>
Use:
AIML File Header Only
Begin
and termination of an AIML file.
Deprecated
version of <aiml>, currently ignored.
Format:
<bot name="botpropertyname"/>
Use:
Pattern and Template Side
Returns
the configured property "botpropertyname", this property is read-only
from
the AIML point of view and it's defined only thru bot configuration
facilities.
Format:
<category></category>
Definition
of an group of structures to manage a unique stimuli-response
combination.
The
following AIML tags are the only valid to be used at the next level:
? <pattern>
? <template>
? <that>
Format:
<condition></condition>
Use:
Template Side
Evaluates
part of a template based on a condition.
Several
forms are supported.
Form A
- Multiple Values
<condition
name="varname">
<li
value="value1">...</li>
<li
value="value2">...</li>
<li
value="value3">...</li>
</condition>
Form B
- Single Value
<condition
name="varname" value="value1"> ... </condition>
Format:
<date/>
Use:
Template Side
This
tag is functionally equivalent to <get name="date"/> and it's
not
natively
supported by TBot.
It's
implemented as a custom tag in the file sys-aiml10.aiml.
Format:
<formal></formal>
Use:
Template Side
This
predicate returns the content with each first word of the sentence
capitalized.
Format:
<get NAME="varname"/>
Use:
Template Side
This
predicate returns the current content of the variable named
"varname",
if the
variable has not been defined it returns the empty string.
The
following aliased forms are also supported:
* <get_xxxxx/> Return the value of the
variable xxxxx.
Format:
<gossip></gossip>
Use:
Template Side
The
resolved template wrapped by this command will be stored under the
label
"Gossip" on the chat.log file.
Format:
<id/>
Use:
Template Side
This
tag is functionally equivalent to <get name="ip"/> and it's not
natively
supported by TBot.
It's
implemented as a custom tag in the file sys-aiml10.aiml.
Format:
<if name="varname" value="value">
<then></then>
<else></else>
</if>
Use:
Template Side
The
content of the variable varname will be compared with the value, if
a match
occurs the child tags of <then> will be executed otherwise the
child
tags of <else> will be executed.
Note:
This is an AIML 1.0 standard tag but the actual child structure
(<then>/<else>)
hasn't been clearly defined as part of the standard, the
current
implementation of TBot might well be non-standard once the
final
definition is made.
Format:
<input index="N"/>
Use:
Template Side
This
predicate returns the Nth input given by the user and being evaluated,
if
recursions are made thru the usage of <srai> the value is preserved from
the
original input.
If no index
is indicated it defaults to "1", if an attempt to recover a
previous
non-existing user input it returns the empty string.
Format:
<javascript></javascript>
Use:
Template Side
Enclosed
a JavaScript scriptlet, currently TBot uses MS JScript.EXE to process
the
script, so any JavaScript file able to run under it should be fine to use.
TBot
wraps the supplied scriptlet with a simple document model that exposes
all bot
properties and variables at the execution moment.
The
JavaScript segment should be represented as CDATA to avoid conflicts
with
reserved XML characters used on it.
Format:
<learn>filename.aiml</learn>
Load an
AIML file named "filename.aiml from the configured aiml directory.
Format:
<li></li>
Use:
Template Side
List of
mutually exclusive template side AIML structures to be associated with an
answer, usually
employed
together with <random>, <iterate> or <typeof> definition
structures.
This
tag is usually a child of either a <condition>,<if> or
<random> tags.
Format:
<lowercase/> or
<lowercase></lowercase>
Use:
Template Side
Returns
the current pattern string with cases turned into lower.
Format:
<pattern></pattern>
Use:
category level component.
Groups
a pattern for resolution, patterns could be structured as:
* A fully defined set of words (i.e.
"GOOD MORNING").
* A partially defined set of words and one or
more wildcards (i.e. "_ GOOD MORNING *").
Some
non-standard AIML features are supported by TBot.
* A combination of text and get/bot tags (i.e.
HELLO <get name="name"/>).
* One external processor definition (i.e.
<pp NAME="re">(hello|hi)</pp>).
Also,
TBot supports more than one pattern on each category.
Format:
<person></person>
Use:
Template Side
This
tag is not natively supported by TBot and needs to be implemented thru
custom
tag facilities.
The
distribution implements it thru TBot non-AIML standard macros in the
file
sys-macros.aiml.
Format:
<person2></person2>
Use:
Template Side
Idem as
<person>
The
doesn't currently implements it but in case of need might be implemented
in a
similar way than <person>.
Format:
<random></random>
Use:
Template Side
Groups
a set of template side statements (usually in a list form) that will
be
picked at random when the template is evaluated.
Example:
<template>
<random>
<li>One
answer</li>
<li>Another
Answer</li>
</random>
</template>
Format:
<sentence></sentence>
Use:
Template Side
This predicate
returns the content with the first word of the sentence
capitalized.
Format:
<set NAME="varname"></setvar>
Use:
Template Side
Set the
value of the variable named "varname" with the result of the
evaluation
of the enclosed AIML tags, returns the value stored.
The
following aliased forms are also supported:
* <set_xxxx></set_xxxx> Set
the value of the variable xxxx.
Format:
<size/>
Use:
Template Side
This
tag is functionally equivalent to <get name="size"/> and it's
not
natively
supported by TBot.
It's
implemented as a custom tag in the file sys-aiml10.aiml.
Format:
<srai></srai>
Use:
Template Side
Recurses
the pattern evaluation of the current value of the enclosed
combination
of AIML tags and text.
Format:
<sr/>
Use:
Template Side
This
tag is functionally equivalent to <srai><star/></srai> and
it's not
natively
supported by TBot.
It's
implemented as a custom tag in the file sys-aiml10.aiml.
Format:
<star {INDEX="index")/>
Use:
Template Side
This
predicate returns the content associated with a "star" on the pattern
side,
by default the index is assumed as "1" (first star from left to
right),
non
existing indexes are returned as ''.
Format:
<system></system>
Use:
Template Side
Encloses
a platform dependent system commands to be executed (non-aiml). Requires
implementation of
the
system shell access mechanism at the listener object.
It's
highly advisable that the shell commands are represented as CDATA, this
is not
currently a standard AIML requirement.
i.e.
<system>
<![CDATA[dir
*.* > filename]]>
</system>
Format:
<template></template>
Use:
category level component.
Groups
a set of AIML directives to be executed when the associated <pattern> or
<onevent/> of the current
category
matchs the input under a valid <that> context.
Format:
<that></that>
Use:
category level component.
Establish
a context for the current category evaluation, the template will
be
executed if the current input matches the <pattern> of the category and
the
last bot response matches the content of <that>.
Example:
<category>
<pattern>yes</pattern>
<that>do
you feel good?</that>
<template>
I'm
glad to hear that.
</template>
</category>
The
template side will be evaluated only if the current input form the user
is
"yes" and the last response from the bot was "do you feel
good?".
Format:
<thatstar index="N"/>
Use:
Template Side
Recovers
the content of "*" in a <that> structure, the index allows to
retrieve
if more than one. "1" refers to the leftmost *.
If the
index is omitted it defaults to "1".
Format:
<think></think>
Use:
Template Side
Encloses
a set of AIML directives to be executed but the result of the evaluation is
"nullified" from the
perspective
of the response to the user.
Format:
<topic name="topicname"
{LANGUAGE="language",USE="{RESERVED|PRIVATE|PUBLIC")
Start
of a conversation topic, groups a set of categories with a common conversation
topic and controls the
flow of
the conversation.
Not
supported by TBot.
Format:
<uppercase/> or
<uppercase></uppercase>
Use:
Template Side
Returns
the current pattern string with cases turned into upper.
Format:
<version/>
Use:
Template Side
This
tag is functionally equivalent to <get name="version"/> and
it's not
natively
supported by TBot.
It's
implemented as a custom tag in the file sys-aiml10.aiml.
The
following tags and predicates aren't part of the standard AIML set,
inspiration
for some of them comes from online discussions about the AIML
functionality
or research needs.
However,
none of them has been accepted as part of the AIML set and nothing
ensure
they would ever be.
Use
them with care and refrain to include them on files being part of the
AIML
standard set.
Format:
<define></define>
Use:
Define a New Tag Structure, could be defined only under <aiml> or
<topic>,
similar
hierarchy than <category>
Higher
level to start the definition of a new tag; new tags could be defined
as any
valid combination of primitive tags and previously defined custom tags.
New
tags must be defined prior to any usage of them on AIML files.
New
tags are evaluated and expanded into the primitives at load time.
The
basic structure to define a new tag would then be:
<define>
<tag>customtag</tag>
<mapped>...(definition
of custom tag using AIML predicates)...</mapped>
</define>
It's
worth note the functionality of this structure could be avoided with
the
usage of the XSL support provided by the bot.
Format:
<tag></tag>
Use:
Define a New Tag Structure, could be defined only under <define>
Defines
a new tag structure, the enclosed AIML structure will be the
newly
defined tag structure.
Example:
<define>
<tag>
<bot_name/>
</tag>
<mapped>
<getvar
NAME="botname"/>
</mapped>
Here
the new empty tag "<bot_name/>" is defined as an alias to
"<get
NAME="botname"/>"
<define>
<tag>
<set_bot_name></set_bot_name>
</tag>
<mapped>
<set
NAME="botname"></set>
</mapped>
</define>
Here
the new tag "<set_bot_name>" is defined as an alias to
"<set
NAME="botname"></set>".
Please
note that formal XML formatting rules must be followed on the definition
of the
new tag.
<define>
<tag>
<set_newname/>
</tag>
<mapped>
<set
NAME="newname><input/></set>
</mapped>
</define>
Here
the new empty tag "<set_newname>" is defined in terms of the
evaluation
of the "<set>" tag with the current content of the pattern
side as
given by the predicate <input/>.
Format:
<mapped></mapped>
Use:
Define a New Tag Structure, could be defined only under <define>
Defines
the predicates that would resolve the tag being defined.
Format:
<replace>
<from></from>
<with></with>
</replace>
Use:
Template Side.
Replaces
the string chain evaluated under <from> with the string chain
evaluated
under <with> for the current evaluation.
This is
a tag intended to perform replacements when either the <from> or
<with>
arguments requires the usage of AIML predicates to evaluate an
expression,
otherwise use the <subst/> predicate.
Format:
<subst FROM="sourcestring"
TO="targetString"/>
Use:
Template Side.
Replaces
the SourceString by the TargetString whenever it appears on the
current
pattern (<now/>).
Use
with <iterate> to produce multiple replacements on a single category.
Format:
<iterate></iterate>
Use:
Template Side
Iterate
through all the AIML statements below the level and feed each
predicated
with the result of the previous as if it were the current input.
Example:
<template>
<iterate>
<subst
FROM="I'm" TO="I am"/>
<subst
FROM="He's" TO="He is"/>
</iterate>
</template>
Then a
given pattern of the category will be used as the input of the first
<subst>
and the resulting (transformed) string will be feed as input to the
second
<subst>.
Format:
<pp NAME="pattern
processor"></pp>
Use: Pattern Side
Used to
evaluate the enclosed expression with an external pattern matching
processor.
Currently
TBot supports only Regular Expressions as an external pattern
processor
(<pp name="re">pattern</pp>).
When
used it must be the only content of the pattern since a mix usage of
native
and external pattern processors is not supported.
i.e.
<pattern>THIS
IS A <pp name="re">(NAME|THING)</pp></pattern>
is NOT
supported.
When
evaluated either the enclosed expression matches or doesn't matches
the
current pattern being evaluated; when match the context (that) is used
to
further validate the context.
Evaluation
of external processors is performed PRIOR to normal pattern
evaluation,
so an improperly coded regular expression might override
other
valid categories loaded in the bot.
<pattern>
<pp
NAME="re">
(see|look
at|watch) my (bike|bicycle)
</pp>
</pattern>
The input
"see my bike", "see my bicycle", "look at my
bike" and
"look
at my bicycle" among others would produce this pattern to be considered
as a
hit.
Even if
this structure could be successfully replaced with "reductionism"
(combination
of all the possible patterns reduced into a single category
to
produce a single response) this feature introduces a very compact notation
when
expressions could be in a wide variety of syntactical forms with the
same
semantic meaning on a given language.
Format:
<spc/>
Use:
Template Side
Returns
a blank space.
It's
intended to be used when in the template side the following structure
is
used:
<tag/> <othertag/>
The XML
parsing process will remove the space between both tags, so in
order
to make it explicit this tag could be used:
<tag/><spc/><othertag/>
Format:
<trimleft/>
Use:
Template Side
Returns
the current pattern string with spaces and CR removed at the left.
Format:
<trimleft/>
Use:
Template Side
Returns
the current pattern string with spaces and CR removed at the right.
Format:
<flush/>
Use:
Template Side
Flushes
the currently stored answer.
This
predicate is used to remove any accumulated response produced during
the
pattern matching process.
It's
scope is mostly to be used together with events, when an event occur
it
might be at any moment of the pattern evaluation process so a partially
evaluated
response might exist, still the result of the event execution
might
need to override whatever that response might be, in that situation
this
predicate would allow to clean any previously evaluated response.
Format:
<property name="propertyname" value="value"/>
Use:
Configuration
This
tag set the value of a property (to be retrieved by <bot/>), it's
usage
is mostly for configuration purposes.
TBot
uses it in the sys-botproperties.aiml configuration file.
Format:
<botsaid index="index"/>
Use:
Template Side
This
predicate has been internally aliased to <that index="N"/>.
Format:
<bye/>
Use:
Template Side
Produces
the current session to be terminated inmediately.
Format:
<now/>
Use:
Template Side
This
predicate returns the content of the current string evaluated against the
pattern. it's similar to <input/>
but
instead of preserving the original input this tag reflects the currently
evaluated string which might have
changed
because of a <srai> statement.
Format:
<clientsaid index="index"/>
Use:
Template Side
This
predicate has been internally aliased to <input index="N"/>.
Format:
<event NAME="eventname"
{VALUE="eventvalue"}/>
Use:
Template Side
Trigger
an event named eventname with optional value eventvalue, the result
of the
predicate will be the combined evaluation of all the templates found
on
categories with a matching <onevent/> tag present.
Format:
<onevent NAME="eventname"
{VALUE="eventvalue"}/>
Use:
Category Level only (equivalent to <pattern>).
Produces
the template associated to the category to be evaluated (executed)
when an
event of name eventname is fired.
If the
optional VALUE attribute is indicated the template is only executed
if the
event value matches the one indicated, if no value is indicated any
event
with name eventname will produce a match.
Format:
<timer name="timername"
interval="N">Pattern</timer>
Use:
Template Side
This
tag creates a timer named timername that will expire in interval
milliseconds.
When
expired it will perform the equivalent of <srai>Pattern</srai>.
Timers
could be perceived as a "delayed" <srai>.
The
timer is not armed upon expiration unless done so explicitly.
The
timer could be disarmed at any time setting an interval of "0" to it.
Format:
<save {NAME="topicname"}
FILE="filename"></save>
Use:
Template Side
Saves
all categories originally loaded from file FILE into the filename
indicated
by the evaluation of the tag.
This
predicate retuns a variable "SAVE" with the values
"success" or "fail"
according
with the result of the execution of the predicate.
Any
change dynamically introduced into the bot AIML structures is reflected
in the
resulting file.
Format:
<forget
FILE="filename.aiml"></forget>
Use:
Template Side
When
executed this predicate remove all the categories included on a given
file
from the current set of categories held in memory.
Format:
<macro></macro>
Use:
Define a New Macro Structure, could be defined only under <aiml> or
<topic>, similar hierarchy than <category>
Higher
level to start the definition of a new macro; new tags could be
defined
as any valid combination of primitive predicates, customs tags or
previously
defined macros.
Macros
must be defined prior to any usage on AIML files.
Macros
are evaluated during execution (as opposed to custom tags which are
evaluated
during load).
The
basic structure to define a macro would then be:
<macro>
<new>macrotag.</new>
<definition>...AIML
definition...</definition>
</macro>
Use
macros when the behaviour of a newly defined structure is dependent on
the
actual status of execution,otherwise use the custom tag feature since
it's
far more efficient.
This
functionality could be replaced using the XSL capabilities of the bot.
Format:
<new></new>
Use:
Define a New Macro structure, could be defined only under <macro>
Defines
a macro structure, the enclosed AIML structure will be the newly defined macro
structure.
Format:
<definition></definition>
Use:
Define a Macro Structure, could be defined only under <macro>
Defines
the predicates that would resolve the macro is defined.
When
enabled by the configuration patterns could be solved by a
secondary
brain as a template side pattern processor.
TBot
incorporates the MegaHAL engine (Markov Model based) which is the
inference
engine behind the winner of the 1996 Loebner Prize.
Some
predicates has been included to allow the access to this facility.
Format:
<train></train>
Use:
Template Side
Pass
the contained string to the Inference Engine for trainning.
Format:
<srai engine="{megahal|mkdict}"></srai>
Use:
Template Side
This
tag operates exactly like the standard <srai> but the pattern is
matched
by the secondary brain instead of the main Graphmaster.
TBot
incorporates the capability to exchange information with other bots
thru
standard XML/SOAP messages.
Some
predicates has been included to allow the access to this facility.
Format:
<learn url="http://host:port" method="{post|get}">filename.aiml</learn>
Use:
Same as <learn>
Load
the indicated file from the remote bot at url.
If the
method is "get" the request will be a simple HTTP GET request
(no
XML/SOAP) which could be answered by either an enabled bot or a
Web
Server.
If the
method is "post" the request will be made thru a XML/SOAP envelope
that
requires an enabled bot to service it.
The
received AIML structure will be loaded internally and referenced as
if
comming from the local filename.aiml file (see Save/Forget).
Format:
<srai url="http://host:port"
alt="altresponse"></srai>
Use:
Template Side
Same as
the standard <srai> but the pattern is recursed into the remote
bot
pointed by url instead of locally; if no connection is possible the
response
will be the one provided by the alt attribute (if indicated,
otherwise
it will be empty).
Format:
<learn that="that" pattern="pattern"
template="template"></learn>
Use:
Template Side
Same as
the standard <learn> but the that-pattern-template will be the
one
contained in the respective attributes. A new category will be
dynamically
built and placed in the Graphmaster as if comming from the
file
indicated by the child nodes of the tag.
In
order to avoid XML conflicts the content of the that/pattern/template
attributes
could be made indirect by prefixing them with the "$" sign;
in that
case the string following the $ will be assumed to be a variable
name
from where to extract the actual information from.
This
tag is mostly intended to cache responses acquired from a remote
bot.
The
following AIML 0.9 deprecated tags has been implemented as either
custom
tags or macro tags on the configuration files
sys-aiml09.aiml
sys-aiml09-deprecated.aiml
Supported
by definition of aliases thru the <define> tag with a map to
<bot
name="botproperty"/> structures.
Irregular
tags referring to bot properties which are part of the standard
AIML
tagset (i.e.<favorite_movie/>) are supported thru the <define> tag
and
the
usage of the appropriate <bot name="property"/> tag.
Supported
by definition of aliases thru the <define> tag with a map to
<that
index="N"/> and <input index="N"/>.
Supported
by definition of aliases thru the <define> tag with a map to
<get
name="name"/>.
Supported
by definition of aliases thru the <define> tag with a map to
<get
name="animagent"/>.
The
TBot makes no use of this variable which is initialized as empty.
Supported
by definition of aliases thru the <define> tag with a map to
<get
name="female"/>.
Supported
by definition of aliases thru the <define> tag with a map to
<get
name="it"/>.
Supported
by definition of aliases thru the <define> tag with a map to
<get
name="male"/>.
The
following tags and predicates are evaluated as correct but actually ignored
during execution:
* <A>
* <UL>
* <OM>
*
<EM>
*
<IMG>
*
<BR>
*
<P>
In
general, in order to avoid conflicts all XML-like tags not part of AIML
(i.e.
HTML) should be used as CDATA.
i.e.
<![CDATA[<html>
<body>
Hello
</body>
</html>]]>