def _retrieve_documents (self, doc_term_map): """ Takes the doc_term_mapping produced by the organize method and then builds a proper dictionary mapping id -> doc_data and terms that occur in the given document. Returns a dictionary of this document data. """ docs = DocumentModel.get(doc_term_map.keys()) united = list() for doc in docs: doc['terms'] = doc_term_map[doc['_id']] united.append(doc) return united