pythonnlpchatbotaiml

<that> and <topic> tags cause no matches


I am trying to learn AIML and I build a simple chatbot with the following 3 files:

std-startup.xml

<aiml version="1.0.1" encoding="UTF-8">
<category>
    <pattern>
        LOAD AIML B
    </pattern>
    <template>
        <learn>key.aiml</learn>
    </template> 
</category>
</aiml>

key.aiml

<aiml version="2.0" encoding="UTF-8">

<category>
    <pattern>
        CAN NOT UNLOCK
    </pattern>
    <template>
        What are you trying to unlock? 
    </template>
</category>

<category>
    <pattern>* DOOR</pattern>
    <that>What are you trying to unlock?</that>
    <template>
        <think><set name="door"><star/></set></think>
        <condition name="door" value="apartment">
            <think><set name="topic"><star/></set></think>
            Is there any video on the screen? 
        </condition>
        <condition name="door" value="entrance">
            <think><set name="topic"><star/></set></think>
            Is there a green light? 
        </condition>    
    </template>
</category>

<topic name="apartment">
<category>
    <pattern>yes</pattern>
    <template>
        topic set to apartment  
    </template>
</category>
</topic>

<topic name="entrance">
<category>
    <pattern>yes</pattern>
    <template>
        topic set to entrance  
    </template>
</category>
</topic>

</aiml>

simply.py

import aiml

kernel = aiml.Kernel()
kernel.learn("std-startup.xml")
kernel.respond("load aiml b")

while True: 
    input_text = input(">Tenant: ")
    response = kernel.respond(input_text)
    print(">Bot: ", response)

However, the above does not work and returns no matches for "* DOOR" and "yes" unless I comment the and the tags. I followed the tutorials to a T and yet I don't understand why it says WARNING: No match found for input: yes

Please help me understand my error .


Solution

  • You shouldn't include punctuation inside a <that> tag. Miss out the question mark and it should be okay.