AIML tags

There is a set of AIML tags to represent knowledge inside files. The following are some of the important tags and their uses:

  • <aiml>: Each AIML file starts with this tag and ends with the </aiml> tag. Basically, it holds the version of AIML and character encoding of the file. The <aiml> tag is not mandatory, but it will be useful when handling a huge AIML dataset. Here is the basic usage of the <aiml> tag:
        <aiml version="1.0.1" encoding="UTF-8"?> 
        </aiml> 
  • <category>: Each knowledge segment is kept under this tag. This tag holds the input pattern from the user and outputs a response for it. The possible input from the user is kept under the <pattern> tag, and the corresponding response is under the <template> tag. Here is an example of the category, pattern, and template tags:
        <aiml version="1.0.1" encoding="UTF-8"> 
          <category> 
            <pattern> WHAT IS YOUR NAME </pattern> 
            <template> MY NAME IS ROBOT </template> 
          </category> 
        </aiml> 

When a user asks the robot, "What is your name?", the robot replies, "My name is Robot." This is how we store knowledge for the robot.

  • <pattern>: This tag consists of user input. From the preceding code, we can see that WHAT IS YOUR NAME is the user input. There will only be one pattern inside a category, placed after the category tag. Inside a pattern, we can include wild cards such as * or -, which can replace a string in the corresponding position.
  • <template>: The template tag consists of responses to user input. In the previous code, MY NAME IS ROBOT is the response.
  • <star index = "n" />: This tag helps extract a word from a sentence. The n indicates which word of the sentence is to be extracted:

<star index= "1" />: This indicates the first fragment of the template sentence.

<star index= "2" />: This indicates the second fragment of the template sentence.

Using the star index, we can extract the word from user input and insert the word into the response if needed.

Here is an example of using wildcards and a start index:

        <aiml version="1.0.1" encoding="UTF-8"> 
          <category> 
            <pattern> MY NAME IS * </pattern> 
              <template> 
                NICE TO SEE YOU <star index="1"/> 
              </template> 
          </category> 
 
          <category> 
            <pattern> MEET OUR ROBOTS * AND * </pattern> 
              <template> 
                NICE TO SEE <star index="1"/> AND <star      
             index="2"/>. 
              </template> 
          </category> 
        </aiml> 

Here, we can reuse the word that comes in the * position in the <template> tag. Consider this input:

        You: MY NAME IS LENTIN 
        Robot: NICE TO SEE YOU LENTIN 

In the second category, you will get the following reply from the robot for the given input:

You: MEET OUR ROBOTS ROBIN AND TURTLEBOT 
Robot: NICE TO SEE ROBIN AND TURTLEBOT 

These are the basic tags used inside AIML files. Next, we'll see how to load these files and retrieve an intelligent reply from the AIML knowledge base for a random input from the user.

The following link will give you the list of AIML tags: http://www.alicebot.org/documentation/aiml-reference.html

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.87.161