-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
std lang codes #13
std lang codes #13
Conversation
WalkthroughThe changes in this pull request primarily focus on improving the handling of language tags and enhancing the intent matching logic within the Changes
Possibly related PRs
Suggested labels
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (3)
requirements.txt (1)
1-4
: Consider adding a version constraint for 'xxhash'.While not directly related to the changes made, it's noticed that 'xxhash' doesn't have a version constraint. To ensure long-term stability and reproducibility of the project setup, consider adding a version constraint for 'xxhash' as well.
For example:
xxhash>=2.0.0,<3.0.0
Replace the version numbers with those that are compatible with your project.
ovos_padatious/opm.py (2)
96-99
: LGTM: Consistent language tag standardization.The changes ensure that both the primary language and secondary languages are standardized using
standardize_lang_tag
. This is a good practice for maintaining consistency across the system.Consider using a list comprehension for better readability:
langs = [standardize_lang_tag(l) for l in (core_config.get('secondary_langs') or [])]This would combine the initialization and standardization of
langs
into a single line.🧰 Tools
🪛 Ruff
98-98: Ambiguous variable name:
l
(E741)
252-254
: LGTM: Standardized language tag in intent calculation.The use of
standardize_lang_tag
here ensures that the language tag is consistently formatted when calculating intents. This change aligns with the standardization approach used throughout the file.Regarding the TODO comment:
# TODO - allow close langs, match dialects
This suggests potential future enhancements to the language matching system. Would you like assistance in creating a GitHub issue to track this feature request for future implementation?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- ovos_padatious/opm.py (6 hunks)
- requirements.txt (1 hunks)
🧰 Additional context used
🪛 Ruff
ovos_padatious/opm.py
98-98: Ambiguous variable name:
l
(E741)
🔇 Additional comments (5)
requirements.txt (1)
4-4
: LGTM: New dependency added with appropriate version constraints.The addition of
ovos-workshop>=0.1.7,<2.0.0
is a good practice. It allows for compatible updates while ensuring a minimum version, which helps maintain stability and allows for bug fixes and minor improvements.ovos_padatious/opm.py (4)
28-28
: LGTM: New import for language tag standardization.The new import
standardize_lang_tag
fromovos_utils.lang
is correctly placed and necessary for the language standardization functionality being introduced.
51-51
: Improvement: Standardized language tag handling.The use of
standardize_lang_tag
ensures consistent language tag formatting throughout the matching process. This change enhances the robustness of language handling and reduces potential issues caused by inconsistent language tag formats.
216-216
: LGTM: Standardized language tag in intent registration.The use of
standardize_lang_tag
here ensures that the language tag is consistently formatted when registering intents. This change aligns with the standardization approach used throughout the file.
228-228
: LGTM: Standardized language tag in entity registration.The use of
standardize_lang_tag
here ensures that the language tag is consistently formatted when registering entities. This change maintains consistency with the standardization approach used throughout the file.
86766a0
to
0e7a2db
Compare
There was a problem hiding this 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)
tests/test_container.py (3)
36-36
: Approve changes, but consider using a more portable approach for temporary directories.The switch from relative paths to absolute paths in
/tmp
improves test reliability. However, hardcoding/tmp
might not be portable across all operating systems.Consider using
tempfile.mkdtemp()
to create a temporary directory for the tests. This approach is more portable and ensures proper cleanup after the tests.Example:
import tempfile def setUp(self): self.test_dir = tempfile.mkdtemp() self.cont = IntentContainer(self.test_dir) def tearDown(self): shutil.rmtree(self.test_dir)This change would make the tests more robust and portable across different operating systems.
Also applies to: 47-47, 51-51, 55-55, 59-59
90-90
: Approve change, but consider adding back tearDown method.The update to use
/tmp/cache
is consistent with earlier modifications. However, the removal of thetearDown
method might lead to accumulated temporary files.Consider adding back a
tearDown
method to ensure proper cleanup after tests:def tearDown(self): import shutil shutil.rmtree('/tmp/cache', ignore_errors=True)This will help maintain a clean test environment and prevent potential issues with accumulated temporary files.
Line range hint
1-255
: Overall changes improve test reliability, but consider addressing cleanup.The modifications in this file consistently update file paths to use absolute paths in
/tmp
, which improves test reliability across different environments. The test logic and coverage remain intact, ensuring that theIntentContainer
functionality is still properly tested.However, the removal of the
tearDown
method inTestIntentContainer
might lead to accumulated temporary files. Consider adding back atearDown
method or using a context manager to ensure proper cleanup after tests.Additionally, to improve portability across different operating systems, consider using
tempfile.mkdtemp()
instead of hardcoding/tmp
paths.These suggestions will further enhance the robustness and maintainability of the test suite.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- ovos_padatious/intent_container.py (2 hunks)
- ovos_padatious/opm.py (6 hunks)
- requirements.txt (1 hunks)
- tests/test_container.py (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- requirements.txt
🧰 Additional context used
🪛 Ruff
ovos_padatious/opm.py
98-98: Ambiguous variable name:
l
(E741)
🔇 Additional comments (6)
tests/test_container.py (4)
16-19
: LGTM: Import statements updated appropriately.The new import statements are correctly added and are likely used in the modified test cases. These changes improve the readability and maintainability of the test file.
68-68
: LGTM: Consistent change in test_instantiate_from_disk method.The update to use
/tmp/cache2
is consistent with the earlier modifications. The test logic remains unchanged, maintaining the integrity of the test case.
97-97
: LGTM: Consistent update to use absolute paths in test_load_intent.The change to use
/tmp
for file paths is consistent with earlier modifications and improves test reliability by using absolute paths.Also applies to: 101-101
177-178
: LGTM: Improved readability in test_calc_intents assertion.The assertion has been split across two lines, which improves readability without altering the logic. The test still correctly compares the confidence of intents and their names.
ovos_padatious/intent_container.py (1)
17-17
: LGTM: Import statement addition is appropriate.The addition of the
time
module import is necessary for thetime.sleep()
call introduced in thetrain
method. This is a standard Python module, so there are no compatibility concerns.ovos_padatious/opm.py (1)
267-277
: LGTMThe
_get_closest_lang
method appropriately usesclosest_match
from thelangcodes
library to find the closest matching language and ensures that only acceptable language differences (score less than 10) are considered.
Summary by CodeRabbit
New Features
ovos-utils
andlangcodes
to support additional functionalities.Bug Fixes
Tests