code: def get_entities_from_brat(
      text_filepath, annotation_filepath, verbose=False
  ):
      # load text
      with codecs.open(text_filepath, "r", "UTF-8") as f:
          text = f.read()
      if verbose:
          print("\ntext:\n{0}\n".format(text))
  
      # parse annotation file
      entities = []
      with codecs.open(annotation_filepath, "r", "UTF-8") as f:
          for line in f.read().splitlines():
              anno = line.split()
              id_anno = anno[0]
              # parse entity
              if id_anno[0] == "T":
                  entity = {}
                  entity["id"] = id_anno
                  entity["type"] = anno[1]
                  entity["start"] = int(anno[2])
                  entity["end"] = int(anno[3])
                  entity["text"] = " ".join(anno[4:])
                  if verbose:
                      print("entity: {0}".format(entity))
                  # Check compatibility between brat text and anootation
                  if utils_nlp.replace_unicode_whitespaces_with_ascii_whitespace(
                      text[entity["start"] : entity["end"]]
                  ) != utils_nlp.replace_unicode_whitespaces_with_ascii_whitespace(
                      entity["text"]
                  ):
                      print(
                          "Warning: brat text and annotation do not match."
                      )
                      print(
                          "\ttext: {0}".format(
                              text[entity["start"] : entity["end"]]
                          )
                      )
                      print("\tanno: {0}".format(entity["text"]))
                  # add to entitys data
                  entities.append(entity)
      if verbose:
          print("\n\n")
  
      return text, entities
  
file_path: NeuroNER/neuroner/brat_to_conll.py
imports: import codecs
  import glob
  import json
  import os
  from pycorenlp import StanfordCoreNLP
  import spacy
  from neuroner import utils_nlp
label_desc: Use image node_id 5 for calling a global function with example usage: get_entities_from_brat(text_filepath, annotation_filepath, verbose) and returns: text,  entities