Closed achingacham closed 5 years ago
Hi @Chingcham, make sure you are viewing the latest
version of the documentation for 1.0.0a3. The default (stable
) will be for version 0.8.
https://chatterbot.readthedocs.io/en/latest/quickstart.html#training-your-chatbot
from chatterbot.trainers import ListTrainer
conversation = [
"Hello",
"Hi there!",
"How are you doing?",
"I'm doing great.",
"That is good to hear",
"Thank you.",
"You're welcome."
]
trainer = ListTrainer(chatbot)
trainer.train(conversation)
Thank you! I suspected that, but I was unable to find version difference for documentation. The link helped.
This is my code
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from chatterbot.trainers import ChatterBotCorpusTrainer import os
bot=ChatBot('Bot') bot.set_trainer(ListTrainer)
for files in os.listdir('C:\chatterbot-corpus-1.2.0\chatterbot_corpus\data\english/'): data= open('C:\chatterbot-corpus-1.2.0\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
@gunthercox can you please help me with the error(AttributeError: 'ChatBot' object has no attribute 'set_trainer')
@moiz7994 Please see the example in my code above (https://github.com/gunthercox/ChatterBot/issues/1555#issuecomment-453700386) You need to modify your code to match the new format.
I am running the below code:
from chatterbot import ChatBot #import the chatbot from chatterbot.trainers import ListTrainer # Method to train chatterbot from chatterbot.trainers import ChatterBotCorpusTrainer import os
bot= ChatBot('Bot')
trainer = ListTrainer('Bot')
for files in os.listdir ('C:/Users/XXX/Desktop/chatterbot-corpus-master/chatterbot_corpus/data/english/'): data = open ('C:/Users/XXX/Desktop/chatterbot-corpus-master/chatterbot_corpus/data/english/' +files, 'r').readlines() trainer.train('Bot')
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
I am getting the below error while running the code Test1.py:
C:\Users\XXX>C:/Users/XXX\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/XXX\Desktop\ABC\Test1.py
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] C:\Users\XXX\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\XXX\AppData\Roaming\nltk_data...
[nltk_data] Package punkt is already up-to-date!
[nltk_data] Downloading package stopwords to
[nltk_data] C:\Users\XXX\AppData\Roaming\nltk_data...
[nltk_data] Package stopwords is already up-to-date!
List Trainer: [####### ] 33%Traceback (most recent call last):
File "C:/Users/XXX\Desktop\ABC\Test1.py", line 12, in
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
@kbose02, @dilzeet100 I believe I have been able to answer your questions here: #1586 and here: https://github.com/gunthercox/chatterbot-corpus/issues/112. I hope those solutions work for you.
from chatterbot import ChatBot #import the chatbot from chatterbot.trainers import ChatterBotCorpusTrainer import os
bot= ChatBot('Bot') trainer = ChatterBotCorpusTrainer(bot)
corpus_path='C:/Users/716926/Downloads/chatterbot-corpus-master/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)
(base) C:\Users\716926\Documents\hello>D:/Development_Avecto/Anaconda3/python.exe c:/Users/716926/Documents/hello/bot.py D:\Development_Avecto\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py:17: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Mapping, defaultdict [nltk_data] Error loading averaged_perceptron_tagger: <urlopen error [nltk_data] Tunnel connection failed: 407 Proxy Authorization [nltk_data] Required> [nltk_data] Error loading punkt: <urlopen error Tunnel connection [nltk_data] failed: 407 Proxy Authorization Required> [nltk_data] Error loading stopwords: <urlopen error Tunnel connection [nltk_data] failed: 407 Proxy Authorization Required> 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: [####################] 100% Training money.yml: [####################] 100% Training movies.yml: [####################] 100% Training politics.yml: [####################] 100% Training psychology.yml: [####################] 100% Training science.yml: [####################] 100% Training sports.yml: [####################] 100% Training trivia.yml: [####################] 100% You:hello hello No value for search_text was available on the provided input ChatBot: Hi there! You:what are you doing what are you doing No value for search_text was available on the provided input ChatBot: I'm doing great. You:what you ate what you ate No value for search_text was available on the provided input ChatBot: I consume RAM, and binary digits.
I am getting an extra line That "No value for search_text was available on the provided input" can you help me with that
Sure, that output (No value for search_text was available on the provided input
) is just logging information. The logging level can be changed like this:
import logging
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
You can add these lines to the top of your program.
This is my code: from chatterbot.trainers import ListTrainer
conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome." ]
trainer = ListTrainer(chatbot) trainer.train(conversation)
This is the error:
Traceback (most recent call last):
File "C:/Users/zarai/OneDrive/Documents/KACST/BobBot/newchatbot.py", line 13, in
Python version: 3.7.2 Chatterbot version: 0.8.7
Why does ListTrainer not work? I have tried many different solutions but nothing works. Sometimes ListTrainer downloads only 14% and then it quits with an error.
Thank you, solved.
HI,
I am facing an issue regarding set_trainer in chatterbot please check the bellow code if their is any error please let me know
from flask import Flask, render_template from chatterbot import ChatBot from chatterbot.trainers import ListTrainer
app = Flask(name)
english_bot = ChatBot("Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter")
english_bot.set_trainer(ListTrainer) english_bot.train("./data")
@app.route("/") def home(): return render_template("index.html")
@app.route("/get") def get_bot_response(): userText = request.args.get('msg') return str(english_bot.get_response(userText))
if name == "main": app.run()
Thank you in Advance
@mady143 Please see this comment for an example of how to change your training code: https://github.com/gunthercox/ChatterBot/issues/1555#issuecomment-453700386
This is my code
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from chatterbot.trainers import ChatterBotCorpusTrainer import os
bot=ChatBot('Bot') bot.set_trainer(ListTrainer)
for files in os.listdir('C:\chatterbot-corpus-1.2.0\chatterbot_corpus\data\english/'): data= open('C:\chatterbot-corpus-1.2.0\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
@gunthercox can you please help me with the error(AttributeError: 'ChatBot' object has no attribute 'set_trainer')
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os
bot = ChatBot('Bot')
trainer = ListTrainer(bot)
for files in os.listdir('C:/Users/Era/Desktop/Chat/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/'): data=open('C:/Users/Era/Desktop/Chat/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/' + files, 'r').readlines() trainer.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
Hi, Just after installing ChatterBot ( version is 1.0.0a3.) , I tried to execute the following code snippet from quick start guide:
from chatterbot import ChatBot chatbot = ChatBot("Ron Obvious") from chatterbot.trainers import ListTrainer conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome." ] chatbot.set_trainer(ListTrainer) chatbot.train(conversation)
It failed to execute with the error, " AttributeError: 'ChatBot' object has no attribute 'set_trainer' ". I couldn't find any other post related to this attribute either. I skimmed through the code of chatterbot.py and found ChatBot indeed has neither 'set_trainer' nor 'train' function. Am I missing something here? I would really appreciate if anybody could help me here. Thanks,
hi bro
i am also same issue facing but fix this error
please following solve error steps: Flask==0.12.3 chatterbot==0.8.4 SQLAlchemy==1.1.11
install same version packages
issue is solved .....
This is my code from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from chatterbot.trainers import ChatterBotCorpusTrainer import os bot=ChatBot('Bot') bot.set_trainer(ListTrainer) for files in os.listdir('C:\chatterbot-corpus-1.2.0\chatterbot_corpus\data\english/'): data= open('C:\chatterbot-corpus-1.2.0\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 @gunthercox can you please help me with the error(AttributeError: 'ChatBot' object has no attribute 'set_trainer')
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os
bot = ChatBot('Bot')
trainer = ChatterBotCorpusTrainer(ChatBot)
trainer.train("chatterbot.corpus.english")
trainer = ListTrainer(bot)
for files in os.listdir('C:/Users/Era/Desktop/Chat/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/'): data=open('C:/Users/Era/Desktop/Chat/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/' + files, 'r').readlines() trainer.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
hi !
i am also same issue facing but fix this error
please following solve error steps: Flask==0.12.3 chatterbot==0.8.4 SQLAlchemy==1.1.11
install same version packages
issue is solved .....
Hi, Just after installing ChatterBot ( version is 1.0.0a3.) , I tried to execute the following code snippet from quick start guide:
from chatterbot import ChatBot chatbot = ChatBot("Ron Obvious") from chatterbot.trainers import ListTrainer conversation = [ "Hello", "Hi there!", "How are you doing?", "I'm doing great.", "That is good to hear", "Thank you.", "You're welcome." ] chatbot.set_trainer(ListTrainer) chatbot.train(conversation)
It failed to execute with the error, " AttributeError: 'ChatBot' object has no attribute 'set_trainer' ". I couldn't find any other post related to this attribute either. I skimmed through the code of chatterbot.py and found ChatBot indeed has neither 'set_trainer' nor 'train' function. Am I missing something here? I would really appreciate if anybody could help me here. Thanks,
hi bro
i am also same issue facing but fix this error
please following solve error steps: Flask==0.12.3 chatterbot==0.8.4 SQLAlchemy==1.1.11
install same version packages
issue is solved .....
HI,
I am facing an issue regarding set_trainer in chatterbot please check the bellow code if their is any error please let me know
from flask import Flask, render_template from chatterbot import ChatBot from chatterbot.trainers import ListTrainer
app = Flask(name)
english_bot = ChatBot("Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter")
english_bot.set_trainer(ListTrainer) english_bot.train("./data")
@app.route("/") def home(): return render_template("index.html")
@app.route("/get") def get_bot_response(): userText = request.args.get('msg') return str(english_bot.get_response(userText))
if name == "main": app.run()
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
app = Flask(name)
english_bot = ChatBot("Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter")
english_bot.set_trainer(ChatterBotCorpusTrainer)
english_bot.train("./data")
@app.route("/")
def home():
return render_template("index.html")
@app.route("/get")
def get_bot_response():
userText = request.args.get('msg')
return str(english_bot.get_response(userText))
if name == "main":
app.run()
Thank you in Advance
hi bro
i am also same issue facing but fix this error
please following solve error steps: Flask==0.12.3 chatterbot==0.8.4 SQLAlchemy==1.1.11
install same version packages
issue is solved .....
Hi, Just after installing ChatterBot ( version is 1.0.0a3.) , I tried to execute the following code snippet from quick start guide:
It failed to execute with the error, " AttributeError: 'ChatBot' object has no attribute 'set_trainer' ". I couldn't find any other post related to this attribute either. I skimmed through the code of chatterbot.py and found ChatBot indeed has neither 'set_trainer' nor 'train' function. Am I missing something here? I would really appreciate if anybody could help me here. Thanks,