gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.1k stars 4.45k forks source link

AttributeError: type object 'ChatBot' has no attribute 'storage' #1586

Closed akash1998mittal closed 5 years ago

akash1998mittal commented 5 years ago

from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer import os

bot = ChatBot('Bot')

trainer = ChatterBotCorpusTrainer(ChatBot) trainer.train("chatterbot.corpus.english")

for files in os.listdir('C:/Users/Dell/Downloads/chatterbot-corpus-master/chatterbot_corpus/data/english/'): data = open('C:/Users/Dell/Downloads/chatterbot-corpus-master/chatterbot_corpus/data/english/' + files, 'r').readlines() bot.train(data)

while True: message = input('You:') if message.strip() != 'Bye': reply = bot.get_response(message) print('ChatBot:',reply)

if message.strip() == 'Bye': print('ChatBot : bye') break

this error is showing...

[nltk_data] Downloading package averaged_perceptron_tagger to [nltk_data] C:\Users\Dell\AppData\Roaming\nltk_data... [nltk_data] Package averaged_perceptron_tagger is already up-to- [nltk_data] date! [nltk_data] Downloading package punkt to [nltk_data] C:\Users\Dell\AppData\Roaming\nltk_data... [nltk_data] Package punkt is already up-to-date! [nltk_data] Downloading package stopwords to [nltk_data] C:\Users\Dell\AppData\Roaming\nltk_data... [nltk_data] Package stopwords is already up-to-date! Training ai.yml: [ ] 1%Traceback (most recent call last): File "C:\Users\Dell\Desktop\chatbot.py", line 9, in trainer.train("chatterbot.corpus.english") File "C:\Users\Dell\AppData\Local\Programs\Python\Python37-32\lib\site-packages\chatterbot\trainers.py", line 157, in train statement_search_text = self.chatbot.storage.tagger.get_bigram_pair_string(text) AttributeError: type object 'ChatBot' has no attribute 'storage'

gunthercox commented 5 years ago

Hi @dilzeet100, I made a few changes to your code, try this:

from chatterbot import ChatBot #import the chatbot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os

bot= ChatBot('Bot')
trainer = ChatterBotCorpusTrainer(bot)

corpus_path = 'C:/Users/Dell/Downloads/chatterbot-corpus-master/chatterbot_corpus/data/english/'

for file in os.listdir(corpus_path):
    trainer.train(corpus_path + file)

while True:
    message = input('You:')
    print(message)
    if message.strip() == 'Bye':
        print('ChatBot: Bye')
        break
    else:
        reply = bot.get_response(message)
        print('ChatBot:', reply)

Also, please make sure to download the latest copy of the corpus data. I have made changes that fix a few lines of invalid data.

akash1998mittal commented 5 years ago

hello @gunthercox , problem is still persist...pls check

C:\Users\Dell\Desktop>chatbot.py [nltk_data] Downloading package averaged_perceptron_tagger to [nltk_data] C:\Users\Dell\AppData\Roaming\nltk_data... [nltk_data] Package averaged_perceptron_tagger is already up-to- [nltk_data] date! [nltk_data] Downloading package punkt to [nltk_data] C:\Users\Dell\AppData\Roaming\nltk_data... [nltk_data] Package punkt is already up-to-date! [nltk_data] Downloading package stopwords to [nltk_data] C:\Users\Dell\AppData\Roaming\nltk_data... [nltk_data] Package stopwords is already up-to-date! Training ai.yml: [####################] 100% Training botprofile.yml: [####################] 100% Training computers.yml: [####################] 100% Training conversations.yml: [####################] 100% Training emotion.yml: [####################] 100% Training food.yml: [####################] 100% Training gossip.yml: [####################] 100% Training greetings.yml: [####################] 100% Training health.yml: [####################] 100% Training history.yml: [####################] 100% Training humor.yml: [####################] 100% Training literature.yml: [############# ] 67%Traceback (most recent call last): File "C:\Users\Dell\Desktop\chatbot.py", line 11, in trainer.train(corpus_path + file) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37-32\lib\site-packages\chatterbot\trainers.py", line 157, in train statement_search_text = self.chatbot.storage.tagger.get_bigram_pair_string(text) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37-32\lib\site-packages\chatterbot\tagging.py", line 135, in get_bigram_pair_string for sentence in self.tokenize_sentence(text.strip()): AttributeError: 'dict' object has no attribute 'strip'

thanks for your help

On Sun, Jan 27, 2019 at 9:34 PM Gunther Cox notifications@github.com wrote:

Hi @dilzeet100 https://github.com/dilzeet100, I made a few changes to your code, try this:

from chatterbot import ChatBot #import the chatbotfrom chatterbot.trainers import ChatterBotCorpusTrainerimport os

bot= ChatBot('Bot') trainer = ChatterBotCorpusTrainer(bot)

corpus_path = 'C:/Users/Dell/Downloads/chatterbot-corpus-master/chatterbot_corpus/data/english/' for file in os.listdir(corpus_path): trainer.train(corpus_path + file) while True: message = input('You:') print(message) if message.strip() == 'Bye': print('ChatBot: Bye') break else: reply = bot.get_response(message) print('ChatBot:', reply)

Also, please make sure to download the latest copy of the corpus data. I have made changes that fix a few lines of invalid data.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gunthercox/ChatterBot/issues/1586#issuecomment-457930333, or mute the thread https://github.com/notifications/unsubscribe-auth/As2iuSw9XdbXp8kYNin_mrXtROQRC3YNks5vHc4qgaJpZM4aS21W .

gunthercox commented 5 years ago

Did you make sure you downloaded the latest copy of the ChatterBot corpus data?

akash1998mittal commented 5 years ago

Yes...I think so... If not..then share link for latest corpus data plss

On Mon, 28 Jan 2019, 07:05 Gunther Cox <notifications@github.com wrote:

Did you make sure you downloaded the latest copy of the ChatterBot corpus data?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gunthercox/ChatterBot/issues/1586#issuecomment-457974212, or mute the thread https://github.com/notifications/unsubscribe-auth/As2iuVjcUTTMKln8qz3guyTWu2l7Z09Aks5vHlOPgaJpZM4aS21W .

gunthercox commented 5 years ago

https://github.com/gunthercox/chatterbot-corpus

akash1998mittal commented 5 years ago

thank you so much buddy for your help

On Mon, Jan 28, 2019 at 7:19 AM Gunther Cox notifications@github.com wrote:

https://github.com/gunthercox/chatterbot-corpus

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gunthercox/ChatterBot/issues/1586#issuecomment-457975886, or mute the thread https://github.com/notifications/unsubscribe-auth/As2iuT048N-y8TScxp3GEzZlSoAYIaRvks5vHlcSgaJpZM4aS21W .

akash1998mittal commented 5 years ago

buddy, I want to set some questions on my own for chatbot...how can I do that??

On Mon, Jan 28, 2019 at 6:37 PM akki bhatia akash1998mittal@gmail.com wrote:

thank you so much buddy for your help

On Mon, Jan 28, 2019 at 7:19 AM Gunther Cox notifications@github.com wrote:

https://github.com/gunthercox/chatterbot-corpus

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gunthercox/ChatterBot/issues/1586#issuecomment-457975886, or mute the thread https://github.com/notifications/unsubscribe-auth/As2iuT048N-y8TScxp3GEzZlSoAYIaRvks5vHlcSgaJpZM4aS21W .

gunthercox commented 5 years ago

@dilzeet100 I'm not certain what you are asking. Perhaps you are looking to enter your own training data, similar to this example: https://github.com/gunthercox/ChatterBot/blob/master/examples/training_example_list_data.py

akash1998mittal commented 5 years ago

Hello, I want to know that, like chatterbot corpus has already files having set of questions and answers... I want to make my own file with questions and responses,,,and want to load it in my chatbot..how I can do that

On Tue, Jan 29, 2019 at 6:05 PM Gunther Cox notifications@github.com wrote:

@dilzeet100 https://github.com/dilzeet100 I'm not certain what you are asking. Perhaps you are looking to enter your own training data, similar to this example: https://github.com/gunthercox/ChatterBot/blob/master/examples/training_example_list_data.py

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gunthercox/ChatterBot/issues/1586#issuecomment-458783070, or mute the thread https://github.com/notifications/unsubscribe-auth/As2iuc2_k8CqvPG4NUkTP7yXMpRfAyCZks5vIP36gaJpZM4aS21W .

gunthercox commented 5 years ago

If you would like to create your own corpus files, it is very easy to do so.

First, create the files containing the data that you want them to contain. An explanation of how to format the data can be found here: https://chatterbot-corpus.readthedocs.io/en/latest/data.html

Then, you can pass the path to the directory or file that contains the data into the train method.

trainer.train('path-to/my-data/')
akash1998mittal commented 5 years ago

thanks a lot for your help

On Fri, Feb 1, 2019 at 6:20 AM Gunther Cox notifications@github.com wrote:

If you would like to create your own corpus files, it is very easy to do so.

First, create the files containing the data that you want them to contain. An explanation of how to format the data can be found here: https://chatterbot-corpus.readthedocs.io/en/latest/data.html

Then, you can pass the path to the directory or file that contains the data into the train method.

trainer.train('path-to/my-data/')

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gunthercox/ChatterBot/issues/1586#issuecomment-459564218, or mute the thread https://github.com/notifications/unsubscribe-auth/As2iuXuIYJOVaa83fu4wKl_o5x1h2tQYks5vI485gaJpZM4aS21W .

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.