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

[RU] Improved responses #2957

Merged
merged 3 commits into from
Feb 14, 2025
Merged

[RU] Improved responses #2957

merged 3 commits into from
Feb 14, 2025

Conversation

mitrokun
Copy link
Contributor

@mitrokun mitrokun commented Feb 4, 2025

Improved selection of correct endings for names.

  • Первый блок проверки теперь позволяет учитывать составные имена "главный выключатель, темная ночь.." Если есть более простой способ узнать наличие пересечения списков - надо будет изменить.
          {% if ((slots.name.split() + ["выключатель","пользователь","день","дождь","ночь"])
                | count != dict.fromkeys(slots.name.split() + ["выключатель","пользователь","день","дождь","ночь"]) | count)  or
                (slots.name[-2].lower() in "рь" and slots.name.lower() != "дверь") %}
  • Во втором блоке добавлена проверка на окончания У, Ю, с последующей модификацией в ответе (лампу, штору, кастрюлю). Большинство команд использует винительный падеж, но только недавно столкнулся в жизни с этим кейсом.
  • Упростил ответ для сover, чтоб ответ соответствовал длительности процесса.
  • Добавил дополнительные тесты и поправил зависимые тесты.

Лучше внимательно проверить, что налепил. Вероятно необходимы стилистические правки.

Comment on lines 11 to 13
{% if ((slots.name.split() + ["выключатель","пользователь","день","дождь","ночь"])
| count != dict.fromkeys(slots.name.split() + ["выключатель","пользователь","день","дождь","ночь"]) | count) or
(slots.name[-2].lower() in "рь" and slots.name.lower() != "дверь") %}
Copy link
Member

Choose a reason for hiding this comment

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

Думаю лучше добавить комментарии:
"If slots.name contains some of the words in defined list"
"Or last two characters of the name are "рь" but the name is not "дверь"
Потому что мне потребовалось время чтобы понять, что здесь происходит.

Copy link
Member

Choose a reason for hiding this comment

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

Мы делаем исключение для слова "дверь", но разве "ночь" — не женского рода? Если я правильно понял, то по итогу этих условий мы идем в male_ending

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Дверь - исключение для оканчивающихся на рь, прошлый раз просмотрел просмотрел такой вариант. А с ночью наоборот перемудрил и записал её в мужской род - надо убрать. Но ситуации разные

{% set ending = male_ending %}
{% else %}
{% set ending = female_ending %}
{% endif %}
{% elif slots.name[-1].lower() in "а, у, я" %}
{% elif slots.name[-1].lower() in "а, у, ю, я" %}
Copy link
Member

Choose a reason for hiding this comment

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

Добавить комментарий в духе:
"Change the ending of a feminine name in the accusative case so that the response returns the name in the nominative case. Eg:
Выключи лампу -> Лампа выключена"

Copy link
Member

Choose a reason for hiding this comment

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

Просто опять-таки, с наскока трудно понять о чем тут речь

@HepoH3
Copy link
Member

HepoH3 commented Feb 13, 2025

В общем, потребовалось время, чтоб без комментариев разобраться, но вроде все отлично

@HepoH3 HepoH3 merged commit 3962c5a into home-assistant:main Feb 14, 2025
2 checks passed
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.

2 participants