The rule engine

When adding an article, the rule engine will be activated and apply the rules ordered by priority. At the first validated rule, the article is placed in the target category. If no rules match then the article will not have a category.

To manage the rules, go tothe configuration screen:

Click on the Add rule button to add a rule:

A rule is:

  • An alias (its visual identifier)
  • A priority (its order of execution)
  • A definition
  • And a target category

The definition of a rule

The definition of a rule is a pseudo code whose result must be true or false.

Within the rule it is possible to refer to some attributes:

  • title: article title
  • text: article text content
  • url: article source URL
  • tags: article input tags
  • key: alias of the used API key

Syntax

Operators

  • == (equal)
  • != (non equal)
  • matches (validate a regular expression)
  • not ("foo" matches "bar") (does not validate a regular expression)

Logical operators

  • not or !
  • and or &&
  • or or ||

Other operators

  • ~ (concatenation) Example: 'Harry' ~ ' ' ~ 'Potter' will be Harry Potter
  • in
  • not in Example: key in ["test", "bookmarklet"]

Functions

  • len (length of the character string) Example: len(text) >= 100

Examples:

Classify articles whose API key is “foo”:

key == "foo"

Classify articles with API key “foo” or “bar”:

key == "foo" || key == "bar"
// Peut aussi s'écrire:
key in ["foo", "bar"]

Classify articles with “foo” as tag:

"foo" in tags

Classify articles with titles containing “Amazon” and “Alexa”:

title matches "Amazon" and title matches "Alexa"

Classify items that come from CNN:

url matches "^https://edition.cnn.com"