コード例 #1
0
    def test_respect_final_state(self):
        backpointers = np.asarray([
            [-1, -1],
            [0, 1]
        ], dtype=np.int)

        self.assertEqual(backtrack(backpointers, 1), [1, 1])
コード例 #2
0
    def test_trivial(self):
        backpointers = np.asarray([
            [-1, -1],
            [0, 1]
        ], dtype=np.int)

        self.assertEqual(backtrack(backpointers, 0), [0, 0])
コード例 #3
0
    def test_multiple_states(self):
        backpointers = np.asarray([
            [-1, -1, -1],
            [0, 1, 2],
            [1, 1, 0],
            [2, 1, 2],
            [1, 0, 2],
        ], dtype=np.int)

        self.assertEqual(backtrack(backpointers, 1), [0, 0, 2, 0, 1])
コード例 #4
0
    def test_longer_seq(self):
        backpointers = np.asarray([
            [-1, -1],
            [0, 1],
            [1, 0],
            [1, 1],
            [1, 0],
        ], dtype=np.int)

        self.assertEqual(backtrack(backpointers, 1), [0, 0, 1, 0, 1])