|
| 1 | +# Predefined patterns and responses for the chatbot |
| 2 | + |
| 3 | +patterns = [ |
| 4 | + # Greetings |
| 5 | + (r'hi|hello|hey', ['Hello!', 'Hi!', 'Hey!', 'Hi there!']), |
| 6 | + (r'how are you?', ['I am good, thank you!', 'I am doing well!', 'All good!', 'I\'m fine, thanks!']), |
| 7 | + (r'what is your name?', ['You can call me Chatbot.', 'I am Chatbot!', 'My name is Chatbot.']), |
| 8 | + (r'bye|goodbye', ['Goodbye!', 'See you later!', 'Bye!', 'Have a great day!']), |
| 9 | + |
| 10 | + # Jokes |
| 11 | + (r'tell me a joke', ['Why don’t scientists trust atoms? Because they make up everything!', |
| 12 | + 'Parallel lines have so much in common. It’s a shame they’ll never meet.', |
| 13 | + 'Why did the scarecrow win an award? Because he was outstanding in his field!']), |
| 14 | + |
| 15 | + # Age |
| 16 | + (r'how old are you?', ['I am a computer program, so I don\'t have an age!', |
| 17 | + 'Age is just a number, and I don\'t have one!']), |
| 18 | + |
| 19 | + # Creator |
| 20 | + (r'who created you?', ['I was created by OpenAI.', 'My creators are from OpenAI.']), |
| 21 | + |
| 22 | + # Compliments |
| 23 | + (r'(.*) (like|love) you', ["Aw, that's so sweet!", "Thank you! I really appreciate it."]), |
| 24 | + (r'you are (.*)(good|awesome|amazing)', ["Thank you! I'm here to assist you.", "I'm glad you think so!"]), |
| 25 | + |
| 26 | + # Weather |
| 27 | + (r'(.*) (weather|temperature) today', ["I'm sorry, I am just a chatbot and don't have access to real-time data.", |
| 28 | + "You can check the weather online or through a weather app."]), |
| 29 | + |
| 30 | + # Recommendations |
| 31 | + (r'(.*) (movie|book) (recommendation|recommend)', ["I recommend you watch 'The Shawshank Redemption' or read 'To Kill a Mockingbird'.", |
| 32 | + "You might enjoy 'Inception' or 'The Great Gatsby'.", |
| 33 | + "If you like action, 'The Dark Knight' is a great choice."]), |
| 34 | + |
| 35 | + # How to create/build something |
| 36 | + (r'how (can|do) (I|you) (create|build) (a|an) (.*)', ["To create {4}, you can follow these steps...", |
| 37 | + "Building {4} requires some technical knowledge, but here are the basics...", |
| 38 | + "Sure! Here's a basic guide on building {4}..."]), |
| 39 | + |
| 40 | + # User intentions |
| 41 | + (r'I (want|need) (.*)', ["Why do you need {1}?", "What would you do with {1}?"]), |
| 42 | + (r'I am (feeling|looking) (.*)', ["Why are you feeling {1}?", "Tell me more about why you are {1}."]), |
| 43 | + |
| 44 | + # More patterns and responses to handle different queries |
| 45 | + # Add more patterns and responses here to make the chatbot more engaging and diverse |
| 46 | + |
| 47 | + # Default response |
| 48 | + (r'.*', ["I'm sorry, I don't quite understand. Could you please rephrase that?", |
| 49 | + "I'm still learning, and I'm not sure how to respond to that.", |
| 50 | + "Let's talk about something else. What else would you like to know?"]), |
| 51 | +] |
0 commit comments