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: Check if entities are correctly annotated in the training data.
  
  If the start and end values of an entity do not match any start and end values
  of the respected token, we define an entity as misaligned and log a warning.
  
  Args:
      training_data: The training data.
docstr_tok: ["Check","if","entities","are","correctly","annotated","in","the","training","data",".","If","the","start","and","end","values","of","an","entity","do","not","match","any","start","and","end","values","of","the","respected","token",",","we","define","an","entity","as","misaligned","and","log","a","warning",".","Args",":","training_data",":","The","training","data","."]
code: def check_correct_entity_annotations(
      training_data: TrainingData,
  ) -> None:
      """Check if entities are correctly annotated in the training data.
  
      If the start and end values of an entity do not match any start and end values
      of the respected token, we define an entity as misaligned and log a warning.
  
      Args:
          training_data: The training data.
      """
      for example in training_data.entity_examples:
          entity_boundaries = [
              (
                  entity[ENTITY_ATTRIBUTE_START],
                  entity[ENTITY_ATTRIBUTE_END],
              )
              for entity in example.get(ENTITIES)
          ]
          token_start_positions = [
              t.start for t in example.get(TOKENS_NAMES[TEXT])
          ]
          token_end_positions = [
              t.end for t in example.get(TOKENS_NAMES[TEXT])
          ]
  
          for entity_start, entity_end in entity_boundaries:
              if (
                  entity_start not in token_start_positions
                  or entity_end not in token_end_positions
              ):
                  entities_repr = [
                      (
                          entity[ENTITY_ATTRIBUTE_START],
                          entity[ENTITY_ATTRIBUTE_END],
                          entity[ENTITY_ATTRIBUTE_VALUE],
                      )
                      for entity in example.get(ENTITIES)
                  ]
                  tokens_repr = [
                      (t.start, t.end, t.text)
                      for t in example.get(TOKENS_NAMES[TEXT])
                  ]
                  rasa.shared.utils.io.raise_warning(
                      f"Misaligned entity annotation in message "
                      f"'{example.get(TEXT)}' with intent '{example.get(INTENT)}'. "
                      f"Make sure the start and end values of entities "
                      f"({entities_repr}) in the training "
                      f"data match the token boundaries ({tokens_repr}). "
                      "Common causes: \n  1) entities include trailing whitespaces "
                      "or punctuation"
                      "\n  2) the tokenizer gives an unexpected result, due to "
                      "languages such as Chinese that don't use whitespace for word "
                      "separation",
                      docs=DOCS_URL_TRAINING_DATA_NLU,
                  )
                  break
  
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 12 for calling the EntityExtractorMixin obj's underlying member method code with example usage: obj.check_correct_entity_annotations(training_data) without return types