Search code examples
pythonaiml

Aiml files won't load in python


I've recently taken up aiml with python and I've tried the simplest program but even that seems to give me problems and I can't figure out why.

Here is the python script:

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

while True:
    print (kernel.respond(raw_input("Enter your message >> ")))

Here is the contents of std-startup.xml:

<category>

    <pattern>
         LOAD AIML B
    </pattern>
    <template>
        <learn>basic-chat.aiml</learn>
    </template>

</category>

and here is the contents of basic-chat.aiml:

<category>
    <pattern>HELLO</pattern>
    <template>
        Well, hello!
    </template>
</category>

<category>
    <pattern>WHAT ARE YOU</pattern>
    <template>
        I'm a bot, silly!
    </template>
</category>

And I get this error WARNING: No match found for input: load aiml b.

I've seen a few people deal with them before and I've tried their solutions but nothing seems to work. Thanks in advance for any wisdom you have to offer


Solution

  • Nevermind I got it to work, I scrapped the following line:

    kernel.learn("std-startup.xml")
    

    and replaced it with:

    kernel.learn("basic-chat.aiml")
    

    This loaded the basic-chat.aiml file and I received the desired output even though it will mean more lines of code in my python file