dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

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

Open jgarvin opened this issue 10 years ago • 2 comments

If you setup a rule "hello <X>" 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."

jgarvin avatar Feb 12 '15 19:02 jgarvin

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

Voxellence avatar Mar 10 '15 16:03 Voxellence

@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.

t4ngo avatar Apr 10 '15 10:04 t4ngo