home-assistant / intents

Intents to be used with Home Assistant
https://developers.home-assistant.io/docs/voice/overview/
Creative Commons Attribution 4.0 International
453 stars 516 forks source link

[FR] Make timers great again #2239

Closed jlpouffier closed 4 months ago

jlpouffier commented 4 months ago

Context

Timers in French were completely broken (mostly because I went way to fast on my first PR)

Issues

The standard STT engine of HA Cloud yields very complex results regarding time. It was challenging to fix.

Here are a few examples:

Solution

A painful set of expansion rules:

For seconds, minutes, and hours, we now have: 1/ A numerical range

  timer_seconds:
    range:
      from: 1
      to: 100

2/ A literal list

  timer_words_seconds:
    values:
      - in: "un|une"
        out: "1"

We then merge them for both duration and start, ie:

  nb_seconds_duration: "({timer_seconds:seconds}|{timer_words_seconds:seconds})"
  nb_seconds_start: "({timer_seconds:start_seconds}|{timer_words_seconds:start_seconds})"

We use these intermediate expansion rules to define the final duration and start., ie:

  timer_duration_seconds: "<nb_seconds_duration>[ ]<second_unit>"
  timer_start_seconds: "<nb_seconds_start>[ ]<second_unit>"

There are a small of smaller nuances such as the units that are mandatory for the first key of the tuple (h,m,s) but optional for the rest (To accommodate for the 02h16), ie:

  timer_start_minutes: "<nb_minutes_start>[ ]<minute_unit>[[ ][et][ ]<nb_seconds_start>[ ][<second_unit>]]"

The tests have been edited to reflect all this madness complexity

Summary by CodeRabbit

coderabbitai[bot] commented 4 months ago
Walkthrough ## Walkthrough The recent updates encompass refining error messages and enhancing timer configurations in French. This involves adjustments aimed at increasing clarity and conciseness, especially regarding timer durations by abbreviating units like "minutes" to "min." Additionally, modifications in various test cases reflect these changes, ensuring consistency across error messages and timer-related configuration descriptions. ## Changes | Files | Change Summaries | |------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| | `sentences/fr/_common.yaml` | Refined error messages related to timers and updated configurations using numerical and literal values for time measurements. | | ...homeassistant_HassCancelTimer.yaml | Adjusted text description for stopping a 5-minute timer to be more concise. | | ...homeassistant_HassDecreaseTimer.yaml | Modified expressions to use "2 min" instead of "2 minute" for decreasing timers. | | ...homeassistant_HassIncreaseTimer.yaml | Changed wording to "2 min" for increasing timers to enhance clarity. | | ...homeassistant_HassPauseTimer.yaml | Abbreviated "minutes" to "min" in commands for pausing timers. | | ...homeassistant_HassStartTimer.yaml | Adjusted timer duration expressions, including abbreviating "minutes" to "min" and refining naming conventions. | | ...homeassistant_HassTimerStatus.yaml | Modified wording in timer duration queries to be more concise by using "min" instead of "minutes." | | ...homeassistant_HassUnpauseTimer.yaml | Introduced a new sentence for resuming a timer for 5 minutes in French. | ## Sequence Diagram(s) Silently ignored generating this section because the changes focus on refining existing messages and improving test cases, which do not significantly alter control flows or introduce new features.

Recent review details **Configuration used: CodeRabbit UI** **Review profile: ASSERTIVE**
Commits Files that changed from the base of the PR and between b5e68692e9d6cc3a4a32e085fc07bea962b641ce and 29502a4c2a2bb6a90c7af92bd4d7f50396c87912.
Files selected for processing (8) * sentences/fr/_common.yaml (3 hunks) * tests/fr/homeassistant_HassCancelTimer.yaml (1 hunks) * tests/fr/homeassistant_HassDecreaseTimer.yaml (3 hunks) * tests/fr/homeassistant_HassIncreaseTimer.yaml (4 hunks) * tests/fr/homeassistant_HassPauseTimer.yaml (1 hunks) * tests/fr/homeassistant_HassStartTimer.yaml (6 hunks) * tests/fr/homeassistant_HassTimerStatus.yaml (1 hunks) * tests/fr/homeassistant_HassUnpauseTimer.yaml (1 hunks)
Additional comments not posted (9)
tests/fr/homeassistant_HassUnpauseTimer.yaml (1)
`22-22`: The inclusion of both "min" and "minutes" ensures compatibility with varied user inputs. Ensure that both forms are correctly recognized and handled by the intent processing logic.
Verification successful --- The inclusion of both "min" and "minutes" ensures compatibility with varied user inputs. The intent processing logic correctly handles both forms of input for the duration slot.
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that both "min" and "minutes" are correctly handled. # Test: Search for function handling in the intent processing code. rg --type yaml 'HassUnpauseTimer' --context 10 ``` Length of output: 20881
tests/fr/homeassistant_HassCancelTimer.yaml (1)
`26-26`: Standardizing on "min" for minutes aligns with the PR's objectives and enhances consistency. Ensure that the abbreviation is consistently used across all related functionalities.
tests/fr/homeassistant_HassDecreaseTimer.yaml (1)
`7-7`: Including both "min" and "minute" ensures compatibility with varied user inputs. Ensure that both forms are correctly recognized and handled by the intent processing logic. Also applies to: 19-19, 30-30
Verification successful --- The intent processing logic for `HassDecreaseTimer` correctly handles both "min" and "minute". - `tests/fr/homeassistant_HassDecreaseTimer.yaml` includes test cases for both "min" and "minute".
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that both "min" and "minute" are correctly handled. # Test: Search for function handling in the intent processing code. rg --type yaml 'HassDecreaseTimer' --context 10 ``` Length of output: 26330
tests/fr/homeassistant_HassIncreaseTimer.yaml (1)
`6-6`: Including both "min" and "minute" ensures compatibility with varied user inputs. Ensure that both forms are correctly recognized and handled by the intent processing logic. Also applies to: 19-19, 30-31, 42-42
tests/fr/homeassistant_HassPauseTimer.yaml (1)
`29-31`: Updated phrases for consistency in timer duration representation.
tests/fr/homeassistant_HassTimerStatus.yaml (1)
`29-29`: Updated phrase for consistency in timer duration representation.
tests/fr/homeassistant_HassStartTimer.yaml (1)
`6-8`: Standardized the representation of time units and enhanced clarity in timer names for better STT recognition. Also applies to: 17-24, 26-37, 49-52, 62-70, 77-101, 111-137
sentences/fr/_common.yaml (2)
`312-314`: Updated error messages to be more specific about timer issues. --- Line range hint `638-737`: Added comprehensive timer configurations for handling both numerical and literal values in French, enhancing the system's ability to understand and process timer-related commands in natural language.
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.