text_plain_output_1.png
from keras.preprocessing.sequence import pad_sequences

from keras.preprocessing.text import one_hot

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

dataset = pd.read_csv('../input/emotions-in-text/Emotion_final.csv')
dataset.sample(5)

def get_longest_text(texts):
    longest_input = 0
    for text in texts:
        text_len = len(text.split())
        longest_input = max(longest_input, text_len)
    return longest_input
longest_input = get_longest_text(dataset['Text'])
longest_input

vocab_size = 21000
encoded_docs = [one_hot(d, vocab_size) for d in dataset['Text']]

max_length = longest_input
padded_docs = pad_sequences(encoded_docs, maxlen=max_length, padding='post')
print(padded_docs[0])