Slot syntax with rules

is this valid syntax ??
Was asking myself if I can mix rules with alternatives, possible word and such but didn’t find anything regarding this in doc.

time = ( minuit | <hour> ) [ <minute> ]

Also, is there a solution for at least duration in actual docker version ? Seems we have to wait for .25 version but even not sure ?

Really miss date time duration number and age to finish converting all my snips intents/slots :grin:

1 Like

For optional alternatives and rules you can do:
time = [ ( Minuit | midi ) à ] < hour> [ < minute> ]

For more info on JSGF grammar, take a look at the reference here:
https://www.w3.org/TR/2000/NOTE-jsgf-20000605/

Hope this helps :blush:

2 Likes

I put your file in an intent file, with at the end:

allume (dans | de la | du) (le | la) ($house_room){house_room} [pendant | durant] (<number> <duration>){duration}

And it works !
I got the right intent, with slot duration and house_room !!

Now, duration slot returned is “dix minutes”, we would need to get duration slot in intent always in same unit and as a number. Here it should be just “10”, if we ask two hours, it should be “120”, etc. Or in second to be more precise, and only later in handling the intent we do the conversion we need. But duration must be a float or int.

I guess rhasspy should intercept duration slot and convert all years, months, weeks etc to a number.

Anyway, can’t get these rules to work when separated in another file.

/slots/mathSlots

[mathSlots]
# Number
two_to_nine = ( deux | trois | quatre | cinq | six | sept | huit | neuf )
....

then in an intent:

[LightTimeOnJeedom]
allume (dans | de la | du) (le | la) ($house_room){house_room} [pendant | durant] (<mathSlots.number> <mathSlots.duration>){duration}

got error line 135, in walk_expression for item in replacements[key]: KeyError: ‘<number>’

You cannot put rules in slot files (yet). Only in intent files for now.

That’s my conclusion yes :laughing:
You say for now, so it will possible ? :upside_down_face:

According to @synesthesiam, it seems to be on the road map for the next major release 0.25.

Thanks, would be awesome !

Hi,

Ok, one year later, does duration slot have evolved ?

Can we get an entity with duration.years, quarters, months, weeks, days, jours, minutes, seconds ?
With like ( ){duration} ? I retried this with rhasspy 2.5.8, doesn’t seems to work.

This works in sentences:
quel jour [était on | étions nous] [il y a] [(1..52){duration_years} ans] [et] [(1..52){duration_weeks} semaines] [et] [(1..31){duration_days} jours] [avant]

but then I have to get every possible slot combination in my skill. And construct sentences isn’t easy and quite limiting.

Sorry, have been off of rhasspy for a while, trying to set it back on with all last evolutions.