1

I'm attempting to run a sample Chatbot Python script is:

import aiml
import os

kernel = aiml.Kernel()


kernel.bootstrap(learnFiles = os.path.abspath("home/pi/watson/std-startup.xml"), commands = "load aiml b")
kernel.saveBrain("bot_brain.brn")

# kernel now ready for use
while True:
    message = input("Enter your message to the bot: ")
    if message == "quit":
        exit()
    elif message == "save":
        kernel.saveBrain("bot_brain.brn")
    else:
        bot_response = kernel.respond(message)
        print(bot_response)

Standard Startup is:

aiml version="2.0">
    <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>basic_chat.aiml</learn>
            <!-- You can add more aiml files here -->
            <!--<learn>more_aiml.aiml</learn>-->
        </template>
        
    </category>

</aiml>

When I run the script I get the following:

WARNING: No match found for input: load aiml b and basic_chat.aiml does not load

If I run this simple script

import aiml
import os

kernel = aiml.Kernel()
kernel.learn("basic_chat.aiml")

while True:
    message = input("Enter your message to the bot: ")
    if message == "quit":
        exit()
    elif message == "save":
        kernel.saveBrain("bot_brain.brn")
    else:
        bot_response = kernel.respond(message)
        print(bot_response)

it works fine. This is okay but eventually I want to add many more aiml files to the chatbot and I think I need the startup file for this.

JIST
  • 1,139
  • 2
  • 8
  • 30
Hankp
  • 47
  • 5

1 Answers1

1

My AIML header in Syandard Startup Was in Error. Change to:

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

Resolved problem

Hankp
  • 47
  • 5