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

Commit

Permalink
Allow Padatious to override Adapt (#1713)
Browse files Browse the repository at this point in the history
Allow a Padatious intent to override Adapt when it is VERY
certain that the utterance is directed at it.  (95% confidence
or greater.)  Right now that only occurs if the intent match
for the given phrase is perfect.

This solves this kind of issue:
* Adapt:  Matching on "Set" and "Alarm"
* Padatious: Handling "is an alarm set"

* Fix logic error for when no Padatious intent
  • Loading branch information
Steve Penrod authored Aug 3, 2018
1 parent d49d991 commit 609a09b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 7 additions & 3 deletions mycroft/skills/intent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from mycroft.util.log import LOG
from mycroft.util.parse import normalize
from mycroft.metrics import report_timing, Stopwatch
from mycroft.skills.padatious_service import PadatiousService


class AdaptIntent(IntentBuilder):
Expand Down Expand Up @@ -244,7 +245,6 @@ def send_metrics(self, intent, context, stopwatch):
NOTE: This only applies to those with Opt In.
"""
LOG.debug('Sending metric if opt_in is enabled')
ident = context['ident'] if context else None
if intent:
# Recreate skill name from skill id
Expand Down Expand Up @@ -287,15 +287,19 @@ def handle_utterance(self, message):
if not converse:
# No conversation, use intent system to handle utterance
intent = self._adapt_intent_match(utterances, lang)
padatious_intent = PadatiousService.instance.calc_intent(
utterances[0])

if converse:
# Report that converse handled the intent and return
ident = message.context['ident'] if message.context else None
report_timing(ident, 'intent_service', stopwatch,
{'intent_type': 'converse'})
return
elif intent:
# Send the message to the intent handler
elif intent and not (padatious_intent and
padatious_intent.conf >= 0.95):
# Send the message to the Adapt intent's handler unless
# Padatious is REALLY sure it was directed at it instead.
reply = message.reply(intent.get('intent_type'), intent)
else:
# Allow fallback system to handle utterance
Expand Down
11 changes: 9 additions & 2 deletions mycroft/skills/padatious_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@


class PadatiousService(FallbackSkill):
instance = None

def __init__(self, emitter, service):
FallbackSkill.__init__(self)
if not PadatiousService.instance:
PadatiousService.instance = self

self.config = Configuration.get()['padatious']
self.service = service
intent_cache = expanduser(self.config['intent_cache'])
Expand Down Expand Up @@ -113,8 +118,7 @@ def handle_fallback(self, message):

utt = message.data.get('utterance')
LOG.debug("Padatious fallback attempt: " + utt)
data = self.container.calc_intent(utt)

data = self.calc_intent(utt)
if data.conf < 0.5:
return False

Expand All @@ -124,3 +128,6 @@ def handle_fallback(self, message):

self.emitter.emit(message.reply(data.name, data=data.matches))
return True

def calc_intent(self, utt):
return self.container.calc_intent(utt)

0 comments on commit 609a09b

Please sign in to comment.