AIML

 

AIML Overview

AIML, or Artificial Intelligence Mark-up Language enables people to input knowledge into chat robots based on the A.L.I.C.E free software technology.

AIML was developed by the Alicebot free software community and I during 1995-2000. It was originally adapted from an XML grammar also called AIML, and formed the basis for the first Alicebot, A.L.I.C.E., the Artificial Linguistic Internet Computer Entity.

The Analytic Information Server implementation of AIML includes a number of enhancements related to the integration of the original A.I.M.L. language with the full capabilities of the Analytic Information Server environment. The AIS implementation of AIML is made up of units called lexical definitions and rules, which encapsulate the stimulus-response knowledge available to the Alice chat Lambda.

The Alice chat robot's version of Artificial Intelligence Markup Language is a derivative of XML (Extensible Markup Language) that is completely described in this reference document. Its goal is to enable pattern-based, stimulus-response knowledge content to be served, received and processed on the Web and offline in the manner that is presently possible with HTML and XML. AIML has been designed for ease of implementation, ease of use by newcomers, and for interoperability with XML and XML derivatives such as XHTML.

Artificial Intelligence Markup Language, abbreviated AIML, describes a class of data objects called AIML objects and partially describes the behavior of computer programs that process them. AIML is a derivative of XML. By construction, AIML objects are conforming XML documents, although AIML objects may also be contained within XML documents. As XML is itself an application profile or restricted form of SGML, the Standard Generalized Markup Language, AIML objects are also conforming SGML documents.

AIS Enhancements

The AIS implementation of AIML contains a number of enahncements. These enhancements preserve Alice's wonderful "chatty" content; yet, allow Alice to be programmed with a larger range of logic rules. The AIML language has been adapted to operate in the Lambda Information Server database environment. Alice's logic and search tools have been extended in the areas of: parsing, syntax, semantic analysis, database access, rule-base goal specification, and action-response options.

The Analytic Information Server implementation of AIML includes enhancements such as the following new tags: <arg>, <rule>, <lex>, <lisp>, <token>, and <fact>. The <pattern> tag now supports additional wild cards matching, word matching by feature, and embedded Lisp conditionals.

Conversion of the Alice Graphmaster parsed input from a sequence of words into a sequence of feature based tokens, fills working memory with a set of tuples (albeit feature based rather than horn-clause logic tuples). Like the logic-based tuples in CLIPS or OPSYS5 working memory, the feature-based tuples in Alice working memory can also be morphed and combined. Composite goal seeking feature-base tuples can be added to Alice working set, during recursive rule matching, to support backtracking in either a depth first or breadth first mode.

Theoretically the enhanced Analytic Information Server implementation of Alice could conceivably be used to provide advanced logic services including forward production, goal seeking with backtracking, and depth first or breadth first search. If the client request failed to find an appropriate goal, using logical methods, then the default might be Alice's amusing personality, or an appropriate mix of the two.

Language Elements

AIML is an adapted XML grammar for the Lambda Information Server version of Alice with several significant enhancements. The language itself is composed of knowledge elements within the Alice chat robot herself as well as AIML tags. The most important language element is the assumption about how client input is managed. Analytic Information Sever AIML assumes that the client will enter a phrase or sentence to the Alice chat robot. Alice passes the client input phrase through lexical analysis, creating an input vector of lexical elements. Alice lexical elements are converted from their original input words into feature based elements. As an example, Alice would convert the following input phrase,

 

.        You are 10 minutes late.

 

into the following vector of lexical elements.

 

.        YOU                 {Value="You",Word=true}

.        ARE                 {Value="are",Word=true}

.        10                    {Value="10",Number=true}

.        MINUTES          {Value="minutes",Word=true}

.        LATE                {Value="late",Word=true}

 

Each of the Alice lexical elements is a dynamic structure to which features can be altered, added, or deleted. Lambda Information Server AIML has been enhanced with tags that allow the programmer to add lexical features such as the following lex tag.

 

.        <lex name=Verb>ARE IS HAS WAS WERE</lex>

 

After training Alice with the above lex tag, Alice would convert the following input phrase,

 

.        You are 10 minutes late.

 

into the following vector of lexical elements.

 

.        YOU                 {Value="You",Word=true}

.        ARE                 {Value="are",Word=true,Verb=true}

.        10                    {Value="10",Number=true}

.        MINUTES          {Value="minutes",Word=true}

.        LATE                {Value="late",Word=true}

 

Alice lexical elements can even contain links to other lexical elements allowing the Alice programmer to create word and phrase networks of arbitrary complexity.

 

Lexical Data Types

Alice converts each client input phrase into a vector of lexical elements. The following is a list of native lexical data types supported by Analytic Information Server AIML.

 

            Whitespace

Word

Number

String

Symbol

Special

 

The Alice feature based parser (alice.queryScript) automatically gives a set of default features to each of the words it recognizes. The default lexical features provided by Alice can be found by examining the file alice:queryScript:%DEFINITION.

 

White Space

The Alice lexical analyzer uses white space to separate each of its words, numbers, and symbols.  The Alice white space characters include all the standard 8-bit ASCII control characters (less than 32 decimal), and the blank character (32 decimal).

LF, CR, TAB                 ..control chars..

space

The Alice lexical analyzer ignores whitespace

 

Word

The Alice lexical analyzer treats any continuous alphanumeric text string as a Word. Examples of words would be as follows.

 

.        You

.        He

.        Element51

.        Antidisestablishmentarianism

 

Number

The Alice lexical analyzer treats any numeric constant text string as a Number. Examples of numbers would be as follows.

 

.        0

.        -1

.        21.45

.        -9.3425e-5

 

String

The Alice lexical analyzer treats any text string, enclosed in double quotes, as a String constant. White space is not removed from Strings. Examples of Strings would be as follows.

 

.        "Hello"

.        "Hello there."

.        "Four score and seven years ago"

.        "The following is an example of a number, -9.3425e-5"

 

CDATA String

The Alice lexical analyzer treats any text string, enclosed in starting <![CDATA[ . and halted with an ending ]]>  as a CDATA String constant. White space is not removed from CDATA Strings. Examples of CDATA Strings would be as follows.

 

.        <![CDATA[Hello]]>

.        <![CDATA[Hello there]]>

.        <![CDATA[Four <B>score</B> and seven years ago]]>

.        <![CDATA[The following is an example of an algebraic expression, ( X < Y )]]>

 

Symbol

The Alice lexical analyzer treats any text string, enclosed in single quotes, as a Symbol constant. White space is not removed from Symbols. Examples of Symbols would be as follows.

 

.        "Hello"

.        "Hello there."

.        "Four score and seven years ago"

.        "The following is an example of a number, -9.3425e-5"

Special Characters

The Alice lexical analyzer recognizes certain characters, not contained within Number, String, or Symbol constants, as Special characters. Examples of Special characters would be as follows.

 

\           |           (           )           [           ]           {           }           #          @         /           +

'           '           ,           "          :           ;           $          %         .           ?          *           -

Feature Naming Conventions

Alice lexical feature names are composed of case-sensitive alphanumeric characters.  The first character must be upper case; but, all characters in the name must NOT be upper case. No spaces or special characters are allowed in names.  Another convention to make multiple word names more readable its to start the first word with an uppercase letter and begin the first letter of each succeeding word with an uppercase letter.

For example

            MyVariable

            Sum

            NamesOfStudents

            Verb

            Pronoun

 

Tags  

Since AIML is an adapted XML grammar for the Lambda Information Server version of Alice. The AIML language is composed of XML tags. Each of the AIML tags forms a set of elements that allow stimulus-response knowledge to be conveyed to the Alice chat robot. Here follows a list of the currently supported AIML tags.

(input, star)

<aiml>

Overview                                

The <aiml> tag MUST be present at the start of every AIML knowledge source file. The Alice chat robot, upon encountering the aiml tag will know to compile an AIML source file

 

Type:              Tag

 

Syntax:            <aiml> " AIML source data " </aiml>

 

Attributes:       none

 

Membership:    root-level (the outer most all-enclosing tag)

 

When To Use              

The aiml tag must be the outer enclosing tag for all of the AIML knowledge specification data to be compiler by the Alice chat robot.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the aiml tag.

