fix: use the shared language-match helper for dialect configs - #428
fix: use the shared language-match helper for dialect configs#428JarbasAl wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Ready for review! The automated tests have finished. ✅I've aggregated the results of the automated checks for this PR below. 🔍 LintThe data is in, and it's looking interesting! 🧐 ❌ ruff: issues found — see job log 🔒 Security (pip-audit)A detailed security audit of your contribution. 📝 ✅ No known vulnerabilities found (65 packages scanned). 🏷️ Release PreviewThe release banner is being designed! 🎨 Current:
✅ PR title follows conventional commit format. 🚀 Release Channel Compatibility Predicted next version:
📋 Repo HealthI've performed a health check on the project. 🏥 ✅ All required files present. Latest Version: ✅ ⚖️ License CheckI've checked the genealogical tree of your licenses. 🌳 ✅ No license violations found. Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed. 📊 CoverageChecking the insulation of our logic. 🏠 ✅ 82.7% total coverage Files below 80% coverage (23 files)
Full report: download the 🔨 Build TestsEnsuring the gears are properly lubricated. 💧
❌ 3.10: Install OK, tests failed Automatically generated, personally appreciated 💖 |
Both dialect filters compared a distance by hand; lang_matches owns that comparison and its threshold.
fe0e8a8 to
9508a6c
Compare
What
ovos_plugin_manager/utils/config.pycompared a language distance by hand intwo places:
get_valid_plugin_configs(dialect filter)get_plugin_language_configs(macro filter)Both read
if lang_distance(...) < 10. Both now calllang_matches, whichowns the comparison and the threshold.
Why
ovos_spec_tools.DEFAULT_MAX_LANGUAGE_DISTANCEis 10. A< 10comparisonadmits 0 to 9 and rejects 10 itself.
langcodesgives a distance of exactly 10 to a language measured against itsmacrolanguage tag:
tag_distance('arz', 'ar')andtag_distance('wuu', 'zh')are both 10. Its own
closest_matchfilters withdistance <= max_distance.The hand-rolled
<therefore excluded the one relation the number 10 names —which is the relation the second call site is literally named after
(
macro).Behaviour change
A plugin that ships a config for a macrolanguage now offers it to a request in
a member language. A TTS or STT plugin with an
arconfig is offered for anarzrequest; a plugin with azhconfig is offered forwuu. The dialectpriority boost applies as it already does for regional variants.
Not every variety moves. Only pairs
langcodesscores at 10 or less change;aryandapcagainstarscore 14 and are still excluded, as areafagainst
nl(24) andyueagainstzh(64).Tests
New file
test/unittests/test_lang_distance_boundary.pypins both sides:arz/arandwuu/zhare offered.ar-SA/ar,en-AU/en-GB,pt-BR/pt-PTare offered.en/zh,es/fr,fr-CH/de-CH,af/nlare not offered.RED, with the
< 10comparisons restored:GREEN, in isolation:
3 passed, 9 subtests passed.In-suite with
test/unittests/test_utils.py:30 passed, 9 subtests passed.No
pytest.importorskipat any level in the new file.Verified against source
< 10sites — read fromorigin/dev.distance <= max_distanceinlangcodes.closest_match, and thetag_distancemacrolanguage docstring — read from the installedlangcodes.ovos_spec_tools.language.lang_distance, not copied from documentation.Dependency
pyproject.tomlpinsovos-spec-tools[langcodes]>=0.0.1a2.lang_matchesneeds the inclusive bound from OpenVoiceOS/ovos-spec-tools#96, so the floor
must be raised to the release carrying it before this merges. That release does
not exist yet, so the bump is not in this branch.
Merge order
ovos-spec-tools, then raise the floor pin here