|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.15.0/keras/preprocessing/text.py#L84-L132) |

One-hot encodes a text into a list of word indexes of size `n`.

    tf.keras.preprocessing.text.one_hot(
        input_text,
        n,
        filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',
        lower=True,
        split=' ',
        analyzer=None
    )

> [!WARNING]
> **Deprecated:** `tf.keras.text.preprocessing.one_hot` does not operate on tensors and is not recommended for new code. Prefer [`tf.keras.layers.Hashing`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/keras/layers/Hashing) with `output_mode='one_hot'` which provides equivalent functionality through a layer which accepts [`tf.Tensor`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/Tensor) input. See the [preprocessing layer guide](https://www.tensorflow.org/guide/keras/preprocessing_layers) for an overview of preprocessing layers.

This function receives as input a string of text and returns a
list of encoded integers each corresponding to a word (or token)
in the given input string.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input_text` | Input text (string). |
| `n` | int. Size of vocabulary. |
| `filters` | list (or concatenation) of characters to filter out, such as punctuation. Default: ``'!"#$%&()*+,-./:;<=>?@[\]^_`{|}~\t\n``, includes basic punctuation, tabs, and newlines. |
| `lower` | boolean. Whether to set the text to lowercase. |
| `split` | str. Separator for word splitting. |
| `analyzer` | function. Custom analyzer to split the text |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| List of integers in `[1, n]`. Each integer encodes a word (unicity non-guaranteed). ||

<br />