MCPcopy Create free account
hub / github.com/google-research/language / test_reader_inputs

Method test_reader_inputs

language/orqa/ops/orqa_ops_test.py:22–50  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

20class OrqaOpsTest(tf.test.TestCase):
21
22 def test_reader_inputs(self):
23 concat_inputs = orqa_ops.reader_inputs(
24 question_token_ids=[0, 1],
25 block_token_ids=[[2, 3, 4], [5, 6, 0]],
26 block_lengths=[3, 2],
27 block_token_map=[[1, 2, 5], [1, 3, 4]],
28 answer_token_ids=[[3, 4], [7, 0]],
29 answer_lengths=[2, 1],
30 cls_token_id=10,
31 sep_token_id=11,
32 max_sequence_len=10)
33
34 self.assertAllEqual(
35 concat_inputs.token_ids.numpy(),
36 [[10, 0, 1, 11, 2, 3, 4, 11, 0, 0], [10, 0, 1, 11, 5, 6, 11, 0, 0, 0]])
37 self.assertAllEqual(
38 concat_inputs.mask.numpy(),
39 [[1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0]])
40 self.assertAllEqual(
41 concat_inputs.segment_ids.numpy(),
42 [[0, 0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0]])
43 self.assertAllEqual(
44 concat_inputs.block_mask.numpy(),
45 [[0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]])
46 self.assertAllEqual(concat_inputs.token_map.numpy(),
47 [[-1, -1, -1, -1, 1, 2, 5, -1, -1, -1],
48 [-1, -1, -1, -1, 1, 3, -1, -1, -1, -1]])
49 self.assertAllEqual(concat_inputs.gold_starts.numpy(), [[5], [-1]])
50 self.assertAllEqual(concat_inputs.gold_ends.numpy(), [[6], [-1]])
51
52 def test_has_answer(self):
53 result = orqa_ops.has_answer(blocks=["abcdefg", "hijklmn"], answers=["hij"])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected