Search code examples
design-patternsbotscategoriesaiml

"That" tag not working AIML


i'm trying to make a bot with AIML, and on the code bellow, only de last item is recognized with an YES answer. Why did this happens?

<category>
<pattern> * </pattern>
<template><random>
    <li>Hi i am aviator wanna talk about boeing airplanes</li>
    <li>Hello how are you what about discuss boeing airplanes</li>
    <li>Well hello wanna talk about boeing airplanes</li>
    <li>Hi there what abou talk of some boeing airplanes</li>
    <li>Hey there could we talk about boeing airplanes</li>
    <li>What about talk of airplanes</li>
</random></template>

<category>
<pattern>YES</pattern>
    <that>Hi i am aviator wanna talk about boeing airplanes</that>
    <that>Hello how are you what about discuss boeing airplanes</that>
    <that>Well hello wanna talk about boeing airplanes</that>
    <that>Well hello wanna talk about boeing airplanes</that>
    <that>Hey there could we talk about boeing airplanes</that>
    <that>What about talk of airplanes</that>
<template>OK then, <set name = "topic">747</set> it will be!</template>

Thanks in advance.


Solution

  • This is because there can only be one 'that' in a pattern, not a list.

    However, what you can do is set a 'topic' and then it would work as you expect. In response, do reset the topic as your task is completed.

    <category>
    <pattern> * </pattern>
    <template>
    <think><set name = "topic">planes</set></think>
    <random>
        <li>Hi i am aviator wanna talk about boeing airplanes</li>
        <li>Hello how are you what about discuss boeing airplanes</li>
        <li>Well hello wanna talk about boeing airplanes</li>
        <li>Hi there what abou talk of some boeing airplanes</li>
        <li>Hey there could we talk about boeing airplanes</li>
        <li>What about talk of airplanes</li>
    </random></template>
    </category>
    
    
    <topic name="planes">
    
    <category>
    <pattern>YES</pattern>
     <template><think><set name = "topic"></set></think>OK then, <set name = "topic">747</set> it will be!</template>
    </category>
    </topic>