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: drop lingua_franca #268

Merged
merged 3 commits into from
Nov 11, 2024
Merged

fix: drop lingua_franca #268

merged 3 commits into from
Nov 11, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Nov 7, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced user interaction with improved handling of yes/no questions through the new YesNoSolver.
    • Updated number pronunciation functionality using the pronounce_number method.
  • Bug Fixes

    • Simplified logic for processing yes/no responses, improving reliability.
  • Chores

    • Updated dependencies by removing ovos-lingua-franca and adding ovos-solver-yes-no-plugin and ovos-number-parser.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 51.41%. Comparing base (7c02206) to head (daab462).
Report is 88 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_workshop/skills/ovos.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #268      +/-   ##
==========================================
- Coverage   53.41%   51.41%   -2.01%     
==========================================
  Files          37       36       -1     
  Lines        4362     4209     -153     
==========================================
- Hits         2330     2164     -166     
- Misses       2032     2045      +13     

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

@JarbasAl JarbasAl marked this pull request as ready for review November 7, 2024 08:51
@JarbasAl JarbasAl mentioned this pull request Nov 7, 2024
@github-actions github-actions bot added fix and removed fix labels Nov 7, 2024
Copy link
Contributor

@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: 2

🧹 Outside diff range and nitpick comments (3)
ovos_workshop/skills/common_query_skill.py (3)

70-72: LGTM! Consider extracting the language code splitting logic.

The language code handling is correct, but consider extracting the split("-")[0] logic into a helper method for better reusability and maintainability.

+    def _get_base_lang(self) -> str:
+        """Extract base language code (e.g., 'en' from 'en-US')"""
+        return self.lang.split("-")[0]

     def __init__(self, *args, **kwargs):
         # ...
-        lang = self.lang.split("-")[0]
+        lang = self._get_base_lang()

93-93: LGTM! Consider caching the base language code.

The implementation is correct, but the language code splitting is repeated in multiple places. Consider using the suggested _get_base_lang() method here as well.

     @property
     def translated_noise_words(self) -> List[str]:
-        return self._translated_noise_words.get(self.lang.split("-")[0], [])
+        return self._translated_noise_words.get(self._get_base_lang(), [])

     @translated_noise_words.setter
     def translated_noise_words(self, val: List[str]):
-        self._translated_noise_words[self.lang.split("-")[0]] = val
+        self._translated_noise_words[self._get_base_lang()] = val

Also applies to: 99-99


Line range hint 183-189: LGTM! Apply the same language code handling improvement here.

The noise word removal logic is correct. For consistency, use the suggested _get_base_lang() method here as well.

     def remove_noise(self, phrase: str, lang: str = None) -> str:
-        lang = (lang or self.lang).split("-")[0]
+        lang = lang.split("-")[0] if lang else self._get_base_lang()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c71926e and c72d708.

📒 Files selected for processing (13)
  • ovos_workshop/res/text/az/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/ca/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/cs/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/da/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/de/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/en/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/fa/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/pl/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/sl/word_connectors.json (1 hunks)
  • ovos_workshop/res/text/uk/word_connectors.json (1 hunks)
  • ovos_workshop/skills/common_query_skill.py (4 hunks)
  • ovos_workshop/skills/ovos.py (5 hunks)
  • requirements/requirements.txt (1 hunks)
✅ Files skipped from review due to trivial changes (10)
  • ovos_workshop/res/text/az/word_connectors.json
  • ovos_workshop/res/text/ca/word_connectors.json
  • ovos_workshop/res/text/cs/word_connectors.json
  • ovos_workshop/res/text/da/word_connectors.json
  • ovos_workshop/res/text/de/word_connectors.json
  • ovos_workshop/res/text/en/word_connectors.json
  • ovos_workshop/res/text/fa/word_connectors.json
  • ovos_workshop/res/text/pl/word_connectors.json
  • ovos_workshop/res/text/sl/word_connectors.json
  • ovos_workshop/res/text/uk/word_connectors.json
🔇 Additional comments (8)
requirements/requirements.txt (2)

5-6: LGTM! Version constraints follow best practices.

The version constraints >=0.0.1,<1.0.0 follow semantic versioning best practices, allowing patches and minor updates while preventing major breaking changes.


5-6: Verify package stability and feature completeness.

The new packages are at very early versions (0.0.1). Let's verify their stability and ensure they fully replace the removed ovos-lingua-franca functionality.

Consider adding comments in requirements.txt to document that these packages replace lingua_franca functionality:

+# Replacements for ovos-lingua-franca
 ovos-solver-yes-no-plugin>=0.0.1,<1.0.0
 ovos-number-parser>=0.0.1,<1.0.0
✅ Verification successful

Package versions and functionality are stable and complete

The verification shows:

  • ovos-solver-yes-no-plugin is at v0.1.0a1 (not 0.0.1) with comprehensive yes/no parsing capabilities
  • ovos-number-parser v0.0.1 provides full number parsing functionality across multiple languages
  • No remaining lingua_franca imports found in the codebase, indicating complete migration

The packages appear to be stable replacements for the removed lingua_franca functionality:

  • Yes/No solver handles affirmative/negative response parsing with extensive test coverage
  • Number parser supports number extraction, pronunciation, ordinals and fractions across 19 languages
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check package information and recent activity

