Rules

Rules are what will determine a text can be categorized into a category. In other words, they define a category's categorization criteria and as such, they are something we are always going to need to define for a specific category.

As we've seen before, we can create a rule directly from the category editing view.

Rules view

These are the fields available:

  • Label: The name of the rule. It is useful to make the rule easy to locate.
  • Definition: The rule itself. The language to create it will be described in the rules syntax section.
  • Priority: The order in which rules are executed. Lowest priorities are run first, and high priorities last, so those that determine the behavior are the rules with a high priority.
  • Weight: The influence we set for each rule. There are three different options:
    • Exclude category: To exclude a category from the results. So, if this rule is triggered for a text, its category won't appear in the output.
    • Always include category: When this rule is triggered, the category will be automatically included in the results for the text analyzed.
    • Specify weight: We can specify a concrete weight for each rule. It is expressed with a number. The weight of each rule will be added to calculate the minimum absolute relevance.
  • Comments: With the behavior settings defined for the model.

Important

Rules designed to exclude a category from the classification should always have a high priority. That way the rule will be run last, ensuring that the category is really excluded from the results.

When a text is categorized, the results will consist of categories ordered by absolute relevance, which in turn is obtained from the weight of the rules triggered for that category.

This is what you will see when you add a rule with "my-first-rule" as label:

Rules view

For each rule created you will see a small summary of its contents: the definition and both the priority and weight. Also, if the rule is currently activated.

In the first column of the table there are two actions associated to the category:

  • , to access the editing in the rule view and modify the rule.
  • , to delete the rule and all its contents from the category.

All the rules created for a category will be shown in the table within the edit category view. The table will show all the fields of the rule; you will be able to select how many rules are visible per page, order them by any of the columns and filter them dynamically by text appearance.

Edit rules

To modify any field defining a rule, you will have to access its editing view. From there, you can modify any of its attributes.

Edit category

Most of the fields in this view are the same as the ones we've seen for the rule creation. The only additional fields are the ID and the active checkbox. The ID is an alphanumeric ID that identifies the entry univocally. It's composed by 32 characters, and it's generated automatically when the rule is created and cannot be edited. The active checkbox allows to activate/deactivate the rule to see its effect on the categorization. By default, every rule is active on creation.