def p_boolean_document(corpus, segmented_topics):
 top_ids = _ret_top_ids(segmented_topics)
 per_topic_postings = {}
 for id in top_ids:
  id_list = set()
  for (n, document) in enumerate(corpus):
   if (id in frozenset((x[0] for x in document))):
    id_list.add(n)
  per_topic_postings[id] = id_list
 num_docs = len(corpus)
 return (per_topic_postings, num_docs)

def p_boolean_document ( corpus , segmented_topics ) : top_ids = _ret_top_ids ( segmented_topics ) per_topic_postings = { } for id in top_ids : id_list = set ( ) for ( n , document ) in enumerate ( corpus ) : if ( id in frozenset ( ( x [ 0 ] for x in document ) ) ) : id_list . add ( n ) per_topic_postings [ id ] = id_list num_docs = len ( corpus ) return ( per_topic_postings , num_docs )
this function performs the boolean document probability estimation .