Skip to main content

Named Patterns

tip
Named pattern — part of the pattern, separated into a separate entity, which can be used several times.

Allocated in the named patterns of the rules on a semantic basis. For example:

  • synonyms;
  • various spellings of expressions, united by one meaning and occurring in a certain position in similar sentences.

How to use

The list of named patterns is declared in the patterns tag in the .sc-file. And represents the structure:

patterns:
$<pattern name> = (pattern body | multiline body)
$<pattern name> = (pattern body) || converter=nameConverter

Each nested element of the patterns tag is treated as a definition of a new named pattern. $ is used to declare and access the named pattern.

After the = sign, the value of the multiline string type is specified with the optional converter attribute having the string type.

caution

If a pattern is created with $entity<> and converter, its name must not match the name of an NLU core entity. For example, if a project has an $Example pattern and an Example entity, it might cause errors during the script execution.

Like patterns, named patterns can be specified using basic and extended elements:

patterns:
$mistake = (mistake*|rewrite* * answer|retype)
$roamingRegion = $entity<RoamingRegions>