pythonnlpchatbotaiml

AIML chatbot not learning from aiml file


I am making a voice-assistant for food ordering in fast-food restaurants. For dialog management tasks I am making aiml chatbot. This is my std-startup.xml code:

<aiml version="1.0.1" encoding="UTF-8">
    <!-- std-startup.xml -->

    <!-- Category is an atomic AIML unit -->
    <category>

        <!-- Pattern to match in user input -->
        <!-- If user enters "LOAD AIML B" -->
        <pattern>LOAD AIML B</pattern>

        <!-- Template is the response to the pattern -->
        <!-- This learn an aiml file -->
        <template>
            <learn>output.aiml</learn>
            <!-- You can add more aiml files here -->
            <!--<learn>more_aiml.aiml</learn>-->
        </template>
        
    </category>

</aiml>

BELOW IS MAIN.PY CODE

import aiml
import os

kernel = aiml.Kernel()

if os.path.isfile("bot_brain.brn"):
    kernel.bootstrap(brainFile = "bot_brain.brn")
else:
    kernel.bootstrap(learnFiles = "std-startup.xml", commands = "load aiml b")
    kernel.saveBrain("bot_brain.brn")

# kernel now ready for use
while True:
    print (kernel.respond(input("Enter your message >> ")))

After entering a msg which is from output.aiml itself the bot says the msg does not exists enter image description here

Please can someone tell how to fix it. The bot should generate a response as given in output.aiml file

Here is another example with category enter image description here

and here is bot's repsonse enter image description here


Solution

  • Some interpreters need the patterns to be in upper case. Try this instead:

    <category>
        <pattern>THANK YOU</pattern>
        <template>
            Bye.
        </template>
    </category>