I'm wrote a basic chatterbot. What would you do to pretty much improve it and make it better than this?
Because I want this chatterbot to be the best it could be, and I really want other peoples' opinion of how they would improve it. Here is the code:
import tkinter as tk
# --- functions ---
def cmd3():
# default value at start
x = None
y = None
# remove previous text
label1['text'] = ""
label2['text'] = ""
text = text1.get()
if text == "":
label1['text'] = "Statement"
elif text == "Hello":
x = "Hello"
elif text == "Goodbye":
x = "Goodbye"
elif text == "Hi":
x = "Hello"
else:
label1['text'] = "Please enter a valid statement"
text = text2.get()
if text == "":
label2['text'] = "Question"
elif text == "How are You?":
y = "I'm going good"
elif text == "What is your name?":
y = "I'm Turing"
elif text == "When did your Creator start working on you?":
y = "In the year 2022"
elif text == "Do you like Star Wars?":
y = "Yes, I was actually inspired by the personallities from droids from Star Wars."
else:
label2['text'] = "please enter a valid question"
print(x, y)
if (x is not None) and (y is not None):
label_result['text'] = str(x + " " + y)
# --- main ---
new = tk.Tk()
label1 = tk.Label(new, text="", fg="red")
label1.pack()
text1 = tk.Entry(new, width="60")
text1.pack()
label2 = tk.Label(new, text="", fg="red")
label2.pack()
text2 = tk.Entry(new, width="60")
text2.pack()
btn3 = tk.Button(new, text="Enter", command=cmd3)
btn3.pack()
label_result = tk.Label(new, text="", fg="green")
label_result.pack()
new.mainloop()
