The simplest form of category in AIML is one with an atomic pattern, namely, a pattern with no wild cards.
For example
<category>
<pattern>NAME</pattern>
<template>My name is ALICE.</template>
</category>
produces the dialog:
Human: Name?
Robot: My name is ALICE.
But there are many different ways of asking for a name. "What is your name?", "Who are you?", "Tell me your name", "Do you have a name?", "Your name is?" are all synonyms for "Name?".
In AIML we link all of these synonyms together using the <srai> tag.
The category:
<category>
<pattern>WHAT IS YOUR NAME</pattern>
<template><srai>NAME</srai></template>
</category>
used in conjunction with the category above, produces the dialog:
Human: What is your name?
Robot: My name is ALICE.
Similarly, we can add categories such as:
<category>
<pattern>DO YOU HAVE A NAME</pattern>
<template><srai>NAME</srai></template>
</category>
and
<category>
<pattern>YOUR NAME IS</pattern>
<template><srai>NAME</srai></template>
</category>
and so on for all the variations of "Name?"
Creating a new chat bot involves writing an enormous amount of original AIML content. Because of its minimalism, AIML lets the botmaster approach content creation one small step at a time. Typically when creating a bot, we identify in the chat logs a new variation of an input we have already seen before. For example, we might see "I want to know your name", and realize there is already a response for this. The convenience of <srai> is that we don't have to go searching through files and files of code to find the response. We know the response is already in there somewhere, so we can just link to it with <srai>:
<category>
<pattern>I WANT TO KNOW YOUR NAME</pattern>
<template><srai>WHAT IS YOUR NAME</srai></template>
</category>
Notice that we linked to WHAT IS YOUR NAME. This doesn't matter, because there is already another category linking WHAT IS YOUR NAME to NAME.
As a general rule of thumb, a good design principle of AIML is to follow the rule that each <srai> should "shorten" then input. In this case that means that reducing WHAT IS YOUR NAME (4 words) to NAME (1 word) is ok, and reducing I WANT TO KNOW YOUR NAME (6 words) to WHAT IS YOUR NAME (4 words) is ok, but we should avoid categories like:
<category>
<pattern>TELL ME YOUR NAME</pattern>
<template><srai>I WANT TO KNOW YOUR NAME</srai></template>
</category>
By avoiding such designs, the AIML program is guaranteed to terminate, and we will never see the "Too much recursion in AIML" error. Why this is, will be explained in more detail later. For now, keep in mind the design rule that in AIML, it is better to store actual responses along with the simplest and shortest possible patterns. That is why putting the response "My name is ALICE" inside the category with pattern NAME, is better than putting it with WHAT IS YOUR NAME.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment