natural language toolkit zen chatbot c 20012023 nltk project amy holland amyrhcsse unimelb edu au url https www nltk org for license information see license txt zen chatbot talks in gems of zen wisdom this is a sample conversation with zen chatbot zc welcome my child me good afternoon zc ask the question you have come to ask me how can i achieve enlightenment zc how do you suppose me through meditation zc form is emptiness and emptiness form me how can i empty my mind of worldly troubles zc will an answer to that really help in your search for enlightenment me yes zc it is better to be right than to be certain me i seek truth and wisdom zc the search for truth is a long journey me are you sure zc maybe sure maybe not sure the chatbot structure is based on that of chat eliza thus it uses a translation table to convert from question to response i e i am you are of course since zen chatbot does not understand the meaning of any words responses are very limited zen chatbot will usually answer very vaguely or respond to a question by asking a different question in much the same way as eliza responses are matched top to bottom so nonspecific matches occur later for each match a list of possible responses is provided zen chatbot opens with the line welcome my child the usual response will be a greeting problem good matches good morning good day etc but also good grief and other sentences starting with the word good that may not be a greeting i need and i want can be followed by a thing eg help or an action eg to see you this is a problem with this style of response person i need you chatbot me can be achieved by hard work and dedication of the mind i e you is not really a thing that can be mapped this way so this interpretation only makes sense for some inputs why questions are separated into three types why i e g why am i here why do i like cake why you e g why are you here why won t you tell me why e g why is the sky blue problems person why can t you tell me chatbot are you sure i tell you this style works for positives e g why do you like cake but does not work for negatives e g why don t you like cake e g are you listening are you a duck e g am i a duck am i going to die what questions e g what time is it problems person what do you want chatbot seek truth not what do me want how questions e g how do you do can questions e g can you run can you come over here please can questions e g can i have some cake can i know truth e g it is raining implies the speaker is certain of a fact e g is there a doctor in the house e g is it possible is this true nonspecific question expression of hate of form i hate you or kelly hates cheese statement containing the word truth desire to do an action e g i want to go shopping desire for an object e g i want a pony e g i can t wait or i can t do this i think indicates uncertainty e g i think so problem exceptions e g i think therefore i am i feel emotionssicklightheaded exclaimation mark indicating emotion e g wow or no because statement e g because i said so yes or no raise an issue of certaintycorrectness sentence containing word love sentence containing word understand r i me my person is talking about themself this breaks down when words contain these eg thyme irish you starting a sentence e g you stink say goodbye with some extra zen wisdom fall through case when stumped respond with generic zen wisdom natural language toolkit zen chatbot c 2001 2023 nltk project amy holland amyrh csse unimelb edu au url https www nltk org for license information see license txt zen chatbot talks in gems of zen wisdom this is a sample conversation with zen chatbot zc welcome my child me good afternoon zc ask the question you have come to ask me how can i achieve enlightenment zc how do you suppose me through meditation zc form is emptiness and emptiness form me how can i empty my mind of worldly troubles zc will an answer to that really help in your search for enlightenment me yes zc it is better to be right than to be certain me i seek truth and wisdom zc the search for truth is a long journey me are you sure zc maybe sure maybe not sure the chatbot structure is based on that of chat eliza thus it uses a translation table to convert from question to response i e i am you are of course since zen chatbot does not understand the meaning of any words responses are very limited zen chatbot will usually answer very vaguely or respond to a question by asking a different question in much the same way as eliza responses are matched top to bottom so non specific matches occur later for each match a list of possible responses is provided zen chatbot opens with the line welcome my child the usual response will be a greeting problem good matches good morning good day etc but also good grief and other sentences starting with the word good that may not be a greeting i need and i want can be followed by a thing eg help or an action eg to see you this is a problem with this style of response person i need you chatbot me can be achieved by hard work and dedication of the mind i e you is not really a thing that can be mapped this way so this interpretation only makes sense for some inputs why questions are separated into three types why i e g why am i here why do i like cake why you e g why are you here why won t you tell me why e g why is the sky blue problems person why can t you tell me chatbot are you sure i tell you this style works for positives e g why do you like cake but does not work for negatives e g why don t you like cake e g are you listening are you a duck e g am i a duck am i going to die what questions e g what time is it problems person what do you want chatbot seek truth not what do me want how questions e g how do you do can questions e g can you run can you come over here please can questions e g can i have some cake can i know truth e g it is raining implies the speaker is certain of a fact e g is there a doctor in the house e g is it possible is this true non specific question expression of hate of form i hate you or kelly hates cheese statement containing the word truth desire to do an action e g i want to go shopping desire for an object e g i want a pony e g i can t wait or i can t do this i think indicates uncertainty e g i think so problem exceptions e g i think therefore i am i feel emotions sick light headed exclaimation mark indicating emotion e g wow or no because statement e g because i said so yes or no raise an issue of certainty correctness sentence containing word love sentence containing word understand r i me my person is talking about themself this breaks down when words contain these eg thyme irish you starting a sentence e g you stink say goodbye with some extra zen wisdom fall through case when stumped respond with generic zen wisdom
from nltk.chat.util import Chat, reflections



