mefiz
mefiz

Reputation: 31

How to use make srai work for both cases in AIML?

How to use one AIML srai category in such a way that it will redirect to the category regardless of whether there is a word after the keyword or not? For instance

<category>
    <pattern>WHERE IS SOMEPLACE</pattern>
    <template>here</template>
</category>

<category>
    <pattern> * SOMEPLACE *</pattern>
    <template>
      <srai>WHERE IS SOMEPLACE</srai>
    </template>
</category>

it works when I ask something like, "tell me where someplace is". But it doesnt work when I ask, "where is someplace". it works for case 2 when i remove the last * but then it doesn't work for case 1. I realize I can use two different categories but then I would be increasing categories beyond what I need so I can't do that.

Please forgive my english as it is not my native language.

Thank you.

edit: if it helps anyone, AIML 2.0 contains zero+ wildcards, which is essentially the same as _ or * but also accounts for zero words as well. The new order of precedence, (from highest to lowest) is # (zero+), _ , ^(zero+) and *. Please checkout https://docs.google.com/document/d/1wNT25hJRyupcG51aO89UcQEiG-HkXRXusukADpFnDs4/pub for more information.

Upvotes: 1

Views: 153

Answers (1)

Steve Worswick
Steve Worswick

Reputation: 905

It's dangerous to use the same word in your srai as the keyword you are trying to match, as you will get an infinite recursion error. Try this instead, which will srai to the top category, as long as your input has the word "SOMEPLACE" in it:

<category>
    <pattern>SomeplaceAnswer</pattern>
    <template>here</template>
</category>

<category>
    <pattern># SOMEPLACE #</pattern>
    <template>
      <srai>SomeplaceAnswer</srai>
    </template>
</category>

Upvotes: 0

Related Questions