t4ngo / dragonfly

ARCHIVED! - Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS) and Windows Speech Recognition (WSR)
GNU Lesser General Public License v3.0
364 stars 82 forks source link

Rules only included by RuleRef don't have default values put in extras, also process_recognition not called #34

Open jgarvin opened 9 years ago

jgarvin commented 9 years ago

If you setup a rule "hello " where X is a RuleRef to another rule "[]" where n is an Integer and the rule sets the default value of n to be 1, only utterances where the user explicitly named a number will have extras['n']. If they don't speak a number in the utterance then the key is completely missing rather than having a default value. This only happens when the default is part of a referred to rule, not when the default is specified in the top level rule that the match is on. This wouldn't be too much of a problem if the default value at least was put on the Node associated with n, but it's not. So to work around this you have to implement applying defaults yourself.

It also appears (and I'm not sure if this is part of this bug) that process_recognition is not called for rules that are only included by RuleRef. I'd guess that this is intended behavior except the docs say, "This is generally the method which developers should override in derived rule classes to give them custom functionality when a top-level rule is recognized."

Voxellence commented 9 years ago

How about an example to go with your narrative? As they say, a picture is worth a thousand words.

t4ngo commented 9 years ago

@jgarvin: Could you please give an example showing this problem?

RuleRef elements handle defaults the same way as other basic elements, so there shouldn't be any different behavior seen there. Perhaps you set the default value on the Rule instead of the RuleRef? What the desired behavior is in that case is of course debatable.