Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Fix an issue where intents are not returned from Adapt in confidence …
Browse files Browse the repository at this point in the history
…order.
  • Loading branch information
chrisveilleux committed Jul 8, 2021
1 parent b3a0b3b commit f07c80f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions mycroft/skills/intent_services/adapt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ def get_context(self, max_frames=None, missing_entities=None):


class AdaptService:
"""Intent service wrapping the Apdapt intent Parser."""
"""Intent service wrapping the Adapt intent Parser."""
def __init__(self, config):
self.config = config
self.engine = IntentDeterminationEngine()
# Context related intializations
# Context related initialization
self.context_keywords = self.config.get('keywords', [])
self.context_max_frames = self.config.get('max_frames', 3)
self.context_timeout = self.config.get('timeout', 2)
Expand Down Expand Up @@ -202,8 +202,12 @@ def match_intent(self, utterances, _=None, __=None):
"""Run the Adapt engine to search for an matching intent.
Args:
utterances (iterable): iterable of utterances, expected order
[raw, normalized, other]
utterances (iterable): utterances for consideration in intent
matching. As a practical matter, a single utterance will be
passed in most cases. But there are instances, such as
streaming STT that could pass multiple. Each utterance
is represented as a tuple containing the raw, normalized, and
possibly other variations of the utterance.
Returns:
Intent structure, or None if no match was found.
Expand All @@ -227,7 +231,11 @@ def take_best(intent, utt):
include_tags=True,
context_manager=self.context_manager)]
if intents:
take_best(intents[0], utt_tup[0])
intents_with_best_confidence = max(
intents,
key=lambda intent: intent.get('confidence', 0.0)
)
take_best(intents_with_best_confidence, utt_tup[0])

except Exception as err:
LOG.exception(err)
Expand Down

0 comments on commit f07c80f

Please sign in to comment.