code: def read_xml_file(input_filename):
      """
      Convert an XML file into a list of trees - each <s> becomes its own object
      """
      print("Reading {}".format(input_filename))
      with open(input_filename, encoding="utf-8") as fin:
          lines = fin.readlines()
  
      sentences = []
      current_sentence = []
      in_sentence = False
      for line_idx, line in enumerate(lines):
          if line.startswith("<s "):
              if len(current_sentence) > 0:
                  raise ValueError(
                      "Found the start of a sentence inside an existing sentence, line {}".format(
                          line_idx
                      )
                  )
              in_sentence = True
  
          if in_sentence:
              current_sentence.append(line)
  
          if line.startswith("</s>"):
              assert in_sentence
              current_sentence = [
                  x.replace("<{parentes-udeladt}>", "")
                  for x in current_sentence
              ]
              current_sentence = [
                  x.replace("<{note}>", "") for x in current_sentence
              ]
              sentences.append("".join(current_sentence))
              current_sentence = []
              in_sentence = False
  
      assert len(current_sentence) == 0
  
      xml_sentences = []
      for sent_idx, text in enumerate(sentences):
          sentence = io.StringIO(text)
          try:
              tree = ET.parse(sentence)
              xml_sentences.append(tree)
          except ET.ParseError as e:
              raise ValueError(
                  "Failed to parse sentence {}".format(sent_idx)
              )
  
      return xml_sentences
  
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 1 for calling a global function with example usage: read_xml_file(input_filename) and returns: xml_sentences