-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatbot.py
41 lines (28 loc) · 1007 Bytes
/
chatbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Importing required libraries
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from flask import Flask, render_template, request
app =Flask(__name__)
bot = ChatBot("chatbot", read_only=False,
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'Sorry, I don\'t have any response for that.',
'maximum_similarity_threshold': 0.9
}
]
)
trainer =ChatterBotCorpusTrainer(bot)
trainer.train('chatterbot.corpus.english')
@app.route("/")
def main():
return render_template("index.html")
#while True:
#user_response =input("User:")
#print("ChatBot:"+ str (bot.get_response(user_response)))
@app.route("/get")
def get_chatbot_response():
userText = request.args.get('userMessage')
return str (bot.get_response(userText))
if __name__=="__main__":
app.run(debug=True)