From 230c3057b4b928b91fcec4fad05acb8bbf5ec958 Mon Sep 17 00:00:00 2001 From: Steve Penrod Date: Tue, 5 Mar 2019 03:33:02 -0600 Subject: [PATCH] Give Padatious high and low match passes Padatious was accepting fairly low confidence matches (0.5). This would match a phrase such as "Where is the Empire State Building?" to the intent "Where were you born?" (Which is a 0.54 match) Now there are two passes mad on the Padatious fallback. The first is looking for high confidence matches (> 0.8). Then other fallbacks -- such as the CommonQuery fallbacks -- have an opportunity to consume the utterance. If they don't consume it, Padatious is invoked again with looser confidence before finally invoking the Unknown fallback. --- mycroft/skills/padatious_service.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mycroft/skills/padatious_service.py b/mycroft/skills/padatious_service.py index f486f59c32..fe54544c0e 100644 --- a/mycroft/skills/padatious_service.py +++ b/mycroft/skills/padatious_service.py @@ -56,7 +56,13 @@ class PadatiousService(FallbackSkill): self.bus.on('detach_intent', self.handle_detach_intent) self.bus.on('detach_skill', self.handle_detach_skill) self.bus.on('mycroft.skills.initialized', self.train) + + # Call Padatious an an early fallback, looking for a high match intent self.register_fallback(self.handle_fallback, 5) + + # Try loose Padatious intent match before going to fallback-unknown + self.register_fallback(self.handle_fallback_last_chance, 99) + self.finished_training_event = Event() self.finished_initial_train = False @@ -127,7 +133,7 @@ class PadatiousService(FallbackSkill): def register_entity(self, message): self._register_object(message, 'entity', self.container.load_entity) - def handle_fallback(self, message): + def handle_fallback(self, message, threshold=0.8): if not self.finished_training_event.is_set(): LOG.debug('Waiting for Padatious training to finish...') return False @@ -135,7 +141,7 @@ class PadatiousService(FallbackSkill): utt = message.data.get('utterance') LOG.debug("Padatious fallback attempt: " + utt) data = self.calc_intent(utt) - if data.conf < 0.5: + if data.conf < threshold: return False data.matches['utterance'] = utt @@ -145,5 +151,8 @@ class PadatiousService(FallbackSkill): self.bus.emit(message.reply(data.name, data=data.matches)) return True + def handle_fallback_last_chance(self, message): + return self.handle_fallback(message, 0.5) + def calc_intent(self, utt): return self.container.calc_intent(utt)