#NEWLINE# def _parse_relation( chunk , type = 'O' ) : #NEWLINE# #INDENT# ' Returns a string of the roles and relations parsed from the given <chunk> element.\n        The chunk type (which is part of the relation string) can be given as parameter.\n    ' #NEWLINE# r1 = chunk . get ( XML_RELATION ) #NEWLINE# r2 = chunk . get ( XML_ID , chunk . get ( XML_OF ) ) #NEWLINE# r1 = ( [ ( ( ( x != '-' ) and x ) or None ) for x in r1 . split ( '|' ) ] or [ None ] ) #NEWLINE# r2 = ( [ ( ( ( x != '-' ) and x ) or None ) for x in r2 . split ( '|' ) ] or [ None ] ) #NEWLINE# r2 = [ ( ( ( x is not None ) and x . split ( _UID_SEPARATOR ) [ ( - 1 ) ] ) or x ) for x in r2 ] #NEWLINE# if ( len ( r1 ) < len ( r2 ) ) : #NEWLINE# #INDENT# r1 = ( r1 + ( r1 * ( len ( r2 ) - len ( r1 ) ) ) ) #NEWLINE# #UNINDENT# if ( len ( r2 ) < len ( r1 ) ) : #NEWLINE# #INDENT# r2 = ( r2 + ( r2 * ( len ( r1 ) - len ( r2 ) ) ) ) #NEWLINE# #UNINDENT# return ';' . join ( [ '-' . join ( [ x for x in ( type , r2 , r2 ) if x ] ) for ( r1 , r2 ) in zip ( r1 , r2 ) ] )