diff --git a/jarvis/skills/__init__.py b/jarvis/skills/__init__.py index af32180..ec5dbee 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("Registred entitie(s) and regex(s) for " + self.name) + print("[" + self.name + "] Registred entitie(s) and regex(s)") def register_entities(self): path = os.path.dirname(get_path_file.__file__) + "/skills/" + self.category + "/" + self.skill_folder @@ -27,8 +27,7 @@ class Skill: for line in infile.readlines(): filename = file.split("/")[-1].split(".voc")[0] - intent_manager.engine.register_entity(line.replace('\n', ''), filename, self.name) - # intent_manager.register_entity(line.replace('\n', ''), filename, self.name) + intent_manager.register_entity(line.replace('\n', ''), filename, self.name) def register_regex(self): path = os.path.dirname(get_path_file.__file__) + "/skills/" + self.category + "/" + self.skill_folder @@ -38,5 +37,4 @@ class Skill: for file in files: with open(file, "r") as infile: for line in infile.readlines(): - intent_manager.engine.register_regex_entity(line.replace('\n', ''), self.name) - # intent_manager.register_regex(line.replace('\n', ''), self.name) + intent_manager.register_regex(line.replace('\n', ''), self.name) diff --git a/jarvis/skills/intent_manager.py b/jarvis/skills/intent_manager.py index 844217a..54d60d0 100644 --- a/jarvis/skills/intent_manager.py +++ b/jarvis/skills/intent_manager.py @@ -1,38 +1,21 @@ from adapt.engine import DomainIntentDeterminationEngine -from adapt.intent import IntentBuilder engine = DomainIntentDeterminationEngine() -def register_entity(value, type, domain): - engine.register_entity(entity_value=value, entity_type=type, domain=domain) - - print("entity : " + value + " / " + type + " / " + domain) - # print("Registred entity : \"" + entity + "\" for domain : " + domain) +def register_entity(entity_value, entity_type, domain): + engine.register_entity(entity_value=entity_value, entity_type=entity_type, domain=domain) + print("[Adapt]: Added entity with type " + entity_type + " for " + domain) def register_regex(regex, domain): engine.register_regex_entity(regex, domain) - # print("Registred regex : \"" + regex + "\" for domain : " + domain) + print("[Adapt]: Added new regex for " + domain) def register_intent(intent, domain): - if domain not in engine.domains: - engine.register_domain(domain) - - # TODO: INVESTIGATE WHY IT WORKS WHEN DID MANUALLY BUT DOESN'T WHEN DID AUTOMATICALLY VIA THE INTENT - # register_entity('cherche', "Wikipedia", domain='WikipediaSkill') - # register_regex('.*(wiki|sur|au sujet de|wikipedia)(?! (sur|au sujet)) (?P.+)', - # domain='WikipediaSkill') - - # engine.register_entity('cherche', "Wikipedia", domain='WikipediaSkill') - # engine.register_regex_entity('.*(wiki|sur|au sujet de|wikipedia)(?! (sur|au sujet)) (?P.+)', - # domain='WikipediaSkill') - - # intent = IntentBuilder("WikipediaQueryIntent").require("Wikipedia").optionally('ArticleTitle').build() - engine.register_intent_parser(intent, domain='WikipediaSkill') - # print("Registred intent : " + domain) + print("[Adapt]: Registered new intent for skill " + domain) def recognise(sentence): diff --git a/jarvis/skills/research/wikipedia/__init__.py b/jarvis/skills/research/wikipedia/__init__.py index 37d109e..e061fef 100644 --- a/jarvis/skills/research/wikipedia/__init__.py +++ b/jarvis/skills/research/wikipedia/__init__.py @@ -10,4 +10,5 @@ class WikipediaSkill(Skill): def register(self): super().register() - intent_manager.engine.register_intent_parser(IntentBuilder("WikipediaQueryIntent").require("Wikipedia").build(), domain=self.name) + intent_manager.register_intent(IntentBuilder("WikipediaQueryIntent").require("Wikipedia").require("ArticleTitle").build(), + domain=self.name)