# Check PyPI metadata for both packages
echo "Checking ovos-solver-yes-no-plugin PyPI info..."
curl -s "https://pypi.org/pypi/ovos-solver-yes-no-plugin/json" | jq -r '.info | {version: .version, author: .author, description: .description}'

echo "Checking ovos-number-parser PyPI info..."
curl -s "https://pypi.org/pypi/ovos-number-parser/json" | jq -r '.info | {version: .version, author: .author, description: .description}'

# Search for any remaining lingua_franca imports that might need updating
echo "Checking for remaining lingua_franca imports..."
rg -l "from lingua_franca" || echo "No lingua_franca imports found"
rg -l "import lingua_franca" || echo "No lingua_franca imports found"

Length of output: 10507

ovos_workshop/skills/common_query_skill.py (2)

83-84: LGTM! Clean implementation of language-specific noise words storage.

The dictionary-based storage using base language codes is a good approach for managing multilingual noise words.


Line range hint 70-189: Verify language resource files.

Let's ensure all required language resource files are present in the repository.

✅ Verification successful

Language resource files are properly structured and available

The verification shows that noise word files are present for multiple languages (cs, de, en, ru) in the expected location ovos_workshop/res/text/{lang}/noise_words.list. Each file contains appropriate noise words for its respective language, properly formatted with one word per line.

The implementation correctly:

  • Handles language codes by splitting on "-" (e.g., "en-US" → "en")
  • Provides default resource paths that match the actual file structure
  • Contains valid content in the noise word files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for language resource files in the repository

# Test: List all noise_words.list files
echo "Checking noise words files..."
fd "noise_words.list" --type f

# Test: Check content format of noise words files
echo -e "\nVerifying noise words file format..."
fd "noise_words.list" --type f --exec cat {} \; | grep -v '^[[:space:]]*$' || true

Length of output: 1183

ovos_workshop/skills/ovos.py (4)

2-2: Necessary import of json module

The json module is correctly imported to handle JSON operations in the newly added helper functions.


19-20: Update imports to new dependencies

The import statements are updated to use ovos_number_parser and ovos_yes_no_solver, replacing lingua_franca functions. This aligns with the shift to the new dependencies and ensures compatibility with the updated libraries.


2013-2013: Initialize YesNoSolver in ask_yesno method

The ask_yesno method now utilizes the YesNoSolver class to improve the accuracy of yes/no response handling, enhancing language support and flexibility.


2059-2061: Utilize join_word_list for localized option presentation

The ask_selection method now uses the join_word_list function to present options in a localized and readable format, improving internationalization and user experience.

ovos_workshop/skills/ovos.py Outdated Show resolved Hide resolved
ovos_workshop/skills/ovos.py Outdated Show resolved Hide resolved
@JarbasAl
Copy link
Member Author

JarbasAl commented Nov 7, 2024

@coderabbitai review

@github-actions github-actions bot added fix and removed fix labels Nov 7, 2024
Copy link
Contributor

coderabbitai bot commented Nov 7, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Nov 7, 2024

Walkthrough

The changes in this pull request involve significant updates to the ovos.py file within the OVOSSkill class, focusing on the imports and implementations of methods for handling number pronunciation and yes/no questions. The requirements.txt file has been modified to remove the ovos-lingua-franca dependency and add ovos-solver-yes-no-plugin and ovos-number-parser. These changes streamline the skill's functionality by integrating new libraries for improved user interaction.

Changes

File Change Summary
ovos_workshop/skills/ovos.py - Updated imports to use ovos_number_parser and ovos_yes_no_solver.
- Modified ask_yesno method to use YesNoSolver.
- Updated ask_selection method to utilize pronounce_number from ovos_number_parser.
requirements/requirements.txt - Removed dependency on ovos-lingua-franca.
- Added dependencies for ovos-solver-yes-no-plugin and ovos-number-parser.

Possibly related PRs

  • fix:lingua_franca #257: The changes in this PR also modify the ask_yesno method in the OVOSSkill class in ovos.py, focusing on language handling for yes/no responses, which is relevant to the changes made in the main PR regarding the same method.
  • feat: list join util #269: This PR introduces new utility functions in ovos.py for joining word lists using "and" and "or," which relates to the modifications in the ask_selection method of the main PR that also deals with presenting options to the user.

Suggested reviewers

  • goldyfruit

Poem

🐰 In the meadow where bunnies play,
New skills are hopping in a bright array.
With numbers spoken and answers clear,
Our voices ring out, for all to hear!
So let’s cheer for changes, both fresh and bright,
As we leap through the code, with pure delight! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f77e498 and daab462.

📒 Files selected for processing (2)
  • ovos_workshop/skills/ovos.py (2 hunks)
  • requirements/requirements.txt (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • requirements/requirements.txt
🔇 Additional comments (2)
ovos_workshop/skills/ovos.py (2)

19-20: LGTM: Import changes align with PR objective

The replacement of lingua_franca with ovos_number_parser and ovos_yes_no_solver is appropriate and maintains the required functionality.


2015-2015: LGTM: Clean migration to YesNoSolver

The implementation correctly replaces lingua_franca's yes_or_no with YesNoSolver while maintaining the same functionality and return value contract.


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 fix and removed fix labels Nov 7, 2024
@JarbasAl JarbasAl requested review from NeonDaniel and a team November 11, 2024 15:01
@JarbasAl JarbasAl merged commit 5df2cd4 into dev Nov 11, 2024
9 of 10 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 30, 2025
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.

1 participant