#NEWLINE# def _get_parsed_sent( self , grid , pos_in_tree , tagset = None ) : #NEWLINE# #INDENT# words = self . _get_column ( grid , self . _colmap [ 'words' ] ) #NEWLINE# pos_tags = self . _get_column ( grid , self . _colmap [ 'pos' ] ) #NEWLINE# if ( tagset and ( tagset != self . _tagset ) ) : #NEWLINE# #INDENT# pos_tags = [ map_tag ( self . _tagset , tagset , t ) for t in pos_tags ] #NEWLINE# #UNINDENT# parse_tags = self . _get_column ( grid , self . _colmap [ 'tree' ] ) #NEWLINE# treestr = '' #NEWLINE# for ( word , pos_tag , parse_tag ) in zip ( words , pos_tags , parse_tags ) : #NEWLINE# #INDENT# if ( word == '(' ) : #NEWLINE# #INDENT# word = '-LRB-' #NEWLINE# #UNINDENT# if ( word == ')' ) : #NEWLINE# #INDENT# word = '-RRB-' #NEWLINE# #UNINDENT# if ( pos_tag == '(' ) : #NEWLINE# #INDENT# pos_tag = '-LRB-' #NEWLINE# #UNINDENT# if ( pos_tag == ')' ) : #NEWLINE# #INDENT# pos_tag = '-RRB-' #NEWLINE# #UNINDENT# ( left , right ) = parse_tag . split ( '*' ) #NEWLINE# right = ( right . count ( ')' ) * ')' ) #NEWLINE# treestr += ( '%s (%s %s) %s' % ( left , pos_tag , word , right ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# tree = self . _tree_class . parse ( treestr ) #NEWLINE# #UNINDENT# except ( ValueError , IndexError ) : #NEWLINE# #INDENT# tree = self . _tree_class . parse ( ( '(%s %s)' % ( self . _root_label , treestr ) ) ) #NEWLINE# #UNINDENT# if ( not pos_in_tree ) : #NEWLINE# #INDENT# for subtree in tree . subtrees ( ) : #NEWLINE# #INDENT# for ( i , child ) in enumerate ( subtree ) : #NEWLINE# #INDENT# if ( isinstance ( child , Tree ) and ( len ( child ) == 1 ) and isinstance ( child [ 0 ] , compat . string_types ) ) : #NEWLINE# #INDENT# subtree [ i ] = ( child [ 0 ] , child . label ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return tree