How to use the mindmeld.path function in mindmeld

To help you get started, we’ve selected a few mindmeld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cisco / mindmeld / tests / test_path.py View on Github external
def test_get_domains():
    domains = set(path.get_domains(APP_PATH))
    assert len(domains) == 1
    assert DOMAIN_NAME in domains
github cisco / mindmeld / mindmeld / components / nlp.py View on Github external
def __init__(self, app_path, domain, resource_loader=None):
        """Initializes a domain processor object

        Args:
            app_path (str): The path to the directory containing the app's data
            domain (str): The name of the domain
            resource_loader (ResourceLoader): An object which can load resources for the processor
        """
        super().__init__(app_path, resource_loader)
        self.name = domain
        self.intent_classifier = IntentClassifier(self.resource_loader, domain)
        for intent in path.get_intents(app_path, domain):
            self._children[intent] = IntentProcessor(
                app_path, domain, intent, self.resource_loader
            )
github cisco / mindmeld / mindmeld / components / nlp.py View on Github external
app_path (str): The path to the directory containing the app's data
            resource_loader (ResourceLoader): An object which can load resources for the processor
            config (dict): A config object with processor settings (e.g. if to use n-best
                transcripts)
        """
        super().__init__(app_path, resource_loader, config)
        self._app_path = app_path

        # initialize the system entity recognizer singleton
        SystemEntityRecognizer.get_instance(app_path)

        self.name = app_path
        self._load_custom_features()
        self.domain_classifier = DomainClassifier(self.resource_loader)

        for domain in path.get_domains(self._app_path):
            self._children[domain] = DomainProcessor(
                app_path, domain, self.resource_loader
            )

        nbest_transcripts_nlp_classes = self.config.get(
            "resolve_entities_using_nbest_transcripts", {}
        )
        if len(nbest_transcripts_nlp_classes) > 0:
            nbest_transcripts_nlp_classes = self.extract_allowed_intents(
                nbest_transcripts_nlp_classes
            )

            for domain in nbest_transcripts_nlp_classes:
                for intent in nbest_transcripts_nlp_classes[domain]:
                    self.domains[domain].intents[
                        intent
github cisco / mindmeld / mindmeld / components / _config.py View on Github external
def _get_config_module(app_path):
    module_path = path.get_config_module_path(app_path)

    config_module = imp.load_source(
        "config_module_" + os.path.basename(app_path), module_path
    )
    return config_module
github cisco / mindmeld / mindmeld / cli.py View on Github external
def _find_duckling_os_executable():
    """Returns the correct duckling path for this OS."""
    os_platform_name = "-".join(
        distro.linux_distribution(full_distribution_name=False)
    ).lower()
    for os_key in path.DUCKLING_OS_MAPPINGS:
        if os_key in os_platform_name:
            return path.DUCKLING_OS_MAPPINGS[os_key]
github cisco / mindmeld / mindmeld / cli.py View on Github external
shutil.rmtree(full_path)
                        logger.info("Removed cached ts folder: %s", full_path)
                except ValueError:
                    logger.warning(
                        "Folder %s is not named as a proper timestamp. Ignoring it.",
                        full_path,
                    )
        else:
            try:
                shutil.rmtree(model_cache_path)
                logger.info("Model cache data deleted")
            except FileNotFoundError:
                logger.info("No model cache to delete")
        return

    gen_path = path.get_generated_data_folder(app.app_path)
    try:
        shutil.rmtree(gen_path)
        logger.info("Generated data deleted")
    except FileNotFoundError:
        logger.info("No generated data to delete")
github cisco / mindmeld / mindmeld / resource_loader.py View on Github external
def _check_query_entities(self, queries):
        entity_types = path.get_entity_types(self.app_path)
        for query in queries:
            for entity in query.entities:
                if (
                    entity.entity.type not in entity_types
                    and not entity.entity.is_system_entity
                ):
                    msg = "Unknown entity {!r} found in query {!r}"
                    raise MindMeldError(
                        msg.format(entity.entity.type, query.query.text)
                    )
github cisco / mindmeld / mindmeld / components / nlp.py View on Github external
def _dump(self):
        model_path, incremental_model_path = path.get_role_model_paths(
            self._app_path,
            self.domain,
            self.intent,
            self.type,
            timestamp=self.incremental_timestamp,
        )
        self.role_classifier.dump(
            model_path, incremental_model_path=incremental_model_path
        )
github cisco / mindmeld / mindmeld / resource_loader.py View on Github external
def get_gazetteer_hash(self, gaz_name):
        """
        Gets the hash of a gazetteer by entity name.

        Args:
            gaz_name (str): The name of the entity the gazetteer corresponds to

        Returns:
            str: Hash of a gazetteer specified by name.
        """
        self._update_entity_file_dates(gaz_name)
        entity_data_path = path.get_entity_gaz_path(self.app_path, gaz_name)
        entity_data_hash = self._hasher.hash_file(entity_data_path)

        mapping_path = path.get_entity_map_path(self.app_path, gaz_name)
        mapping_hash = self._hasher.hash_file(mapping_path)

        return self._hasher.hash_list([entity_data_hash, mapping_hash])
github cisco / mindmeld / mindmeld / components / nlp.py View on Github external
def _dump(self):
        if len(self.intents) == 1:
            return

        model_path, incremental_model_path = path.get_intent_model_paths(
            self._app_path, domain=self.name, timestamp=self.incremental_timestamp
        )

        self.intent_classifier.dump(
            model_path, incremental_model_path=incremental_model_path
        )