我正在尝试制作聊天机器人,但它有一些意想不到的错误。请帮我解决这个问题。在
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os
bot = ChatBot('bot',storage_adapter='chatterbot.storage.SQLStorageAdapter',
trainer='chatterbot.trainers.ListTrainer')
for files in os.listdir('C:/Users/HP/Downloads/Packages/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/') :
data = open(r'C:/Users/HP/Downloads/Packages/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/'+files,).readlines()
trainer = ListTrainer(bot)
trainer.train(data)
print("Training completed")
while True :
message = input('You: ')
if message.strip() != 'Bye':
replay = bot.get_responce(message)
print('ChatBot :',replay)
if message.strip()=='bye':
print('bye')
break
命令的输出
^{pr2}$Traceback (most recent call last): File "victoria_train.py", line 21, in replay = bot.get_responce(message) AttributeError: 'ChatBot' object has no attribute 'get_responce'
您正在使用一个不存在的函数(在Response上键入)。相反,请使用:
get_response
。Click here对于聊天文档。相关问题 更多 >
编程相关推荐