code: def check_compatibility_between_conll_and_brat_text(
      conll_filepath, brat_folder
  ):
      """
      check if token offsets match between conll and brat .txt files.
  
      conll_filepath: path to conll file
      brat_folder: folder that contains the .txt (and .ann) files that are formatted according to brat.
  
      """
      verbose = False
      dataset_type = utils.get_basename_without_extension(
          conll_filepath
      )
      print(
          "Checking compatibility between CONLL and BRAT for {0} set ... ".format(
              dataset_type
          ),
          end="",
      )
      conll_file = codecs.open(conll_filepath, "r", "UTF-8")
  
      previous_filename = ""
      for line in conll_file:
          line = line.strip().split(" ")
          # New sentence
          if (
              len(line) == 0
              or len(line[0]) == 0
              or "-DOCSTART-" in line[0]
          ):
              continue
  
          filename = str(line[1])
          # New file
          if filename != previous_filename:
              text_filepath = os.path.join(
                  brat_folder, "{0}.txt".format(filename)
              )
              with codecs.open(text_filepath, "r", "UTF-8") as f:
                  text = f.read()
              previous_filename = filename
  
          label = str(line[-1]).replace("_", "-")  # For LOCATION-OTHER
  
          token = {}
          token["text"] = str(line[0])
          token["start"] = int(line[2])
          token["end"] = int(line[3])
  
          # check that the token text matches the original
          if token["text"] != text[token["start"] : token["end"]]:
              print("Warning: conll and brat text do not match.")
              print("\tCONLL: {0}".format(token["text"]))
              print(
                  "\tBRAT : {0}".format(
                      text[token["start"] : token["end"]]
                  )
              )
              if token["text"] != text[
                  token["start"] : token["end"]
              ].replace(" ", "-"):
                  raise AssertionError(
                      "CONLL and BRAT files are incompatible."
                  )
  
      print("Done.")
  
file_path: NeuroNER/neuroner/conll_to_brat.py
imports: import codecs
  import glob
  import os
  import shutil
  from neuroner import utils
  from neuroner import utils_nlp
label_desc: Use image node_id 2 for calling a global function with example usage: check_compatibility_between_conll_and_brat_text(conll_filepath, brat_folder) without return types