class_docstr: Label Encoder for the named entity recognition task.
class_docstr_tok: ["Label","Encoder","for","the","named","entity","recognition","task","."]
docstr: Validate the JSON annotations with predefined JSON schema and convert it into list.
  
  Parameters
  ----------
  y
      The raw json annotations.
  
  Returns
  -------
  all_annotations
      A list of NER annotations.
  unique_entity_groups
      A list of unique entity groups.
docstr_tok: ["Validate","the","JSON","annotations","with","predefined","JSON","schema","and","convert","it","into","list",".","Parameters","--","--","--","--","--","y","The","raw","json","annotations",".","Returns","--","--","--","-","all_annotations","A","list","of","NER","annotations",".","unique_entity_groups","A","list","of","unique","entity","groups","."]
code: def extract_ner_annotations(self, y: pd.Series):
      """
      Validate the JSON annotations with predefined JSON schema and convert it into list.
  
      Parameters
      ----------
      y
          The raw json annotations.
  
      Returns
      -------
      all_annotations
          A list of NER annotations.
      unique_entity_groups
          A list of unique entity groups.
      """
  
      # Predefined Json schema
      schema = {
          "$schema": "http://json-schema.org/draft-04/schema#",
          "type": "array",
          "items": {
              "type": "object",
              "properties": {
                  ENTITY_GROUP: {"type": "string"},
                  START_OFFSET: {"type": "integer"},
                  END_OFFSET: {"type": "integer"},
              },
              "required": [ENTITY_GROUP, START_OFFSET, END_OFFSET],
          },
      }
      all_annotations = []
      all_entity_groups = []
      for _, ner_annotations in y.items():
          json_ner_annotations = json.loads(
              ner_annotations
          )  # load the json annotations
          try:
              jsonschema.validate(
                  json_ner_annotations, schema
              )  # verify the json schema
          except jsonschema.ValidationError as e:
              # Raise an error if the provided json annotations do not match the predefined schema
              raise ValueError(
                  f"The provided json annotations are invalid: {e.message}"
              )
          sentence_annotations = []
          for annot in json_ner_annotations:
              entity_group = annot[ENTITY_GROUP]
              if not (
                  re.match(self.b_prefix, entity_group, re.IGNORECASE)
                  or re.match(
                      self.i_prefix, entity_group, re.IGNORECASE
                  )
              ):
                  all_entity_groups.append(self.b_prefix + entity_group)
                  all_entity_groups.append(self.i_prefix + entity_group)
              else:
                  all_entity_groups.append(entity_group)
              sentence_annotations.append(
                  (
                      (annot[START_OFFSET], annot[END_OFFSET]),
                      entity_group,
                  )
              )
          all_annotations.append(sentence_annotations)
      unique_entity_groups = list(set(all_entity_groups))
      return all_annotations, unique_entity_groups
  
imports: import json
  import logging
  import re
  from typing import Any, Dict, List, Optional, Union
  import jsonschema
  import numpy
  import pandas
  from omegaconf import DictConfig, OmegaConf
  from sklearn.preprocessing import LabelEncoder
  from ..constants import AUTOMM, END_OFFSET, ENTITY_GROUP, NER_ANNOTATION, PROBABILITY, START_OFFSET
label_desc: Use image node_id 3 for calling the NerLabelEncoder obj's underlying member method code with example usage: obj.extract_ner_annotations(y) and returns: all_annotations,  unique_entity_groups