A catch-all rule to return text not matching other rules - possible?


Is it possible to construct a set of rules to do the following:

I would like reco a particular phrase to produce a result and then anything else other than that phrase will return the complete text.

For example I have a .rule file like this:

TopRule =
        (help | what | how) {action='help'}  
    $*) |

    $anything_else {action=anything_else._action} {text = anything_else._text}

anything_else @= (+$w) {_action='null'} {_text=_parsed}; 

However, I am not getting the results I want. If I put in “help” I get “action=help”. But, if I put in “i need help” or “help me” I get the anything else rule triggering instead and get back “action=null”.

How can I code up this rule to get what I am looking for: selected phrases return action=help and all other phrases will return action=null.



you can use wild cards for that. Here is an example of something I use:

TopRule = $* (
((*turn) ($onoff{onoff=onoff._state}) (*the) $zone{action='Connect'}{zone=zone._zone})  |
    ) $*;

In the example above, *turn and *the are optional. All Jibo cares about is the onoff state and the zone.
Also in the example above I can say anything I want prior to turn and it is just ignored. So for instance, I can say “Can you please turn off the kitchen light” and it still parses just fine.

I’m told you can put open ended wild cards in the middle as well but I haven’t had a change to play with that yet. For me that would be used if I was having a bad day and said something like Jibo turn on the F-ing kitchen light. That way I wouldn’t need specify each curse word. :slight_smile:

Hope that helps.


@codemonkey2k5 thanks for your suggestion. I used your example to spiff up my rule quite a bit. In the end I found my problem - my while loop condition was incorrect and I really did not need a catch all parse nor did I really want that text - whatever it may have been. In the event of a Listen fail,I now spin back around successfully.