Closed nish-sura closed 5 years ago
Hi @nish-sura, this looks like a duplicate of https://github.com/gunthercox/ChatterBot/issues/1624. I'll respond there.
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os import spacy nlp = spacy.load("en_core_web_sm") bot = ChatBot('Bot') trainer=ListTrainer(bot) for files in os.listdir("""C\Users\suriya prakash\chatterbot-corpus-master\chatterbot-corpus-master\chatterbot_corpus\data\english\"""): data = open("""C\User\suriya prakash\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 hey everyone, the code is correct but when I try to train the chat bot in cmd it shows the following error, C:\Users\suriya prakash\ChatBot>python chatbot_train.py File "chatbot_train.py", line 9 for files in os.listdir("""C\Users\suriya prakash\chatterbot-corpus-master\chatterbot-corpus-master\chatterbot_corpus\data\english\"""): data = open("""C\User\suriya prakash\chatterbot-corpus-master\chatterbot-corpus-master\chatterbot_corpus\data\english\"""+files,'r').readlines() ^ SyntaxError: invalid syntax
I cant find what is the error here!!
This is my code: ` 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") trainer = ChatterBotCorpusTrainer(english_bot) trainer.train("chatterbot.corpus.english")
@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() ` It raise error:
Traceback (most recent call last):
File "app.py", line 9, in
I can't find error? Would you mind helping me?
i am getting this error. does anyone know how to fix it?
CODE_ from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os
bot = ChatBot('Bot') bot.set_trainer(ListTrainer)
for files in os.listdir('C:/Users/nisha\chatterbot-corpus-master\chatterbot_corpus\data\english'): data = open('C:/Users/nisha\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
ERROR- FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/nisha\chatterbot-corpus-master\chatterbot_corpus\data\englishai.yml'