-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (41 loc) · 1.81 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.response_selection import get_random_response
app = Flask(__name__)
Mini_Cortana = ChatBot(name="Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter",
response_selection_method=get_random_response,
logic_adapters=[
{
'import_path': 'chatterbot.logic.SpecificResponseAdapter',
'input_text': 'empty',
'output_text': ''
},
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I honestly have no idea how to respond to that.',
'maximum_similarity_threshold': 0.9
},
{
'import_path': 'chatterbot.logic.MathematicalEvaluation'
}
],
database="db.sqlite3"
)
trainer = ChatterBotCorpusTrainer(Mini_Cortana)
trainer.train("chatterbot.corpus.english")
trainer.train("data/data.yml")
@app.route("/")
def index():
return render_template("index.html") # to send context to html
@app.route("/get")
def get_bot_response():
userText = request.args.get("msg")
bot_msg = str(Mini_Cortana.get_response(userText))
return bot_msg
def run_Speech_Recognition():
userText = request.args.get("msg")
bot_msg = str(Mini_Cortana.get_response(userText))
return bot_msg
if __name__ == "__main__":
app.run(debug=True)