tfds.deprecated.text.TokenTextEncoder
In the deprecated encoding method with tfds.deprecated.text.TokenTextEncoder We first create a vocab set of token
tokenizer = tfds.deprecated.text.Tokenizer()
vocabulary_set = set()
#imdb_train --> imdb dataset from tensorflow_datasets
for example, label in imdb_train:
some_tokens = tokenizer.tokenize(example.numpy())
Then load it into the encoder
encoder = tfds.deprecated.text.TokenTextEncoder(vocabulary_set,
lowercase=True,
tokenizer=tokenizer)
Afterward when performing encoding I notice the encoder will output a single integer, for example while debugging I found that the word "the" got encoded with 112
token_id = encoder.encode(word)[0]
>> token_id = 112
But then when it comes to
tensorflow.keras.preprocessing.text.Tokenizer
tokenizer = tensorflow.keras.preprocessing.text.Tokenizer()
tokenizer.fit_on_texts(words)
token_id = tokenizer.texts_to_sequences(word) #word = the
>> token_id = [800,2085,936]
It produces a sequence of 3 integers, so now do I use all 3 numbers or should it be also correct if I take just 1 number in that sequence? I'm trying to use this encoded integer to create embedding matrix using Glove Embedding. The old deprecated one produces just one integer so it's easier to map, with integer sequence I'm not sure how to proceed