def tree2conlltags(t):
 tags = []
 for child in t:
  try:
   category = child.label()
   prefix = u'B-'
   for contents in child:
    if isinstance(contents, Tree):
     raise ValueError(u'Tree is too deeply nested to be printed in CoNLL format')
    tags.append((contents[0], contents[1], (prefix + category)))
    prefix = u'I-'
  except AttributeError:
   tags.append((child[0], child[1], u'O'))
 return tags

def tree2conlltags ( t ) : tags = [ ] for child in t : try : category = child . label ( ) prefix = u'B-' for contents in child : if isinstance ( contents , Tree ) : raise ValueError ( u'Tree is too deeply nested to be printed in CoNLL format' ) tags . append ( ( contents [ 0 ] , contents [ 1 ] , ( prefix + category ) ) ) prefix = u'I-' except AttributeError : tags . append ( ( child [ 0 ] , child [ 1 ] , u'O' ) ) return tags
return a list of 3-tuples containing .