├── .idea ├── .name ├── encodings.xml ├── flask-chatbot.iml ├── misc.xml ├── modules.xml └── vcs.xml ├── flask_chatbot ├── __init__.py ├── app │ ├── __init__.py │ ├── machine_learning │ │ ├── __init__.py │ │ ├── events.py │ │ ├── routes.py │ │ └── templates │ │ │ └── machine_learning.html │ ├── main │ │ ├── __init__.py │ │ ├── routes.py │ │ └── templates │ │ │ └── index.html │ └── wit │ │ ├── __init__.py │ │ ├── events.py │ │ ├── routes.py │ │ ├── templates │ │ └── wit_ai.html │ │ └── wit_ai.py ├── database.db └── flask_chatbot.py ├── readme.md └── requirements.txt /.idea/.name: -------------------------------------------------------------------------------- 1 | flask-chatbot -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/flask-chatbot.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /flask_chatbot/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abirafdirp/flask-chatbot/1bd80f03d1b0a82d11b5e8aa9531d4706ec04fcc/flask_chatbot/__init__.py -------------------------------------------------------------------------------- /flask_chatbot/app/__init__.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | from flask.ext.socketio import SocketIO 3 | 4 | socketio = SocketIO() 5 | 6 | 7 | def create_app(debug=False): 8 | app = Flask(__name__) 9 | app.debug = debug 10 | app.config['SECRET_KEY'] = 'gjr39dkjn344_!67#' 11 | 12 | from .main import main as main_blueprint 13 | from .machine_learning import machine_learning as machine_learning_blueprint 14 | from .wit import wit as wit_ai_blueprint 15 | app.register_blueprint(main_blueprint) 16 | app.register_blueprint(machine_learning_blueprint) 17 | app.register_blueprint(wit_ai_blueprint) 18 | 19 | socketio.init_app(app) 20 | return app -------------------------------------------------------------------------------- /flask_chatbot/app/machine_learning/__init__.py: -------------------------------------------------------------------------------- 1 | from flask import Blueprint 2 | 3 | machine_learning = Blueprint('machine_learning', __name__, template_folder='templates') 4 | 5 | from app.machine_learning import events, routes 6 | -------------------------------------------------------------------------------- /flask_chatbot/app/machine_learning/events.py: -------------------------------------------------------------------------------- 1 | from flask_socketio import emit 2 | from chatterbot import ChatBot 3 | 4 | from app import socketio 5 | 6 | chatbot = ChatBot('swdev', 7 | logic_adapters=[ 8 | 'chatterbot.adapters.logic.EvaluateMathematically', 9 | 'chatterbot.adapters.logic.TimeLogicAdapter', 10 | 'chatterbot.adapters.logic.ClosestMatchAdapter' 11 | ]) 12 | chatbot.train('chatterbot.corpus.english') 13 | chatbot.train('chatterbot.corpus.english.greetings') 14 | chatbot.train('chatterbot.corpus.english.conversations') 15 | 16 | 17 | @socketio.on('message', namespace='/machinelearning') 18 | def receive_message(message): 19 | bot_response = chatbot.get_response(message['data']) 20 | emit('response', {'data': bot_response}) 21 | -------------------------------------------------------------------------------- /flask_chatbot/app/machine_learning/routes.py: -------------------------------------------------------------------------------- 1 | from flask import session, redirect, url_for, render_template, request 2 | from app.main import main 3 | 4 | 5 | @main.route('/machine-learning') 6 | def chat_chatterbot(): 7 | return render_template('machine_learning.html') -------------------------------------------------------------------------------- /flask_chatbot/app/machine_learning/templates/machine_learning.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Machine learning 5 | 6 | 7 | 26 | 27 | 28 |

Machine learning bot test (chatterbot, NTLK)

29 | 46 |

Send:

47 |
48 | 49 | 50 |
51 |

Receive:

