code: def phi5_plaintext_cleanup(
      text, rm_punctuation=False, rm_periods=False
  ):
      """Remove and substitute post-processing for Latin PHI5 text.
      TODO: Surely more junk to pull out. Please submit bugs!
      TODO: This is a rather slow now, help in speeding up welcome.
      """
      # This works OK, doesn't get some
      # Note: rming all characters between {} and ()
      remove_comp = regex.compile(
          r"-\n|«|»|\<|\>|\.\.\.|‘|’|_|{.+?}|\(.+?\)|\(|\)|“|#|%|⚔|&|=|/|\\|〚|†|『|⚖|–|˘|⚕|☾|◌|◄|►|⌐|⌊|⌋|≈|∷|≈|∞|”|[0-9]"
      )
      text = remove_comp.sub("", text)
  
      new_text = None
      if rm_punctuation:
          new_text = ""
          punctuation = [
              ",",
              ";",
              ":",
              '"',
              "'",
              "?",
              "-",
              "!",
              "*",
              "[",
              "]",
              "{",
              "}",
          ]
          if rm_periods:
              punctuation += ["."]
          for char in text:
              # rm acute combining acute accents made by TLGU
              # Could be caught by regex, tried and failed, not sure why
              if bytes(char, "utf-8") == b"\xcc\x81":
                  pass
              # second try at rming some punctuation; merge with above regex
              elif char in punctuation:
                  pass
              else:
                  new_text += char
      if new_text:
          text = new_text
  
      # replace line breaks w/ space
      replace_comp = regex.compile(r"\n")
      text = replace_comp.sub(" ", text)
  
      comp_space = regex.compile(r"\s+")
      text = comp_space.sub(" ", text)
  
      return text
  
imports: import os
  import regex
  from cltk.corpora.lat.phi.phi5_index import PHI5_INDEX, PHI5_WORKS_INDEX
  from cltk.utils.file_operations import make_cltk_path
label_desc: Use image node_id 1 for calling a global function with example usage: phi5_plaintext_cleanup(text, rm_punctuation, rm_periods) and returns: text