def construct_doc2author(corpus, author2doc):
 doc2author = {}
 for (d, _) in enumerate(corpus):
  author_ids = []
  for (a, a_doc_ids) in author2doc.items():
   if (d in a_doc_ids):
    author_ids.append(a)
  doc2author[d] = author_ids
 return doc2author

def construct_doc2author ( corpus , author2doc ) : doc2author = { } for ( d , _ ) in enumerate ( corpus ) : author_ids = [ ] for ( a , a_doc_ids ) in author2doc . items ( ) : if ( d in a_doc_ids ) : author_ids . append ( a ) doc2author [ d ] = author_ids return doc2author
make a mapping from document ids to author ids .