code: def convert_tiger_treebank(input_filename):
      sentences = read_xml_file(input_filename)
  
      unfixable = 0
      dangling = 0
      broken_links = 0
      missing_words = 0
      weird_constituents = 0
      trees = []
  
      with tsurgeon.Tsurgeon() as tsurgeon_processor:
          for sent_idx, sentence in enumerate(tqdm(sentences)):
              try:
                  tree, words = process_tree(sentence)
  
                  if not tree.all_leaves_are_preterminals():
                      dangling += 1
                      continue
  
                  if word_sequence_missing_words(tree):
                      missing_words += 1
                      continue
  
                  tree = check_words(tree, tsurgeon_processor)
                  if tree is None:
                      unfixable += 1
                      continue
  
                  if has_weird_constituents(tree):
                      weird_constituents += 1
                      continue
  
                  tree = replace_words(tree, words)
                  tree = split_underscores(tree)
                  tree = tree.remap_constituent_labels(REMAP_LABELS)
                  trees.append(tree)
              except BrokenLinkError as e:
                  # the get("id") would have failed as a different error type if missing,
                  # so we can safely use it directly like this
                  broken_links += 1
                  # print("Unable to process {} because of broken links: {}".format(sentence.getroot().get("id"), e))
  
      print("Found {} trees with empty nodes".format(dangling))
      print(
          "Found {} trees with unattached words".format(missing_words)
      )
      print(
          "Found {} trees with confusing constituent labels".format(
              weird_constituents
          )
      )
      print("Not able to rearrange {} nodes".format(unfixable))
      print(
          "Unable to handle {} trees because of broken links, eg names in another tree".format(
              broken_links
          )
      )
      print(
          "Parsed {} trees from {}".format(len(trees), input_filename)
      )
      return trees
  
file_path: stanza/stanza/utils/datasets/constituency/convert_arboretum.py
imports: from collections import namedtuple
  import io
  import xml.etree.ElementTree
  from tqdm import tqdm
  from stanza.models.constituency.parse_tree import Tree
  from stanza.server import tsurgeon
label_desc: Use image node_id 9 for calling a global function with example usage: convert_tiger_treebank(input_filename) and returns: trees