expansions — Extension expansion classes and functions module¶
This module contains extension rule expansion classes and functions.
Class representing dictation input matching any spoken words.
This is largely based on the
Dictationelement class in the dragonfly Python library.
Dictationexpansions compile to a special reference (
<DICTATION>), similar to
VoidRef. See the
DictationGrammarclass if you want to use this expansion type with CMU Pocket Sphinx.
The matching implementation for
Dictationexpansions will look ahead for possible next literals to avoid matching them and making the rule fail to match. It will also look backwards for literals in possible future repetitions.
It will not however look at referencing rules for next possible literals. If you have match failures because of this, only use
Dictationexpansions in public rules or use the
JointTreeContextclass before matching if you don’t mind reducing the matching performance.
A regex pattern for matching this expansion.
This property has been left in for backwards compatibility. The
Expansion.matchesmethod now uses the
Returns: regex pattern object
Whether to match the
current_matchvalue next time rather than matching one or more words.
This is used by the
Check that the expansion is compilable. If it isn’t, this method should raise a
Split an expansion into 2*n expansions where n is the number of
Dictationexpansions in the expansion tree.
If there aren’t any
Dictationexpansions, the result will be the original expansion.
- expansion – Expansion
- should_deepcopy – whether to deepcopy the expansion before using it
Take an expansion and expand any
AlternativeSetwith alternatives containing
Dictationexpansions. This function returns a list of all expanded expansions.
Parameters: expansion – Expansion Returns: list