Esempio n. 1
0
 def get_input_vector(self, ind):
     """
     Given an index, get the corresponding vector of the Input Matrix.
     """
     dim = self.get_dimension()
     b = fasttext.Vector(dim)
     self.f.getInputVector(b, ind)
     return np.array(b)
Esempio n. 2
0
 def get_sentence_vector(self, text, normalise=False):
     """
     Given a string, get a single vector represenation. This function
     assumes to be given a single line of text. We split words on
     whitespace (space, newline, tab, vertical tab) and the control
     characters carriage return, formfeed and the null character.
     """
     if text.find('\n') != -1:
         raise ValueError(
             "predict processes one line at a time (remove \'\\n\')")
     text += "\n"
     dim = self.get_dimension()
     b = fasttext.Vector(dim)
     self.f.getSentenceVector(b, text, normalise)
     return np.array(b)
Esempio n. 3
0
 def get_new_vector(self):
     return fasttext.Vector(self.get_dimension())
Esempio n. 4
0
 def get_word_vector(self, word, normalise=False):
     """Get the vector representation of word."""
     dim = self.get_dimension()
     b = fasttext.Vector(dim)
     self.f.getWordVector(b, word, normalise)
     return np.array(b)
Esempio n. 5
0
 def get_subword_vector(self, word):
     """Get the vector representation of subword."""
     dim = self.get_dimension()
     b = fasttext.Vector(dim)
     self.f.getSubwordVector(b, word)
     return np.array(b)