tf.keras.preprocessing.text.hashing_trick
Преобразует текст в последовательность индексов в пространстве хеширования фиксированного размера.
tf.keras.preprocessing.text.hashing_trick(
text, n, hash_function=None, filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',
lower=True, split=' '
)
Аргументы
text: Input text (string).
n: Dimension of the hashing space.
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.
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.
Возвращаемые значения
A list of integer word indices (unicity non-guaranteed).
0 — это зарезервированный индекс, который не будет назначен ни одному слову.
Два или более слова могут быть назначены одному и тому же индексу из-за возможных коллизий хеш-функции. Вероятность коллизии зависит от размерности пространства хеширования и количества различных объектов.
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/preprocessing/text/hashing_trick