rules — Extension rule classes module¶
This module contains extension rule classes.
SequenceRule(name, visible, expansion, case_sensitive=False)¶
Class representing a list of regular expansions and
Dictationexpansions that must be spoken in a sequence.
Whether the entire SequenceRule can be repeated multiple times.
Note that if the rule can be repeated, data from a repetition of the rule, such as
current_matchvalues of each sequence expansion, should be stored before
restart_sequenceis called for a further repetition.
Compile this rule’s expansion tree and return the result. Set ignore_tags to True to not include expansion tags in the result.
Parameters: ignore_tags – bool Returns: str
Whether the current expansion in the sequence contains only
If the entire sequence is matched by successive calls to the matches method, this returns all strings that matched joined together by spaces.
The expansion sequence used by the rule.
SequenceRuleand an expansion and attempt to graft the matches of all expansions in the sequence onto the given expansion in-place.
Not all expansions in the sequence need to have been matched.
- sequence_rule – SequenceRule
- expansion – Expansion
Whether there is another sequence expansion after the current one.
Return whether or not speech matches the current expansion in the sequence.
This also sets
current_matchvalues for the original expansion used to create this rule.
This method will only match once and return False on calls afterward until
Parameters: speech – str Returns: bool
Whether or not matches on this rule can succeed.
This is set to False if
set_nextis called and there is a next expansion or if
This can also be manually set with the setter for problematic situations where, for example, the current expansion is a
Repeatexpansion with a
Resets the current sequence expansion to the first one in the sequence and clears the match data of each sequence expansion.
Moves to the next expansion in the sequence if there is one.
The set of JSGF tags in this rule’s expansion. This does not include tags in referenced rules.
PublicSequenceRule(name, expansion, case_sensitive=False)¶
SequenceRule subclass with
visibleset to True.