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: Convert the list of tokens into discrete features.
docstr_tok: ["Convert","the","list","of","tokens","into","discrete","features","."]
code: def _crf_tokens_to_features(
      self,
      crf_tokens: List[CRFToken],
      include_tag_features: bool = False,
  ) -> List[Dict[Text, Any]]:
      """Convert the list of tokens into discrete features."""
      configured_features = self.component_config[self.CONFIG_FEATURES]
      sentence_features = []
  
      for token_idx in range(len(crf_tokens)):
          # the features for the current token include features of the token
          # before and after the current features (if defined in the config)
          # token before (-1), current token (0), token after (+1)
          window_size = len(configured_features)
          half_window_size = window_size // 2
          window_range = range(-half_window_size, half_window_size + 1)
  
          token_features = self._create_features_for_token(
              crf_tokens,
              token_idx,
              half_window_size,
              window_range,
              include_tag_features,
          )
  
          sentence_features.append(token_features)
  
      return sentence_features
  
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 16 for calling the CRFEntityExtractor obj's underlying member method code with example usage: obj._crf_tokens_to_features(crf_tokens, include_tag_features) and returns: sentence_features