我正在使用Python启动一个使用AIML的项目,当我运行脚本时,它会给我一个“未找到匹配”的错误。这是Python代码:
import aiml
kernel = aiml.Kernel()
kernel.learn("bot.aiml")
while True:
print kernel.respond(raw_input("\n>>"))只是一个简单的AIML内核。是不是出了什么问题?
发布于 2016-09-13 15:23:43
如果你感兴趣,我有一个更好的python脚本
import aiml
import sys <br>
brainLoaded = False
forceReload = False
while not brainLoaded:
if forceReload or (len(sys.argv) >= 2 and sys.argv[1] == "reload"):
kern.bootstrap(learnFiles="Database.xml", commands="load aiml b")
brainLoaded = True
kern.saveBrain("Cache.brn")
else:
# Attempt to load the brain file. If it fails, fall back on the Reload
try:
# It is our cache file.
kern.bootstrap(brainFile = "Cache.brn")
brainLoaded = True
except:
forceReload = True
# Enter the main input/output loop.
print "Enter your message for the chatbot"
while(True):
print kern.respond(raw_input("> "))注意:您需要创建一个文件夹数据库,在其中放置AIML文件和文件Database.xml
发布于 2016-09-27 01:56:27
因为"bot.aiml“没有与您的输入匹配的输出,所以会出现"No match found for input”警告。尝试包含如下所示的默认响应:
<category>
<pattern>*</pattern>
<template>
Sorry. I didn't quite get that.
</template>
</category>发布于 2016-10-26 23:47:31
尝试删除代码中的'print‘语句
import aiml
kernel = aiml.Kernel()
kernel.learn("bot.aiml")
while True:
kernel.respond(raw_input("\n>>"))https://stackoverflow.com/questions/38982462
复制相似问题