class_docstr: Implements conditional random fields (CRF) to do named entity recognition.
class_docstr_tok: ["Implements","conditional","random","fields","(","CRF",")","to","do","named","entity","recognition","."]
docstr: Extract entities from the given message using the trained model(s).
docstr_tok: ["Extract","entities","from","the","given","message","using","the","trained","model","(","s",")","."]
code: def extract_entities(self, message: Message) -> List[Dict[Text, Any]]:
      """Extract entities from the given message using the trained model(s)."""
      if self.entity_taggers is None or not message.features_present(
          attribute=TEXT,
          featurizers=self.component_config.get(FEATURIZERS),
      ):
          return []
  
      tokens = message.get(TOKENS_NAMES[TEXT])
      crf_tokens = self._convert_to_crf_tokens(message)
  
      predictions: Dict[Text, List[Dict[Text, float]]] = {}
      for tag_name, entity_tagger in self.entity_taggers.items():
          # use predicted entity tags as features for second level CRFs
          include_tag_features = tag_name != ENTITY_ATTRIBUTE_TYPE
          if include_tag_features:
              self._add_tag_to_crf_token(crf_tokens, predictions)
  
          features = self._crf_tokens_to_features(
              crf_tokens, include_tag_features
          )
          predictions[
              tag_name
          ] = entity_tagger.predict_marginals_single(features)
  
      # convert predictions into a list of tags and a list of confidences
      tags, confidences = self._tag_confidences(tokens, predictions)
  
      return self.convert_predictions_into_entities(
          message.get(TEXT),
          tokens,
          tags,
          self.split_entities_config,
          confidences,
      )
  
imports: from __future__ import annotations
  from collections import OrderedDict
  from enum import Enum
  import logging
  import typing
  import numpy
  from typing import Any, Dict, List, Optional, Text, Tuple, Callable, Type
  import rasa.nlu.utils.bilou_utils
  import rasa.shared.utils.io
  import rasa.utils.train_utils
  from rasa.engine.graph import GraphComponent, ExecutionContext
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.nlu.test import determine_token_labels
  from rasa.nlu.tokenizers.spacy_tokenizer import POS_TAG_KEY
  from rasa.nlu.extractors.extractor import EntityExtractorMixin
  from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  from rasa.nlu.constants import TOKENS_NAMES
  from rasa.shared.nlu.constants import TEXT, ENTITIES, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE, NO_ENTITY_TAG, SPLIT_ENTITIES_BY_COMMA, SPLIT_ENTITIES_BY_COMMA_DEFAULT_VALUE
  from rasa.shared.constants import DOCS_URL_COMPONENTS
  from rasa.utils.tensorflow.constants import BILOU_FLAG, FEATURIZERS
label_desc: Use image node_id 10 for calling the CRFEntityExtractor obj's underlying member method code with example usage: obj.extract_entities(message) and returns: self, list