#OK so I ve had ~3 5h of sleep which is
1 messages Β· Page 1 of 1 (latest)
Here's an example on how you could write an intent with local expansion rules.
_common.yaml
expansion_rules:
area: "[the] {area}"
sentences/lang/light_HassGetState.yaml
...
- expansion_rules:
verb: "(are|is)"
subject: "[all] [the] light[s]"
state: "on"
location: "[in <area>]"
sentences:
- "<verb> <subject> <state> <location>"
- "<verb> <subject> <location> <state>"
Here's how you would write the same thing also using permutations (of the state and location)
- expansion_rules:
verb: "(are|is)"
subject: "[all] [the] light[s]"
state: "on"
location: "[in <area>]"
sentences:
- "<verb> <subject> (<state>; <location>)"
I think the local expansion rules are indeed a good idea
And here's how you would write the same sentence pattern for many binary_sensor_HassGetState intents using sentence templates
_common.yaml
sentence_templates:
is_name_in_area_state:
sentence: "<is> <name> (<state>; <in_area>)"
defaults:
is: "is [the state of]"
name: "<name>" # from common expansion_rules
state: "{state}"
in_area: "[in {area}]"
sentences/lang/binary_sensor_HassGetState.yaml
- expansion_rules:
name: "<name> [battery]" # used only as a demo, can also be in the data below
sentences:
- template: is_name_in_area_state
data:
state: "{bs_battery_states:state}"
response: one_yesno
requires_context:
domain: binary_sensor
device_class: battery
slots:
domain: binary_sensor
device_class: battery
the upside for sentence templates is that you'd just copy/paste this template instance for all other applicable device_classes and just change the state. <name> [battery] is particular to this specific device_class
local expansion_rules overwrite the global expansion_rules with the same name. sentence template instance data overwrites sentence template defaults with the same name. not sure if/how they should overwrite local/global expansion rules.
I'd disagree about the hard permutation limitation to just sets of two. Not all languages are equal on this regard. Just take a peek at what I'm building in Finnish: https://github.com/Arkkimaagi/home-assistant-intents/blob/finnish_major_update/sentences/fi/fan_HassTurnOn.yaml
seems like you're (or Finnish is) a prime candidate for this usecase
indeed π
I'm struggling with conjugations (<alueessa>|<alueesta>|<alueeseen>|<alueella>|<alueelta>|<alueelle>) and permutations
especially the {area} is a tough one, as the {area} known as living room has a base of olohuone, but should be said with different conjugation depending on what you're trying to do. (olohuone|olohuoneen|olohuonetta|olohuoneena|olohuoneeksi|olohuoneessa|olohuoneesta|olohuoneeseen|olohuoneella|olohuoneelta|olohuoneelle|olohuoneetta|olohuonein|olohuoneineen)
anyways, having all this complexity, any help is surely welcome π
My suggestion was like this: https://github.com/home-assistant/intents/issues/907
Where I basically suggest also the permutations approach you're working on π in addition to getting the base word instead of trying to conjugate all words to their variations
would you need spacing between the permuted items? would you expect (one;two) to produce one two and two one or onetwo and twoone?
good question π€
I had not thought of using the permutation for parts of words, but it might be smart to support that too. But how should it be supported for words with spaces then, because that's my primary need π€
(one;two) --> (one two|two one) is what I expected to get, but I do understand the need for (one;two) --> (onetwo|twoone) too. I wish there would be a neat syntax for both cases. Preferrably one that does not depend on whitespace alone, as that can be confusing already with the (one|two) vs (one | two) I see already in the codebase.
I can not think of a need for switching just parts of words immediately. So to answer your question, I'd expect/need the former (with spaces between words) and only extend to the partial-words if the need arises with another character, like : or something
got it, thanks! i imagine there are languages with composed words where you want to permute parts of words, that's why I was asking
I take it Finnish doesn't need this
Kinda hard to say as my native language surprises me daily: https://translate.google.com/?sl=fi&tl=en&text=vihdoin vihdoin vihdoin&op=translate
Yes, that's correct translation
And something that I might actually say, but never thought of it before π
Anyways, I'll go sleep for now π Thanks for the chat and your possibly upcoming code for the permutations π΄
I've been giving it some thought and I think that sentence templates are useless. You can simply define common expansion rules and overwrite parts of them with local expansion rules, while still maintaining some level of readability. I've got that idea from @royal crow 's latest updates to Dutch.
I guess your comments and suggestions triggered that ideaπ‘