parameters: (self)
return_statement: return shortest_path_through_root, root_index
docstring: We define shortest path through root as always going from subject past the root to object.
docstring_summary: We define shortest path through root as always going from subject past the root to object.
docstring_tokens: We define shortest path through root as always going from subject past the root to object .
function: def get_shortest_path_through_root(self):
          ''' We define shortest path through root as always going from subject past the root to object.
          '''
          subject_to_root, root_idx1 = get_path_to_root(self.idx2node[self.subject_head_idx])
          object_to_root, root_idx2 = get_path_to_root(self.idx2node[self.object_head_idx])
          # sanity check
          if len(subject_to_root) == 0 or len(object_to_root) == 0:
              raise Exception('Entity to root path is empty.')
          assert(root_idx1 == root_idx2)
          # reverse object_to_root and append to subject_to_path
          shortest_path_through_root = subject_to_root + object_to_root[:-1][::-1] # the second seq should not include root
          return shortest_path_through_root, root_index
function_tokens: def get_shortest_path_through_root ( self ) : subject_to_root , root_idx1 = get_path_to_root ( self . idx2node [ self . subject_head_idx ] ) object_to_root , root_idx2 = get_path_to_root ( self . idx2node [ self . object_head_idx ] ) # sanity check if len ( subject_to_root ) == 0 or len ( object_to_root ) == 0 : raise Exception ( 'Entity to root path is empty.' ) assert ( root_idx1 == root_idx2 ) # reverse object_to_root and append to subject_to_path shortest_path_through_root = subject_to_root + object_to_root [ : - 1 ] [ : : - 1 ] # the second seq should not include root return shortest_path_through_root , root_index