Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/intent_plugs #100

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mycroft/deprecated/intent_services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from mycroft.deprecated.intent_services.adapt_service \
import AdaptService, AdaptIntent
from mycroft.deprecated.intent_services.padatious_service \
import PadatiousService, PadatiousMatcher
95 changes: 95 additions & 0 deletions mycroft/deprecated/intent_services/adapt_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2020 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""An intent parsing service using the Adapt parser."""
from threading import Lock
from ovos_plugin_manager.utils.intent_context import ContextManagerFrame, ContextManager

from adapt.intent import IntentBuilder

from mycroft.configuration import Configuration
from ovos_plugin_manager.templates.intents import IntentMatch


def _entity_skill_id(skill_id):
"""Helper converting a skill id to the format used in entities.

Arguments:
skill_id (str): skill identifier

Returns:
(str) skill id on the format used by skill entities
"""
skill_id = skill_id[:-1]
skill_id = skill_id.replace('.', '_')
skill_id = skill_id.replace('-', '_')
return skill_id


class AdaptIntent(IntentBuilder):
"""Wrapper for IntentBuilder setting a blank name.

Args:
name (str): Optional name of intent
"""

def __init__(self, name=''):
super().__init__(name)


class AdaptService:
"""DEPRECATED - use adapt intent plugin directly instead"""

def __init__(self, config):
self.config = config
self.lang = Configuration.get().get("lang", "en-us")
self.engines = {}
# Context related initializations
self.context_keywords = self.config.get('keywords', [])
self.context_max_frames = self.config.get('max_frames', 3)
self.context_timeout = self.config.get('timeout', 2)
self.context_greedy = self.config.get('greedy', False)
self.context_manager = ContextManager(self.context_timeout)
self.lock = Lock()
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def update_context(self, intent):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def match_intent(self, utterances, lang=None, __=None):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def register_vocab(self, start_concept, end_concept,
alias_of, regex_str, lang):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def register_vocabulary(self, entity_value, entity_type,
alias_of, regex_str, lang):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def register_intent(self, intent):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def detach_skill(self, skill_id):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")

def detach_intent(self, intent_name):
"""DEPRECATED - use adapt intent plugin directly instead"""
LOG.error("AdaptService has been deprecated, stop importing this class!!!")
95 changes: 95 additions & 0 deletions mycroft/deprecated/intent_services/padatious_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2020 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Intent service wrapping padatious."""
from threading import Event
from time import time as get_time
from mycroft.configuration import Configuration
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG
from ovos_plugin_manager.templates.intents import IntentMatch


class PadatiousMatcher:
"""Matcher class to avoid redundancy in padatious intent matching."""

def __init__(self, service):
self.service = service
self.has_result = False
self.ret = None
self.conf = None
LOG.error("PadatiousMatcher has been deprecated, stop importing this class!!!")

def match_high(self, utterances, lang=None, __=None):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousMatcher has been deprecated, stop importing this class!!!")

def match_medium(self, utterances, lang=None, __=None):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousMatcher has been deprecated, stop importing this class!!!")

def match_low(self, utterances, lang=None, __=None):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousMatcher has been deprecated, stop importing this class!!!")


class PadatiousService:
"""DEPRECATED - use padatious intent plugin directly instead"""

def __init__(self, bus, config):
self.padatious_config = config
self.bus = bus

self.lang = Configuration.get().get("lang", "en-us")

self.containers = {}

self.finished_training_event = Event()
self.finished_initial_train = True
self.finished_training_event.set()

self.train_delay = self.padatious_config['train_delay']
self.train_time = get_time() + self.train_delay

self.registered_intents = []
self.registered_entities = []
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def train(self, message=None):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def wait_and_train(self):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def handle_detach_intent(self, message):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def handle_detach_skill(self, message):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def register_intent(self, message):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def register_entity(self, message):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")

def calc_intent(self, utt, lang=None):
"""DEPRECATED - use padatious intent plugin directly instead"""
LOG.error("PadatiousService has been deprecated, stop importing this class!!!")
3 changes: 2 additions & 1 deletion mycroft/skills/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready,

# Connect this process to the Mycroft message bus
bus = start_message_bus_client("SKILLS")
_register_intent_services(bus)
intentservice = _register_intent_services(bus)
event_scheduler = EventScheduler(bus, autostart=False)
event_scheduler.daemon = True
event_scheduler.start()
Expand All @@ -68,6 +68,7 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready,

wait_for_exit_signal()

intentservice.shutdown()
shutdown(skill_manager, event_scheduler)


Expand Down
Loading