Given a `doc`, flatten it out so that each JSON blob contains exactly one question and one answer. Logic taken from the reference implementation available at https://github.com/allenai/qasper-led-baseline/blob/main/scripts/evaluator.py
(self, doc)
| 144 | yield from self._process_doc(doc) |
| 145 | |
| 146 | def _process_doc(self, doc): |
| 147 | """Given a `doc`, flatten it out so that each JSON blob |
| 148 | contains exactly one question and one answer. Logic taken from |
| 149 | the reference implementation available at |
| 150 | https://github.com/allenai/qasper-led-baseline/blob/main/scripts/evaluator.py |
| 151 | """ |
| 152 | obs_list = [] |
| 153 | for question, answer_list in zip(doc["qas"]["question"], doc["qas"]["answers"]): |
| 154 | for answer_blob in answer_list["answer"]: |
| 155 | answer, answer_type = categorise_answer(answer_blob) |
| 156 | obs_list.append( |
| 157 | { |
| 158 | "title": doc["title"], |
| 159 | "abstract": doc["abstract"], |
| 160 | "question": question, |
| 161 | "answer": answer, |
| 162 | "answer_type": answer_type, |
| 163 | } |
| 164 | ) |
| 165 | return obs_list |
| 166 | |
| 167 | def process_results(self, doc, results): |
| 168 | # TODO: Calculate a score for extractive spans once a request type for generating |
no test coverage detected