added padatious entity support

This commit is contained in:
Mathieu B 2021-08-02 11:57:16 +02:00
parent 69697818ec
commit 7152a73031
2 changed files with 19 additions and 2 deletions

View File

@ -56,11 +56,12 @@ class Skill:
thread.start() thread.start()
def register(self): def register(self):
self.register_entities() self.register_entities_adapt()
self.register_entities_padatious()
self.register_regex() self.register_regex()
print("[" + self.name + "] Registered entity/entities and regex(s)") 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" path = self.path + "/vocab/" + languages_utils.get_language() + "/*.voc"
files = glob.glob(path, recursive=True) files = glob.glob(path, recursive=True)
@ -71,6 +72,17 @@ class Skill:
intent_manager.register_entity_adapt(line.replace('\n', ''), filename, self.name) 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): def register_regex(self):
path = self.path + "/regex/" + languages_utils.get_language() + "/*.rx" path = self.path + "/regex/" + languages_utils.get_language() + "/*.rx"

View File

@ -17,6 +17,11 @@ def register_entity_adapt(entity_value, entity_type, domain):
# print("[Adapt]: Added entity with type " + entity_type + " for " + 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): def register_regex_adapt(regex, domain):
adapt_engine.register_regex_entity(regex, domain) adapt_engine.register_regex_entity(regex, domain)
# print("[Adapt]: Added new regex for " + domain) # print("[Adapt]: Added new regex for " + domain)