tf.keras.preprocessing.text.text_to_word_sequence
| Просмотреть исходный код на GitHub |
Преобразует текст в последовательность слов (или токенов).
tf.keras.preprocessing.text.text_to_word_sequence(
input_text,
filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',
lower=True, split=' '
)
Эта функция преобразует строку текста в список слов, игнорируя filters по умолчанию, которые включают знаки препинания.
sample_text = 'This is a sample sentence.' tf.keras.preprocessing.text.text_to_word_sequence(sample_text) ['this', 'is', 'a', 'sample', 'sentence']
| Аргументы | ||
|---|---|---|
input_text | Текст-вход (строка). | |
filters | Список (или конкатенация) символов для фильтрации, таких как знаки препинания. По умолчанию: '!"#$%&()*+,-./:;<=>?@[\]^_{|}~\t\n', includes basic punctuation, tabs, and newlines. </td> </tr><tr> <td>нижнего регистра</td> <td> boolean. Whether to convert the input to lowercase. </td> </tr><tr> <td>разделения` | str. Разделитель для разделения слов. |
| Возвращает | |
|---|---|
| Список слов (или токенов). |
© 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/r2.4/api_docs/python/tf/keras/preprocessing/text/text_to_word_sequence