old_contents: import itertools
  import os
  from lxml import etree as ET
  import gate
  
  
  conversations_path = "/home/nick/hilt/pes/conversations"
  
  files = list(
      itertools.chain.from_iterable(
          (
              [
                  os.path.join(
                      results[0],
                      x,
                  )
                  for x in results[2]
                  if x.lower().endswith(".xml")
              ]
              for results in os.walk(conversations_path)
          )
      )
  )
  
  annotation_files = (
      gate.AnnotationFile(f)
      for f in files
  )
  
  for f in annotation_files:
      for annotation in f.iter_annotations():
          if annotation._type.lower() == "event":
              for feature in annotation.get_features():
                  if "positive" in feature.get_name().lower():
                      feature.set_name("Polarity")
                      f.tree.write(f.filename)
  
  # print(
  #     set(
  #         feature.get_name()
  #         for annotation_file in annotation_files
  #         for annotation in annotation_file.iter_annotations()
  #         for feature in annotation.get_features()
  #         if annotation._type.lower() == "event"
  #     )
  # )
  
new_contents: import itertools
  import os
  from lxml import etree as ET
  import gate
  
  
  conversations_path = "/home/nick/hilt/pes/conversations"
  
  annotation_files = list(
      itertools.chain.from_iterable(
          (
              [
                  os.path.join(
                      results[0],
                      x,
                  )
                  for x in results[2]
                  if x.lower().endswith(".xml")
              ]
              for results in os.walk(conversations_path)
          )
      )
  )
  
  for f in annotation_files:
      annotation_file = gate.AnnotationFile(f)
      changes = False
      for annotation in gate.filter_annotations_by_type(
          annotation_file.iter_annotations(),
          "attribution",
          with_continuations=True,
      ):
          for feature in annotation.get_features():
              if "cause" in feature.get_name().lower():
                  feature.set_name("Caused_Event")
                  changes = True
      if changes:
          annotation_file.tree.write(annotation_file.filename)
          print("changes written: " + f)
      else:
          print("no changes made: " + f)
  
subject: Normalize Attribution features