Last active
September 27, 2019 22:59
-
-
Save alexboche/57d688db0215a436cfaa342bdfe4e760 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dragonfly | |
class GreedyishRule(MappingRule): | |
mapping = { | |
"say <dictation>": Text("%(<dictation>)s"), | |
"numb <number_sequence>": Text("%(<number_sequence>)s"), | |
} | |
digits = {"one": "1", "two": "2", "three": "3"} | |
extras = [Dictation("dictation"), | |
Repetition( Choice("digits", digits), min=1, max=15, number_sequence)] | |
defaults = {"n":1} | |
greedyish_rule = GreedyishRule() | |
cmd_sequence = | |
Sequence(Optional(RuleRef(regular_ccr_rule)), | |
Optional(Sequence(RuleRef(greedyish_rule)), | |
Optional(Sequence(Literal("over"), RuleRef(regular_ccr_rule))))) | |
class SequenceRule(CompoundRule): | |
spec = "<cmd_sequence>" | |
extras = [cmd_sequence] | |
def _process_recognition(self, node, extras): | |
for action in extras["cmd_sequence"]: | |
print(action) | |
action.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment