code: def read_tsv(
      filename,
      text_column,
      annotation_column,
      remap_fn=None,
      skip_comments=True,
      keep_broken_tags=False,
      keep_all_columns=False,
      separator="\t",
  ):
      """
      Read sentences from a TSV file
  
      Returns a list of list of (word, tag)
  
      If keep_broken_tags==True, then None is returned for a missing.  Otherwise, an IndexError is thrown
      """
      with open(filename, encoding="utf-8") as fin:
          lines = fin.readlines()
  
      lines = [x.strip() for x in lines]
  
      sentences = []
      current_sentence = []
      for line_idx, line in enumerate(lines):
          if not line:
              if current_sentence:
                  sentences.append(current_sentence)
                  current_sentence = []
              continue
          if skip_comments and line.startswith("#"):
              continue
  
          pieces = line.split(separator)
          try:
              word = pieces[text_column]
          except IndexError as e:
              raise IndexError(
                  "Could not find word index %d at line %d |%s|"
                  % (text_column, line_idx, line)
              ) from e
          if word == "\x96":
              # this happens in GermEval2014 for some reason
              continue
          try:
              tag = pieces[annotation_column]
          except IndexError as e:
              if keep_broken_tags:
                  tag = None
              else:
                  raise IndexError(
                      "Could not find tag index %d at line %d |%s|"
                      % (annotation_column, line_idx, line)
                  ) from e
          if remap_fn:
              tag = remap_fn(tag)
  
          if keep_all_columns:
              pieces[annotation_column] = tag
              current_sentence.append(pieces)
          else:
              current_sentence.append((word, tag))
  
      if current_sentence:
          sentences.append(current_sentence)
  
      return sentences
  
imports: from collections import defaultdict
  import json
  import os
  import random
  from stanza.models.common.doc import Document
  import stanza.utils.datasets.ner.prepare_ner_file
label_desc: Use image node_id 7 for calling a global function with example usage: read_tsv(filename, text_column, annotation_column, remap_fn, skip_comments, keep_broken_tags, keep_all_columns, separator) and returns: sentences