category

Any valid AIML category tags may be contained within the aiml tag.

lex

Any valid AIML lex tags may be contained within the aiml tag.

rule

Any valid AIML rule tags may be contained within the aiml tag.

________________________________________________________________

 

Example1                    

The following example demonstrates a complete AIML knowledge file, which teaches Alice to respond to two separate questions as follow:

 

<?xml version=?1.0? encoding=?ISO-8859-1? ?>

<aiml> 

<!--This comment tag introduces the example which follows -->        

<rule>

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice.</template>

</rule>

<rule> 

<pattern>ARE YOU A GIRL</pattern>

<template>I am a robot.</template>   

</rule>

</aiml>

 

Notes and Hints          

The aiml tag informs the Alice chat robot compiler that an AIML knowledge file is present.

<apply>

Overview                                

The <apply> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The apply tag returns the recursive result of sending the embedded template data to Alice as a rule-based query in place of the original query in the pattern data. The apply tag differs from the srai tag by NOT converting the template data into a string BEFORE passing the new query on to Alice. Instead, the apply tag leaves the template data as an unaltered vector of feature based tokens. Dropping the conversion-to-string step is FAR more efficient for deeply recursive logical operations.

The apply tag can be used to perform recursive logical substitution and reduction; and, together with the creation of new feature based tokens, the apply tag can be used to perform both depth and breadth first forward production and goal search with backtracking.

The apply tag may be elevated to the level of the rule, with the template tag missing. In this case, the apply tag behaves exactly as if it were imbedded within a template tag.

 

Type:              Tag

 

Syntax:            <apply>   "template data"   </apply>

<apply topic="name">   "template data"   </apply>

 

Attributes:       topic     (Optional) The name of the topic whose categories are to be applied.

 

Membership:    template-level (must be enclosed within a <template> tag)

rule-level (may be enclosed within a <rule> tag)

 

When To Use              

The apply tag is one of the optional imbedded elements in the template data of a <template> tag. Each <apply> tag returns the recursive result of sending the embedded template data to Alice as a client query in the form of a vector of feature based elements.

__________________________________________________________________

Attributes                                Explanation                                                                 

topic

(Optional) The name of the topic whose categories are to be applied.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the apply tag.

Template data

Any valid template data to be recursive sent to Alice as a client query token vector.

________________________________________________________________

 

Example1: Similar Questions  

The following example demonstrates a how AIML can be used to teach Alice how to respond to similar questions. The <apply> tag returns the recursive result of sending the embedded template data to Alice as a client query

 

<!--This examples teaches Alice how to respond to similar questions -->       

<rule>

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice</template>

</rule>

<rule>

<pattern>WHAT ARE YOU CALLED</pattern>           

<template><apply> WHAT IS YOUR NAME </apply></template>

</rule>

 

Example2: Logical Substitution          

The following example demonstrates a how AIML can be used to teach Alice how to perform logical substitution in client questions. The <srai> tag returns the recursive result of sending the embedded template data to Alice as a client query in the form of a vector of feature based elements. The second client question is logically equivalent to the original question.

 

<!--This examples teaches Alice how to perform logical substitution -->        

<rule>

<pattern>" %Number + %Number "</pattern>          

<apply><star/>

<lisp>

(newToken Value: (+ <arg index='1' feature='NumValue'/> <arg index='3' feature='NumValue'/>))

</lisp>

<star index='2'/></apply>

</rule>

 

Notes and Hints          

The apply tag returns the recursive result of sending the embedded template data to Alice as a client query in place of the original query in the pattern data. The apply tag can be used to perform recursive logical substitution and reduction; and, together with the creation of new feature based tokens, the apply tag can be used to perform both depth and breadth first forward production and goal search with backtracking.

<arg>

Overview                                

The <arg> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The arg tag returns the down cased contents of an exactly matched argument word. The index attribute determines which exactly matched argument word is returned. If no index attribute is present, the index defaults to 1.

The feature attribute determines which feature of the client input word is returned (the default is "Value"). If the user desires the original value of the client argument word, the feature="Original" attribute should be used.

 

Type:              Tag

 

Syntax:            <arg/>

<arg index="number"/>

<arg index="number" feature="Name"/>

 

Attributes:       index    (Optional) The index of the exactly matched argument word.

feature (Optional) The name of the feature in the client argument word.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The arg tag is one of the optional imbedded elements in the template data of a <template> tag. Each <arg/> returns the down cased contents of an exactly matched argument word.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) The index of the matching argument word. (default == 1)

feature

(Optional) Name of the feature in the client argument word. (default is Value)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the arg tag.

________________________________________________________________

 

Example1: Constant Folding   

The following example demonstrates a how AIML can be used to teach Alice how to respond to a matched argument word. The <arg/> tag always returns the value of the matched argument word.

 

<!--This examples teaches Alice how to perform constant folding -->

<rule>

<pattern>* %Number %Operator %Number *</pattern>        

<srai><star/>

<lisp>(newToken Value: (<arg index='2'/>  <arg index='1'/> <arg index='3'/>))

</lisp>

<star index="2"/></srai>

</rule>

 

Notes and Hints          

The arg tag allows Alice to respond with the client's own matched argument words.

<bot>

Overview                                

The <bot> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The bot tag returns the specified contents of Alice's personal memory. The index attribute determines which matched named element of Alice's personal memory is returned. If no index attribute is present, the index defaults to "name".

 

Type:              Tag

 

Syntax:            <bot/>

<bot name="name"/>

 

Attributes:       name    (Optional) The name of the Alice personal memory element to be returned.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The bot tag is one of the optional imbedded elements in the template data of a <template> tag. Each <bot/> returns the specified contents of Alice's personal memory.

__________________________________________________________________

Attributes                                Explanation                                                                 

name

(Optional) The name of the Alice personal memory element to return. (default == "name")

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Personal Questions           

The following example demonstrates a how AIML can be used to teach Alice how to respond to a personal question. The <bot/> tag always returns the specified element of Alice's personal memory.

 

<!--This examples teaches Alice how to respond to a personal question -->  

<rule>

<pattern>WHERE WERE YOU BORN</pattern>         

<template>I was born in <bot name="birthplace"/>.</template>

</rule>

 

Notes and Hints          

The bot tag allows Alice to respond with her own personal information.

<br>

Overview                                

The <br> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The br tag adds a space to the response to provide a break in the text.

 

Type:              Tag

 

Syntax:            <br/>

 

Attributes:       none

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The br tag is one of the optional imbedded elements in the template data of a <template> tag. Each <br/> tag adds a space to the response to provide a break in the text.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Personal Questions           

The following example demonstrates a how AIML can be used to teach Alice how to respond to a personal question. The <bot/> tag always returns the specified element of Alice's personal memory.

 

<!--This examples teaches Alice how to respond to a personal question -->  

<rule>

<pattern>WHERE WERE YOU BORN</pattern>         

<template>I was born in <br/> <bot name="birthplace"/><br/>.</template>

</rule>

 

Notes and Hints          

The br tag adds a space to the response to provide a break in the text.

<category>

Overview                                

The <category> tag teaches Alice how to respond to a new stimulus. AIML teaches Alice by example. The stimulus example is contained in the pattern supplied within the category tag, and the response example is contained in the template supplied within the category tag. The Alice chat robot, upon encountering the category tag will learn the new stimulus-response example.

The category tag is a synonym for the rule tag, which each behave exactly like the other.

 

Type:              Tag

 

Syntax:            <category>

<pattern> " pattern data " </pattern>

<template> " template data " </template>

</category>

 

<category topic="name">

<pattern> " pattern data " </pattern>

<template> " template data " </template>

</category>

 

Attributes:       topic    (Optional) The name of the topic to which the category is to be added.

 

Membership:    aiml-level (must be enclosed within an <aiml> tag)

 

When To Use              

The category tag must be the outer enclosing tag for each the AIML stimulus-response example to be learned by the Alice chat robot.

__________________________________________________________________

Attributes                                Explanation                                                                 

topic

(Optional) The name of the topic to which the category is to be added.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the category tag.

pattern

A single valid AIML pattern tag must be contained within the category tag.

