Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FI] Areas rework part 1 of many #2501

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

salleq
Copy link
Contributor

@salleq salleq commented Nov 11, 2024

  • Added conjugations for areas

  • simplified home_assistant_HassTurnOn

  • made some other changes to common and fixtures

@Arkkimaagi
Copy link
Contributor

I've been thinking this approach. I think it's quite problematic and we need to consider it more.

You've added support for two special rooms, ullakko and eteinen, but what if the people have "kura-eteinen" or something similar? I mean, we really can not anticipate all the rooms and names people give to their areas.

@v1k70rk4
Copy link
Member

v1k70rk4 commented Nov 17, 2024

Hi, since we’re part of the same language family, I ran a test, and as I see, it works in Finnish too :)

In Hungarian, there are some words where the root changes, so I added "filler words" after the area. For example: room, space, and it works.

So, for cases where the word cannot be conjugated, you can still use these. In your case, it might look something like this: Sytytä ullakko huoneen lamppu. Of course, words that can be conjugated without altering the root can still be supported.

This is precisely why I suggested creating a guide in everyone’s native language to explain usage. But until we can modify word roots, I’ve been solving it in Hungarian in this way.

Consider whether this works in all special cases.

example from Hungarian:

  area: "[a |az ]{area}[<area_suffixes>|<area_words>]"
  area_suffixes : "(b(a|e)[n]|(o|e|ö)n|t|i)"
  area_words: "([ ](szob(a|á)[ba[n]|t|i]|hely[i]ség[be[n]|en|et]))"

@Arkkimaagi
Copy link
Contributor

Yep, that's the option salleq is changing with this pr away from.

And the words fo not behave nicely, for eteinen, the extra word does not work as well.

It's also kinda difficult to remember what filler words to add.

@salleq
Copy link
Contributor Author

salleq commented Nov 18, 2024

This PR adds the option for conjugated room names, I'm not taking away the possibility to say "laita huoneen olohuone valo päälle" ("put the light on in the room living room"). You can see that I have added some tests, but not removed any.

We can't possibly take into account every room name there is (like "kura-eteinen") and what people will use, but the most common ones we can + some rooms that aren't conjugated nicely (ullakko and eteinen for example).

I don't see how this could be better implemented unless we get Arkkimaagi's lemmatization idea go through or something similar.

It's more for us to maintain (having both conjugations and area {area} ) but I can't agree on talking to the voice assistant using filler words, it's not natural.

@v1k70rk4
Copy link
Member

In Hungarian, there’s just one word type that’s extremely frustrating in room names. I try to avoid it in every possible way, but if it’s entered, there’s nothing I can do about it. :(

That’s why a language tutorial would be helpful. To use the Voice Assistant, unless everything is set up very precisely according to all the rules (switches, names, aliases), modifications are needed.

For example, it would be ideal (for the Hungarian language) if the last character of room names could be trimmed off :) and only match up to the n-1 characters. Although, as I see, for Finnish, n-2 would be needed.

e.g.: Konyh* = Konyha, Konyhában, Konyhai, Konyhát, etc...

Copy link
Contributor

@Arkkimaagi Arkkimaagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all, I love how you've taken care of this project on the Finnish translations. Since we've been discussing in discord and you asked for my opinion, I've checked the code. We can discuss further.

@@ -345,8 +346,12 @@ expansion_rules:
# laitteille: "[äly]laitteille"
# laitteitta: "[äly]laitteitta"

# Special treatment for certain rooms
eteinen_pääte: "(eteinen|eteisessä|eteisestä|eteiseen|eteiselle|eteiseltä|eteisen)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this {area} can work like this at all.

Have you tested this on your HA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested this - Had a light in a room called "Ullakko", and asked HA to "Sammuta ullakon valo". So it works.

# Area prefix to avoid congjugating areas if possible
alue: "(alue|paikka|huone|tila)" # nominatiivi = mikä, kuka
alue: "(alue|paikka|huone|tila|<alueen>|<alueessa>|<alueesta>|<alueeseen>|<alueella>|<alueelta>|<alueelle>)" # nominatiivi = mikä, kuka
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not mix this format like this, maybe instead:

alue_all: "(<alue>|<alueen>|<alueessa>|<alueesta>|<alueeseen>|<alueella>|<alueelta>|<alueelle>)"
alue: "(alue|paikka|huone|tila)"

And then change the <alue> from all places to <alue_all>.

If you feel strongly about changing the <alue> from different places, you could consider:

