MCPcopy Create free account
hub / github.com/tensorflow/models / process

Method process

official/projects/triviaqa/preprocess.py:339–360  ·  view source on GitHub ↗
(
      self, question_answer_evidence: QuestionAnswerEvidence
  )

Source from the content-addressed store, hash-verified

337 token_offsets=offsets)
338
339 def process(
340 self, question_answer_evidence: QuestionAnswerEvidence
341 ) -> Generator[Features, None, None]:
342 # Tokenize question which is shared among all examples.
343 ids = (
344 self._sentencepiece_processor.EncodeAsIds(
345 question_answer_evidence.question.value) +
346 [self._sentencepiece_processor.PieceToId(_SEP_PIECE)])
347 paragraph_texts = list(
348 filter(
349 lambda p: p,
350 map(lambda p: p.strip(),
351 question_answer_evidence.evidence.text.split('\n'))))
352 stride_index, paragraphs, paragraph_index = 0, [], 0
353 while paragraph_index < len(paragraph_texts):
354 paragraph_index, features = self._make_features(stride_index,
355 paragraph_texts,
356 paragraphs,
357 question_answer_evidence,
358 ids, paragraph_index)
359 stride_index += 1
360 yield features
361
362
363def _handle_exceptional_examples(

Callers

nothing calls this directly

Calls 2

_make_featuresMethod · 0.95
PieceToIdMethod · 0.80

Tested by

no test coverage detected