(
self,
element: Tuple[Text, List[Features]],
answer_sets: Dict[Text, Set[Text]],
)
| 426 | self._sentencepiece_model_path) |
| 427 | |
| 428 | def process( |
| 429 | self, |
| 430 | element: Tuple[Text, List[Features]], |
| 431 | answer_sets: Dict[Text, Set[Text]], |
| 432 | ) -> Generator[Tuple[Features, List[AnswerSpan]], None, None]: |
| 433 | question_id, features = element |
| 434 | answer_set = answer_sets[question_id] |
| 435 | has_answer = False |
| 436 | for feature in features: |
| 437 | answer_spans = [] |
| 438 | for answer_span in find_answer_spans(feature.context, answer_set): |
| 439 | realigned_answer_span = realign_answer_span( |
| 440 | feature, answer_set, self._sentencepiece_processor, answer_span) |
| 441 | if realigned_answer_span: |
| 442 | answer_spans.append(realigned_answer_span) |
| 443 | if not answer_spans: |
| 444 | answer_spans = _handle_exceptional_examples( |
| 445 | feature, self._sentencepiece_processor) |
| 446 | if answer_spans: |
| 447 | has_answer = True |
| 448 | else: |
| 449 | metrics.Metrics.counter('_', 'answerless_examples').inc() |
| 450 | yield feature, answer_spans |
| 451 | if not has_answer: |
| 452 | metrics.Metrics.counter('_', 'answerless_questions').inc() |
| 453 | logging.error('Question %s has no answer.', question_id) |
| 454 | |
| 455 | |
| 456 | def make_example( |
nothing calls this directly
no test coverage detected