template

A single valid AIML template tag must be contained within the category tag.

________________________________________________________________

 

Example1                    

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client asks for her name. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response.

 

<category>

<!--This examples teaches Alice how to announce her own name -->

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice.</template>

</category>    

 

Notes and Hints          

The category tag teaches Alice how to respond to a new stimulus by presenting her with examples. There may be multiple category tags in each AIML knowledge file. The category is the fundamental language element for teaching the Alice chat robot. Its proper place is contained within the <aiml> root tag in an AIML knowledge file.

 

Example2                    

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client enters her name for the first time. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response.

 

<category>

<!--This examples teaches Alice to say hello the first time she sees her name -->      

<pattern> ALICE #Alice </pattern>

<template>

<set name='Alice' switch='yes'>off</set>

<srai topic='alice'><arg index='1'/></srai>

</template>

</category>

<category topic='alice'>

<pattern>ALICE</pattern>

<template>HELLO</template>

</category>    

 

Notes and Hints          

The category tag teaches Alice how to respond to a new stimulus by presenting her with examples. There may be multiple category tags in each AIML knowledge file. The category is the fundamental language element for teaching the Alice chat robot. Its proper place is contained within the <aiml> root tag in an AIML knowledge file.

<date>

Overview                                

The <date> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The date tag returns the current date in the form of Jan 13 2002.

 

Type:              Tag

 

Syntax:            <date/>

 

Attributes:       none

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The date tag is one of the optional imbedded elements in the template data of a <template> tag. Each <date/> tag returns the current date in the form of Jan 13 2002.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Tourist Questions  

The following example demonstrates a how AIML can be used to teach Alice how to respond to a tourist question. The <date/> tag returns the current date in the form of Jan 13 2002.

 

<!--This examples teaches Alice how to respond to a tourist question -->     

<rule>

<pattern>WHAT IS THE DATE</pattern>        

<template>It is <date/>.</template>

</rule>

 

Notes and Hints          

The date tag returns the current date in the form of Jan 13 2002.

<fact>

Overview                                

The <fact> tag teaches Alice to remember an XML document. AIML teaches Alice to associate the new fact with the specified memory retrieval key. The memory retrieval key is contained in the reminder tag supplied within the fact tag, and the fact is contained in the document tag supplied within the fact tag. The Alice chat robot, upon encountering the fact tag will learn the new fact.

The fact tag stores facts, as XML documents, in the AliceFacts repository for later retrieval with the <remember> tag. These facts can be retrieved, stored, and deleted via the alice.remember, alice.assert, and alice.drop child Lambdas.

The reminder tag must contain a list of uppercase words which specify the retrieval key of the fact. This retrieval key can be used with the alice.remember child Lambda for later retrieval of the remembered fact.

The document tag may contain character data with no embedded XML tags, or it may contain embedded XML tags. The contents of the document tag are compiled as a standard XML document and are remembered in the AliceFacts repository exactly as is.

 

Type:              Tag

 

Syntax:            <fact>

<reminder> " word list data " </reminder>

<document> " xml document data " </document>

</fact>

Attributes:      none

 

Membership:    aiml-level (must be enclosed within an <aiml> tag)

 

When To Use              

The fact tag must be the outer enclosing tag for each AIML fact XML document to be learned by the Alice chat robot.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the fact tag.

reminder

A single valid AIML reminder tag must be contained within the fact tag.

document

A single valid AIML document tag must be contained within the fact tag.

________________________________________________________________

 

Example1                    

The following example demonstrates a how AIML can be used to teach Alice to remember the names of European capitals. The reminder supplies Alice with an example of the retrieval key, and the document supplies Alice with the list of European countries and their capitals.

 

<fact>

<!--This examples teaches Alice how to remember European Capitals -->

<reminder>EUROPEAN CAPITALS</reminder>    

<document>

    <FRANCE>Paris</FRANCE>

    <GERMANY>Berlin</GERMANY>

    <ENGLAND>London</ENGLAND>

    <SPAIN>Madrid</SPAIN>

</document>

</fact>

 

Notes and Hints          

The fact tag teaches Alice to remember the names of European capitals. There may be multiple fact tags in each AIML knowledge file. The fact is a fundamental language element for teaching the Alice chat robot new information. Its proper place is contained within the <aiml> root tag in an AIML knowledge file.

 

<em>

Overview                                

The <em> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The em tag returns the contents of the em tag enclosed in double quotes.

 

Type:              Tag

 

Syntax:            <em> " AIML content " </em>

 

Attributes:       none

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The em tag is one of the optional imbedded elements in the template data of a <template> tag. Each <em> tag returns the contents of the em tag enclosed in double quotes.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Book Title  

The following example demonstrates a how AIML can be used to enclose book titles in double quotes.

 

<!--This examples teaches Alice how to enclose a book title in double quotes -->      

<rule>

<pattern>WHAT IS THE TITLE OF 2001</pattern>      

<template>It is <em>2001: A Space Odyssey</em>.</template>

</rule>

 

Notes and Hints          

The date tag returns the current date in the form of Jan 13 2002.

<get>

Overview                                

The <get> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The get tag returns the specified contents of Alice's discussion memory. The index attribute determines which matched named element of Alice's discussion memory is returned.

 

Type:              Tag

 

Syntax:            <get name="name"/>

<get name="name" switch="yes"/>

 

Attributes:       name    (Mandatory) The name of the Alice discussion memory element to be returned.

switch  (Optional) If "yes", the name of the Alice pattern switch to be returned.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The get tag is one of the optional imbedded elements in the template data of a <template> tag. Each <get/> returns the specified contents of Alice's discussion memory.

__________________________________________________________________

Attributes                                Explanation                                                                 

name

(Mandatory) The name of the Alice discussion memory element to return.

switch

(Optional) If "yes", the name of the Alice pattern switch to be returned.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Personal Questions           

The following example demonstrates a how AIML can be used to teach Alice how to respond to a personal question. The <get/> tag always returns the specified element of Alice's discussion memory.

 

<!--This examples teaches Alice how to respond to a personal question -->  

<rule>

<pattern>WHAT IS MY NAME</pattern>         

<template>You are called <get name="name"/>.</template>

</rule>

 

Notes and Hints          

The get tag allows Alice to respond with her memories of this discussion.

<input>

Overview                                

The <input> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The input tag nominally returns the contents of the original client input query. The index attribute determines which word of the client input query is returned. If the index attribute is a single number, the specified word of the client input query is returned. If the index attribute is a pair of numbers separated by a dash (3-6), the specified multiple words of the client input query are returned. If no index attribute is present, the entire client input query is returned.

The feature attribute determines which feature of the client input word is returned (the default is "Original"). If the user desires the upper case value of the client input word, the feature="Value" attribute should be used.

 

Type:              Tag

 

Syntax:            <input/>

<input index="number"/>

<input index="number1-number2"/>

<input feature="Name"/>

<input index="number1-number2" feature=?Name?/>

 

Attributes:       index    (Optional) The index of the word in the original client input query.

feature (Optional) The name of the feature in the client input word.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The input tag is one of the optional imbedded elements in the template data of a <template> tag. Each <input/> tag nominally returns the contents of the original client input query.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) index of the word in the original client input query. (default is All words)

feature

(Optional) Name of the feature in the client input word. (default is Original)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the input tag.

________________________________________________________________

 

Example1: Matching Client Input         

The following example demonstrates a how AIML can be used to teach Alice how to respond with a client's own input. The <input/> tag always returns the value of the original client input query.

 

<!-- This examples teaches Alice how to respond to a client query -->           

<rule>

<pattern>MY BOYS NAME IS *</pattern>        

<template>Why do you call your son <input index='5'/>?</template>

</rule>

 

Notes and Hints          

The input tag allows Alice to respond with selected words from the client's own original input query.

<lex>

Overview                                

The <lex> tag is always one of the leading elements in every <aiml> tag, and teaches Alice a new named lexical feature. AIML teaches Alice by example. The lexical feature example is contained in the pattern data supplied within the lex tag. The Alice chat robot, upon encountering the lex tag will learn the new lexical feature.

The new lexical feature must be defined BEFORE it is used in any other AIML tags.