alue: "(<alue_base>|<alueen>|<alueessa>|<alueesta>|<alueeseen>|<alueella>|<alueelta>|<alueelle>)"
alue_base: "(alue|paikka|huone|tila)"

@@ -358,6 +363,7 @@ expansion_rules:
alueelta: "(alueelta|paikalta|huoneelta|tilalta)" # ablatiivi = miltä, keneltä
alueelle: "(alueelle|paikalle|huoneelle|tilalle)" # allatiivi = mille, kenelle
# alueetta: "(alueetta|paikatta|huoneetta|tilatta)" # abessiivi = ilman mitä, ketä
alue_pääte: "({area}[e][ssa|ssä|sta|stä|än|in|an|on|ön|seen|ltä|llä|lla|lta|lle|n])"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this <alue_pääte> to a text match will make that matching have 34x more items.

  • {area}ssa
  • {area}ssä
  • {area}sta
  • {area}stä
  • {area}än
  • {area}in
  • {area}an
  • {area}on
  • {area}ön
  • {area}seen
  • {area}ltä
  • {area}llä
  • {area}lla
  • {area}lta
  • {area}lle
  • {area}n
  • {area}
  • {area}essa
  • {area}essä
  • {area}esta
  • {area}estä
  • {area}eän
  • {area}ein
  • {area}ean
  • {area}eon
  • {area}eön
  • {area}eseen
  • {area}eltä
  • {area}ellä
  • {area}ella
  • {area}elta
  • {area}elle
  • {area}en
  • {area}e

Lets consider this: <pysäytä> (<tuuletin>;(<huone>|<alue> <huone>))

  • <pysäytä> has 3 variants: pysäytä, sammuta, stoppaa
  • first parenthesis can be arranged in 2 different ways: 1, 2 ; 2, 1
    • has 6 variants: tuuletin, tuuletus, puhallin, puhallus, ilmastointi, ilmanvaihto
    • second parenthesis can have 2 dirrent contents; or
      • has 1 variant: {area}
      • has 4 variants: alue, paikka, huone, tila

3 * 2 * ( 6 * 2 * (1 + 4)) = 360 variants


The new <alue_pääte> has:

  • 1 variant for the start: {area}
  • 2 variants for [e]: with and without "e"
  • 16 variants for the ending + 1 if there's no ending: "ssa|ssä|sta|stä|än|in|an|on|ön|seen|ltä|llä|lla|lta|lle|n" and "", so 17 total.

1217 = 34 variants in <alue_pääte> total


If we modify original sentence to contain <alue_pääte>:
<pysäytä> (<tuuletin>;(<huone>|<alue> <huone>|<alue_pääte>))

That changes

  • the second parenthesis to have 3 dfferent contents instead of 2
  • Then adds <alue_pääte> with 34 variants

3 * 2 * ( 6 * 3 * (1 + 4 + 34)) = 4212 variants, a 1070% increase for just one sentence.

On a raspberry Pi, that can be significant.

Also, if you check the options, many of them are not correct Finnish and are wasted resources. For {area} "olohuone", only 8 of the 34 outputs are valid Finnish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, this probably won't matter even though the variants are multiplied. But - can be tested if necessary.

- "<pysäytä> <tuuletin> (<alueessa>|<alueesta>|<alueeseen>|<alueella>|<alueelta>|<alueelle>) <huone>"
- "<pysäytä> (<alueen>|<alueessa>|<alueesta>|<alueeseen>|<alueella>|<alueelta>|<alueelle>) <huone> <tuuletin>"
# Yksittäinen tuuletin
- "<pysäytä> (<tuuletin>;(<huone>|<alue> <huone>|<alue_pääte>))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few things happening now in this PR.

  1. Reducing the rows of the matches.
  2. Adding <alue_pääte>

On part 1, it's ok to reduce rows now that we have the (change;order) syntax as long as the code remains readable. With previous code, you could read the line, and see if it makes sense. Now it's way more difficult to check if the sentence is sane.

On part 2. We need to discuss the <alue_pääte> concept a bit more, it has some major drawbacks, including the multiplier of 34 and problematic conjugations like eteinen, ullakko, and many more we can not think of.

When done in a single PR, it's hard to check if everything is as it should be. (sorry, I'm having trouble following the logic here)


# Special room specific sentences
- sentences:
- "[<laita>] (<päältä>;{name};[<eteinen_pääte>])"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to test these before we add them to the code. I'm not sure these actually work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested - seems to work.

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft November 22, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants