简体   繁体   中英

Chatter Bot Corpus'Trainer' missing error

I'm attempting to start working with building chat bot within python. I would really want to start programming one from scratch. I'm starting with the ChatterBot module to learn how it works. I have pip installed all modules but I'm still having trouble with 'ChatterBotCorpusTrainer'Im getting a missing error. I run python 3.7 and I have the updated ChatBot module.

 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). You have 2 options:

1

from chatterbot import trainers

2

trainer = chatterbot.trainers.ChatterBotCorpusTrainer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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