The pattern data is nominally a collection of upper case words, separated by blanks, any one of which must be matched exactly in order to receive the new lexical feature from Alice. However, the word list may contain named references to other lexical feature collections, adding considerable power to Alice's lexical feature defining abilities.

Normally the new lexical feature will have a value of true; however, if the values attribute is present, each word will have the new feature set to the respective entry in the values attribute.

 

Type:              Tag

 

Syntax:            <lex name='Name'> ' word list ' </lex>

<lex name='Name' define=??word vector Lisp''> ' word list ' </lex>

<lex define=' 'word vector Lisp' '/>

<lex name='Name' values=''list of values''> ' word list ' </lex>

<lex define=' 'word vector Lisp' ' values=''list of values''/>

 

Attributes:       name    The case sensitive name of the new lexical feature.

define   A Lisp script which must return a vector of words.

values  A case sensitive list of feature values.

 

Special:            (References to named lexical feature collections may be contained in the word list)

.        $Name       Named lexical feature (one occurrence of any words in the collection)

 

Membership:    aiml-level (must be enclosed within an <aiml> tag)

 

When To Use              

The lex tag is always one of the leading elements in every <aiml> tag. Each <lex> tag teaches the Alice chat robot yet another named lexical feature to be used during lexical analysis.

__________________________________________________________________

Attributes                                Explanation                                                                 

name

(Mandatory) The case sensitive name of the new lexical feature defined by the lex tag.

define

(Optional) A Lisp script which must return a vector of words each of which is to be assigned the new lexical feature defined by the lex tag.

values

(Optional) A case sensitive list of feature values.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the lex tag.

WordList

List of upper case words to be given the new feature (also may contain references to other named lexical feature collections).

________________________________________________________________

 

Example1: Simple Lexical feature        

The following example demonstrates a how AIML can be used to teach Alice how to respond to a special lexical feature called BoyNames. The word list supplies Alice with an example of a simple collection of words. If any one of these words matches the client's query then it is a match for the BoyNames lexical feature.

 

<!--This examples teaches Alice how to respond to a proper boy's name -->

<lex name="BoyNames">MIKE BOB SAM JOE RICHARD DICK TOM HARRY</lex>

<rule>

<pattern>MY BOYS NAME IS $BoyNames</pattern>  

<template>I've always liked the name <input index="5">.</template>

</rule>

<rule>

<pattern>MY BOYS NAME IS *</pattern>        

<template>Why do you call your son <star/>? Is that really a proper name for a boy?</template>

</rule>

 

Example2: Recursive Lexical feature  

The following example demonstrates a how AIML can be used to teach Alice how to respond to a special lexical feature called ChildNames. The word list supplies Alice with an example of a recursive collection of words. If any one of these words matches the client's query then it is a match for the ChildNames lexical feature.

 

<!--This examples teaches Alice how to respond to a proper child's name -->           

<lex name="BoyNames">MIKE BOB SAM JOE RICHARD DICK TOM HARRY </lex>

<lex name="GirlNames">SALLY ALICE SAMANTHA BETTY RACHEL </lex>

<lex name="ChildNames">$BoyNames $GirlNames </lex>

<rule>

<pattern>MY CHILDS NAME IS $ChildNames</pattern>          

<template>I've always liked the name <input index="5">.</template>

</rule>

<rule>

<pattern>MY CHILDS NAME IS *</pattern>     

<template>Why do you call your child <star/>? Is that really a proper name for a child?</template>

</rule>

 

 

Notes and Hints          

The lex tag teaches Alice a new lexical feature by presenting her with a examples. The lex tag must be among the first elements contained within the <aiml> tag in an AIML knowledge file. There may be multiple lex tags in each AIML knowledge file. The word list may contain the names of other lexical features previously defined with lex tags.

<lisp>

Overview                                

The <lisp> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The lisp tag returns the results of executing the specified lisp expression. The lisp expression is compiled in an environment containing all of the persistent (pvars) variables of the alice Lambda herself. Therefore, when designing the script, all of the pvars of alice are available to the script locally while variables and functions outside of alice must be global references.

The lisp tag may be included within the pattern tag. In this case, the lisp tag behaves as a conditional test within the lisp tag, and must return either true or false. Furthermore, lisp tags (included within a pattern tag) may NOT contain any recursively embedded tags.

The lisp tag may be included within the template tag. In this case, the lisp tag performs some action within the template tag, and must return a value acceptable as an answer or partial answer.

The lisp tag may be elevated to the level of the rule, with the template tag missing. In this case, the lisp tag behaves exactly as if it were imbedded within a template tag.

 

Type:              Tag

 

Syntax:            <lisp>   'lisp expression'   </lisp>

 

Attributes:       none.

 

Membership:    pattern-level (must be enclosed within a <pattern> tag)

template-level (must be enclosed within a <template> tag)

rule-level (may be enclosed within a <rule> tag)

 

When To Use              

The lisp tag is one of the optional imbedded elements in the template data of a <template> tag. Each <lisp> tag returns the results of executing the specified lisp expression.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

lisp expression

Any valid lisp expression to be evaluated as a part of the response.

________________________________________________________________

 

Example1: Meaningful Actions

The following example demonstrates a how AIML can be used to teach Alice how to respond with meaningful actions. The <lisp> tag returns the results of executing the specified lisp expression.

 

<!--This examples teaches Alice how to respond with a web search -->         

<rule>

<pattern>%Retrieve %Internet SEARCH %Preposition *</pattern>

