class_docstr: Provides functionality for components that do entity extraction.
  
  Inheriting from this class will add utility functions for entity extraction.
  Entity extraction is the process of identifying and extracting entities like a
  person's name, or a location from a message.
class_docstr_tok: ["Provides","functionality","for","components","that","do","entity","extraction",".","Inheriting","from","this","class","will","add","utility","functions","for","entity","extraction",".","Entity","extraction","is","the","process","of","identifying","and","extracting","entities","like","a","person","'s","name",",","or","a","location","from","a","message","."]
docstr: Convert predictions into entities.
  
  Args:
      text: The text message.
      tokens: Message tokens without CLS token.
      tags: Predicted tags.
      split_entities_config: config for handling splitting a list of entities
      confidences: Confidences of predicted tags.
  
  Returns:
      Entities.
docstr_tok: ["Convert","predictions","into","entities",".","Args",":","text",":","The","text","message",".","tokens",":","Message","tokens","without","CLS","token",".","tags",":","Predicted","tags",".","split_entities_config",":","config","for","handling","splitting","a","list","of","entities","confidences",":","Confidences","of","predicted","tags",".","Returns",":","Entities","."]
code: def convert_predictions_into_entities(
      text: Text,
      tokens: List[Token],
      tags: Dict[Text, List[Text]],
      split_entities_config: Optional[Dict[Text, bool]] = None,
      confidences: Optional[Dict[Text, List[float]]] = None,
  ) -> List[Dict[Text, Any]]:
      """Convert predictions into entities.
  
      Args:
          text: The text message.
          tokens: Message tokens without CLS token.
          tags: Predicted tags.
          split_entities_config: config for handling splitting a list of entities
          confidences: Confidences of predicted tags.
  
      Returns:
          Entities.
      """
      import rasa.nlu.utils.bilou_utils as bilou_utils
  
      entities = []
  
      last_entity_tag = NO_ENTITY_TAG
      last_role_tag = NO_ENTITY_TAG
      last_group_tag = NO_ENTITY_TAG
      last_token_end = -1
  
      for idx, token in enumerate(tokens):
          current_entity_tag = EntityExtractorMixin.get_tag_for(
              tags, ENTITY_ATTRIBUTE_TYPE, idx
          )
  
          if current_entity_tag == NO_ENTITY_TAG:
              last_entity_tag = NO_ENTITY_TAG
              last_token_end = token.end
              continue
  
          current_group_tag = EntityExtractorMixin.get_tag_for(
              tags, ENTITY_ATTRIBUTE_GROUP, idx
          )
          current_group_tag = bilou_utils.tag_without_prefix(
              current_group_tag
          )
          current_role_tag = EntityExtractorMixin.get_tag_for(
              tags, ENTITY_ATTRIBUTE_ROLE, idx
          )
          current_role_tag = bilou_utils.tag_without_prefix(
              current_role_tag
          )
  
          group_or_role_changed = (
              last_group_tag != current_group_tag
              or last_role_tag != current_role_tag
          )
  
          if bilou_utils.bilou_prefix_from_tag(current_entity_tag):
              # checks for new bilou tag
              # new bilou tag begins are not with I- , L- tags
              new_bilou_tag_starts = (
                  last_entity_tag != current_entity_tag
                  and (
                      bilou_utils.LAST
                      != bilou_utils.bilou_prefix_from_tag(
                          current_entity_tag
                      )
                      and bilou_utils.INSIDE
                      != bilou_utils.bilou_prefix_from_tag(
                          current_entity_tag
                      )
                  )
              )
  
              # to handle bilou tags such as only I-, L- tags without B-tag
              # and handle multiple U-tags consecutively
              new_unigram_bilou_tag_starts = (
                  last_entity_tag == NO_ENTITY_TAG
                  or bilou_utils.UNIT
                  == bilou_utils.bilou_prefix_from_tag(
                      current_entity_tag
                  )
              )
  
              new_tag_found = (
                  new_bilou_tag_starts
                  or new_unigram_bilou_tag_starts
                  or group_or_role_changed
              )
              last_entity_tag = current_entity_tag
              current_entity_tag = bilou_utils.tag_without_prefix(
                  current_entity_tag
              )
          else:
              new_tag_found = (
                  last_entity_tag != current_entity_tag
                  or group_or_role_changed
              )
              last_entity_tag = current_entity_tag
  
          if new_tag_found:
              # new entity found
              entity = EntityExtractorMixin._create_new_entity(
                  list(tags.keys()),
                  current_entity_tag,
                  current_group_tag,
                  current_role_tag,
                  token,
                  idx,
                  confidences,
              )
              entities.append(entity)
          elif EntityExtractorMixin._check_is_single_entity(
              text,
              token,
              last_token_end,
              split_entities_config,
              current_entity_tag,
          ):
              # current token has the same entity tag as the token before and
              # the two tokens are separated by at most 3 symbols, where each
              # of the symbols has to be either punctuation (e.g. "." or ",")
              # and a whitespace.
              entities[-1][ENTITY_ATTRIBUTE_END] = token.end
              if confidences is not None:
                  EntityExtractorMixin._update_confidence_values(
                      entities, confidences, idx
                  )
  
          else:
              # the token has the same entity tag as the token before but the two
              # tokens are separated by at least 2 symbols (e.g. multiple spaces,
              # a comma and a space, etc.) and also shouldn't be represented as a
              # single entity
              entity = EntityExtractorMixin._create_new_entity(
                  list(tags.keys()),
                  current_entity_tag,
                  current_group_tag,
                  current_role_tag,
                  token,
                  idx,
                  confidences,
              )
              entities.append(entity)
  
          last_group_tag = current_group_tag
          last_role_tag = current_role_tag
          last_token_end = token.end
  
      for entity in entities:
          entity[ENTITY_ATTRIBUTE_VALUE] = text[
              entity[ENTITY_ATTRIBUTE_START] : entity[
                  ENTITY_ATTRIBUTE_END
              ]
          ]
  
      return entities
  
imports: import abc
  from typing import Any, Dict, List, NamedTuple, Text, Tuple, Optional
  import rasa.shared.utils.io
  from rasa.shared.constants import DOCS_URL_TRAINING_DATA_NLU
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  from rasa.nlu.tokenizers.tokenizer import Token
  from rasa.nlu.constants import TOKENS_NAMES, ENTITY_ATTRIBUTE_CONFIDENCE_TYPE, ENTITY_ATTRIBUTE_CONFIDENCE_ROLE, ENTITY_ATTRIBUTE_CONFIDENCE_GROUP
  from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ENTITY_ATTRIBUTE_VALUE, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, EXTRACTOR, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE, NO_ENTITY_TAG, SPLIT_ENTITIES_BY_COMMA, SINGLE_ENTITY_ALLOWED_INTERLEAVING_CHARSET
  import rasa.utils.train_utils
label_desc: Use image node_id 7 for calling the EntityExtractorMixin obj's underlying member method code with example usage: obj.convert_predictions_into_entities(text, tokens, tags, split_entities_config, confidences) and returns: entities