Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement