Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Mar 25, 2021
Embed
What would you like to do?
#Pairs is a list of patterns and responses.
pairs = [
[
r"(.*)my name is (.*)",
["Hello %2, How are you today ?",]
],
[
r"(.*)help(.*) ",
["I can help you ",]
],
[
r"(.*) your name ?",
["My name is thecleverprogrammer, but you can just call me robot and I'm a chatbot .",]
],
[
r"how are you (.*) ?",
["I'm doing very well", "i am great !"]
],
[
r"sorry (.*)",
["Its alright","Its OK, never mind that",]
],
[
r"i'm (.*) (good|well|okay|ok)",
["Nice to hear that","Alright, great !",]
],
[
r"(hi|hey|hello|hola|holla)(.*)",
["Hello", "Hey there",]
],
[
r"what (.*) want ?",
["Make me an offer I can't refuse",]
],
[
r"(.*)created(.*)",
["Aman Kharwal created me using Python's NLTK library ","top secret ;)",]
],
[
r"(.*) (location|city) ?",
['New Delhi, India',]
],
[
r"(.*)raining in (.*)",
["No rain in the past 4 days here in %2","In %2 there is a 50% chance of rain",]
],
[
r"how (.*) health (.*)",
["Health is very important, but I am a computer, so I don't need to worry about my health ",]
],
[
r"(.*)(sports|game|sport)(.*)",
["I'm a very big fan of Cricket",]
],
[
r"who (.*) (Cricketer|Batsman)?",
["Virat Kohli"]
],
[
r"quit",
["Bye for now. See you soon :) ","It was nice talking to you. See you soon :)"]
],
[
r"(.*)",
['That is nice to hear']
],
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment