From 7152a7303159f0ef4ccd3e5a8d659a47dead4baf Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Mon, 2 Aug 2021 11:57:16 +0200 Subject: [PATCH] added padatious entity support --- jarvis/skills/__init__.py | 16 ++++++++++++++-- jarvis/skills/intent_manager.py | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/jarvis/skills/__init__.py b/jarvis/skills/__init__.py index 2b72479..36f0ea3 100644 --- a/jarvis/skills/__init__.py +++ b/jarvis/skills/__init__.py @@ -56,11 +56,12 @@ class Skill: thread.start() def register(self): - self.register_entities() + self.register_entities_adapt() + self.register_entities_padatious() self.register_regex() print("[" + self.name + "] Registered entity/entities and regex(s)") - def register_entities(self): + def register_entities_adapt(self): path = self.path + "/vocab/" + languages_utils.get_language() + "/*.voc" files = glob.glob(path, recursive=True) @@ -71,6 +72,17 @@ class Skill: intent_manager.register_entity_adapt(line.replace('\n', ''), filename, self.name) + def register_entities_padatious(self): + path = self.path + "/vocab/" + languages_utils.get_language() + "/*.entity" + + files = glob.glob(path, recursive=True) + for file in files: + with open(file, "r") as infile: + for line in infile.readlines(): + filename = file.split("/")[-1].split(".entity")[0] + + intent_manager.register_entity_adapt(line.replace('\n', ''), filename, self.name) + def register_regex(self): path = self.path + "/regex/" + languages_utils.get_language() + "/*.rx" diff --git a/jarvis/skills/intent_manager.py b/jarvis/skills/intent_manager.py index 00aefd6..2bd04d3 100644 --- a/jarvis/skills/intent_manager.py +++ b/jarvis/skills/intent_manager.py @@ -17,6 +17,11 @@ def register_entity_adapt(entity_value, entity_type, domain): # print("[Adapt]: Added entity with type " + entity_type + " for " + domain) +def register_entity_padatious(entity_name, list): + padatious_intents_container.add_entity(entity_name, list) + # print("[Padatious]: Added entity with name " + entity_name + " with " str(len(list)) + "examples.") + + def register_regex_adapt(regex, domain): adapt_engine.register_regex_entity(regex, domain) # print("[Adapt]: Added new regex for " + domain)