我最近开始使用python的aiml,我尝试过最简单的程序,但即使这样也给我带来了问题,我不知道为什么。
下面是python脚本:
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 >> ")))以下是std-startup.xml的内容:
<category>
<pattern>
LOAD AIML B
</pattern>
<template>
<learn>basic-chat.aiml</learn>
</template>
</category>
以下是基本聊天的内容:
<category>
<pattern>HELLO</pattern>
<template>
Well, hello!
</template>
</category>
<category>
<pattern>WHAT ARE YOU</pattern>
<template>
I'm a bot, silly!
</template>
</category>我得到这个错误警告:没有找到匹配的输入: load。
我以前见过一些人和他们打交道,我尝试过他们的解决方案,但似乎没有什么效果。预先感谢你所提供的智慧
发布于 2016-12-11 11:07:07
不管我如何使它起作用,我都取消了下面这句话:
kernel.learn("std-startup.xml")并代之以:
kernel.learn("basic-chat.aiml")这加载了basic-chat.aiml文件,并且我收到了所需的输出,尽管这意味着我的python文件中将有更多的代码行。
发布于 2018-03-09 07:10:50
在python3中使用input而不是raw_input,因为python2可以使用raw_input。
希望能有所帮助
https://stackoverflow.com/questions/41084690
复制相似问题