Chain [ … ]#
A chain is an easy way to implement if-else statements. When you surround rules with a chain, the first one will be run, if it matches, than the rest of the rules are ignored. If it doesn’t, the second rule will be tried, and so on.
lexicon:
{
nice,
polite
} = adj_pos;
chain
[
rule :
{
'be' 'not' .. adj_pos
} = Negative;
rule :
{
'be' .. adj_pos
} = Positive;
]
“That man is not always polite. His wife is nice.”
Sentence -> That man is not always polite .
Negative -> is not always polite
adj_pos -> polite
Sentence -> His wife is nice .
Positive -> is nice
adj_pos -> nice
If we would not put the rules in a chain the first sentence would also match the second rule (<’be’> .. adj_pos) and we would end with a Positive as well as a Negative result that we would need to filter.