In order to put the words into the machine learning algorithm the text data should be converted into a vector representations. A one hot encoding is a representation of categorical variables as…