Skip to content

fix:standardize_lang #10

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

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions ovos_adapt/opm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ovos_plugin_manager.templates.pipeline import IntentMatch, PipelinePlugin
from ovos_utils import flatten_list
from ovos_utils.log import LOG
from ovos_utils.lang import standardize_lang_tag


def _entity_skill_id(skill_id):
Expand All @@ -47,12 +48,13 @@ class AdaptPipeline(PipelinePlugin):

def __init__(self, config=None):
core_config = Configuration()
self.config = config or core_config.get("context", {}) # legacy mycroft-core path
self.lang = core_config.get("lang", "en-us")
config = config or core_config.get("context", {}) # legacy mycroft-core path
super().__init__(config)
self.lang = standardize_lang_tag(core_config.get("lang", "en-US"))
langs = core_config.get('secondary_langs') or []
if self.lang not in langs:
langs.append(self.lang)

langs = [standardize_lang_tag(l) for l in langs]
self.engines = {lang: IntentDeterminationEngine()
for lang in langs}

Expand Down Expand Up @@ -210,7 +212,7 @@ def match_intent(self, utterances: Tuple[str],
LOG.error(f"utterance exceeds max size of {self.max_words} words, skipping adapt match")
return None

lang = lang or self.lang
lang = standardize_lang_tag(lang or self.lang)
if lang not in self.engines:
return None

Expand Down Expand Up @@ -256,18 +258,8 @@ def take_best(intent, utt):
ret = None
return ret

def register_vocab(self, start_concept, end_concept,
alias_of, regex_str, lang):
"""Register Vocabulary. DEPRECATED

This method should not be used, it has been replaced by
register_vocabulary().
"""
self.register_vocabulary(start_concept, end_concept, alias_of,
regex_str, lang)

def register_vocabulary(self, entity_value, entity_type,
alias_of, regex_str, lang):
def register_vocabulary(self, entity_value:str, entity_type:str,
alias_of:str, regex_str:str, lang: str):
"""Register skill vocabulary as adapt entity.

This will handle both regex registration and registration of normal
Expand All @@ -279,6 +271,7 @@ def register_vocabulary(self, entity_value, entity_type,
entity_type: the type/tag of an entity instance
alias_of: entity this is an alternative for
"""
lang = standardize_lang_tag(lang)
if lang in self.engines:
with self.lock:
if regex_str:
Expand Down
3 changes: 1 addition & 2 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
coveralls>=1.8.2
flake8>=3.7.9
pytest>=5.2.4
pytest-cov>=2.8.1
cov-core>=1.15.0
pytest-cov>=2.8.1
Loading