Skip to content

Instantly share code, notes, and snippets.

@alexboche
Last active September 27, 2019 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexboche/57d688db0215a436cfaa342bdfe4e760 to your computer and use it in GitHub Desktop.
Save alexboche/57d688db0215a436cfaa342bdfe4e760 to your computer and use it in GitHub Desktop.
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