-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatb.py
83 lines (63 loc) · 1.77 KB
/
chatb.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from tkinter import *
chatbot=ChatBot('Jarvis')
conversation=[
"hello",
"hi there",
"what is your name",
"my name is bot "
"how are you",
"i am fine",
"How are you",
"What are you doing",
"thank you",
"Hi, can i help you?",
"Sure, I'd like to book a flight to England.",
"Your flight has been booked.",
"what are you doing",
"nothing,what are you doing",
"in which language do you speak",
"i am speaking in english!!"
]
#trainer = ListTrainer(chatbot)
trainer = ListTrainer(chatbot)
trainer.train(conversation)
print("talk to bot ")
while True:
query=input("you ")
if query=='exit':
break
answer=chatbot.get_response(query)
print("jarvis :",answer)
main = Tk()
main.geometry("600x750")
main.title("navneet chatbot")
img = PhotoImage(file="chat3.png")
PhotoL = Label(main ,image=img)
PhotoL.pack(pady=5)
frame = Frame(main)
def lets_chatting_with_me():
query = textF.get()
answer_from_bot = chatbot.get_response(query)
msgs.insert(END, "you :" + query)
#print(type(answer_from_bot))
msgs.insert(END, "bot :",str(answer_from_bot))
#speak(answer_from_bot)
textF.delete(0 , END)
msgs.yview(END)
sc = Scrollbar(frame)
msgs = Listbox(frame , width=80,height=20, yscrollcommand=sc.set)
sc.pack(side=RIGHT , fill=Y)
msgs.pack(side=LEFT, fill=BOTH, pady=10)
frame.pack()
textF = Entry(main, font=("Verdana",20))
textF.pack(fill=X, pady=10)
btn = Button(main, text="Submit",font=("Verdana",20),command=lets_chatting_with_me)
btn.pack()
# creating a function
def enter_function(event):
btn.invoke()
# going to bind main window with enter key....
main.bind('<Return>',enter_function)
main.mainloop()