storage_adapter='chatterbot.storage.a aStorageAdapter',
来源:4-4 代码小练

慕数据4381256
2019-12-28
完全复制老师的代码,结果出现这个错误。找了很多解决不了,跪求老师答疑
AttributeError: module ‘chatterbot.storage’ has no attribute ‘JsonFileStorageAdapter’
4回答
-
查阅了github的一些回答。。
Owner
gunthercox commented on 21 Sep 2018
Hi @ithjz, the JsonFileStorageAdapter class was removed from ChatterBot several versions ago.
I would suggest using the SQLStorageAdapter instead.回答说已经JsonFileStorageAdapter被移除,我按照回答尝试替换SQLStorageAdapter
但又出现AttributeError: module 'chatterbot.logic' has no attribute 'LowConfidenceAdapter'的问题
根据github的回答
gunthercox 评论 on 28 Feb 2019
在LowConfidenceAdapter从聊天机器人移除。看一下在示例中如何使用default_response和maximum_similarity_threshold来作为替代:
https://github.com/gunthercox/ChatterBot/blob/master/examples/default_response_example.py
根据网址提供的实例我对代码进行了更改
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer #构建chatbot 指定一个adapter bot=ChatBot( 'Default Response Example Bot', storage_adapter='chatterbot.storage.SQLStorageAdapter', logic_adapters=[ { 'import_path':'chatterbot.logic.BestMatch', 'thresold':0.65, 'default_response':'I am sorry but i do not understand' } ], ) trainer=ListTrainer(bot) #手动给定一点语料用于训练 trainer.train([ 'How can i help u?', 'I want to create a chat bot', 'Have you read the documentation?', 'No i have not', 'This should help get you started:http://chatterbot.rtfd.org' ]) #给定问题并取回结果 question="How do i make an omelette?" print(question) response=bot.get_response(question) print(response) print("\n") question="How to make a chat bot?" print(question) response=bot.get_response(question) print(response) print("\n")
以下是我的代码结果
List Trainer: [#### ] 20%
[nltk_data] Downloading package stopwords to
[nltk_data] C:\Users\无色彩虹\AppData\Roaming\nltk_data...
[nltk_data] Package stopwords is already up-to-date!
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] C:\Users\无色彩虹\AppData\Roaming\nltk_data...
[nltk_data] Package averaged_perceptron_tagger is already up-to-
[nltk_data] date!
List Trainer: [####################] 100%
How do i make an omelette?
I am sorry but i do not understand
How to make a chat bot?
Have you read the documentation?附上我安装时出现的问题解决链接,希望有所帮助
https://blog.csdn.net/zxy13826134783/article/details/103615399
确实有版本的问题,版本不同好像移除了一些东西,但我的库版本为
ChatterBot 1.0.5
chatterbot-corpus 1.2.0
和老师视频中的一样,具体在版本有什么更改我就还需查阅资料。谢谢大家
012020-03-24 -
胖虎
2020-02-15
再qq上给我个截图,这个看着太费劲了
00 -
VincentVega
2020-02-14
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer #构建chatbot 指定一个adapter bot=ChatBot( 'Default Response Example Bot', storage_adapter='chatterbot.storage.SQLStorageAdapter', logic_adapters=[ { 'import_path':'chatterbot.logic.BestMatch', 'thresold':0.65, 'default_response':'I am sorry but i do not understand' } ], ) trainer=ListTrainer(bot) #手动给定一点语料用于训练 trainer.train([ 'How can i help u?', 'I want to create a chat bot', 'Have you read the documentation?', 'No i have not', 'This should help get you started:http://chatterbot.rtfd.org' ]) #给定问题并取回结果 question="How do i make an omelette?" print(question) response=bot.get_response(question) print(response) print("\n") question="How to make a chat bot?" print(question) response=bot.get_response(question) print(response) print("\n")
不知道为什么回答变成了别的语言还无法修改 重新提交
032020-08-07 -
胖虎
2019-12-30
应该是版本问题,谷歌一下
00