#NEWLINE# def _parse_relation( self , tag ) : #NEWLINE# #INDENT# ' Parses the chunk tag, role and relation id from the token relation tag.\n            - VP                => VP, [], []\n            - VP-1              => VP, [1], [None]\n            - ADJP-PRD          => ADJP, [None], [PRD]\n            - NP-SBJ-1          => NP, [1], [SBJ]\n            - NP-OBJ-1*NP-OBJ-2 => NP, [1,2], [OBJ,OBJ]\n            - NP-SBJ;NP-OBJ-1   => NP, [1,1], [SBJ,OBJ]\n        ' #NEWLINE# ( chunk , relation , role ) = ( None , [ ] , [ ] ) #NEWLINE# if ( ';' in tag ) : #NEWLINE# #INDENT# id = tag . split ( '*' ) [ 0 ] [ ( - 2 ) : ] #NEWLINE# id = ( id if id . startswith ( '-' ) else '' ) #NEWLINE# tag = tag . replace ( ';' , ( n + '*' ) ) #NEWLINE# #UNINDENT# if ( '*' in tag ) : #NEWLINE# #INDENT# tag = tag . split ( '*' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tag = [ tag ] #NEWLINE# #UNINDENT# for s in tag : #NEWLINE# #INDENT# s = s . split ( '-' ) #NEWLINE# n = len ( s ) #NEWLINE# if ( n == 1 ) : #NEWLINE# #INDENT# chunk = s [ 0 ] #NEWLINE# #UNINDENT# if ( n == 2 ) : #NEWLINE# #INDENT# chunk = s [ 0 ] #NEWLINE# relation . append ( s [ 1 ] ) #NEWLINE# role . append ( None ) #NEWLINE# #UNINDENT# if ( n >= 3 ) : #NEWLINE# #INDENT# chunk = s [ 0 ] #NEWLINE# relation . append ( s [ 2 ] ) #NEWLINE# role . append ( s [ 1 ] ) #NEWLINE# #UNINDENT# if ( n > 1 ) : #NEWLINE# #INDENT# id = relation [ ( - 1 ) ] #NEWLINE# if id . isdigit ( ) : #NEWLINE# #INDENT# relation [ ( - 1 ) ] = int ( id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( relation [ ( - 1 ) ] , role [ ( - 1 ) ] ) = ( None , id ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( chunk , relation , role )