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: normalization + disable new feats by default #38

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Changes from all commits
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
13 changes: 9 additions & 4 deletions ovos_padatious/opm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ovos_padatious.match_data import MatchData as PadatiousIntent
from ovos_plugin_manager.templates.pipeline import ConfidenceMatcherPipeline, IntentHandlerMatch, IntentMatch
from ovos_utils import flatten_list
from ovos_utils.bracket_expansion import expand_template
from ovos_utils.fakebus import FakeBus
from ovos_utils.lang import standardize_lang_tag
from ovos_utils.log import LOG, deprecated, log_deprecation
Expand Down Expand Up @@ -280,8 +281,11 @@ def __init__(self, bus: Optional[Union[MessageBusClient, FakeBus]] = None,
disable_padaos=self.config.get("disable_padaos", False))
for lang in langs}

self.stemmers = {lang: Stemmer(lang)
for lang in langs if Stemmer.supports_lang(lang)}
if self.config.get("stem", False):
self.stemmers = {lang: Stemmer(lang)
for lang in langs if Stemmer.supports_lang(lang)}
else:
self.stemmers = {}

self.finished_training_event = Event() # DEPRECATED
self.finished_initial_train = False
Expand Down Expand Up @@ -331,7 +335,7 @@ def _match_level(self, utterances, limit, lang=None, message: Optional[Message]
utterances = normalize_utterances(utterances, lang,
stemmer=stemmer,
keep_order=True,
cast_to_ascii=self.config.get("cast_to_ascii", True))
cast_to_ascii=self.config.get("cast_to_ascii", False))
padatious_intent = self.calc_intent(utterances, lang, message)
if padatious_intent is not None and padatious_intent.conf > limit:
skill_id = padatious_intent.name.split(':')[0]
Expand Down Expand Up @@ -468,14 +472,15 @@ def _register_object(self, message, object_name, register_func):
with open(file_name) as f:
samples = [line.strip() for line in f.readlines()]

samples = deduplicate_list(flatten_list([expand_template(s) for s in samples]))
if lang in self.stemmers:
stemmer = self.stemmers[lang]
else:
stemmer = None
samples = normalize_utterances(samples, lang,
stemmer=stemmer,
keep_order=False,
cast_to_ascii=self.config.get("cast_to_ascii", True))
cast_to_ascii=self.config.get("cast_to_ascii", False))

if self.engine_class == DomainIntentContainer:
register_func(skill_id, name, samples)
Expand Down
Loading