def test_vocab_encode_reverse(self): vocab = Vocabulary(self._tmp) sentence = '. unknown the' ids = vocab.encode(sentence, reverse=True) expected = np.array([1, 4, 2, 3, 0], dtype=np.int32) self.assertTrue((ids == expected).all())
def test_vocab_encode(self): vocab = Vocabulary(self._tmp) sentence = 'the unknown .' ids = vocab.encode(sentence) expected = np.array([0, 3, 2, 4, 1], dtype=np.int32) self.assertTrue((ids == expected).all())