Tag by rule is an operation to tag values in the selected field based on the defined keyword-based boolean criteria.
Step-by-step guide
1. Open the operation configuration window
Select the text field you want to tag and click the "Add operation" button at the top of the workspace.
Search for "Tag by rule" or find the operation under "Text enrichment" and click on it.
2. Add a tag by defining a rule
The tag by rule operation enables you to create custom tags based on your specified requirements. Define rules by using AND & OR reserved keywords, where you can also add parentheses for more complex conditions. Keywords for rules support a usual string or regex (regular expression) without a space. Since the keywords cannot include space, a particular expression gets defined for this usage. By adding “\s” to your keywords, you can also tag phrases at a time. Moreover, you can add many keywords to your rules, and the operation is case insensitive. By clicking the left-bottom “+” button, you can add additional tags and rules, or by clicking the top-right “x” button, you can remove the previously assigned tags and rules.
Some examples to describe rule-field syntax:
Tag1: positive
Rule1: beautiful AND great
Explanation: Add a “positive” tag to all texts containing “beautiful” and “great” keywords.
Tag2: satisfaction
Rule2: fine OR nice
Explanation: Add a “satisfaction” tag to all texts containing “fine” or “nice” keywords.
Tag3: supportive
Rule3: “good\sidea”
Explanation: Add a “supportive” tag to all texts containing the “good idea” phrase
Tag4: supportive
Rule4: “good\sidea”
Explanation: Add a “supportive” tag to all texts containing the “good idea” phrase
Tag5: hasEmail
Rule5: “[A-Za-z]*@.*.com”
Explanation: Add “hasEmail” tag to all texts containing letters followed by @ sign, any sequence of characters followed by .com. Please note that this email regex is not the perfect email regex to capture all the different types of emails, and it’s used here just as an example.
For more information on regular expressions, we suggest taking a look here.
3. Name the output field
Under "Output field name,” type the name of the output field. The output will be a tag collection containing matched tags for each text.
4. Apply the operation
Click "Apply" to run the operation. As a result, the Tags field is created, which is visible on the Schema. You can view the matched tags according to the defined rules on Table View.