#NEWLINE# def get_coreferences( self ) : #NEWLINE# #INDENT# '\n        Returns a list of lists of tuples (i, j, k) such that `i` is the start\n        offset of a reference, `j` is the end offset and `k` is the index of the\n        head word within the reference.\n        All offsets are in tokens and relative to the start of the document.\n        All references within the same list refer to the same entity.\n        All references in different lists refer to different entities.\n        ' #NEWLINE# sentence_offsets = self . get_sentence_boundaries ( ) #NEWLINE# coreferences = [ ] #NEWLINE# for mention in self . _get ( 'coreference' , 'coreference' ) : #NEWLINE# #INDENT# occurrences = [ ] #NEWLINE# representative = 0 #NEWLINE# for ( r , occurrence ) in enumerate ( _dict_path ( mention , 'mention' ) ) : #NEWLINE# #INDENT# if ( '@representative' in occurrence ) : #NEWLINE# #INDENT# representative = r #NEWLINE# #UNINDENT# sentence = ( int ( occurrence [ 'sentence' ] ) - 1 ) #NEWLINE# offset = sentence_offsets [ sentence ] #NEWLINE# i = ( ( int ( occurrence [ 'start' ] ) - 1 ) + offset ) #NEWLINE# j = ( ( int ( occurrence [ 'end' ] ) - 1 ) + offset ) #NEWLINE# k = ( ( int ( occurrence [ 'head' ] ) - 1 ) + offset ) #NEWLINE# occurrences . append ( ( i , self , k ) ) #NEWLINE# #UNINDENT# k = representative #NEWLINE# ( occurrences [ 0 ] , occurrences [ k ] ) = ( occurrences [ 0 ] , occurrences [ k ] ) #NEWLINE# coreferences . append ( occurrences ) #NEWLINE# #UNINDENT# return coreferences