defaults to python hash function, can be 'md5' or
any function that takes in input a string and returns a int.
Note that 'hash' is not a stable hashing function, so
it is not consistent across different runs, while 'md5'
is a stable hashing function.
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
Returns
A list of integer word indices (unicity non-guaranteed).
0 is a reserved index that won't be assigned to any word.
Two or more words may be assigned to the same index, due to possible
collisions by the hashing function.
The probability
of a collision is in relation to the dimension of the hashing space and
the number of distinct objects.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.keras.preprocessing.text.hashing_trick\n\n|-----------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.11.0/keras/preprocessing/text.py#L135-L191) |\n\nConverts a text to a sequence of indexes in a fixed-size hashing space.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n\\`tf.compat.v1.keras.preprocessing.text.hashing_trick\\`\n\n\u003cbr /\u003e\n\n tf.keras.preprocessing.text.hashing_trick(\n text,\n n,\n hash_function=None,\n filters='!\"#$%&()*+,-./:;\u003c=\u003e?@[\\\\]^_`{|}~\\t\\n',\n lower=True,\n split=' ',\n analyzer=None\n )\n\n| **Deprecated:** `tf.keras.text.preprocessing.hashing_trick` does not operate on tensors and is not recommended for new code. Prefer [`tf.keras.layers.Hashing`](../../../../tf/keras/layers/Hashing) which provides equivalent functionality through a layer which accepts [`tf.Tensor`](../../../../tf/Tensor) input. See the [preprocessing layer guide](https://www.tensorflow.org/guide/keras/preprocessing_layers) for an overview of preprocessing layers.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`text`](https://www.tensorflow.org/text/api_docs/python/text) | Input text (string). |\n| `n` | Dimension of the hashing space. |\n| `hash_function` | defaults to python `hash` function, can be 'md5' or any function that takes in input a string and returns a int. Note that 'hash' is not a stable hashing function, so it is not consistent across different runs, while 'md5' is a stable hashing function. |\n| `filters` | list (or concatenation) of characters to filter out, such as punctuation. Default: ``!\"#$%&()*+,-./:;\u003c=\u003e?@[\\\\]^_`{|}~\\\\t\\\\n``, includes basic punctuation, tabs, and newlines. |\n| `lower` | boolean. Whether to set the text to lowercase. |\n| `split` | str. Separator for word splitting. |\n| `analyzer` | function. Custom analyzer to split the text |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A list of integer word indices (unicity non-guaranteed). `0` is a reserved index that won't be assigned to any word. Two or more words may be assigned to the same index, due to possible collisions by the hashing function. The [probability](https://en.wikipedia.org/wiki/Birthday_problem#Probability_table) of a collision is in relation to the dimension of the hashing space and the number of distinct objects. ||\n\n\u003cbr /\u003e"]]