Python, NLP, Numpy, Scikit Learn.
1.0 vec = [v for v in vec_dict.values()] return np.array(vec) Here are the one-hot vectors for the first two sentences: encoder = OneHotEncoder(corpus.vocab()) sent1 = [word for word in word_tokenize(corpus.raw('sent1.txt'))] vec1 = encoder.one_hot_vector(sent1) print(vec1) # [0. 0. 1. 0. 1. 0. 0.