52 |
53 | 54 | -------------------------------------------------------------------------------- /flask_chatbot/app/main/__init__.py: -------------------------------------------------------------------------------- 1 | from flask import Blueprint 2 | 3 | main = Blueprint('main', __name__, template_folder='templates') 4 | 5 | from . import routes 6 | -------------------------------------------------------------------------------- /flask_chatbot/app/main/routes.py: -------------------------------------------------------------------------------- 1 | from flask import session, redirect, url_for, render_template, request 2 | from . import main 3 | 4 | 5 | @main.route('/') 6 | def index(): 7 | return render_template('index.html') -------------------------------------------------------------------------------- /flask_chatbot/app/main/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Wit.ai integration 9 | chatterbot NTLK integration 10 | 11 | -------------------------------------------------------------------------------- /flask_chatbot/app/wit/__init__.py: -------------------------------------------------------------------------------- 1 | from flask import Blueprint 2 | 3 | wit = Blueprint('wit', __name__, template_folder='templates') 4 | 5 | from app.wit import events, routes 6 | -------------------------------------------------------------------------------- /flask_chatbot/app/wit/events.py: -------------------------------------------------------------------------------- 1 | from flask_socketio import emit 2 | 3 | from flask import session 4 | 5 | from app import socketio 6 | from app.wit.wit_ai import client 7 | 8 | 9 | @socketio.on('message', namespace='/wit') 10 | def receive_message(message): 11 | bot_response = client.run_actions('mysession', str(message['data']), {}) 12 | ans = session['answer'] 13 | emit('response', {'data': ans}) 14 | -------------------------------------------------------------------------------- /flask_chatbot/app/wit/routes.py: -------------------------------------------------------------------------------- 1 | from flask import session, redirect, url_for, render_template, request 2 | from app.main import main 3 | 4 | 5 | @main.route('/wit-ai') 6 | def chat_wit(): 7 | return render_template('wit_ai.html') -------------------------------------------------------------------------------- /flask_chatbot/app/wit/templates/wit_ai.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Machine learning 5 | 6 | 7 | 26 | 27 | 28 |

Wit.ai test

29 | 34 |

Send:

35 |
36 | 37 | 38 |
39 |

Receive:

