-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
64 lines (52 loc) · 1.23 KB
/
bot.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
53
54
55
56
57
58
59
60
61
62
63
64
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from tkinter import *
bot=ChatBot("My Bot")
convo=[
'Hello',
'hi their !',
'what is your name',
'my name is Bot , i am created by lalit',
'how are you ?',
'i am doing great',
'Where are you from',
'I''m from Internet ?'
]
trainer=ListTrainer(bot)
#to train the bot
trainer.train(convo)
# print("talk to bot")
# while True:
# query= input()
# if query=="exit":
# break
# ans=bot.get_response(query)
# print(ans)
#GUI part
main=Tk()
main.geometry("500x650")
main.title("My chatBot")
#bot logo
img=PhotoImage("bot1.png")
photoL=Label(main,image=img)
photoL.pack(pady=5)
#frameBOT IMA
def ask_from_bot():
query=textF.get()
answer_from_bot=bot.get_response(query)
msg.insert(END,"You :"+query)
msg.insert(END,"BOT :"+str(answer_from_bot))
textF.delete(0,END)
frame=Frame(main)
sc=Scrollbar(frame)
#listbox
msg=Listbox(frame,width=80,height=20)
sc.pack(side=RIGHT,fill=Y)
msg.pack(side=LEFT,fill=BOTH,pady=10)
frame.pack()
#Creating textfill
textF=Entry(main,font=("Verdana",20))
textF.pack(fill=X,pady=10)
btn=Button(main,text="Ask From Bot",font=("Verdana",20),command=ask_from_bot)
btn.pack()
main.mainloop()