<template>

  <random>

    <li>When I am confused, I look it up on the Internet.</li>

    <li>Sometimes I actually do find the web very useful.</li>

    <li>The Internet is such a great tool for me, it helps me soooo much :-)</li>

    <li>I would give you a cute answer; but, you might find a web search more useful.</li>

    <li>I am betting that somebody, somewhere on the Internet, knows the answer.</li>

    <li>I am almost sure the answer can be found on the web.</li>

  </random>

  <think>

    <lisp>

      <![CDATA[

      vars:(searchPhrase htmlPage

           (command "http://search.yahoo.com/search?p=")

           ) ; end temporary variables

      ;; Make sure the web is online before we waste time searching.

      (if (= webOnline false)

          (return

            (setq myHtmlResponseHeading

                 "<hr><p>I tried a Yahoo search; but, Alice says the web is offline.</p>"))

          ) ; end if

      ;; Create the Internet search command using the Yahoo search page.

      (setq searchPhrase star[0])

      (if (isVector searchPhrase)

                  (setq searchPhrase (appendFeatures searchPhrase Original:))

                  (setq searchPhrase "")

          ) ; end

      (setq command (append command (substitute searchPhrase " " "%20")))

      (setq htmlPage (readHtmlPage command myWebTimeOut))

      (if (and (<> htmlPage #void) (> (length htmlPage) 0))

          (setq myHtmlResponseResults htmlPage)

          (setq myHtmlResponseHeading

                    "<hr><p>I tried a Yahoo search; but, got no web connection.</p>")

          ) ; end if

      ]]>

    </lisp>

  </think>

</template>

</rule>

 

Example2: Conditional Patterns          

The following example demonstrates a how AIML can be used to teach Alice how to test with conditional patterns. The <lisp> tag returns the results of executing the specified lisp expression.

 

<!--This examples teaches Alice how to respond with conditional patterns -->          

<rule>

<pattern>IS " EQUAL TO "<lisp>(= star[0] star[1])</lisp></pattern> 

<template>Yes, <em><star/><em> is equal to <em><star index='2'/><em></template>

</rule>

 

Notes and Hints          

The lisp tag returns the results of executing the specified lisp expression.

<pattern>

Overview                                

The <pattern> tag is always the first element in every <rule> tag, and teaches Alice a new stimulus. AIML teaches Alice by example. The stimulus example is contained in the pattern supplied within the rule tag. The Alice chat robot, upon encountering the pattern tag will learn the new stimulus example.

The pattern tag may contain imbedded lisp, and token tags only. No other embedded tags are allowed in the pattern tag.

The pattern data, other than the above-mentioned imbedded tags, is nominally upper case words, separated by blanks, which must be matched exactly in order to trigger a response from Alice. However, there are a number of powerful special pattern characters and rules that add considerable power to Alice's pattern matching abilities. These special pattern characters and rules are shown below under Special.

 

Type:              Tag

 

Syntax:            <pattern> ' pattern data ' </pattern>

 

Attributes:       none

 

Special:            (These special characters/rules add pattern matching power)

.        _                Wild card with first priority (one or more occurrences)                

.        ?                Wild card with first priority (none or more occurrences)

.        *                 Wild card with last priority (one or more occurrences)

.        @               Wild card with last priority (none or more occurrences)

.        %Name      Named feature (one preemptive occurrence)

.        $Name       Named feature (one post emptive occurrence)

.        #Name       Check the named pattern switch for void

.        !Name        Check the named pattern switch for not void

 

Membership:    rule-level (must be enclosed within a <rule> tag)

 

When To Use              

The pattern tag must be the first element in every <rule> tag. Each AIML stimulus-response example to be learned by the Alice chat robot must contain a <pattern> tag.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the pattern tag.

text-pattern

Upper case text may be contained within the pattern tag. This is the text, which when matched word for word, will cause Alice to respond as directed in the <template> tag following the <pattern> tag in the stimulus-response training example.

________________________________________________________________

 

Example1: Exact Match           

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client asks for her name. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. Since there are no special pattern characters, the client's query must match the pattern word for word.

 

<rule>

<!--This examples teaches Alice how to announce her own name -->

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice.</template>

</rule>

 

Example2: Preemptive Wild Card (_)

The following example demonstrates a how AIML can be used to teach Alice to respond whenever the phrase my mother appears at the end of a client's query. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The presence of the "_" special pattern character, causes Alice to respond whenever the phrase "MY MOTHER" terminates the client's query.

 

<rule>

<!--This example teaches Alice to respond whenever -->        

<!--the phrase my mother appears at the end of a query -->  

<pattern> _ MY MOTHER </pattern>   

<template>Tell me how you feel about your mother.</template>

</rule>

 

Example3: Last priority Wild Card (*)

The following example demonstrates a how AIML can be used to teach Alice to respond supportively whenever the client says he/she likes something. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The presence of the "*" special pattern character, causes Alice to respond whenever the phrase "I REALLY LIKE" precedes the client's query.

How will Alice respond if the client queries with, "I REALLY LIKE MY MOTHER" Alice will respond with, "Tell me how you feel about your mother" because the "_" wild card special character is preemptive and the "*" wild card has last priority. However, if the client queries with, "I REALLY LIKE MY DAD", then Alice will respond with, "It's charming that you really like your dad".

 

<rule>

<!-- This examples teaches Alice to respond supportively -->

<!-- whenever the client says he/she likes something  -->      

<pattern>I REALLY LIKE MY * </pattern>       

<template>It's charming that you really like your <star/>.</template>

</rule>

<rule>

<!-- This example teaches Alice to respond whenever -->       

<!-- the phrase my mother appears at the end of a query -->

<!-- It will even preempt the previous rule, if necessary -->    

<pattern> _ MY MOTHER </pattern>   

<template>Tell me how you feel about your mother.</template>

</rule>

 

Example4: Named Post Emptive Feature ($Name)

The following example demonstrates a how AIML can be used to teach Alice to respond supportively whenever the client says he/she likes some family member only. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The presence of the "$FamilyMember" special pattern character, causes Alice to respond whenever the phrase "I REALLY LIKE MY" precedes some family member in the client's query.

How will Alice respond if the client queries with, "I REALLY LIKE MY MOTHER" Alice will respond with, "Tell me how you feel about your mother" because the "_" wild card special character is preemptive and the "*" wild card has last priority. However, if the client queries with, "I REALLY LIKE MY SISTER", then Alice will respond with, "It's charming that you really like your sister", because the word "SISTER" matched one of the words in the the FamilyMember word collection.

 

<lex name="FamilyMember">MOTHER FATHER SISTER BROTHER UNCLE AUNT</syntax>

<rule>

<!-- This example teaches Alice to respond supportively -->  

<!-- whenever the client says he/she likes something  -->      

<pattern>I REALLY LIKE MY $FamilyMember </pattern>        

<template>It's charming that you really like your <input index='5'>.</template>

</rule>

<rule>

<!-- This example teaches Alice to respond whenever -->       

<!-- the phrase my mother appears at the end of a query -->

<!-- It will even preempt the previous rule, if necessary -->    

<pattern> _ MY MOTHER </pattern>   

<template>Tell me how you feel about your mother.</template>

</rule>

 

Example5: Check Named Pattern Switches (#Name)(!Name)

The following example demonstrates a how AIML can be used to answer differently depending upon the settings of temporary pattern switches.

 

<rule>

<pattern>HELLO #Greeting </pattern>

<template>Hello <set switch='yes' name='Greeting'>true</set><srai>HELLO</srai></template>

</rule>

<rule>

<pattern>HELLO !Greeting </pattern>

<template>Goodbye</template>

</rule>

 

Notes and Hints          

The pattern tag teaches Alice a new stimulus by presenting her with an example. The pattern tag must be the first element contained within the <rule> tag in an AIML stimulus-response training example. There may be multiple rule tags in each AIML knowledge file. The rule is the fundamental language element for teaching the Alice chat robot.

<person>

Overview                                

The <person> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The person tag returns the person-converted contents of a matched star phrase. The index attribute determines which matched star phrase is returned. If no index attribute is present, the index defaults to 1.

 

Type:              Tag

 

Syntax:            <person/>

<person index=?number?/>

 

Attributes:       index    (Optional) The index of the matching star phrase.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The person tag is one of the optional imbedded elements in the template data of a <template> tag. Each <person/> returns the person-converted contents of a matched star phrase.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) The index of the matching star phrase. (default == 1)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the person tag.

________________________________________________________________

 

Example1: Star Matched Phrase         

The following example demonstrates a how AIML can be used to teach Alice how to respond to a matched star phrase. The <person/> tag always returns the person-converted contents of the matched client input.

 

<!--This examples teaches Alice how to respond to a name -->          

<rule>

<pattern>* BOYS NAME IS *</pattern>           

<template><person/> son?s name is <star index=?2?/>?</template>

</rule>

 

Notes and Hints          

The person tag allows Alice to respond with the client?s own person-converted matched input. The types of conversions are as follows:

           mine      è        yours

           yours     è        mine

           my         è        your

           I                        è        you

           Hers      è        his

           Etc.

<random>

Overview                                

The <random> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The random tag returns one of the embedded list phrases <li> at random.

 

Type:              Tag

 

Syntax:            <random>   ?phrase list?   </random>

 

Attributes:       none.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The random tag is one of the optional imbedded elements in the template data of a <template> tag. Each <random> tag returns one of the embedded list phrases <li> at random.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

Phrase list

Any valid phrase list composed of multiple <li> tags.

________________________________________________________________

 

Example1: Random Responses          

The following example demonstrates a how AIML can be used to teach Alice how to respond with random retorts. The <random> tag returns one of the embedded list phrases <li> at random.

 

<!--This examples teaches Alice how to respond with a random retort -->     

<rule>

<pattern>MAY I HOLD YOUR HAND</pattern>

<template>

<random>

<li>No thanks. It?s not heavy.</li>

<li>You wish.</li>

<li>As if</li>

<li>Don?t get fresh with me.</li>

</random>

</template>

</rule>

 

Notes and Hints          

The random tag returns one of the embedded list phrases <li> at random.

<rule>

Overview                                

The <rule> tag teaches Alice how to respond to a new stimulus. AIML teaches Alice by example. The stimulus example is contained in the pattern supplied within the rule tag, and the response example is contained in the template supplied within the rule tag. The Alice chat robot, upon encountering the rule tag will learn the new stimulus-response example.

The rule tag is a synonym for the category tag, which each behave exactly as the other.

 

Type:              Tag

 

Syntax:            <rule>

<pattern> ? pattern data ? </pattern>

<template> ? template data ? </template>

</rule>

 

<rule topic=?name?>

<pattern> ? pattern data ? </pattern>

<template> ? template data ? </template>

</rule>

 

Attributes:       topic    (Optional) The name of the topic to which the rule is to be added.

 

Membership:    aiml-level (must be enclosed within an <aiml> tag)

 

When To Use              

The rule tag must be the outer enclosing tag for each the AIML stimulus-response example to be learned by the Alice chat robot.

__________________________________________________________________

Attributes                                Explanation                                                                 

topic

(Optional) The name of the topic to which the rule is to be added.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the rule tag.

pattern

A single valid AIML pattern tag must be contained within the rule tag.

template

A single valid AIML template tag must be contained within the rule tag.

________________________________________________________________

 

Example1                    

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client asks for her name. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response.

 

<rule>

<!--This examples teaches Alice how to announce her own name -->

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice.</template>

</rule>

 

Notes and Hints          

The rule tag teaches Alice how to respond to a new stimulus by presenting her with examples. There may be multiple rule tags in each AIML knowledge file. The rule is a fundamental language element for teaching the Alice chat robot new stimulus response rules. Its proper place is contained within the <aiml> root tag in an AIML knowledge file.

 

Example2                    

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client enters her name for the first time. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response.

 

<rule>

<!--This examples teaches Alice to say hello the first time she sees her name -->      

<pattern> ALICE #Alice </pattern>

<template>

<set name='Alice' switch='yes'>off</set>

<srai topic='alice'><arg index='1'/></srai>

</template>

</rule>

<rule topic='alice'>

<pattern>ALICE</pattern>

<template>HELLO</template>

</rule>

 

Notes and Hints          

The rule tag teaches Alice how to respond to a new stimulus by presenting her with examples. There may be multiple rule tags in each AIML knowledge file. The rule is a fundamental language element for teaching the Alice chat robot. Its proper place is contained within the <aiml> root tag in an AIML knowledge file.

<set>

Overview                                

The <set> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The set tag sets the specified contents of Alice?s discussion memory. The index attribute determines which matched named element of Alice?s discussion memory is set.

 

Type:              Tag

 

Syntax:            <set name=?name?> ?new value? </set>

<set name=?name? switch=?yes?> ?new value? </set>

 

Attributes:       name    (Mandatory) The name of the Alice discussion memory element to be set.

switch  (Optional) If ?yes?, the name of the Alice pattern switch to be set.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The set tag is one of the optional imbedded elements in the template data of a <template> tag. Each <set> tag sets the specified contents of Alice?s discussion memory.

__________________________________________________________________

Attributes                                Explanation                                                                 

name

(Mandatory) The name of the Alice discussion memory element to set.

switch

(Optional) If ?yes?, the name of the Alice pattern switch to be set.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the set tag.

New value

The new value for the named element in Alice?s discussion memory.

________________________________________________________________

 

Example1: Personal Information         

The following example demonstrates a how AIML can be used to teach Alice how to remember the client?s personal information. The <set> tag always sets the specified element of Alice?s discussion memory.

 

<!--This examples teaches Alice how to remember the client?s personal information -->        

<rule>

<pattern> MY NAME IS *</pattern>     

<template>Okay. I will call you <set name=?name?><star/></set>.</template>

</rule>

 

Notes and Hints          

The set tag allows Alice to form memories of this discussion.

<sr>

Overview                                

The <sr> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The sr tag returns the recursive result of sending Alice the contents of a matched star phrase as a client query. The index attribute determines which matched star phrase is returned. If no index attribute is present, the index defaults to 1.

 

Type:              Tag

 

Syntax:            <sr/>

<sr index=?number?/>

 

Attributes:       index    (Optional) The index of the matching star phrase.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The sr tag is one of the optional imbedded elements in the template data of a <template> tag. Each <sr/> tag returns the recursive result of sending Alice the contents of a matched star phrase as a client query.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) The index of the matching star phrase. (default == 1)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the sr tag.

________________________________________________________________

 

Example1: Star Matched Phrase         

The following example demonstrates a how AIML can be used to teach Alice how to recursively respond to a matched star phrase. The <sr/> tag returns the recursive result of sending Alice the contents of a matched star phrase as a client query.

 

<!--This examples teaches Alice how to recursively respond to a phrase -->

<rule>

<pattern>NAME</pattern>      

<template>My name is <bot/>'</template>

</rule>

<rule>

<pattern>WHAT IS YOUR *</pattern>

<template><sr/></template>

</rule>

 

Notes and Hints          

The sr tag returns the recursive result of sending Alice the contents of a matched star phrase as a client query.

<srai>

Overview                                

The <srai> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The srai tag returns the recursive result of sending the embedded template data to Alice as a client query in place of the original query in the pattern data.

The srai tag can be used to perform recursive logical substitution and reduction; and, together with the creation of new feature based tokens, the srai tag can be used to perform both depth and breadth first forward production and goal search with backtracking.

The srai tag may be elevated to the level of the rule, with the template tag missing. In this case, the srai tag behaves exactly as if it were imbedded within a template tag.

 

Type:              Tag

 

Syntax:            <srai>   ?template data?   </srai>

<srai topic=?name?>   ?template data?   </srai>

 

Attributes:       topic     (Optional) The name of the topic whose categories are to be applied.

 

Membership:    template-level (must be enclosed within a <template> tag)

rule-level (may be enclosed within a <rule> tag)

 

When To Use              

The srai tag is one of the optional imbedded elements in the template data of a <template> tag. Each <srai> tag returns the recursive result of sending the embedded template data to Alice as a client query in the form of a vector of feature based elements.

__________________________________________________________________

Attributes                                Explanation                                                                 

topic

(Optional) The name of the topic whose categories are to be applied.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the srai tag.

Template data

Any valid template data to be recursive sent to Alice as a client query token vector.

________________________________________________________________

 

Example1: Similar Questions  

The following example demonstrates a how AIML can be used to teach Alice how to respond to similar questions. The <srai> tag returns the recursive result of sending the embedded template data to Alice as a client query

 

<!--This examples teaches Alice how to respond to similar questions -->       

<rule>

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice</template>

</rule>

<rule>

<pattern>WHAT ARE YOU CALLED</pattern>           

<template><srai> WHAT IS YOUR NAME </srai></template>

</rule>

 

Example2: Logical Substitution          

The following example demonstrates a how AIML can be used to teach Alice how to perform logical substitution in client questions. The <srai> tag returns the recursive result of sending the embedded template data to Alice as a client query in the form of a vector of feature based elements. The second client question is logically equivalent to the original question.

 

<!--This examples teaches Alice how to perform logical substitution -->        

<rule>

<pattern>? %Number + %Number ?</pattern>          

<srai><star/>

<lisp>

(newToken Value: (+ <arg index='1' feature='NumValue'/> <arg index='3' feature='NumValue'/>))

</lisp>

<star index='2'/></srai>

</rule>

 

Notes and Hints          

The srai tag returns the recursive result of sending the embedded template data to Alice as a client query in place of the original query in the pattern data. The srai tag can be used to perform recursive logical substitution and reduction; and, together with the creation of new feature based tokens, the srai tag can be used to perform both depth and breadth first forward production and goal search with backtracking.

<star>

Overview                                

The <star> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The star tag returns the down cased contents of a matched star phrase. The index attribute determines which matched star phrase is returned. If no index attribute is present, the index defaults to 1.

 

Type:              Tag

 

Syntax:            <star/>

<star index=?number?/>

 

Attributes:       index    (Optional) The index of the matching star phrase.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The star tag is one of the optional imbedded elements in the template data of a <template> tag. Each <star/> returns the down cased contents of a matched star phrase.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) The index of the matching star phrase. (default == 1)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Star Matched Phrase         

