31 | can only response to "what's the weather?" and "in {location}". Wit.ai must be trained manually.
32 |
33 |
34 |
Send:
35 |
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 |
--------------------------------------------------------------------------------