PyAIML not loading startup

笑着哭i 提交于 2019-12-05 11:52:08

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!