Added register_intent in Skill class and grammar

This commit is contained in:
Mathieu B 2021-07-28 18:05:34 +02:00
parent 1e9f9cd0ba
commit 3372594987
2 changed files with 9 additions and 4 deletions

View File

@ -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)

View File

@ -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)