#OK so I ve had ~3 5h of sleep which is

1 messages Β· Page 1 of 1 (latest)

tacit sequoia
#

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>)"
royal crow
#

I think the local expansion rules are indeed a good idea

tacit sequoia
#

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.

novel zodiac
tacit sequoia
#

seems like you're (or Finnish is) a prime candidate for this usecase

novel zodiac
#

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 πŸ˜„

tacit sequoia
#

the area is user-generated, so you (as the translator) won't have as much control

novel zodiac
#

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

tacit sequoia
#

would you need spacing between the permuted items? would you expect (one;two) to produce one two and two one or onetwo and twoone?

novel zodiac
#

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

tacit sequoia
#

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

novel zodiac
#

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 😴

tacit sequoia
#

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.

royal crow
#

I guess your comments and suggestions triggered that ideaπŸ’‘