Package/function to convert the word to one hot vector in Python NLP
There are several ways to convert words to one hot encoded vectors. Since I do not know the data structure you store your data. I assume it is going to be a list


  from keras.preprocessing.text import Tokenizer 
  samples = ['The', 'dog','mouse','elephant']
  tokenizer = Tokenizer(num_words=len(samples))


This builds the word index 


  tokenizer.fit_on_texts(samples)


one hot representation


  one_hot_results = tokenizer.texts_to_matrix(samples, mode='binary')


By changing the mode from binary to 'tfidf' or 'count', you can make a matrix of any type, apart from one hot. 

You can achieve the same result using other packages like sklearn. But it does involve a bit more lines of code.