def tree2semi_rel(tree):
 from nltk.tree import Tree
 semi_rels = []
 semi_rel = [[], None]
 for dtr in tree:
  if (not isinstance(dtr, Tree)):
   semi_rel[0].append(dtr)
  else:
   semi_rel[1] = dtr
   semi_rels.append(semi_rel)
   semi_rel = [[], None]
 return semi_rels

def tree2semi_rel ( tree ) : from nltk . tree import Tree semi_rels = [ ] semi_rel = [ [ ] , None ] for dtr in tree : if ( not isinstance ( dtr , Tree ) ) : semi_rel [ 0 ] . append ( dtr ) else : semi_rel [ 1 ] = dtr semi_rels . append ( semi_rel ) semi_rel = [ [ ] , None ] return semi_rels
group a chunk structure into a list of semi-relations of the form (list .