Python Forum
ChatterBot: How to store unanswered question in a text file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ChatterBot: How to store unanswered question in a text file?
Hello, how do i store an unanswered question in chatterbot? I have a here a code for my file, but it wont store in my text file. Cry
from chatbot import chatbot
from flask import Flask, render_template, request

app = Flask(__name__)
app.static_folder = 'static'

def home():
    return render_template("index.html")

def get_bot_response():
    userText = request.args.get('msg')
    return str(chatbot.get_response(userText))
    with open("data/unanswered.txt", "a") as f:
        if str(chatbot.get_response(userText)) == "I am sorry, but I do not understand. I am still learning.":

if __name__ == "__main__":
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import json

# Creating ChatBot Instance
chatbot = ChatBot(
    preprocessor = [
    logic_adapters = [
            'import_path': 'chatterbot.logic.BestMatch',
            'default_response': 'I am sorry, but I do not understand. I am still learning.',
            'maximum_similarity_threshold': 0.90
    database_uri = 'sqlite:///database.sqlite3',
    read_only = True

# Data from Data Folder
data = json.loads(open('data/nfL6.json', 'r').read())

train = []

for k, row in enumerate(data):

trainer = ListTrainer(chatbot)

Thank you! Confused

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] How to convert the CSV text file into a txt file Pinto94 5 889 Dec-23-2020, 08:04 AM
Last Post: ndc85430
  how do i store then call a mp3 from sqlite3 .db file gr3yali3n 3 1,198 Dec-11-2020, 10:28 AM
Last Post: snippsat
  Regex text file to store data in list TheSithSiggi 1 489 Dec-03-2020, 04:46 PM
Last Post: bowlofred
  Saving text file with a click: valueerror i/o operation on closed file vizier87 5 1,268 Nov-16-2020, 07:56 AM
Last Post: Gribouillis
  chatterbot utf-8 errors with mysql database isolatedastronaut 0 511 Nov-08-2020, 06:54 AM
Last Post: isolatedastronaut
  saving data from text file to CSV file in python having delimiter as space K11 1 680 Sep-11-2020, 06:28 AM
Last Post: bowlofred
  Web Form to Python Script to Text File to zip file to web wfsteadman 1 831 Aug-09-2020, 02:12 PM
Last Post: snippsat
  Convert Excel file to Text file marvel_plato 6 4,914 Jul-17-2020, 01:45 PM
Last Post: marvel_plato
  How do I store the data in another txt file blacklight 1 675 Jun-26-2020, 11:09 AM
Last Post: Larz60+
  Rename file from value in text file Nuge93 1 1,046 Jan-20-2020, 03:50 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020