equals
Description
The equals operator (used with a given field name) lets you filter a grammar so that an entry can only be generated if the form in the given field is equal to a particular string or matches a particular regex.
equals applies to the content immediately to its left, but can be chained.
Usage examples
Say, for example, that the A symbol defines the fields text and group, and group can be either "ER", "IR", or "OTHER". The following code creates a symbol B that only contains entries where the group equals "OTHER".
| A = | text | group |
|---|---|---|
| manger | ER | |
| aller | OTHER | |
| choisir | IR | |
| vendre | OTHER | |
| pouvoir | OTHER | |
| B = | embed | equals group |
| A | OTHER |
Below an equals operator, content is interpreted as a regex.
For example, we could filter A only to entries where the text starts with "p", "t", or "k":
| B = | embed | equals text |
|---|---|---|
| A | (p|t|k).* |
(There is also a special convenience operator for this, starts, which you can read about on the starts page, that auto-generates a regex and would suffice for this particular use-case. However, if you have a more complex regex you wish to filter on, we recommend using equals and being explicit about which regex you want to match.)
Below is an example of how you could define a single-field symbol (like VOWEL shown below) and use it in place of a long or complicated regex:
| VOWEL = | text |
|---|---|
| a | |
| e | |
| i | |
| o | |
| u |
Suppose we want to define a new symbol V that contains any entry from Nouns below if it the form in text ends with a vowel:
| Nouns = | text | |
|---|---|---|
| casa | ||
| gato | ||
| sabor | ||
| animal | ||
| V = | embed | equals text |
| Nouns | .*{VOWEL} |
To use a symbol like this, it can only have one field.