Skip to content

Instantly share code, notes, and snippets.

@makmac213
Last active December 17, 2018 11:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save makmac213/2939c1e4898fe82aaa1ebe1d7f5032a2 to your computer and use it in GitHub Desktop.
Save makmac213/2939c1e4898fe82aaa1ebe1d7f5032a2 to your computer and use it in GitHub Desktop.
hugotbot.py
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