简体   繁体   English

Chatter Bot语料库'Trainer'丢失错误

[英]Chatter Bot Corpus'Trainer' missing error

I'm attempting to start working with building chat bot within python. 我正在尝试开始在python中构建聊天机器人。 I would really want to start programming one from scratch. 我真的很想从头开始编程。 I'm starting with the ChatterBot module to learn how it works. 我从ChatterBot模块开始学习它的工作原理。 I have pip installed all modules but I'm still having trouble with 'ChatterBotCorpusTrainer'Im getting a missing error. 我已经安装了所有模块的pip,但仍然无法使用'ChatterBotCorpusTrainer',但出现错误。 I run python 3.7 and I have the updated ChatBot module. 我运行python 3.7,并且具有更新的ChatBot模块。

 from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer import os bot= ChatBot('Bot') trainer = ChatterBotCorpusTrainer(bot) corpus_path = '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chatterbot_corpus/data/english' for file in os.listdir(corpus_path): trainer.train(corpus_path + file) conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome." ] trainer = ChatterBotCorpusTrainer(chatbot) trainer.train('chatterbot.corpus.english') response = chatbot.get_response("Good morning!") print(response) 

this is the error I'm getting 这是我得到的错误

 /Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot/storage/jsonfile.py:26: UnsuitableForProductionWarning: The JsonFileStorageAdapter is not recommended for production environments. self.UnsuitableForProductionWarning Traceback (most recent call last): File "/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/chat_1_1.py", line 6, in <module> trainer = ChatterBotCorpusTrainer(bot) File "/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot/trainers.py", line 101, in __init__ from .corpus import Corpus File "/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot/corpus/__init__.py", line 6, in <module> from chatterbot_corpus import Corpus ImportError: cannot import name 'Corpus' from 'chatterbot_corpus' (/Users/singlefawn/Desktop/Our Realm/1997/Programs/random gallery/venv/lib/python3.7/site-packages/chatterbot_corpus/__init__.py) 

You need to specify the module (chatterbot.trainers). 您需要指定模块(chatterbot.trainers)。 You have 2 options: 您有2个选择:

1 1

from chatterbot import trainers

2 2

trainer = chatterbot.trainers.ChatterBotCorpusTrainer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM