From 337259498741816d185635c635546a1057a76c59 Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Wed, 28 Jul 2021 18:05:34 +0200 Subject: [PATCH] Added register_intent in Skill class and grammar --- jarvis/skills/__init__.py | 5 ++++- jarvis/skills/research/wikipedia/__init__.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/jarvis/skills/__init__.py b/jarvis/skills/__init__.py index ec5dbee..4e96295 100644 --- a/jarvis/skills/__init__.py +++ b/jarvis/skills/__init__.py @@ -15,7 +15,7 @@ class Skill: def register(self): self.register_entities() self.register_regex() - print("[" + self.name + "] Registred entitie(s) and regex(s)") + print("[" + self.name + "] Registered entity/entities and regex(s)") def register_entities(self): path = os.path.dirname(get_path_file.__file__) + "/skills/" + self.category + "/" + self.skill_folder @@ -38,3 +38,6 @@ class Skill: with open(file, "r") as infile: for line in infile.readlines(): intent_manager.register_regex(line.replace('\n', ''), self.name) + + def register_intent(self, intent): + intent_manager.register_intent(intent.build(), domain=self.name) diff --git a/jarvis/skills/research/wikipedia/__init__.py b/jarvis/skills/research/wikipedia/__init__.py index e061fef..8cd7fa6 100644 --- a/jarvis/skills/research/wikipedia/__init__.py +++ b/jarvis/skills/research/wikipedia/__init__.py @@ -1,6 +1,6 @@ from adapt.intent import IntentBuilder -from jarvis.skills import Skill, intent_manager +from jarvis.skills import Skill class WikipediaSkill(Skill): @@ -10,5 +10,7 @@ class WikipediaSkill(Skill): def register(self): super().register() - intent_manager.register_intent(IntentBuilder("WikipediaQueryIntent").require("Wikipedia").require("ArticleTitle").build(), - domain=self.name) + wikipedia_query_intent = IntentBuilder("WikipediaQueryIntent")\ + .require("Wikipedia")\ + .require("ArticleTitle") + super().register_intent(wikipedia_query_intent)