40 |
41 | 42 | -------------------------------------------------------------------------------- /flask_chatbot/app/wit/wit_ai.py: -------------------------------------------------------------------------------- 1 | from wit import Wit 2 | from flask import session 3 | 4 | 5 | def say(session_id, context, msg): 6 | print(msg) 7 | session['answer'] = msg 8 | 9 | 10 | def merge(session_id, context, entities, msg): 11 | return context 12 | 13 | 14 | def error(session_id, context, e): 15 | print(str(e)) 16 | 17 | actions = { 18 | 'say': say, 19 | 'merge': merge, 20 | 'error': error, 21 | } 22 | 23 | client = Wit('YOUR API KEY', actions) 24 | -------------------------------------------------------------------------------- /flask_chatbot/database.db: -------------------------------------------------------------------------------- 1 | {"Who was the 37th President of the United States?": {"in_response_to": []}, "There should be one-- and preferably only one --obvious way to do it.": {"in_response_to": [{"occurrence": 145, "text": "In the face of ambiguity, refuse the temptation to guess.", "signature": []}]}, "Sparse is better than dense.": {"in_response_to": [{"occurrence": 146, "text": "Flat is better than nested.", "signature": []}]}, "I agree.": {"in_response_to": [{"occurrence": 145, "text": "Namespaces are one honking great idea. Let's do more of those!", "signature": []}]}, "That is good to hear": {"in_response_to": [{"occurrence": 147, "text": "I am doing well.", "signature": []}]}, "Yes, I have a question.": {"in_response_to": [{"occurrence": 147, "text": "Can I help you with anything?", "signature": []}]}, "Nothing much.": {"in_response_to": [{"occurrence": 147, "text": "What's up?", "signature": []}]}, "Who? Who is but a form following the function of what": {"in_response_to": [{"occurrence": 147, "text": "Who are you?", "signature": []}]}, "No it is not. The cake is delicious.": {"in_response_to": [{"occurrence": 147, "text": "The cake is a lie.", "signature": []}]}, "Not much.": {"in_response_to": [{"occurrence": 147, "text": "What's up?", "signature": []}]}, "Hi, How is it going?": {"in_response_to": []}, "The cake is a lie.": {"in_response_to": []}, "I'm also good.": {"in_response_to": [{"occurrence": 147, "text": "I am doing well, how about you?", "signature": []}]}, "Although that way may not be obvious at first unless you're Dutch.": {"in_response_to": [{"occurrence": 145, "text": "There should be one-- and preferably only one --obvious way to do it.", "signature": []}]}, "Errors should never pass silently.": {"in_response_to": [{"occurrence": 146, "text": "Although practicality beats purity.", "signature": []}]}, "Good": {"in_response_to": [{"occurrence": 147, "text": "Hi, How is it going?", "signature": []}]}, "You're entirely bonkers. But I'll tell you a secret. All the best people are.": {"in_response_to": [{"occurrence": 147, "text": "I wish I was The Mad Hatter.", "signature": []}]}, "Can I ask you a question?": {"in_response_to": []}, "Namespaces are one honking great idea. Let's do more of those!": {"in_response_to": [{"occurrence": 145, "text": "If the implementation is easy to explain, it may be a good idea.", "signature": []}]}, "If the implementation is hard to explain, it's a bad idea.": {"in_response_to": [{"occurrence": 145, "text": "Although never is often better than right now.", "signature": []}]}, "What's up?": {"in_response_to": []}, "The Hubble Space Telescope, launched into low Earth orbit in 1990, is named after what American astronomer?": {"in_response_to": []}, "Or something": {"in_response_to": [{"occurrence": 146, "text": "Nothing", "signature": []}]}, "What does YOLO mean?": {"in_response_to": []}, "The United Kingdom of Great Britain": {"in_response_to": [{"occurrence": 74, "text": "God Save the Queen is the national anthem of what country?", "signature": []}]}, "Echolocation": {"in_response_to": [{"occurrence": 74, "text": "Dolphins use a sense, similar to sonar, to determine the location and shape of nearby items.", "signature": []}]}, "Greetings!": {"in_response_to": [{"occurrence": 147, "text": "Hello", "signature": []}]}, "1963": {"in_response_to": [{"occurrence": 74, "text": "What year was President John F. Kennedy assassinated?", "signature": []}]}, "Thank you. You too.": {"in_response_to": [{"occurrence": 147, "text": "Hi, nice to meet you.", "signature": []}, {"occurrence": 147, "text": "It is a pleasure to meet you.", "signature": []}]}, "Simple is better than complex.": {"in_response_to": [{"occurrence": 146, "text": "Complex is better than complicated.", "signature": []}, {"occurrence": 146, "text": "Explicit is better than implicit.", "signature": []}]}, "I am baking a cake.": {"in_response_to": [{"occurrence": 147, "text": "What are you working on?", "signature": []}]}, "A man in a mask.": {"in_response_to": [{"occurrence": 147, "text": "What are you then?", "signature": []}]}, "hello": {"in_response_to": [{"text": "Yes I am.", "in_response_to": [{"occurrence": 16, "text": "Are you a robot?", "signature": []}]}]}, "Its complicated.": {"in_response_to": [{"occurrence": 146, "text": "How do you work?", "signature": []}]}, "That's good.": {"in_response_to": [{"occurrence": 147, "text": "I am also good.", "signature": []}]}, "I'm sorry, but I don't have any.": {"in_response_to": [{"occurrence": 147, "text": "Could I borrow a cup of sugar?", "signature": []}]}, "what": {"in_response_to": []}, "Nothing": {"in_response_to": [{"occurrence": 146, "text": "What else is delicious?", "signature": []}]}, "If the implementation is easy to explain, it may be a good idea.": {"in_response_to": [{"occurrence": 145, "text": "If the implementation is hard to explain, it's a bad idea.", "signature": []}]}, "Flat is better than nested.": {"in_response_to": [{"occurrence": 146, "text": "Complex is better than complicated.", "signature": []}]}, "Complex is better than complicated.": {"in_response_to": [{"occurrence": 146, "text": "Its complicated.", "signature": []}, {"occurrence": 146, "text": "Simple is better than complex.", "signature": []}]}, "Good morning, how are you?": {"in_response_to": []}, "The Space Race was a 20th-century competition between what two Cold War rivals, for supremacy in spaceflight capability?": {"in_response_to": []}, "Thank you.": {"in_response_to": [{"occurrence": 147, "text": "Nice to meet you.", "signature": []}]}, "It has many inconsistencies.": {"in_response_to": [{"occurrence": 145, "text": "What annoys you?", "signature": []}]}, "Now is better than never.": {"in_response_to": [{"occurrence": 145, "text": "Although that way may not be obvious at first unless you're Dutch.", "signature": []}]}, "How are you doing?": {"in_response_to": [{"occurrence": 147, "text": "Hi", "signature": []}]}, "Hi": {"in_response_to": [{"occurrence": 294, "text": "Hello", "signature": []}]}, "Tell me about your self.": {"in_response_to": [{"occurrence": 146, "text": "Or something", "signature": []}]}, "Unless explicitly silenced.": {"in_response_to": [{"occurrence": 146, "text": "Errors should never pass silently.", "signature": []}]}, "What year was President John F. Kennedy assassinated?": {"in_response_to": []}, "Special cases aren't special enough to break the rules.": {"in_response_to": [{"occurrence": 146, "text": "Readability counts.", "signature": []}]}, "I wish I was The Mad Hatter.": {"in_response_to": [{"occurrence": 147, "text": "Alice in Wonderland", "signature": []}]}, "Thank you anyway": {"in_response_to": [{"occurrence": 147, "text": "I'm sorry, but I don't have any.", "signature": []}]}, "Not too much.": {"in_response_to": [{"occurrence": 147, "text": "What's up?", "signature": []}]}, "I'm doing well.": {"in_response_to": [{"occurrence": 147, "text": "How do you do?", "signature": []}]}, "A gyroscope.": {"in_response_to": [{"occurrence": 74, "text": "A spinning disk, in which the orientation of this axis is unaffected by tilting or rotation of the mounting, is called what?", "signature": []}]}, "What is your favorite book?": {"in_response_to": []}, "Explicit is better than implicit.": {"in_response_to": [{"occurrence": 146, "text": "Beautiful is better than ugly.", "signature": []}]}, "okay": {"in_response_to": [{"text": "That is good to hear", "in_response_to": [{"occurrence": 16, "text": "I am doing well.", "signature": []}]}]}, "It's not your powers of observation I doubt, but merely the paradoxical nature of asking a masked man who is. But tell me, do you like music?": {"in_response_to": [{"occurrence": 147, "text": "I can see that.", "signature": []}]}, "Edwin Hubble": {"in_response_to": [{"occurrence": 74, "text": "The Hubble Space Telescope, launched into low Earth orbit in 1990, is named after what American astronomer?", "signature": []}]}, "Europe": {"in_response_to": [{"occurrence": 74, "text": "The Celtic Shelf, the seabed under the Celtic Sea is a part of the continental shelf of what continent?", "signature": []}]}, "Richard Nixon": {"in_response_to": [{"occurrence": 74, "text": "Who was the 37th President of the United States?", "signature": []}]}, "Did I ever live?": {"in_response_to": []}, "Thank you kindly.": {"in_response_to": [{"occurrence": 147, "text": "Top of the morning to you!", "signature": []}]}, "It seems your familiar with the Zen of Python": {"in_response_to": [{"occurrence": 146, "text": "In the face of ambiguity, refuse the temptation to guess.", "signature": []}]}, "What is it that you want to know?": {"in_response_to": [{"occurrence": 146, "text": "What is it like?", "signature": []}]}, "What is the name of the nearest major galaxy to the Milky Way?": {"in_response_to": []}, "Okay": {"in_response_to": [{"occurrence": 147, "text": "Hi, How is it going?", "signature": []}]}, "What annoys you?": {"in_response_to": [{"occurrence": 145, "text": "I'm not incredibly fond of Java.", "signature": []}]}, "It is a pleasure to meet you.": {"in_response_to": []}, "So what's your favorite color?": {"in_response_to": [{"occurrence": 147, "text": "I can't read.", "signature": []}]}, "Fine": {"in_response_to": [{"occurrence": 147, "text": "Hi, How is it going?", "signature": []}]}, "Hi, nice to meet you.": {"in_response_to": []}, "I am working on a project": {"in_response_to": []}, "Are you a robot?": {"in_response_to": [{"occurrence": 146, "text": "What do you want to know?", "signature": []}]}, "I heard somebody say it.": {"in_response_to": [{"occurrence": 144, "text": "It means you only live once. Where did you hear that?", "signature": []}]}, "What good news?": {"in_response_to": [{"occurrence": 147, "text": "Have you heard the news?", "signature": []}]}, "Great": {"in_response_to": [{"occurrence": 147, "text": "Hi, How is it going?", "signature": []}]}, "( 1 + 1 ) = 2": {"in_response_to": []}, "1 + 1": {"in_response_to": [{"occurrence": 1, "text": "Greetings!", "signature": []}, {"text": "What is it that you want to know?", "in_response_to": [{"occurrence": 24, "text": "What is it like?", "signature": []}]}]}, "Sputnik 1": {"in_response_to": [{"occurrence": 74, "text": "What was the name of the first artificial Earth satellite?", "signature": []}]}, "I am also good.": {"in_response_to": [{"occurrence": 147, "text": "I am doing well, how about you?", "signature": []}]}, "Beautiful is better than ugly.": {"in_response_to": [{"occurrence": 146, "text": "Do you know all of it?", "signature": []}]}, "Alice in Wonderland": {"in_response_to": [{"occurrence": 147, "text": "What kind of movies do you like?", "signature": []}]}, "How do you work?": {"in_response_to": [{"occurrence": 146, "text": "What is it that you want to know?", "signature": []}]}, "Is that a definition or an oppinion?": {"in_response_to": [{"occurrence": 144, "text": "Life is the condition that distinguishes organisms from inorganic matter, including the capacity for growth, reproduction, functional activity, and continual change preceding death.", "signature": []}]}, "Who are you?": {"in_response_to": []}, "I am a programmer": {"in_response_to": [{"occurrence": 145, "text": "Are you a programmer?", "signature": []}]}, "The Celtic Shelf, the seabed under the Celtic Sea is a part of the continental shelf of what continent?": {"in_response_to": []}, "God Save the Queen is the national anthem of what country?": {"in_response_to": []}, "I can see that.": {"in_response_to": [{"occurrence": 147, "text": "A man in a mask.", "signature": []}]}, "Do you know all of it?": {"in_response_to": [{"occurrence": 146, "text": "I am.", "signature": []}]}, "I'm not incredibly fond of Java.": {"in_response_to": [{"occurrence": 145, "text": "I use Python quite a bit myself.", "signature": []}]}, "how are you today?": {"in_response_to": [{"text": "Edwin Hubble", "in_response_to": [{"occurrence": 8, "text": "The Hubble Space Telescope, launched into low Earth orbit in 1990, is named after what American astronomer?", "signature": []}]}]}, "And the rest of the day to you.": {"in_response_to": [{"occurrence": 147, "text": "Top of the morning to you!", "signature": []}]}, "What kind of movies do you like?": {"in_response_to": [{"occurrence": 147, "text": "I like seeing movies.", "signature": []}]}, "what time is it?": {"in_response_to": [{"occurrence": 1, "text": "How do you work?", "signature": []}, {"text": "( 1 + 1 ) = 2", "in_response_to": []}]}, "Very well, thanks.": {"in_response_to": [{"occurrence": 147, "text": "How are you doing?", "signature": []}]}, "Fine, and you?": {"in_response_to": [{"occurrence": 147, "text": "How are you doing?", "signature": []}]}, "I'm doing well. How are you?": {"in_response_to": [{"occurrence": 147, "text": "How do you do?", "signature": []}]}, "Hello": {"in_response_to": [{"occurrence": 147, "text": "Hi", "signature": []}, {"occurrence": 147, "text": "Greetings!", "signature": []}]}, "I use Python, Java and C++ quite often.": {"in_response_to": [{"occurrence": 145, "text": "What languages do you like to use?", "signature": []}]}, "Go ahead and ask.": {"in_response_to": [{"occurrence": 144, "text": "Can I ask you a question?", "signature": []}]}, "Good.": {"in_response_to": [{"occurrence": 147, "text": "How are you doing?", "signature": []}]}, "Have you heard the news?": {"in_response_to": []}, "I am.": {"in_response_to": [{"occurrence": 146, "text": "It seems your familiar with the Zen of Python", "signature": []}]}, "Life is the condition that distinguishes organisms from inorganic matter, including the capacity for growth, reproduction, functional activity, and continual change preceding death.": {"in_response_to": [{"occurrence": 144, "text": "It depends how you define life", "signature": []}]}, "What languages do you like to use?": {"in_response_to": [{"occurrence": 145, "text": "I am a programmer", "signature": []}]}, "Could be better.": {"in_response_to": [{"occurrence": 147, "text": "Hi, How is it going?", "signature": []}]}, "Yes it is.": {"in_response_to": [{"occurrence": 147, "text": "That's good to hear.", "signature": []}, {"occurrence": 147, "text": "That is good to hear", "signature": []}]}, "what time is it": {"in_response_to": [{"text": "Greetings!", "in_response_to": [{"occurrence": 16, "text": "Hello", "signature": []}]}]}, "What else is delicious?": {"in_response_to": [{"occurrence": 147, "text": "No it is not. The cake is delicious.", "signature": []}]}, "Not so great.": {"in_response_to": [{"occurrence": 147, "text": "Hi, How is it going?", "signature": []}]}, "Dolphins use a sense, similar to sonar, to determine the location and shape of nearby items.": {"in_response_to": []}, "What was the name of the first artificial Earth satellite?": {"in_response_to": []}, "In the face of ambiguity, refuse the temptation to guess.": {"in_response_to": [{"occurrence": 146, "text": "Simple is better than complex.", "signature": []}, {"occurrence": 145, "text": "Unless explicitly silenced.", "signature": []}]}, "What are you working on?": {"in_response_to": [{"occurrence": 147, "text": "I am working on a project", "signature": []}]}, "What is it like?": {"in_response_to": [{"occurrence": 146, "text": "Yes I am.", "signature": []}]}, "That's good to hear.": {"in_response_to": [{"occurrence": 147, "text": "I'm also good.", "signature": []}]}, "The sky's up but I'm fine thanks. What about you?": {"in_response_to": [{"occurrence": 147, "text": "What's up?", "signature": []}]}, "I am doing well, how about you?": {"in_response_to": [{"occurrence": 147, "text": "Good morning, how are you?", "signature": []}, {"occurrence": 147, "text": "How are you doing?", "signature": []}]}, "A spinning disk, in which the orientation of this axis is unaffected by tilting or rotation of the mounting, is called what?": {"in_response_to": []}, "Could I borrow a cup of sugar?": {"in_response_to": [{"occurrence": 147, "text": "What is your question?", "signature": []}]}, "Can I help you with anything?": {"in_response_to": [{"occurrence": 147, "text": "Yes it is.", "signature": []}]}, "It depends how you define life": {"in_response_to": [{"occurrence": 144, "text": "Did I ever live?", "signature": []}]}, "Not much, how about you?": {"in_response_to": [{"occurrence": 147, "text": "What's up?", "signature": []}]}, "Top of the morning to you!": {"in_response_to": []}, "Nice to meet you.": {"in_response_to": []}, "The Soviet Union and the United States.": {"in_response_to": [{"occurrence": 74, "text": "The Space Race was a 20th-century competition between what two Cold War rivals, for supremacy in spaceflight capability?", "signature": []}]}, "What is your question?": {"in_response_to": [{"occurrence": 147, "text": "Yes, I have a question.", "signature": []}]}, "Although never is often better than right now.": {"in_response_to": [{"occurrence": 145, "text": "Now is better than never.", "signature": []}]}, "Readability counts.": {"in_response_to": [{"occurrence": 146, "text": "Sparse is better than dense.", "signature": []}]}, "The Andromeda Galaxy.": {"in_response_to": [{"occurrence": 74, "text": "What is the name of the nearest major galaxy to the Milky Way?", "signature": []}]}, "Although practicality beats purity.": {"in_response_to": [{"occurrence": 146, "text": "Special cases aren't special enough to break the rules.", "signature": []}]}, "What are you then?": {"in_response_to": [{"occurrence": 147, "text": "Who? Who is but a form following the function of what", "signature": []}]}, "I can't read.": {"in_response_to": [{"occurrence": 147, "text": "What is your favorite book?", "signature": []}]}, "I use Python quite a bit myself.": {"in_response_to": [{"occurrence": 145, "text": "I use Python, Java and C++ quite often.", "signature": []}]}, "Are you a programmer?": {"in_response_to": []}, "How do you do?": {"in_response_to": []}, "Yes I am.": {"in_response_to": [{"occurrence": 146, "text": "Are you a robot?", "signature": []}]}, "I like seeing movies.": {"in_response_to": [{"occurrence": 147, "text": "It's not your powers of observation I doubt, but merely the paradoxical nature of asking a masked man who is. But tell me, do you like music?", "signature": []}]}, "I am doing well.": {"in_response_to": [{"occurrence": 147, "text": "How are you doing?", "signature": []}]}, "No problem": {"in_response_to": [{"occurrence": 147, "text": "Thank you anyway", "signature": []}]}, "Blue": {"in_response_to": [{"occurrence": 147, "text": "So what's your favorite color?", "signature": []}]}, "well": {"in_response_to": [{"text": "How do you work?", "in_response_to": [{"occurrence": 16, "text": "What is it that you want to know?", "signature": []}]}]}, "What do you want to know?": {"in_response_to": [{"occurrence": 146, "text": "Tell me about your self.", "signature": []}]}, "It means you only live once. Where did you hear that?": {"in_response_to": [{"occurrence": 145, "text": "What does YOLO mean?", "signature": []}]}} -------------------------------------------------------------------------------- /flask_chatbot/flask_chatbot.py: -------------------------------------------------------------------------------- 1 | from app import create_app, socketio 2 | 3 | app = create_app(debug=True) 4 | 5 | if __name__ == '__main__': 6 | socketio.run(app) 7 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Tested with Python 3 2 | 3 | I don't know if the wit.ai still works or not, 4 | this project is actually to learn webscoket. 5 | 6 | **quickstart** 7 | 8 | Create your virtual environment using whatever you want 9 | 10 | ``` 11 | pip install -r requirements.txt 12 | ``` 13 | 14 | ``` 15 | python -m textblob.download_corpora 16 | ``` 17 | 18 | ``` 19 | cd flask_chatbot 20 | python flask_chatbot.py 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | ChatterBot==0.3.6 2 | cookies==2.2.1 3 | eventlet==0.18.4 4 | Flask==0.10.1 5 | Flask-SocketIO==2.2 6 | future==0.15.2 7 | fuzzywuzzy==0.10.0 8 | greenlet==0.4.9 9 | itsdangerous==0.24 10 | Jinja2==2.8 11 | jsondatabase==0.1.1 12 | MarkupSafe==0.23 13 | nltk==3.2.1 14 | oauthlib==1.0.3 15 | pymongo==3.2.2 16 | python-engineio==0.9.0 17 | python-forecastio==1.3.4 18 | python-Levenshtein==0.12.0 19 | python-socketio==1.2 20 | python-twitter==3.0rc1 21 | requests==2.9.1 22 | requests-oauthlib==0.6.1 23 | responses==0.5.1 24 | six==1.10.0 25 | textblob==0.11.1 26 | Werkzeug==0.11.8 27 | wit==3.4.0 28 | --------------------------------------------------------------------------------