Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nltk
- def decode_review(review):
- tokens = ['<START>'] + nltk.tokenize.wordpunct_tokenize(review)
- indices = np.array([word_index[word] if (word in word_index and word_index[word] < 10000) else word_index['<UNK>'] for word in tokens])
- return indices
- review = "This isn't just a beautifully crafted gangster film. Or an outstanding family portrait, for that matter. An amazing period piece. A character study. A lesson in filmmaking and an inspiration to generations of actors, directors, screenwriters and producers. For me, this is more: this is the definitive film. 10 stars out of 10."
- indices = decode_review(review)
- sequence = keras.preprocessing.sequence.pad_sequences([indices],
- value=word_index["<PAD>"],
- padding='post',
- maxlen=256)
- model.predict_proba(sequence)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement