Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Chatbot.py #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions Programs/Chatbot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import nltk
'''import nltk
from nltk.chat.util import Chat, reflections

reflections = {
Expand Down Expand Up @@ -138,8 +138,40 @@
def chat():
print("Hi! I am Y2K..")
chat = Chat(pairs, reflections)
chat.converse()

#initiate the conversation
if __name__ == "__main__":
chat()
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()