Module: tf.keras.preprocessing.text
Stay organized with collections
Save and categorize content based on your preferences.
Utilities for text input preprocessing.
Classes
class Tokenizer
: Text tokenization utility class.
Functions
hashing_trick(...)
: Converts a text to a sequence of indexes in a fixed-size hashing space.
one_hot(...)
: One-hot encodes a text into a list of word indexes of size n
.
text_to_word_sequence(...)
: Converts a text to a sequence of words (or tokens).
tokenizer_from_json(...)
: Parses a JSON tokenizer configuration and returns a tokenizer instance.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-03-27 UTC.
[null,null,["Last updated 2023-03-27 UTC."],[],[],null,["# Module: tf.keras.preprocessing.text\n\n\u003cbr /\u003e\n\nUtilities for text input preprocessing.\n| **Deprecated:** [`tf.keras.preprocessing.text`](../../../tf/keras/preprocessing/text) APIs are not recommended for new code. Prefer [`tf.keras.utils.text_dataset_from_directory`](../../../tf/keras/utils/text_dataset_from_directory) and [`tf.keras.layers.TextVectorization`](../../../tf/keras/layers/TextVectorization) which provide a more efficient approach for preprocessing text input. For an introduction to these APIs, see the [text loading tutorial](https://www.tensorflow.org/tutorials/load_data/text) and [preprocessing layer guide](https://www.tensorflow.org/guide/keras/preprocessing_layers).\n\nClasses\n-------\n\n[`class Tokenizer`](../../../tf/keras/preprocessing/text/Tokenizer): Text tokenization utility class.\n\nFunctions\n---------\n\n[`hashing_trick(...)`](../../../tf/keras/preprocessing/text/hashing_trick): Converts a text to a sequence of indexes in a fixed-size hashing space.\n\n[`one_hot(...)`](../../../tf/keras/preprocessing/text/one_hot): One-hot encodes a text into a list of word indexes of size `n`.\n\n[`text_to_word_sequence(...)`](../../../tf/keras/preprocessing/text/text_to_word_sequence): Converts a text to a sequence of words (or tokens).\n\n[`tokenizer_from_json(...)`](../../../tf/keras/preprocessing/text/tokenizer_from_json): Parses a JSON tokenizer configuration and returns a tokenizer instance."]]