Example #1
0
 def test_project_2D_2(self):
     from wordvector import WordVector
     dictionary = {
         'the': 0,
         'quick': 1,
         'brown': 2,
         'fox': 3,
         'jumped': 4,
         'over': 5
     }
     embed_matrix = np.array([[1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
                              [1.0, 0.05, 0.1, 0.1, 0.1, 0.1, 0.1],
                              [-1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
                              [1.0, 0.1, 0.1, 1.1, 1.1, 1.1, 0.1],
                              [1.0, 0.1, 0.1, 0.9, 0.9, 0.9, 0.1],
                              [1.0, 0.1, 0.1, 1.0, 1.0, 0.8, 0.1]])
     word_embedding = WordVector(embed_matrix, dictionary)
     proj, words = word_embedding.project_2d(0, 6)
     self.assertEqual((6, 2), proj.shape,
                      'incorrect projection array size returned')
     self.assertEqual('the', words[0], 'incorrect word at index 0')
     self.assertEqual('fox', words[3], 'incorrect word at index 3')