首页 > 解决方案 > chatterbot.logic.SpecificResponseAdapter 不工作

问题描述

我想开发自己的自定义聊天机器人,但在开发过程中遇到了一些问题,我想在chatterbot. 有一个代码示例。

from chatterbot.trainers import ListTrainer
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
bot = ChatBot('Mybot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[{'import_path': 'chatterbot.logic.SpecificResponseAdapter',
               'input_text': 'Help me!',
                'output_text': 'Ok'
                        }]) # Crate Chatbot
trainer = ListTrainer(bot)
text = open('/content/drive/My Drive/Chatbot/Data/data.txt').readlines()
trainer.train(text)

while True:
   request = input("Your: ")
   response = bot.get_response(request)
   print("bot:",response)

这是输出:

 Your: Help me!
 bot: I am sorry, but I do not understand.
 Your: 'Help me!'
 bot: I am sorry, but I do not understand.

请帮我解决这个问题

标签: python-3.xchatterbot

解决方案


推荐阅读