def log_conditional_probability(segmented_topics, per_topic_postings, num_docs):
 m_lc = []
 for s_i in segmented_topics:
  for (w_prime, w_star) in s_i:
   w_prime_docs = per_topic_postings[w_prime]
   w_star_docs = per_topic_postings[w_star]
   co_docs = w_prime_docs.intersection(w_star_docs)
   if w_star_docs:
    m_lc_i = np.log((((len(co_docs) / float(num_docs)) + EPSILON) / (len(w_star_docs) / float(num_docs))))
   else:
    m_lc_i = 0.0
   m_lc.append(m_lc_i)
 return m_lc

def log_conditional_probability ( segmented_topics , per_topic_postings , num_docs ) : m_lc = [ ] for s_i in segmented_topics : for ( w_prime , w_star ) in s_i : w_prime_docs = per_topic_postings [ w_prime ] w_star_docs = per_topic_postings [ w_star ] co_docs = w_prime_docs . intersection ( w_star_docs ) if w_star_docs : m_lc_i = np . log ( ( ( ( len ( co_docs ) / float ( num_docs ) ) + EPSILON ) / ( len ( w_star_docs ) / float ( num_docs ) ) ) ) else : m_lc_i = 0.0 m_lc . append ( m_lc_i ) return m_lc
this function calculates the log-conditional-probability measure which is used by coherence measures such as u_mass .