#NEWLINE# def ieertree2conlltags( tree , tag = nltk . tag . pos_tag ) : #NEWLINE# #INDENT# ( words , ents ) = zip ( * tree . pos ( ) ) #NEWLINE# iobs = [ ] #NEWLINE# prev = None #NEWLINE# for ent in ents : #NEWLINE# #INDENT# if ( ent == node_label ( tree ) ) : #NEWLINE# #INDENT# iobs . append ( 'O' ) #NEWLINE# prev = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( prev == ent ) : #NEWLINE# #INDENT# iobs . append ( ( 'I-%s' % ent ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# iobs . append ( ( 'B-%s' % ent ) ) #NEWLINE# prev = ent #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ( words , tags ) = zip ( * tag ( words ) ) #NEWLINE# return zip ( words , tags , iobs )