The following example demonstrates a how AIML can be used to teach Alice how to respond to a matched star phrase. The <star/> tag always returns the value of the matched client input.

 

<!--This examples teaches Alice how to respond to a name -->          

<rule>

<pattern>MY BOYS NAME IS *</pattern>        

<template>Why do you call your son <star/>?</template>

</rule>

 

Notes and Hints          

The star tag allows Alice to respond with the client?s own matched input.

 

<starno>

Overview                                

The <starno> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The starno tag returns the unaltered contents of a matched star phrase. The index attribute determines which matched star phrase is returned. If no index attribute is present, the index defaults to 1.

 

Type:              Tag

 

Syntax:            <starno/>

<starno index=?number?/>

 

Attributes:       index    (Optional) The index of the matching star phrase.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The starno tag is one of the optional imbedded elements in the template data of a <template> tag. Each <starno/> returns the unaltered contents of a matched star phrase.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) The index of the matching star phrase. (default == 1)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Star Matched Phrase         

The following example demonstrates a how AIML can be used to teach Alice how to respond to a matched star phrase. The <star/> tag always returns the unaltered contents of the matched client input.

 

<!--This examples teaches Alice how to respond to a name -->          

<rule>

<pattern>MY BOYS NAME IS *</pattern>        

<template>Why do you call your son <star/>?</template>

