Use default when an optional tag is not present

I’d like to match

how is the weather today    -> day: today
how is the weather tomorrow -> day: tomorrow
how is the weather          -> day: today

This is what I came up with:

[Weather]
day = ((today|tomorrow){day} | (:){day:today})
how is the weather <day>

Is that correct?

This part would match also other words.

(:){day:today}

This should work the way you intended.

[Weather]
day = ((today|tomorrow){day} | ( ){day:today})
how is the weather <day>

you can also do things like this if i remeber correctly:

[Weather]
day = ((today|tomorrow| :today){day} 

or what i often when i have multiple words for one option which also should be the drfault option.

[Weather]
day = ((today| this day| ):today | tomorrow){day} 

I dont have acess to my setup at the moment so i could not test the first 2 variants. You can always use the web interface to test just the intent recognition.

Why not make the day optional?

[Weather]
day = (today|tomorrow){day}
how is the weather [<day>]

Then in your intent handler check if the slot has a value, if not, assume today.

The you get:

or when no day

Sure, I could do that, but then it would be off topic here. :yum:

Sorry, I do not understand your comment. What is offtopic?

I offer a solution by making the day slot optional :slight_smile:
Works fine and no complicated stuff in the sentences.ini

I just moves the complicated stuff from Rhasspy to the intent handler.

Yup, and that is where is belongs IMHO.
The sentences should reflect what you actually say and not add functionality.
So, when no day is spoken, let the intent handler decide what to do with it and keep the spoken sentence clean.

That way, you can add extra thing to the intenthandler when no day is spoken, a 4 day forecast or something like that.

just my 2 cents :slight_smile: