Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Use IntentServiceInterface in MycroftSkill.register_vocabulary()
Browse files Browse the repository at this point in the history
This moves the message logic for adapt keyword registration into a single location.
  • Loading branch information
forslund committed Aug 2, 2021
1 parent a1f9bd5 commit 6abbf11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 2 additions & 3 deletions mycroft/skills/mycroft_skill/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,9 +1168,8 @@ def register_vocabulary(self, entity, entity_type):
entity: word to register
entity_type: Intent handler entity to tie the word to
"""
self.bus.emit(Message('register_vocab', {
'start': entity, 'end': to_alnum(self.skill_id) + entity_type
}))
keyword_type = to_alnum(self.skill_id) + entity_type
self.intent_service.register_adapt_keyword(keyword_type, entity)

def register_regex(self, regex_str):
"""Register a new regex.
Expand Down
9 changes: 8 additions & 1 deletion test/unittests/skills/test_mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,14 @@ def test_register_vocab(self):

# Normal vocaubulary
self.emitter.reset()
expected = [{'start': 'hello', 'end': 'AHelloKeyword'}]
expected = [
{
'start': 'hello',
'end': 'AHelloKeyword',
'entity_value': 'hello',
'entity_type': 'AHelloKeyword'
}
]
s.register_vocabulary('hello', 'HelloKeyword')
self.check_register_vocabulary(expected)
# Regex
Expand Down

0 comments on commit 6abbf11

Please sign in to comment.