我正在尝试运行一个示例聊天机器人脚本Pythom脚本是:
import aiml
import os
kernel = aiml.Kernel()
kernel.bootstrap(learnFiles = os.path.abspath("home/pi/watson/std-startup.xml"), commands = "load aiml b")
kernel.saveBrain("bot_brain.brn")
# kernel now ready for use
while True:
message = input("Enter your message to the bot: ")
if message == "quit":
exit()
elif message == "save":
kernel.saveBrain("bot_brain.brn")
else:
bot_response = kernel.respond(message)
print(bot_response)标准启动为:
aiml version="2.0">
<category>
<!-- Pattern to match in user input -->
<!-- If user enters "load aiml b" -->
<pattern>load aiml b</pattern>
<!-- Template is the response to the pattern -->
<!-- This learn an aiml file -->
<template>
<learn>basic_chat.aiml</learn>
<!-- You can add more aiml files here -->
<!--<learn>more_aiml.aiml</learn>-->
</template>
</category>
</aiml>当我运行这个脚本时,我得到了以下信息:
警告:未找到输入的匹配项:加载aiml b,但basic_chat.aiml未加载
如果我运行这个简单的脚本
import aiml
import os
kernel = aiml.Kernel()
kernel.learn("basic_chat.aiml")
while True:
message = input("Enter your message to the bot: ")
if message == "quit":
exit()
elif message == "save":
kernel.saveBrain("bot_brain.brn")
else:
bot_response = kernel.respond(message)
print(bot_response)它工作得很好。这是可以的,但最终我想添加更多的aiml文件到聊天机器人中,我想我需要启动文件来完成这个任务。
发布于 2020-08-22 09:57:31
我在Syandard Startup中的AIML头出错。更改为:
<aiml version = "2.0" encoding = "UTF-8">已解决的问题
https://stackoverflow.com/questions/63477676
复制相似问题