Created
November 12, 2019 07:16
-
-
Save amansrivastava17/e1f25b1d7ac74ef9c0040931ed1e7bbb to your computer and use it in GitHub Desktop.
Revisions
-
amansrivastava17 created this gist
Nov 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ def test(sentence, model_path, word_index_path) classifier = models.load_model( 'models/models.h5' ) tokenizer = tf.keras.preprocessing.text.Tokenizer(filters='.,:?{} ') sentences = re.sub(r'.,:?{}', ' ', sentence) with open(word_index_path, 'r') as f: tokenizer.word_index = json.loads(f.read()) tokenized_messages = tokenizer.texts_to_matrix(sentence.split()) p = list(classifier.predict(tokenized_messages)[0]) for index, each in enumerate(p): print(index, each)