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)
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)
def get_new_vector(self): return fasttext.Vector(self.get_dimension())
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)
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)