def _make_seg(w_prime, w, per_topic_postings, measure, gamma, backtrack, num_docs):
 context_vectors = {}
 if isinstance(w_prime, np.ndarray):
  for w_j in w:
   for w_i in w_prime:
    if ((w_i, w_j) not in backtrack):
     backtrack[(w_i, w_j)] = measure[0]([[(w_i, w_j)]], per_topic_postings, num_docs, measure[1])[0]
    if (w_j not in context_vectors):
     context_vectors[w_j] = (backtrack[(w_i, w_j)] ** gamma)
    else:
     context_vectors[w_j] += (backtrack[(w_i, w_j)] ** gamma)
 else:
  for w_j in w:
   if ((w_prime, w_j) not in backtrack):
    backtrack[(w_prime, w_j)] = measure[0]([[(w_prime, w_j)]], per_topic_postings, num_docs, measure[1])[0]
   context_vectors[w_j] = (backtrack[(w_prime, w_j)] ** gamma)
 return (context_vectors, backtrack)

def _make_seg ( w_prime , w , per_topic_postings , measure , gamma , backtrack , num_docs ) : context_vectors = { } if isinstance ( w_prime , np . ndarray ) : for w_j in w : for w_i in w_prime : if ( ( w_i , w_j ) not in backtrack ) : backtrack [ ( w_i , w_j ) ] = measure [ 0 ] ( [ [ ( w_i , w_j ) ] ] , per_topic_postings , num_docs , measure [ 1 ] ) [ 0 ] if ( w_j not in context_vectors ) : context_vectors [ w_j ] = ( backtrack [ ( w_i , w_j ) ] ** gamma ) else : context_vectors [ w_j ] += ( backtrack [ ( w_i , w_j ) ] ** gamma ) else : for w_j in w : if ( ( w_prime , w_j ) not in backtrack ) : backtrack [ ( w_prime , w_j ) ] = measure [ 0 ] ( [ [ ( w_prime , w_j ) ] ] , per_topic_postings , num_docs , measure [ 1 ] ) [ 0 ] context_vectors [ w_j ] = ( backtrack [ ( w_prime , w_j ) ] ** gamma ) return ( context_vectors , backtrack )
internal helper function to return context vectors for segmentations .