responses = (
    
    
    
    
    (
        r"(hello(.*))|(good [a-zA-Z]+)",
        (
            "The path to enlightenment is often difficult to see.",
            "Greetings. I sense your mind is troubled. Tell me of your troubles.",
            "Ask the question you have come to ask.",
            "Hello. Do you seek englightenment?",
        ),
    ),
    
    
    
    
    
    
    
    
    
    (
        r"i need (.*)",
        (
            "%1 can be achieved by hard work and dedication of the mind.",
            "%1 is not a need, but a desire of the mind. Clear your mind of such concerns.",
            "Focus your mind on%1, and you will find what you need.",
        ),
    ),
    (
        r"i want (.*)",
        (
            "Desires of the heart will distract you from the path to enlightenment.",
            "Will%1 help you attain enlightenment?",
            "Is%1 a desire of the mind, or of the heart?",
        ),
    ),
    
    
    
    
    
    
    
    
    
    (r"why (.*) i (.*)\?", ("You%1%2?", "Perhaps you only think you%1%2")),
    (r"why (.*) you(.*)\?", ("Why%1 you%2?", "%2 I%1", "Are you sure I%2?")),
    (r"why (.*)\?", ("I cannot tell you why%1.", "Why do you think %1?")),
    
    (
        r"are you (.*)\?",
        ("Maybe%1, maybe not%1.", "Whether I am%1 or not is God's business."),
    ),
    
    (
        r"am i (.*)\?",
        ("Perhaps%1, perhaps not%1.", "Whether you are%1 or not is not for me to say."),
    ),
    
    
    
    
    (r"what (.*)\?", ("Seek truth, not what%1.", "What%1 should not concern you.")),
    
    (
        r"how (.*)\?",
        (
            "How do you suppose?",
            "Will an answer to that really help in your search for enlightenment?",
            "Ask yourself not how, but why.",
        ),
    ),
    
    (
        r"can you (.*)\?",
        (
            "I probably can, but I may not.",
            "Maybe I can%1, and maybe I cannot.",
            "I can do all, and I can do nothing.",
        ),
    ),
    
    (
        r"can i (.*)\?",
        (
            "You can%1 if you believe you can%1, and have a pure spirit.",
            "Seek truth and you will know if you can%1.",
        ),
    ),
    
    (
        r"it is (.*)",
        (
            "How can you be certain that%1, when you do not even know yourself?",
            "Whether it is%1 or not does not change the way the world is.",
        ),
    ),
    
    (
        r"is there (.*)\?",
        ("There is%1 if you believe there is.", "It is possible that there is%1."),
    ),
    
    (r"is(.*)\?", ("%1 is not relevant.", "Does this matter?")),
    
    (
        r"(.*)\?",
        (
            "Do you think %1?",
            "You seek the truth. Does the truth seek you?",
            "If you intentionally pursue the answers to your questions, the answers become hard to see.",
            "The answer to your question cannot be told. It must be experienced.",
        ),
    ),
    
    (
        r"(.*) (hate[s]?)|(dislike[s]?)|(don\'t like)(.*)",
        (
            "Perhaps it is not about hating %2, but about hate from within.",
            "Weeds only grow when we dislike them",
            "Hate is a very strong emotion.",
        ),
    ),
    
    (
        r"(.*) truth(.*)",
        (
            "Seek truth, and truth will seek you.",
            "Remember, it is not the spoon which bends - only yourself.",
            "The search for truth is a long journey.",
        ),
    ),
    
    
    (
        r"i want to (.*)",
        ("You may %1 if your heart truly desires to.", "You may have to %1."),
    ),
    
    
    (
        r"i want (.*)",
        (
            "Does your heart truly desire %1?",
            "Is this a desire of the heart, or of the mind?",
        ),
    ),
    
    (
        r"i can\'t (.*)",
        (
            "What we can and can't do is a limitation of the mind.",
            "There are limitations of the body, and limitations of the mind.",
            "Have you tried to%1 with a clear mind?",
        ),
    ),
    
    
    
    (
        r"i think (.*)",
        (
            "Uncertainty in an uncertain world.",
            "Indeed, how can we be certain of anything in such uncertain times.",
            "Are you not, in fact, certain that%1?",
        ),
    ),
    
    (
        r"i feel (.*)",
        (
            "Your body and your emotions are both symptoms of your mind."
            "What do you believe is the root of such feelings?",
            "Feeling%1 can be a sign of your state-of-mind.",
        ),
    ),
    
    
    (
        r"(.*)!",
        (
            "I sense that you are feeling emotional today.",
            "You need to calm your emotions.",
        ),
    ),
    
    
    (
        r"because (.*)",
        (
            "Does knowning the reasons behind things help you to understand"
            " the things themselves?",
            "If%1, what else must be true?",
        ),
    ),
    
    (
        r"(yes)|(no)",
        (
            "Is there certainty in an uncertain world?",
            "It is better to be right than to be certain.",
        ),
    ),
    
    (
        r"(.*)love(.*)",
        (
            "Think of the trees: they let the birds perch and fly with no intention to call them when they come, and no longing for their return when they fly away. Let your heart be like the trees.",
            "Free love!",
        ),
    ),
    
    (
        r"(.*)understand(.*)",
        (
            "If you understand, things are just as they are;"
            " if you do not understand, things are just as they are.",
            "Imagination is more important than knowledge.",
        ),
    ),
    
    
    (
        r"(.*)(me )|( me)|(my)|(mine)|(i)(.*)",
        (
            "'I', 'me', 'my'... these are selfish expressions.",
            "Have you ever considered that you might be a selfish person?",
            "Try to consider others, not just yourself.",
            "Think not just of yourself, but of others.",
        ),
    ),
    
    
    (
        r"you (.*)",
        ("My path is not of concern to you.", "I am but one, and you but one more."),
    ),
    
    (
        r"exit",
        (
            "Farewell. The obstacle is the path.",
            "Farewell. Life is a journey, not a destination.",
            "Good bye. We are cups, constantly and quietly being filled."
            "\nThe trick is knowning how to tip ourselves over and let the beautiful stuff out.",
        ),
    ),
    
    
    
    (
        r"(.*)",
        (
            "When you're enlightened, every word is wisdom.",
            "Random talk is useless.",
            "The reverse side also has a reverse side.",
            "Form is emptiness, and emptiness is form.",
            "I pour out a cup of water. Is the cup empty?",
        ),
    ),
)

zen_chatbot = Chat(responses, reflections)


def zen_chat():
    print("*" * 75)
    print("Zen Chatbot!".center(75))
    print("*" * 75)
    print('"Look beyond mere words and letters - look into your mind"'.center(75))
    print("* Talk your way to truth with Zen Chatbot.")
    print("* Type 'quit' when you have had enough.")
    print("*" * 75)
    print("Welcome, my child.")

    zen_chatbot.converse()


def demo():
    zen_chat()


if __name__ == "__main__":
    demo()