How to use the mindmeld.models.taggers.taggers.extract_sequence_features 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 / mindmeld / models / taggers / memm.py View on Github external
def extract_example_features(example, config, resources):
        """Extracts feature dicts for each token in an example.

        Args:
            example (mindmeld.core.Query): A query.
            config (ModelConfig): The ModelConfig which may contain information used for feature \
                                  extraction.
            resources (dict): Resources which may be used for this model's feature extraction.

        Returns:
            (list[dict]): Features.
        """
        return extract_sequence_features(
            example, config.example_type, config.features, resources
        )
github cisco / mindmeld / mindmeld / models / taggers / crf.py View on Github external
def extract_example_features(example, config, resources):
        """Extracts feature dicts for each token in an example.

        Args:
            example (mindmeld.core.Query): A query.
            config (ModelConfig): The ModelConfig which may contain information used for feature \
                                  extraction.
            resources (dict): Resources which may be used for this model's feature extraction.

        Returns:
            list[dict]: Features.
        """
        return extract_sequence_features(
            example, config.example_type, config.features, resources
        )
github cisco / mindmeld / mindmeld / models / taggers / lstm.py View on Github external
def _extract_features(self, example):
        """Extracts feature dicts for each token in an example.

        Args:
            example (mindmeld.core.Query): an query

        Returns:
            (list of dict): features
        """
        default_gaz_one_hot = self._gaz_transform([DEFAULT_GAZ_LABEL]).tolist()[0]
        extracted_gaz_tokens = [default_gaz_one_hot] * self.padding_length
        extracted_sequence_features = extract_sequence_features(
            example, self.example_type, self.features, self.resources
        )

        for index, extracted_gaz in enumerate(extracted_sequence_features):
            if index >= self.padding_length:
                break

            if extracted_gaz == {}:
                continue

            combined_gaz_features = set()
            for key in extracted_gaz.keys():
                regex_match = re.match(GAZ_PATTERN_MATCH, key)
                if regex_match:
                    # Examples of gaz features here are:
                    # in-gaz|type:city|pos:start|p_fe,