1

When using an AIML context (via <that>) I get some conversations I cannot explain. I expected that a (that) context would have priority over anything else.

Below I first show the script. Then I show a few conversations. I marked the inexpected parts with a // behind the response.

I added this Aiml file to the standard ALICE conversations.

The script:

<category><pattern>STEP 1</pattern>
  <template>Step 2</template>
</category>
<category><pattern>YES</pattern><that>STEP 2</that>
  <template>step 3</template>
</category>
<category><pattern>NO</pattern><that>STEP 2</that>
  <template>step 3</template>
</category>
<category><pattern>*</pattern><that>STEP 2</that>
  <template>step 3</template>
</category>
<category><pattern>*</pattern><that>STEP 3</that>
  <template>Step 4! and you typed '<star/>'</template>
</category>

In the following conversation I marked the unexpected responses with // ?

Human : step 1
Robot : Step 2
Human : yes
Robot : step 3
Human : yes
Robot : Step 4! and you typed 'yes'
Human : step 1
Robot : Step 2
Human : no
Robot : step 3
Human : no
Robot : So. // ? I expected here step 4
Human : step 1
Robot : Step 2
Human : any
Robot : any is a name. // ? I expected here step 3

Can you explain both UNexpected flows of conversation?

tm1701
  • 7,307
  • 17
  • 79
  • 168

1 Answers1

1

The <that> element takes priority over other patterns at the same pattern level. I don't know if you're using AIML v1 or v2, but broadly speaking there are 3 levels of patterns [but see note below]

  1. Most important level = patterns including underscore wildcards (_)
  2. Middle level = atomic patterns without any wildcards
  3. Lowest level = patterns including star wildcards (*)

Your unexpected responses are because there is an ALICE response at a higher priority level. Eg when robot replies "step 3" and human says "no", you want <pattern>*</pattern><that>STEP 3</that> category to take effect. But if there is an ALICE response at a higher level (eg <pattern>NO</pattern> or <pattern>STEP _</pattern>) the ALICE responses will take effect over your level 3 category <pattern>*</pattern><that>STEP 3</that>. The quickest way of finding the ALICE category is just to ask "NO" and see what the bot replies. You could also search the ALICE files but this would be very time consuming.

[note] In AIML v2 there are at least two extra levels: level 0 above underscore wildcards, and level 2.5 using pattern side sets. However the simpler levels of AIML v1 explain your anomalies.

Ubercoder
  • 711
  • 8
  • 24
  • SUPERB! Even experts didn't know the answer on another famous forum. Can you answer in a similar fashion this question: https://stackoverflow.com/q/52973100/3143823? I will +1 + v! – tm1701 Nov 01 '18 at 18:28
  • Thanks for the nice comment! I worked on an AI interpreter www.uberbot.ai that handles some AIML-like constructs, so I have experimented with the pattern matching algorithms. – Ubercoder Nov 02 '18 at 11:15
  • @ ubercoder - can you just copy your answer to the stackoverflow.com/q/52973100/3143823 question? The answer you gave for this question also solves the other question. Notice: I tried to play with the 'uberbot.ai' bot with the bad/good answer. Does it have effect? I could not notice. – tm1701 Nov 03 '18 at 08:55