Debian Codegraph @

docs/template_syntax.md

raw
1 # Template Syntax
2
3 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][].
4
5 ## Reserved Characters
6
7 The following characters are reserved for special syntax: `()[]{}<>|@`
8 These characters can be escaped with a backslash: `\`
9
10 Everything else (except whitespace) is matched literally, so it is not advised to have punctuation in your sentence templates.
11
12 ## Optionals
13
14 Template block that may be omitted, surrounded by `[]`
15 Example: `[the]`
16
17 An optional `[x]` is equivalent to the alternative `(x|)`
18
19 ## Alternatives
20
21 Example: `(red|green|blue)`
22
23 Template blocks separated by `|` and surrounded by `()` or `[]`
24 Blocks surrounded by `()` are required while `[]` is optional.
25
26 ## Permutations
27
28 Example: `(TV; pause)`
29
30 Template blocks separated by `;` and surrounded by `()`
31 All possible orderings of the blocks are considered.
32
33 ## Lists
34
35 Example: `{list_name}`
36
37 Reference to a pre-defined list. The matched list value will be copied to an entity with the same name as the list.
38
39 ### Slot Name
40
41 Example: `{list_name:slot_name}`
42
43 Copies the matched list value to a differently named slot.
44
45 ### Captures
46
47 Example: `{list_name:@capture_name}`
48
49 Copies the matched list text to a "capture", which is intended for use in the response (not a slot).
50
51 Example `{@list_name}`
52
53 Compact syntax equivalent to `{list_name:@list_name}`
54
55 ## Expansion Rules
56
57 Example: `<rule_name>`
58
59 Reference to a named template block that is substituted in place of the reference.
60 Rules cannot reference themselves.
61
62 <!-- Links -->
63 [JSGF]: https://www.w3.org/TR/jsgf/
64 [rhasspy]: https://rhasspy.readthedocs.io/en/latest/training/