<s> from keras . preprocessing . text import Tokenizer , one_hot <EOL> import pytest <EOL> import numpy as np <EOL> def test_one_hot ( ) : <EOL> text = '<STR_LIT>' <EOL> encoded = one_hot ( text , <NUM_LIT:5> ) <EOL> assert len ( encoded ) == <NUM_LIT:6> <EOL> assert np . max ( encoded ) <= <NUM_LIT:4> <EOL> assert np . min ( encoded ) >= <NUM_LIT:0> <EOL> def test_tokenizer ( ) : <EOL> texts = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> tokenizer = Tokenizer ( nb_words = <NUM_LIT:10> ) <EOL> tokenizer . fit_on_texts ( texts ) <EOL> sequences = [ ] <EOL> for seq in tokenizer . texts_to_sequences_generator ( texts ) : <EOL> sequences . append ( seq ) <EOL> assert np . max ( np . max ( sequences ) ) < <NUM_LIT:10> <EOL> assert np . min ( np . min ( sequences ) ) == <NUM_LIT:1> <EOL> tokenizer . fit_on_sequences ( sequences ) <EOL> for mode in [ '<STR_LIT>' , '<STR_LIT:count>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> matrix = tokenizer . texts_to_matrix ( texts , mode ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pytest . main ( [ __file__ ] ) </s>
