πŸ” Rule-Based Syntax for Intents and Entities

Rule-based syntax is a simple, word-matching approach to triggering an intent or entity without relying on an NLP model.

Matching Basics

  • A sample matches any word that begins with the same characters as the sample.

    Example:

    • Sample al matches aloha and alcohol, but not banal.
  • A multiple-choice sample provides alternate options and is expanded into individual matches.

    Example:

    • Sample Alibaba/Aladdin matches both Alibaba and Aladdin.

Handling Multiple Matches

When there are multiple matches for a given entity type:

  1. Wrapper Handling:

    • If the entity has a wrapper, it determines which match to keep.
  2. First Match Preference:

    • If no wrapper is used, the first match in the message is kept.

    Example:

    • If the sample is Al and the message is "Alibaba and Aladdin," both match, but Alibaba is chosen since it appears first.
  3. Matches Starting at the Same Position:

    • If two samples start at the same position, conflicts arise. For example, if the entity type has samples Al (for Aladdin) and Alice, then both match Alice.

    Solution:

    • Use - to exclude specific matches. For instance, use Al -Alice to match Aladdin and exclude Alice.

    ❗️

    Caution

    If someone says "I want Aladdin, not Alice," you might still match Alice.

Syntax Recap

  • " / ": Separate multiple-choice options (e.g., Alibaba/Aladdin)
  • " - ": Exclude specific matches (e.g., Al -Alice)
  • " [ ] ": Enclose exact expressions (e.g., [Hello World])