qq_39610896 2022-08-20 12:08 采纳率: 56.3%
浏览 74
已结题

chatterbot训练报错

各位朋友,想要用chatterbot训练机器人,下载的chatterbot版本为0.8.5,同时安装了spacy和en_core_web_sm,但是依然报错。
以下为我的测试代码:

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
bot = ChatBot("Candice")
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.english")

以下为报错内容:

C:\Users\Melody\AppData\Local\Programs\Python\Python37\python.exe C:/Users/Melody/PycharmProjects/pythonProject1/main.py
ai.yml Training: [                    ] 1%Traceback (most recent call last):
  File "C:/Users/Melody/PycharmProjects/pythonProject1/main.py", line 5, in <module>
    trainer.train("chatterbot.corpus.english")
  File "C:\Users\Melody\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\trainers.py", line 133, in train
    statement = self.get_or_create(text)
  File "C:\Users\Melody\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\trainers.py", line 28, in get_or_create
    statement = self.storage.find(statement_text)
AttributeError: 'ChatBot' object has no attribute 'find'
Process finished with exit code 1

请问如何能解决该问题?

  • 写回答

2条回答 默认 最新

  • 快乐小土狗 2022-08-20 14:50
    关注

    trainer = ChatterBotCorpusTrainer(bot)
    trainer.train(“chatterbot.corpus.english”)
    替换为以下行:
    bot.set_trainer(ChatterBotCorpusTrainer)
    bot.train(“chatterbot.corpus.english”)

    出自:https://github.com/gunthercox/ChatterBot/issues/1426

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月31日
  • 已采纳回答 8月23日
  • 创建了问题 8月20日