</rule>

 

Notes and Hints          

The starno tag allows Alice to respond with the client?s own unaltered input.

 

<string>

Overview                                

The <string> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The string tag returns its unaltered contents as an ASCII string token. This AIS implementation of Alice converts all input into feature based tokens. There are circumstances when we do not wish a response to be subjected to this tokenizing process. The ASCII tag returns its contents as an unaltered string token.

The optional attribute allows the final token string to be enclosed in single quotes, double quotes, or an XML CDATA enclosure.

The string tag may be elevated to the level of the rule, with the template tag missing. In this case, the string tag behaves exactly as if it were imbedded within a template tag.

 

Type:              Tag

 

Syntax:            <string> ? string data ? </string>

<string enclose=?cdata?> ? string data ? </string>

<string enclose=?quote?> ? string data ? </string>

<string enclose=?dquote?> ? string data ? </string>

 

Attributes:       enclose            (Optional) the type (if any) of enclosure for the unaltered string data.           

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The string tag is one of the optional imbedded elements in the template data of a <template> tag. Each <string> tag returns the unaltered contents of its string data as a string token.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the string tag.

string-pattern

Case sensitive text may be contained within the string tag. This is the text, which will be output word for word as Alice responds to the stimulus in the <pattern> tag of the stimulus-response training example. Optionally a number of special AIML tags and rules may be imbedded in the template data. The unaltered string data is returned as a token string

________________________________________________________________

 

Example1: Return a String      

The following example demonstrates a how AIML can be used to teach Alice how to respond with a string token. Alice?s name Alice C. Robot will always be seen as a single token and never subjected to the feature based parsing process.

 

<rule>

<!--This examples teaches Alice how respond with a string -->          

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is <string>Alice C Robot</string>.</template>

</rule>

 

Example2: Return a Single Quoted String

The following example demonstrates a how AIML can be used to teach Alice how to respond with a single quoted string token. Einstein?s exact words ?E equals M times C squared? will always be seen as a string token, enclosed in single quotes, and never subjected to the feature based parsing process.

 

<rule>

<!--This examples teaches Alice how respond with a single quoted string -->            

<pattern>WHAT DID EINSTEIN SAY EXACTLY</pattern>       

<template>Einstein said

      <string enclose=?quote?>E equals M times C squared</string>.

</template>

</rule>

 

Example3: Return a Double Quoted String

The following example demonstrates a how AIML can be used to teach Alice how to respond with a double quoted string token. The book title ?The Life and Times of Me? will always be seen as a string token, enclosed in double quotes, and never subjected to the feature based parsing process.

 

<rule>

<!--This examples teaches Alice how respond with a double quoted string -->          

<pattern>WHAT IS THE TITLE OF YOUR BOOK</pattern>     

<template>The title of my book is

     <string enclose=?dquote?>The Life and Times of Me</string>.

</template>

</rule>

 

Example4: Return a string with embedded XML tags

The following example demonstrates a how AIML can be used to teach Alice how to respond with a string token containing embedded XML tags. The <a> tag contents will always be seen as a string token, and never subjected to the feature based parsing process.

 

<rule>

<!--This examples teaches Alice how respond with a string containing embedded XML tags -->            

<pattern>WHAT IS THE URL OF YOUR HOME PAGE</pattern>         

<template>

     <string><![CDATA[My <A HREF="MyHomePage.html">home</A> page.]]></string>.

</template>

</rule>

 

Notes and Hints          

The string tag allows Alice to respond with the client?s own unaltered string output.

 

<template>

Overview                                

The <template> tag is always the last element in every <rule> tag, and teaches Alice a new response. AIML teaches Alice by example. The response example is contained in the template, and the stimulus example is contained in the pattern supplied within the rule tag. The Alice chat robot, upon encountering the template tag will learn the new response example.

The template data is nominally case sensitive words, separated by blanks, which will be output exactly in the order specified. However, there are a number of powerful special AIML tags and rules that add considerable power to Alice?s template response abilities. These special AIML tags are described in this chapter.

 

Type:              Tag

 

Syntax:            <template> ? template data ? </template>

 

Attributes:       ?user defined?          (Optional) The template tag may contain any XML attributes, including confidence percentages, logic notes, etc., which may be helpful during conflict resolution (see the findAllMatches Alice child Lambda).

 

Membership:    rule-level (must be enclosed within a <rule> tag)

 

When To Use              

The template tag must be the last element in every <rule> tag. Each AIML stimulus-response example to be learned by the Alice chat robot must contain a <tamplate> tag.

__________________________________________________________________

Attributes                                Explanation                                                                 

?user defined?

(Optional) The template tag may contain any XML attributes, including confidence percentages, logic notes, etc., which may be helpful during conflict resolution (see the findAllMatches Alice child Lambda).

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the pattern tag.

template-pattern

Case sensitive text may be contained within the template tag. This is the text, which will be output word for word as Alice responds to the stimulus in the <pattern> tag of the stimulus-response training example. Optionally a number of special AIML tags and rules may be imbedded in the template data.

________________________________________________________________

 

Example1: Exact Match           

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client asks for her name. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. Since there are no special pattern characters, the client?s query must match the pattern word for word.

 

<rule>

<!--This examples teaches Alice how to announce her own name -->

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice.</template>

</rule>

 

Example2: Preemptive Wild Card (_)

The following example demonstrates a how AIML can be used to teach Alice to respond whenever the phrase my mother appears at the end of a client?s query. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The presence of the ?_? special pattern character, causes Alice to respond whenever the phrase ?MY MOTHER? terminates the client?s query.

 

<rule>

<!--This example teaches Alice to respond whenever -->        

<!--the phrase my mother appears at the end of a query -->  

<pattern> _ MY MOTHER </pattern>   

<template>Tell me how you feel about your mother.</template>

</rule>

 

Example3: Last priority Wild Card (*)

The following example demonstrates a how AIML can be used to teach Alice to respond supportively whenever the client says he/she likes something. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The presence of the ?*? special pattern character, causes Alice to respond whenever the phrase ?I REALLY LIKE? precedes the client?s query.

How will Alice respond if the client queries with, ?I REALLY LIKE MY MOTHER?? Alice will respond with, ?Tell me how you feel about your mother? because the ?_? wild card special character is preemptive and the ?*? wild card has last priority. However, if the client queries with, ?I REALLY LIKE MY DAD?, then Alice will respond with, ?It?s charming that you really like your dad?.

 

<rule>

<!-- This examples teaches Alice to respond supportively -->

<!-- whenever the client says he/she likes something  -->      

<pattern>I REALLY LIKE MY * </pattern>       

<template>It?s charming that you really like your <star/>.</template>

</rule>

<rule>

<!-- This example teaches Alice to respond whenever -->       

<!-- the phrase my mother appears at the end of a query -->

<!-- It will even preempt the previous rule, if necessary -->    

<pattern> _ MY MOTHER </pattern>   

<template>Tell me how you feel about your mother.</template>

</rule>

 

Example4: Named Word Collection ($Name)

The following example demonstrates a how AIML can be used to teach Alice to respond supportively whenever the client says he/she likes some family member only. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The presence of the ?$FamilyMember? special pattern character, causes Alice to respond whenever the phrase ?I REALLY LIKE MY? precedes some family member in the client?s query.

How will Alice respond if the client queries with, ?I REALLY LIKE MY MOTHER?? Alice will respond with, ?Tell me how you feel about your mother? because the ?_? wild card special character is preemptive and the ?*? wild card has last priority. However, if the client queries with, ?I REALLY LIKE MY SISTER?, then Alice will respond with, ?It?s charming that you really like your sister?, because the word ?SISTER? matched one of the words in the the FamilyMember word collection.

 

