AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Selecting a second wildcard
 
 

Hello,

I am working on my AIML Chatbot, and I recently came across an unfortunate problem. What I am trying to do is recall the second wildcard used in the pattern, to be repeated in the template. The code:

<category>
_ FAILURE *</pattern>
<template>Does <star> make you feel angry, <get name=“name”>?
</category>

What I want the Chatbot to do, if the person says (yes I know this makes no sense but this is the example I’ve been using while tesing): Thinks failure sucks, I want the Chatbot to respond with Does sucks make you feel angry, (user’s name). Yes, I know none of this doesn’t make any grammatical sense, but when implmented in my Chatbot, it will over 97% of the time.

If someone could tell me how I can get my Chatbot to respond with the * wildcard instead of whichever comes first, that would be great.

Also, I have tried swapping the wildcards, since _ holds priority over *, but it didn’t help. if someone could help me resolve this issue, they have my many thanks.

 

 
  [ # 1 ]

Hi, Ryan, and welcome to the forums! smile

In the AIML pattern that you’ve mentioned above, the * wildcard should be denoted by the following:

<star index="2" /> 

In fact, in each of the following AIML patterns, the second wildcard, no matter of which type (_ or *) are all denoted the same way:

first star _ second star _
first star _ second star 
*
first star second star _
first star 
second star *


In the aboveall of the wildcards after "first star" are <star /> or <star index="1" />,
while 
the wildcards after "second star" are <star index="2" /> Any other wildcards in
the pattern are 
"indexed" accordinglyso that "IS A * A * OR A *" will also have a
<star index="3" /> 
 

 
  [ # 2 ]

Dave,

Thank you very, very much for your speedy reply. This worked perfectly, and I can continue on with my project. This is greatly appreciated. Though it also makes me feel slightly dumb, as I had tried using a star index tag previously, but to no avail. However, this was perfect, and I thank you greatly for this!

 

 
  [ # 3 ]

That’s what I’m here for, Ryan! smile I’m glad to have been of help to you.

Just out of curiosity, which AIML interpreter are you using, and is your chatbot “online”?

 

 
  [ # 4 ]

I’m working on the online interpreter at http://www.pandorabots.com, and I do have it published on their servers. The link is http://www.pandorabots.com/pandora/talk?botid=bdd1a5537e347c24, though it’s still a work in progress.

 

 
  [ # 5 ]

As an aside, try not use too many <star> in your templates as Pandorabots will give you a “MATCH LIMIT EXCEEDED” error if you try and use above 8 or so indexes (indices?)

 

 
  [ # 6 ]

Really Steve? That’s weird, I haven’t had an issue with mine and I have roughly 348 <star index=“2”>‘s being rocked out. I’ll keep trying though, see if it comes up with certain messages. Thank you for your input.

 

 
  [ # 7 ]

No sorry, I meant if you have a pattern like:

I * SEE THAT * IS * WHEN * IS ALSO * * THE * ALSO DOES NOT *

and you need to refer to <star index=“8”> and upwards, it will cause problems. I would only recommend a maximum of say 4 star indexes.

 

 
  [ # 8 ]

Oh, okay, I understand. For me, the maximum number of indexes is 2, so I should be good. Though, that reminds me of another question I had. Are any of you guys familiar with the learn.aiml file by Square Bear?

 

 
  [ # 9 ]
Ryan L - Feb 24, 2011:

Are any of you guys familiar with the learn.aiml file by Square Bear?

Yes, I am a little bit. wink
Can I help you with it at all?

 

 
  [ # 10 ]

Yeah, I’m actually really confused when it comes to that file. For every category, the template is a recursion tag bag to a different category with a learn tag in it, with eval tags. The code that each category refers to is:

<category>
  XEDUCATE * XSPLIT * XSPLIT *</pattern>
  <template>

    <learn>
  <category>
   
      <eval><uppercase><star index=“1”><star index=“3”></uppercase></eval>
    </pattern>
    <template>
      <eval><star index=“2”></eval>
    </template>
  </category>
    </learn>
    <learn>
  <category>
   
      <eval><uppercase><star index=“1”><star index=“2”></uppercase></eval>
    </pattern>
    <template>
      <eval><star index=“3”></eval>
    </template>
  </category>
    </learn>

  </template>
</category>

I don’t understand what most of this represents, and if you could break it down for me, that would be great. Though if it’s too much work, that’s understandable. I think I understand some of it, but the Xs infront of EDUCATE and SPLIT don’t make sense to me, nor do the tags inside the learn tag. Thank you in advanced.

 

 
  [ # 11 ]

I’m going to refrain from chiming in here, for two reasons:
1.) I’m not at all familiar with learn.aiml.
2.) It’s best to get the information from the author of the item in question, and that’s Square Bear (AKA Steve). raspberry

[edit]
By the way, one of the examples that I gave is actually a part of ALICE’s AIML set, if I recall
correctly (e.g. IS * A * OR A *), so unless you’ve removed it yourself, it’s buried in there. smile
[/edit]

 

 
  [ # 12 ]

Oh, I had no idea Steve is Square Bear, to be honest, lol.

 

 
  [ # 13 ]

Not to worry, Ryan. Steve’s a great help to us AIML botmasters. He’ll set you right.

 

 
  [ # 14 ]

Say you asked the chatbot to learn “Rome is a city in Italy”. This would match the following category in learn.aiml:

<category>
  <
pattern>* IS A *</pattern>
  <
template>
        
Ok I will add that fact about<person/>to my database.
 <
srai>XEDUCATE WHAT IS XSPLIT <star index="1"/> XSPLIT <star index="2"/>/srai>
<
srai>XEDUCATE WHERE IS XSPLIT <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHO IS XSPLIT <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHAT IS A XSPLIT <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHERE IS A XSPLIT <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHO IS A XSPLIT <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHAT _ IS A XSPLIT <star index="1"/> XSPLIT <star index="2"/></srai>
  </
template>
</
category

What this category does is prepare and teach the bot the following questions and answers:

WHAT IS Rome
WHERE IS Rome
WHO IS Rome
WHAT IS A Rome
WHERE IS A Rome
WHO IS A Rome
WHAT _ IS A Rome

As you can see, a few of these don’t make sense (WHO IS ROME for example) but it’s better to set too many categories up than too few. If we had said to the bot, “Charles is a man” then then question, “WHO IS CHARLES” makes more sense. As we don’t know the subject matter of the user’s question, we set up all the possibilities.

Let’s just take the first <srai> “WHAT IS ROME” and see how this works. It does this by calling the category “XEDUCATE WHAT IS XSPLIT Rome XSPLIT Italy”. Rome and Italy represent <star index=“1”> and <star index=“2”>.

The XEDUCATE category is as follows:

<category>
  <
pattern>XEDUCATE XSPLIT XSPLIT *</pattern>
  <
template>

      <
learn>
 <
category>
   <
pattern>
     <eval><
uppercase><star index="1"/><star index="3"/></uppercase></eval>
   </
pattern>
   <
template>
     <eval><
star index="2"/></eval>
   </
template>
 </
category>
      </
learn>
      <
learn>
 <
category>
   <
pattern>
     <eval><
uppercase><star index="1"/><star index="2"/></uppercase></eval>
   </
pattern>
   <
template>
     <eval><
star index="3"/></eval>
   </
template>
 </
category>
      </
learn>

  </
template>
</
category

What this does is to teach the bot a new category by using the <learn> tag. Anything between the <learn> and </learn> is learned by the chatbot. Ignore the first <learn> and </learn> tags for now. Between the second <learn> and </learn> tags we have:

<category>
   <
pattern>
     <eval><
uppercase><star index="1"/><star index="2"/></uppercase></eval>
   </
pattern>
   <
template>
     <eval><
star index="3"/></eval>
   </
template>
 </
category

Which as you can see is a category in AIML. All that is missing is the pattern and template. Fortunately, we have supplied this by asking, “XEDUCATE WHAT IS XSPLIT Rome XSPLIT a city in Italy”.

As the XEDUCATE category is “XEDUCATE * XSPLIT * XSPLIT *”, this means that the following wil be set:
<star index=“1”>=WHAT IS
<star index=“2”>=Rome
<star index=“3”>=a city in Italy

Let’s see what the <eval> tag is doing here in <eval><uppercase><star index=“1”><star index=“2”></uppercase></eval>:

<eval> tells the interpreter to evaluate whatever is between the tags. So in this case it evaluates what we sent it in star indexes 1 and 2. This will give us “WHAT IS Rome”. I like to keep patterns in categories all uppercase and so we add an <uppercase> tag. This now gives us “WHAT IS ROME” and our <learn> category now looks like:

<category>
   <
pattern>
     
WHAT IS ROME
   
</pattern>
   <
template>
     <eval><
star index="3"/></eval>
   </
template>
 </
category

Now it evaluates star index 3 to make our category complete:

<category>
   <
pattern>
     
WHAT IS ROME
   
</pattern>
   <
template>
     
a city in Italy
   
</template>
 </
category

We don’t want star index 3 to be uppercase, as this is the reply the user will see. So now if the user asks, “What is Rome”, our new category is matched and the reply “a city in Italy” is given but what if the user asks, “What is a city in Italy”? This is where the first <learn> and </learn> tags in the XEDUCATE category come in.

<learn>
 <
category>
   <
pattern>
     <eval><
uppercase><star index="1"/><star index="3"/></uppercase></eval>
   </
pattern>
   <
template>
     <eval><
star index="2"/></eval>
   </
template>
 </
category>
      </
learn

You will remember that the star indexes are:
<star index=“1”>=WHAT IS
<star index=“2”>=Rome
<star index=“3”>=a city in Italy

All the first <learn> tags do is to swap the question around. So now the first eval is now evaluating star index 1 and 3 to give “WHAT IS a city in Italy” and the second is setting the template to “Rome”. Using this means the user can ask “What is a city in Italy” and the bot will answer “Rome”.

Going back to the very first category (if you are still reading wink ), we now srai the other questions to the XEDUCATE category:

<srai>XEDUCATE WHERE IS XSPLIT Rome XSPLIT a city in Italy</srai>
 <
srai>XEDUCATE WHO IS XSPLIT Rome XSPLIT a city in Italy</srai>
 <
srai>XEDUCATE WHAT IS A XSPLIT Rome XSPLIT a city in Italy</srai>
 <
srai>XEDUCATE WHERE IS A XSPLIT Rome XSPLIT a city in Italy</srai>
 <
srai>XEDUCATE WHO IS A XSPLIT Rome XSPLIT a city in Italy</srai>
 <
srai>XEDUCATE WHAT _ IS A XSPLIT <Rome XSPLIT a city in Italy</srai

and the whole thing starts again. Your bot can now answer the following:

WHAT IS ROME - a city in Italy
WHERE IS ROME - a city in Italy
WHO IS ROME - a city in Italy
WHAT IS A ROME - a city in Italy
WHERE IS A ROME - a city in Italy
WHO IS A ROME - a city in Italy
WHAT _ IS A ROME - a city in Italy
WHAT IS A CITY IN ITALY - Rome
WHERE IS A CITY IN ITALY - Rome
WHO IS A CITY IN ITALY - Rome
WHAT IS A A CITY IN ITALY - Rome
WHERE IS A A CITY IN ITALY - Rome
WHO IS A A CITY IN ITALY - Rome
WHAT _ IS A A CITY IN ITALY - Rome

(cont….)

 

 
  [ # 15 ]

(part 2)

The reason for the underscore categories is for when users say something like “My car is blue”, the bot will match the category:

<category>
  <
pattern>MY IS *</pattern>
  <
template>
        
Ok I will learn that your<star index="1"/>is<star index="2"/>.
 <
srai>XEDUCATE WHAT IS XSPLIT MY <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHO IS XSPLIT MY <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHERE IS XSPLIT MY <star index="1"/> XSPLIT <star index="2"/></srai>
 <
srai>XEDUCATE WHAT _ IS XSPLIT MY <star index="1"/> XSPLIT <star index="2"/></srai>
  </
template>
</
category

and will set up a category “WHAT _ IS MY CAR” (answer “blue”). So now the user can ask “what colour is my car” and the bot will answer “blue”. The user can even ask something like “what part of the visible spectrum is my car” and the bot will still answer “blue”, which will hopefully impress the user.

The only reason for me using XEDUCATE instead of EDUCATE and XSPLIT instead of SPLIT is so the bot doesn’t get confused if the user were to say, “Educate me about chatbots” or “My banana split tastes nice”. Hopefully, the user will never say xeducate or xsplit.

Apologies for the long winded explanation but by the nature of the file, it is a little complicated.  Please feel free to ask any further questions about it. I hope I have explained it but I probably ended up just waffling.

Yes, I am Square Bear but choose to use my real name here, as chatbots.org seems a more academic board than the other AIML boards I use. I was going to keep you in the dark for a bit longer (for my own own twisted amusement) until Dave gave the game away LOL

 

 1 2 > 
1 of 2
 
  login or register to react
‹‹ Universal tag      Translated AIML ››