SHARE
TWEET

Untitled

a guest Oct 16th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import dragonfly
  2. class GreedyishRule(MappingRule):
  3.     mapping = {
  4.         "say <dictation>": Text("%(<dictation>)s"),
  5.         "numb <number_sequence>": Text("%(<number_sequence>)s"),
  6.  
  7.         }
  8.     digits = {"one": "1", "two": "2", "three": "3"}
  9.        
  10.     extras = [Dictation("dictation"),
  11.         Repetition( Choice("digits", digits), min=1, max=15, number_sequence)]
  12.     defaults = {"n":1}
  13. greedyish_rule = GreedyishRule()
  14.  
  15. cmd_sequence =  
  16.     Sequence(Optional(RuleRef(regular_ccr_rule)),
  17.     Optional(Sequence(RuleRef(greedyish_rule)),
  18.     Optional(Sequence(Literal("over"), RuleRef(regular_ccr_rule)))))
  19.  
  20.  
  21. class SequenceRule(CompoundRule):
  22.     spec = "<cmd_sequence>"
  23.     extras = [cmd_sequence]
  24.     def _process_recognition(self, node, extras):
  25.         for action in extras["cmd_sequence"]:
  26.             print(action)
  27.             action.execute()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top