-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchatbot_ibrahim.py
52 lines (38 loc) · 1.19 KB
/
chatbot_ibrahim.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
52
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from flask import Flask, render_template, request
app = Flask(__name__)
chatbot = ChatBot(
'ibrahim',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
'chatterbot.logic.MathematicalEvaluation',
'chatterbot.logic.BestMatch',
],
database_uri='sqlite:///database.sqlite3'
)
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.english")
trainer.train("data/icorpus/bengali/")
trainer.train("data/icorpus/manual/")
@app.route("/")
def home():
return render_template("home.html")
@app.route("/get")
def get_bot_response():
userText = request.args.get('msg')
return str(chatbot.get_response(userText))
if __name__ == "__main__":
app.run()
print("\nHello I am Chatter\n")
while True:
try:
bot_input = input()
if bot_input.strip()=='Stop':
print('Chatter: Bye')
break
bot_response = chatbot.get_response(bot_input)
print(bot_response)
except(KeyboardInterrupt, EOFError, SystemExit):
break