-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
40 lines (33 loc) · 1.18 KB
/
app.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
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer
from funk import Covi
app = Flask(__name__)
steam_bot = ChatBot("Forsage",
storage_adapter="chatterbot.storage.SQLStorageAdapter",
logic_adapters = [
"chatterbot.logic.MathematicalEvaluation",
#"chatterbot.logic.TimeLogicAdapter",
"chatterbot.logic.BestMatch"
]
)
with open('tr-data.txt') as tr:
tr = tr.read().strip().split('\n')
traine = ListTrainer(steam_bot)
traine.train(tr)
#trainer.train(['who are you?', 'I\'m a BOT'])
trainer = ChatterBotCorpusTrainer(steam_bot)
trainer.train("chatterbot.corpus.english")#,
#"chatterbot.corpus.english.conversations")
@app.route("/")
def home():
return render_template("index.html")
@app.route("/get")
def get_bot_response():
userText = request.args.get('msg')
if Covi(userText):
return Covi(userText)
else:
return str(steam_bot.get_response(userText))
if __name__ == "__main__":
app.run()