🔍 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
almatchesalohaandalcohol, but notbanal.
- Sample
-
A multiple-choice sample provides alternate options and is expanded into individual matches.
Example:
- Sample
Alibaba/Aladdinmatches bothAlibabaandAladdin.
- Sample
Handling Multiple Matches
When there are multiple matches for a given entity type:
-
Wrapper Handling:
- If the entity has a wrapper, it determines which match to keep.
-
First Match Preference:
- If no wrapper is used, the first match in the message is kept.
Example:
- If the sample is
Aland the message is "Alibaba and Aladdin," both match, butAlibabais chosen since it appears first.
-
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(forAladdin) andAlice, then both matchAlice.
Solution:
- Use
-to exclude specific matches. For instance, useAl -Aliceto matchAladdinand excludeAlice.
Caution
If someone says "I want Aladdin, not Alice," you might still match
Alice. - If two samples start at the same position, conflicts arise. For example, if the entity type has samples
Syntax Recap
- " / ": Separate multiple-choice options (e.g.,
Alibaba/Aladdin) - " - ": Exclude specific matches (e.g.,
Al -Alice) - " [ ] ": Enclose exact expressions (e.g.,
[Hello World])
