Search code examples
aiml

AIML - topic - unexpected answer does not match with STAR (*)


When using the AB.jar Google reference (alice) bot:

When having this simple short script:

<category><pattern>TOPIC 1</pattern>
<template>Topic 2 with current topic '<get name="topic"/>'.<think><set name="topic">topic2</set></think></template>
</category>

<topic name="TOPIC2">
<category><pattern>YES</pattern>
<template>Going to topic3-yes <think><set name="topic">topic3-yes</set></think></template>
</category></topic>

<topic name="TOPIC2">
<category><pattern>*</pattern>
<template>Going to topic3-rest on '<star/>' <think><set name="topic">topic3-rest</set></think></template>
</category></topic>

... answering not 'yes' will not navigate to the topic-3 '*' pattern. Why is that?

This is the conversation. I marked the unexpected answer with '// here'

Human : topic 1
Robot : Topic 2 with current topic 'unknown'.
Human : any
Robot : any is a name. // here -- expected to go to topic-3-rest

Solution

  • Putting this '_' pattern (in stead of the '*' pattern) inside a topic answers the question.

    Thanks to Ubercoder:

    The 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]

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