Question

I am beginning a project on Python that implements PyAIML and I wrote the following code to create a brain for my project:

import aiml

k=aiml.Kernel()
k.learn("std-startup.xml")
k.respond("LOAD AIML B")
k.saveBrain("jarvis.brn")

When I run the program I get this error: WARNING: No match found for input: LOAD AIML B

I understand that I needed to download an AIML set to begin development. So I did, but I'm stuck there.

Please help. I'm a noob programmer so don't be rough on me for this dumb mistake.

Thanks in advance!

Was it helpful?

Solution

The .learn() method will not throw an error if the file you pass it does not exist, and I'm guessing that you are trying to learn patterns from "std-startup.xml" without having this file in your directory.

Make sure the file std-startup.xml is in the directory you are running your script from. You should also have a directory called standard in your working directory that contains the standard set of aiml files. Basically your directory should look like this:

 mydir/my_script.py
 mydir/std-startup.xml
 mydir/standard/a-bunch-of-std-aiml-files.aiml

These files can be found in the "Other Files/Standard AIML Set/" folder on the pyaiml source forge site. Go to that folder and download the one of the tarballs or the zip.

OTHER TIPS

A few things:

  1. If your AIML is loading properly, pyAIML will respond with a line that will read something like: Loading std-startup.aiml... done (1.00 seconds) It will not necessarily throw an error if it does not find a file to load, so if you don't see this line, pyAIML has not loaded the AIML file.

  2. I don't see 'std-startup.xml' in the sourceforge directory either, but this shouldn't matter. All that you're loading is any AIML file that will allow you to test the kernel. Try loading the 'self-test.aiml' file in the /aiml directory instead. (Double-check to make sure the file suffix in your code is .aiml and not .xml)

  3. k.respond() is for giving the bot some input and 'LOAD AIML B' is just a test phrase. Once you've loaded 'self-test.aiml' try k.respond('test date') and you should get

The date is Wed Mar 13 01:37:07 2013 in response.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top