Skip to content

Commit

Permalink
support samples sent via bus
Browse files Browse the repository at this point in the history
includes #309
  • Loading branch information
JarbasAl committed Apr 24, 2023
1 parent fbd9026 commit 1c5798a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mycroft/skills/intent_services/padatious_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,22 @@ def _register_object(self, message, object_name):
message (Message): trigger for action
object_name (str): type of entry to register
"""
file_name = message.data['file_name']
file_name = message.data.get('file_name')
samples = message.data.get("samples")
name = message.data['name']
lang = message.data.get('lang', self.lang).lower()

self._init_lang(lang) # if needed create a new intent engine for this lang

LOG.debug('Registering Jurebes ' + object_name + ': ' + name)

if not isfile(file_name):
LOG.warning('Could not find file ' + file_name)
if (not file_name or not isfile(file_name)) and not samples:
LOG.error('Could not find file ' + file_name)
return

with open(file_name) as f:
samples = [l.strip() for l in f.readlines()]
if not samples and isfile(file_name):
with open(file_name) as f:
samples = [l.strip() for l in f.readlines()]

if object_name == "intent":
self.containers[lang].add_intent(name, samples)
Expand Down

0 comments on commit 1c5798a

Please sign in to comment.