From 691c3fe5076c1ad0acb13a613d072bdf56f6d96d Mon Sep 17 00:00:00 2001 From: VittalKumar23 <109903004+VittalKumar23@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:28:04 +0530 Subject: [PATCH] Update Chatbot.py --- Programs/Chatbot.py | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/Programs/Chatbot.py b/Programs/Chatbot.py index 7c35e98..145cd27 100644 --- a/Programs/Chatbot.py +++ b/Programs/Chatbot.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import nltk +'''import nltk from nltk.chat.util import Chat, reflections reflections = { @@ -138,8 +138,40 @@ def chat(): print("Hi! I am Y2K..") chat = Chat(pairs, reflections) - chat.converse() #initiate the conversation if __name__ == "__main__": - chat() \ No newline at end of file + chat() +''' + +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 ?|your name|name please", + ["I am Y2K. You can call me a chatbot!",] + ], + [ + r"how are you ?|how you doing|what about you|how about you ?", + ["I'm doing well. How can I assist you?",] + ], + # Add more patterns and responses here +] + +def chat(): + print("Hi! I am Y2K..") + chat = Chat(pairs, reflections) + chat.converse() + +# Initiate the conversation +if _name_ == "_main_": + chat()