1. Learn
  2. /
  3. Courses
  4. /
  5. Building Chatbots in Python

Connected

Exercise

Intent classification with regex II

With your patterns dictionary created, it's now time to define a function to find the intent of a message.

Instructions

100 XP
  • Iterate over the intents and patterns in the patterns dictionary using its .items() method.
  • Use the .search() method of pattern to look for keywords in the message.
  • If there is a match, return the corresponding intent.
  • Call your match_intent() function inside respond() with message as the argument and then hit 'Submit Answer' to see how the bot responds to the provided messages.