1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Building Chatbots in Python

Connected

Bài tập

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.

Hướng dẫn

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.