簡體   English   中英

Chatter Bot語料庫'Trainer'丟失錯誤

[英]Chatter Bot Corpus'Trainer' missing error

我正在嘗試開始在python中構建聊天機器人。 我真的很想從頭開始編程。 我從ChatterBot模塊開始學習它的工作原理。 我已經安裝了所有模塊的pip,但仍然無法使用'ChatterBotCorpusTrainer',但出現錯誤。 我運行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) 

這是我得到的錯誤

 /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) 

您需要指定模塊(chatterbot.trainers)。 您有2個選擇:

1

from chatterbot import trainers

2

trainer = chatterbot.trainers.ChatterBotCorpusTrainer

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM