def generate_questions_from_passage_answer_pairs()

in paq/generation/question_generator/generator.py [0:0]


    def generate_questions_from_passage_answer_pairs(self, passage_answer_pairs, disable_tqdm=False):
        outputs = []
        for batch in tqdm(
            _batch_iterator(passage_answer_pairs, self.batch_size, include_title=self.include_title),
            disable=disable_tqdm,
            total=len(passage_answer_pairs) // self.batch_size
        ):
            # try:
            batch_ids, batch_answers, batch_inputs = zip(*batch)
            batch_questions, batch_scores = self.generate_question(list(batch_inputs))
            # except Exception as e:
            #     logging.info('skipping Broken batch')
            #     continue

            for passage_id, answer, questions, scores in zip(batch_ids, batch_answers, batch_questions,
                                                             batch_scores):
                for question, score in zip(questions, scores):
                    output = {
                        "passage_id": passage_id,
                        "answer": answer["text"],
                        "question": question,
                        "metadata": {
                            "answer_start": answer["start"],
                            "answer_end": answer["end"],
                            "ae_score": answer["score"],
                            "qg_score": score,
                        },
                    }
                    outputs.append(output)
        return outputs