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

fix:lingua_franca #257

Merged
merged 1 commit into from
Oct 18, 2024
Merged

fix:lingua_franca #257

merged 1 commit into from
Oct 18, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 18, 2024

lingua franca requires lowercased lang codes, which causes ask_yesno to fail

adds better dialect support

closes #256

Summary by CodeRabbit

  • New Features

    • Enhanced language handling for yes/no responses in the ask_yesno method, improving localization support.
  • Bug Fixes

    • Addressed potential issues with language matching, ensuring more accurate yes/no responses.
  • Documentation

    • Updated comments to indicate future changes towards a plugin-based approach for handling yes/no queries.

lingua franca requires lowercased lang codes, which causes ask_yesno to fail

adds better dialect support
@JarbasAl JarbasAl self-assigned this Oct 18, 2024
Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request modifies the ask_yesno method in the OVOSSkill class located in the ovos_workshop/skills/ovos.py file. The changes enhance language handling for yes/no responses by implementing a mechanism to match the current language against a predefined list using the closest_match function. If a close match is found, it defaults to the original language; otherwise, it raises a ValueError. The method signature remains unchanged. The comments indicate a future transition towards a plugin-based approach for handling yes/no queries.

Changes

File Change Summary
ovos_workshop/skills/ovos.py Modified ask_yesno method to improve language handling for yes/no responses.

Assessment against linked issues

Objective Addressed Explanation
Support standardized language codes in lowercase (#256)
Improve language handling for yes/no queries (#256)

Possibly related PRs

  • fix:langcodes #241: The changes in this PR enhance language handling by utilizing the langcodes library for better dialect support, which is directly related to the modifications in the ask_yesno method of the main PR that also focuses on improving language processing capabilities.

Suggested labels

fix

Suggested reviewers

  • goldyfruit

Poem

In the land of code where rabbits play,
A yes or no, they ask each day.
With languages close, they hop and cheer,
For clearer answers, now so near!
So let us dance, with joy we sing,
For better skills, this change will bring! 🐰✨


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the fix label Oct 18, 2024
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 51.49%. Comparing base (7c02206) to head (3846d20).
Report is 54 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_workshop/skills/ovos.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #257      +/-   ##
==========================================
- Coverage   53.41%   51.49%   -1.93%     
==========================================
  Files          37       36       -1     
  Lines        4362     4193     -169     
==========================================
- Hits         2330     2159     -171     
- Misses       2032     2034       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added fix and removed fix labels Oct 18, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c77ccfc and 3846d20.

📒 Files selected for processing (1)
  • ovos_workshop/skills/ovos.py (1 hunks)
🧰 Additional context used

Comment on lines +2002 to +2012
# TODO - lingua_franca does not support standardized lang tags
# deprecate it, use a plugin here https://github.com/TigreGotico/ovos-solver-YesNo-plugin
lf_langs = ("az-az", "ca-es", "cs-cz", "da-dk", "de-de",
"en-us", "es-es", "fr-fr",
"hu-hu", "it-it", "nl-nl", "pl-pl",
"fa-ir", "pt-pt", "ru-ru", "sl-si",
"sv-se", "tr-tr", "eu-eu", "uk-ua")
lang, score = closest_match(self.lang, lf_langs)
if score > 10:
lang = self.lang # let it raise a value Error in next line
answer = yes_or_no(resp, lang=lang) if resp else resp
Copy link

@coderabbitai coderabbitai bot Oct 18, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

Issue Found: yes_or_no from lingua_franca is Still in Use

The yes_or_no function from lingua_franca.parse is still being imported and utilized in ovos_workshop/skills/ovos.py. This indicates that the deprecation of lingua_franca has not been fully implemented as intended.

  • ovos_workshop/skills/ovos.py: from lingua_franca.parse import yes_or_no, extract_number
  • ovos_workshop/skills/ovos.py: answer = yes_or_no(resp, lang=lang) if resp else resp
🔗 Analysis chain

Approve changes addressing language code issue

The modifications to handle language codes and use closest_match effectively address the issue mentioned in the PR objectives. This solution provides better support for various language codes and dialects.

Consider adding a comment explaining the closest_match logic and why a score of 10 was chosen as the threshold. This will help future maintainers understand the reasoning behind this implementation.

lang, score = closest_match(self.lang, lf_langs)
+ # Use a threshold of 10 to determine if the matched language is close enough
+ # Scores: 0-3 (minor difference), 4-10 (significant but acceptable difference)
if score > 10:
    lang = self.lang  # let it raise a ValueError in the next line

The TODO comment suggests deprecating lingua_franca in favor of a plugin-based approach. Would you like me to create a GitHub issue to track this task for future implementation?

Let's verify the impact of these changes on the rest of the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of yes_or_no function from lingua_franca
rg "from lingua_franca.parse import yes_or_no" --type python
rg "yes_or_no\(" --type python

Length of output: 157


Script:

#!/bin/bash
# Retry searching for other usages of yes_or_no function using the correct type identifier
rg "from lingua_franca.parse import yes_or_no" -t py
rg "yes_or_no\(" -t py

Length of output: 257

Copy link
Member Author

Choose a reason for hiding this comment

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

open an issue to track this

Copy link

Choose a reason for hiding this comment

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

@JarbasAl, I've opened issue #259 to track this task.

🔗 Analysis chain

@JarbasAl, I've opened a GitHub issue to track this task.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Create a new GitHub issue to track the deprecation of 'lingua_franca' in favor of a plugin-based approach
gh issue create --title "Deprecate 'lingua_franca' in favor of plugin-based approach" \
--body "As discussed in [PR #257](https://github.com/OpenVoiceOS/OVOS-workshop/pull/257) and [this comment](https://github.com/OpenVoiceOS/OVOS-workshop/pull/257#discussion_r1805688426) by @JarbasAl, we need to deprecate the 'lingua_franca' library in favor of a plugin-based approach. This issue is to track this task for future implementation.

" \
--assignee JarbasAl

Length of output: 524

@JarbasAl JarbasAl merged commit 1b836c3 into dev Oct 18, 2024
10 of 11 checks passed
@JarbasAl JarbasAl deleted the fix/lingua_franca branch October 18, 2024 01:22
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lingua franca does not support standardized lang codes, it needs lower case
1 participant