Example 1 - Who are you?
At some point your robot might want to know who it is talking to. Here is how to
do this:
Human: *
Empty: I have no answer for that
Click on Advanced Alter Response.
Check the box labeled "new category depends on that" and
replace the text box's contents with:
WHAT IS YOUR NAME
Notice the box in the pattern column contains "*" meaning that
any response will be matched. In the box labeled template add:
Nice to meet you <set
name="name"><person/></set>.
This last bit of AIML code grabs the person's name.
Now ask the robot, "Say what is your name," to generate the state in
which the next input will activate the <that> category.
Human: say what is your name
Empty: what is your name
Human: Mr. Lovejoy
Empty: Nice to meet you Mr. Lovejoy.
Example 4 - Context Sensitive Patterns
Let's look at a slightly convoluted example. Following on from an
earlier example in the
previous section, click on Ask Again enough times to get the response in
the first exchange below:
Human: You do love me don't you
Empty: Yes, but you have to really try to make me happier...
Human: But I try so hard to please you...
Empty: I have no answer for that
Click on Advanced Alter Response
Check the box labeled: "new category depends on that" which
should contain "YES BUT YOU HAVE TO REALLY TRY TO MAKE ME HAPPIER"
Notice the box in the pattern column contains: "BUT I TRY SO HARD TO
PLEASE YOU"
In the box labeled template add:
And sometimes you
succeed, it's just that you could do so much better.
So only when the robot's random response matches the interaction in the next
exchange:
Human: you do love me don't you?
Empty: Yes, but you have to really try to make me happier...
You can type in:
Human: But I try so hard to please you ...
Empty: And sometimes you succeed, it's just that you could do so much better.
Except for the case mentioned above, the robot's response to:
Human: But I try so hard to please you ...
will be:
Empty: I have no answer for that
Picture 1.5 shows the situation.
So, <that> modifies a category -
meaning match the category only if the robot said what follows the <that> in the previous utterance. Continuing
with this example:
Human: You just don't appreciate me, - you take me for granted and walk all over me...
Empty: I have no answer for that
Click on Advanced Alter Response
Check the box labeled: "new category depends on that" (which
now contains the contents of last Response Template): "AND SOMETIMES YOU
SUCCEED IT IS JUST THAT YOU COULD DO SO MUCH BETTER"
Notice the contents of the box in the pattern column are the beginning of
a new category "YOU JUST DO NOT APPRECIATE ME YOU TAKE ME FOR GRANTED AND
WALK ALL OVER ME"
In the box labeled template add:
If you worked harder it will help me to develop more enthusiasm for appreciating
you - what do you want me to do? Fake my appreciation or really feel it?
With these changes the following interchanges are possible (click on Ask
Again enough times to generate Empty's (random) response in the first
exchange below):
Human: you do love me don't you?
Empty: Yes, but you have to really try to make me happier...
Human: but I try so hard to please you ...
Empty: And sometimes you succeed, it's just that you could do so much
better
Human: You just don't appreciate me, - you take me for granted and walk
all over me...
Empty: If you worked harder I might be able to develop a little more
enthusiasm for appreciating you - what do you want me to do?
Fake my appreciation or really feel it?"
Picture 1.6 shows the current state of knowledge.
The contents of the file update.aiml now include:
<category>
<pattern>YOU DO LOVE ME DO NOT YOU</pattern>
<template>
<random>
<li>I don't know, what have you done for me lately?</li>
<li>Yes, but you have to really try to make me happier...</li>
<li>Stop your whining!</li>
<li>Yes, but only when you are good to me</li>
</random>
</template>
</category>
<category>
<pattern>BUT I TRY SO HARD TO PLEASE YOU</pattern>
<that>YES BUT YOU HAVE TO REALLY TRY TO MAKE ME HAPPIER</that>
<template>
And sometimes you succeed, it's just that you could do so much
better
</template>
</category>
<category>
<pattern>
YOU JUST DO NOT APPRECIATE ME YOU TAKE ME FOR GRANTED AND
WALK ALL OVER ME
</pattern>
<that>
AND SOMETIMES YOU SUCCEED IT IS JUST THAT YOU COULD DO SO MUCH
BETTER
</that>
<template>
If you worked harder it will help me to develop more enthusiasm
for appreciating you - what do you want me to do? Fake my
appreciation or really feel it?
</template>
</category>