from nltk.chat import Chat, eliza pairs = (( r"I need (.*)", ( "Why do you need %1?", "Would it really help you to get %1?", "Are you sure you need %1?", ), ), ) reflections = { "i am": "you are", "i was": "you were", "i": "you", "i'm": "you are", "i'd": "you would", "i've": "you have", "i'll": "you will", "my": "your", "you are": "I am", "you were": "I was", "you've": "I have", "you'll": "I will", "your": "my", "yours": "mine", "you": "me", "me": "you", } eliza_chatbot = Chat(pairs, reflections) def eliza_chat(): print("Therapist\n---------") print("Talk to the program by typing in plain English, using normal upper-") print('and lower-case letters and punctuation. Enter "quit" when done.') print("=" * 72) print("Hello. How are you feeling today?") eliza_chatbot.converse()