File: template_syntax.md

package info (click to toggle)
hassil 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 536 kB
  • sloc: python: 6,474; makefile: 2
file content (64 lines) | stat: -rw-r--r-- 1,754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Template Syntax

hassil's template syntax compactly represents large numbers of sentences for the purpose of intent recognition. It borrows inspiration from [Rhasspy's template language][rhasspy], which itself borrows from [JSGF][].

## Reserved Characters

The following characters are reserved for special syntax: `()[]{}<>|@`
These characters can be escaped with a backslash: `\`

Everything else (except whitespace) is matched literally, so it is not advised to have punctuation in your sentence templates.

## Optionals

Template block that may be omitted, surrounded by `[]`
Example: `[the]`

An optional `[x]` is equivalent to the alternative `(x|)`

## Alternatives

Example: `(red|green|blue)`

Template blocks separated by `|` and surrounded by `()` or `[]`
Blocks surrounded by `()` are required while `[]` is optional.

## Permutations

Example: `(TV; pause)`

Template blocks separated by `;` and surrounded by `()`
All possible orderings of the blocks are considered.

## Lists

Example: `{list_name}`

Reference to a pre-defined list. The matched list value will be copied to an entity with the same name as the list.

### Slot Name

Example: `{list_name:slot_name}`

Copies the matched list value to a differently named slot.

### Captures

Example: `{list_name:@capture_name}`

Copies the matched list text to a "capture", which is intended for use in the response (not a slot).

Example `{@list_name}`

Compact syntax equivalent to `{list_name:@list_name}`

## Expansion Rules

Example: `<rule_name>`

Reference to a named template block that is substituted in place of the reference.
Rules cannot reference themselves.

<!-- Links -->
[JSGF]: https://www.w3.org/TR/jsgf/
[rhasspy]: https://rhasspy.readthedocs.io/en/latest/training/