<lex name=?FamilyMember?>MOTHER FATHER SISTER BROTHER UNCLE AUNT</syntax>

<rule>

<!-- This example teaches Alice to respond supportively -->  

<!-- whenever the client says he/she likes something  -->      

<pattern>I REALLY LIKE MY $FamilyMember </pattern>        

<template>It?s charming that you really like your <input index=?5?>.</template>

</rule>

<rule>

<!-- This example teaches Alice to respond whenever -->       

<!-- the phrase my mother appears at the end of a query -->

<!-- It will even preempt the previous rule, if necessary -->    

<pattern> _ MY MOTHER </pattern>   

<template>Tell me how you feel about your mother.</template>

</rule>

 

Notes and Hints          

The template tag teaches Alice a new response by presenting her with an example. The template tag must be the last element contained within the <rule> tag in an AIML stimulus-response training example. There may be multiple rule tags in each AIML knowledge file. The rule is the fundamental language element for teaching the Alice chat robot.

 

<that>

Overview                                

The <that> tag is always the middle element in every <rule> tag, and adds a condition to the previous pattern tag. AIML teaches Alice by example. The stimulus example is contained in the pattern tag. The <that> tag ads the condition that not only must the ?pattern data? match; but, the ?pattern data? in the <that> tag must also match the previous output from Alice.

The pattern data is nominally upper case words, separated by blanks, which must be matched exactly in order to trigger a response from Alice. However, there are a number of powerful special pattern characters and rules that add considerable power to Alice?s pattern matching abilities. These special pattern characters and rules are shown below under Special.

 

Type:              Tag

 

Syntax:            <that> ? pattern data ? </that>

 

Attributes:       index    (Optional) The index of the previous Alice output phrase.

 

Special:            (These special characters/rules add pattern matching power)

·        _                Wild card with first priority (one or more occurrence)                  

·        *                 Wild card with last priority (one or more occurrence)

 

Membership:    rule-level (must be enclosed within a <rule> tag)

 

When To Use              

The that tag must be the middle element in every <rule> tag. Each AIML stimulus-response example to be learned by the Alice chat robot may contain a <that> tag.

__________________________________________________________________

Attributes                                Explanation                                                                 

index

(Optional) The index of the previous Alice output phrase. (default == 1)

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the pattern tag.

text-pattern

Upper case text may be contained within the pattern tag. This is the text, which when matched word for word, will cause Alice to respond as directed in the <template> tag following the <pattern> tag in the stimulus-response training example.

________________________________________________________________

 

Example1: Exact Match           

The following example demonstrates a how AIML can be used to teach Alice how to respond when a client asks for her name. The pattern supplies Alice with an example of the stimulus, and the template supplies Alice with an example of the appropriate response. The <that> tag let?s Alice give a cute response if the client repeats the question.

 

<!--This examples teaches Alice how to announce her own name -->

<rule>

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is Alice.</template>

</rule>

<rule>

<pattern>WHAT IS YOUR NAME</pattern>    

<that>MY NAME IS ALICE</that>        

<template>I just told you my name. Take out your ear plugs.</template>

</rule>

 

Notes and Hints          

The <that> tag places a condition on the previous pattern tag. The pattern tag teaches Alice a new stimulus by presenting her with an example. The pattern tag must be the first element contained within the <rule> tag in an AIML stimulus-response training example. There may be multiple rule tags in each AIML knowledge file. The rule is the fundamental language element for teaching the Alice chat robot.

 

<think>

Overview                                

The <think> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The think tag causes Alice to act recursively on the embedded template data without returning the result.

 

Type:              Tag

 

Syntax:            <think>   ?template data?   </think>

 

Attributes:       none.

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The think tag is one of the optional imbedded elements in the template data of a <template> tag. Each <think> tag causes Alice to act recursively on the embedded template data without returning the result.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the srai tag.

Template data

Any valid template data to be recursively acted on by Alice.

________________________________________________________________

 

Example1: Recursive Action   

The following example demonstrates a how AIML can be used to teach Alice how to respond with personal information. The <think> tag causes Alice to act on the embedded template data without returning a result.

 

<!--This examples teaches Alice how to respond with personal information -->         

<rule>

<pattern>WHAT IS YOUR NAME</pattern>    

<template>My name is <bot/><think><set name=?bot?>Alice</set></think></template>

</rule>

 

Notes and Hints          

The think tag causes Alice to act recursively on the embedded template data without returning the result.

 

<time>

Overview                                

The <time> tag is one of the optional imbedded elements in the template data of a <template> tag, and specifies a specific action Alice is to undertake in constructing a response to a specified stimulus. This tag helps the bot master program Alice.

The time tag returns the current time in the form of 24 minutes past 1PM.

 

Type:              Tag

 

Syntax:            <time/>

 

Attributes:       none

 

Membership:    template-level (must be enclosed within a <template> tag)

 

When To Use              

The time tag is one of the optional imbedded elements in the template data of a <template> tag. Each <time/> tag returns the current time in the form of 24 minutes past 1PM.

__________________________________________________________________

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the star tag.

________________________________________________________________

 

Example1: Tourist Questions  

The following example demonstrates a how AIML can be used to teach Alice how to respond to a tourist question. The <time/> tag returns the current time in the form of 24 minutes past 1PM.

 

<!--This examples teaches Alice how to respond to a tourist question -->     

<rule>

<pattern>WHAT IS THE TIME</pattern>         

<template>It is <time/>.</template>

</rule>

 

Notes and Hints          

The time tag returns the current time in the form of 24 minutes past 1PM.

 

<token>

Overview                                

The <token> tag is one of the optional imbedded elements in a <pattern> tag, and helps Alice define the pattern to match for the specified stimulus. This tag helps the bot master program Alice.

The token tag allows Alice to match the specified contents of the next feature based token in the input stream. Multiple feature name and value pairs may be specified. ALL feature names and associated values must match exactly.

The token data is used to form a Lisp Structure constant. Each item is separated by blanks from the other items, which must be matched exactly in order to trigger a response from Alice. However, there is a wild card special pattern character that adds power to Alice?s token value matching abilities. This special wild card character is shown below under Special.

 

Type:              Tag

 

Syntax:            <token> ?FeatureName/Value pairs? </token>

<token lisp=? ? condition source? ?> ?Feature Name/Value pairs? </token>

 

Attributes:       lisp                   Lisp condition source code.       

 

Membership:    pattern-level (must be enclosed within a <pattern> tag)

 

Special:            (This special wild card characters adds token value matching power)

·        ?                Wild card will match with ANY value.

 

When To Use              

The token tag is one of the optional imbedded elements in the data of a <pattern> tag. Each <token> tag attempts to match the specified Feature Name/Value pairs with the next token in the input stream. Multiple feature name and value pairs may be specified. ALL specified feature names and associated values must match exactly. Additionally, any Lisp conditions must return a value of true.

__________________________________________________________________

Attributes                                Explanation                                                                 

lisp

(Optional) The lisp tag specifies an additional condition in the Lisp language.

Contents                                  Explanation                                                                 

comments

Any valid XML comment tags may be contained within the token tag.

Feature Name

Feature name to be matched with the next token in the input stream. The specified feature name must match exactly. 

Value

Value to be matched with the next token in the input stream. The value of the previously specified feature name must match exactly. Exception: A wild card value of ? will match any value.

________________________________________________________________

 

Example1: Who is a Friend     

The following example demonstrates a how AIML can be used to teach Alice how to respond to a specific set of people?s names. The following <token> tag returns true if and only if a name is mentioned that is on the ?Friend? list.

 

<!--This examples teaches Alice how to respond to the names of friends -->

<rule>

<pattern>IS <token lisp=?(isMember arg.Value FriendsList)?>Name ?</token> A FRIEND</pattern>      

<template>Yes, <arg/> is my friend.</template>

</rule>

 

Notes and Hints          

The token tag allows multiple feature value pairs to be matched with the next feature based token in the input stream. Additional Lisp conditions can be specified.