code: def ieertree2conlltags(tree, tag=nltk.tag.pos_tag):
      # tree.pos() flattens the tree and produces [(word, label)] where label is
      # from the word's parent tree label. words in a chunk therefore get the
      # chunk tag, while words outside a chunk get the same tag as the tree's
      # top label
      words, ents = zip(*tree.pos())
      iobs = []
      prev = None
      # construct iob tags from entity names
      for ent in ents:
          # any entity that is the same as the tree's top label is outside a chunk
          if ent == node_label(tree):
              iobs.append("O")
              prev = None
          # have a previous entity that is equal so this is inside the chunk
          elif prev == ent:
              iobs.append("I-%s" % ent)
          # no previous equal entity in the sequence, so this is the beginning of
          # an entity chunk
          else:
              iobs.append("B-%s" % ent)
              prev = ent
      # get tags for each word, then construct 3-tuple for conll tags
      words, tags = zip(*tag(words))
      return zip(words, tags, iobs)
  
file_path: nltk-trainer/nltk_trainer/chunking/chunkers.py
imports: import nltk.tag
  from nltk.chunk import ChunkParserI
  from nltk.chunk.util import conlltags2tree, tree2conlltags
  from nltk.tag import UnigramTagger, BigramTagger, ClassifierBasedTagger
  from .transforms import node_label
label_desc: Use image node_id 3 for calling a global function with example usage: ieertree2conlltags(tree, tag) and returns: zip