Skip to content

Instantly share code, notes, and snippets.

@bluedistro
Created January 1, 2019 19:27
Show Gist options
  • Save bluedistro/54757cd75fb3e01f92fa93e0ad091bc6 to your computer and use it in GitHub Desktop.
Save bluedistro/54757cd75fb3e01f92fa93e0ad091bc6 to your computer and use it in GitHub Desktop.
decode review
def decode_review(text_list):
word_index = tokenizer.word_index
sequences = tokenizer.texts_to_sequences(text_list)
data = pad_sequences(sequences, maxlen=500)
# decode the words
reverse_word_index = dict([(value, key) for (key, value) in word_index.items()])
decoded_review = ' '.join([reverse_word_index.get(i, '?') for i in sequences[0]])
return decoded_review, data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment