コード例 #1
0
 def test_bow_embed_on_multiple_words(self):
     expected = np.zeros((1, len(embeddings.VOCABULARY)))
     expected[0, 0] = 1
     expected[0, 1] = 1
     expected[0, 2] = 1
     expected[0, 3] = 1
     self.assertTrue(
         np.allclose(embeddings.bow_embed(['python java sql delphi']),
                     expected))
コード例 #2
0
 def test_bow_embed_on_single_words(self, input):
     expected = np.zeros((1, len(embeddings.VOCABULARY)))
     expected[0, embeddings.VOCABULARY.index(input)] = 1
     self.assertTrue(np.allclose(embeddings.bow_embed([input]), expected))
コード例 #3
0
 def test_bow_embed_on_multiple_other_words(self):
     expected = np.zeros((1, len(embeddings.VOCABULARY)))
     expected[0, embeddings.VOCABULARY.index(embeddings.OTHER_TOKEN)] = 5
     self.assertTrue(
         np.allclose(embeddings.bow_embed(['this is my test text']),
                     expected))
コード例 #4
0
 def test_bow_embed_on_single_words(self):
     expected = np.zeros((1, len(embeddings.VOCABULARY)))
     expected[0, embeddings.VOCABULARY.index(embeddings.OTHER_TOKEN)] = 1
     self.assertTrue(np.allclose(embeddings.bow_embed(['this']), expected))
コード例 #5
0
 def test_bow_embed_on_multiple_words_num_non_zero(self, input,
                                                   expected_sum):
     self.assertEqual(embeddings.bow_embed(input).sum(), expected_sum)
コード例 #6
0
 def test_bow_embed_on_empty_texts(self):
     expected = np.zeros((1, len(embeddings.VOCABULARY)))
     expected[0, embeddings.VOCABULARY.index(embeddings.EMPTY_TOKEN)] = 1
     self.assertTrue(np.allclose(embeddings.bow_embed(['']), expected))