Last active
December 17, 2018 11:41
-
-
Save makmac213/2939c1e4898fe82aaa1ebe1d7f5032a2 to your computer and use it in GitHub Desktop.
hugotbot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nltk.chat.util import Chat, reflections | |
pairs = [ | |
[ | |
r"My name is (.*)", | |
['hello %1', '%1 mabuhay ka'], | |
], | |
[ | |
r'hi', | |
['hello', 'kamusta', 'mabuhay',], | |
], | |
[ | |
r'(.*) (hungry|sleepy|groot)', | |
[ | |
"%1 %2" | |
] | |
], | |
[ | |
r'(.*)(mahal|love)(.*)', | |
[ | |
"https://goo.gl/ndTZVq", | |
"I always thought Love was a static class until you made an instance of it.", | |
"I love user interfaces it's because that's where U and I are always together.", | |
], | |
], | |
[ | |
r'(.*)(relationship)(.*)', | |
[ | |
"Mabuti pa sa database may relationship. Eh tayo, wala.", | |
], | |
], | |
[ | |
r'(meron|mayron|ano|does|is there|what) (.*) (forever)(.*)', | |
[ | |
"Loading...", | |
"None", | |
"while True: pass", | |
], | |
], | |
[ | |
r'(.*)', # default response if no patterns from above is found | |
[ | |
"http://lmgtfy.com/?q=%1", | |
"Sorry I don't know what `%1` is?", | |
], | |
], | |
] | |
def hugot_bot(): | |
print("Hi what's your name?") | |
chat = Chat(pairs, reflections) | |
chat.converse() | |
if __name__ == "__main__": | |
hugot_bot() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment