This woking code gives me the 5 most relevant documents for a topic out of my corpus.
most_relevant_docs = sorted(bow_corpus, reverse=True, key=lambda doc: abs(dict(doc).get(topic_number, 0.0)))
print most_relevant_docs[ :5]
But since the corpus is not readable by human I want to zip an index to the corpus so I can recover the depending documents.
corpus_ids = range(0,len(corpus))
most_relevant_docs = sorted(zip(corpus_ids, bow_corpus), reverse=True, key=lambda my_id, doc : abs(dict(doc).get(topic_number, 0.0)))
print most_relevant_docs[ :5]
Where do I have to adapt the lambda function so it returns the id together with the document?