import nltk
from nltk.chat.util import Chat, reflections
pairs = [
[
r"my name is (.*)",
["Hello %1, How are you today ?",]
],
[
r"hi|hey|hello",
["Hello", "Hey there",]
],
[
r"what is your name ?",
["I am a chatbot created by Bing.",]
],
[
r"how are you ?",
["I'm doing good. How about You ?",]
],
[
r"sorry (.*)",
["Its alright", "Its OK, never mind",]
],
[
r"bye",
["Bye take care. See you soon :) ", "It was nice talking to you :)"]
],
]
defchatbot():
print("Hi, I'm a chatbot created by Bing. What can I do for you today?")
chat = Chat(pairs, reflections)
chat.converse()
if __name__ == "__main__":
chatbot()