將文本轉換為單詞序列(或標記)。
用法
tf.keras.preprocessing.text.text_to_word_sequence(
input_text,
filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',
lower=True, split=' '
)
參數
-
input_text
輸入文本(字符串)。 -
filters
要過濾掉的字符列表(或連接),例如標點符號。默認值:'!"#$%&()*+,-./:;<=>?@[\]^_`{|}~\t\n'
,包括基本標點符號、製表符和換行符。 -
lower
布爾值。是否將輸入轉換為小寫。 -
split
str. 用於分詞的分隔符。
返回
- 單詞(或標記)列表。
此函數將文本字符串轉換為單詞列表,同時忽略默認情況下包含標點符號的filters
。
sample_text = 'This is a sample sentence.'
tf.keras.preprocessing.text.text_to_word_sequence(sample_text)
['this', 'is', 'a', 'sample', 'sentence']
相關用法
- Python tf.keras.preprocessing.image.ImageDataGenerator用法及代碼示例
- Python tf.keras.preprocessing.sequence.TimeseriesGenerator用法及代碼示例
- Python tf.keras.preprocessing.sequence.pad_sequences用法及代碼示例
- Python tf.keras.preprocessing.image.smart_resize用法及代碼示例
- Python tf.keras.preprocessing.image.DirectoryIterator.__len__用法及代碼示例
- Python tf.keras.preprocessing.sequence.make_sampling_table用法及代碼示例
- Python tf.keras.applications.inception_resnet_v2.preprocess_input用法及代碼示例
- Python tf.keras.metrics.Mean.merge_state用法及代碼示例
- Python tf.keras.layers.InputLayer用法及代碼示例
- Python tf.keras.callbacks.ReduceLROnPlateau用法及代碼示例
- Python tf.keras.layers.serialize用法及代碼示例
- Python tf.keras.metrics.Hinge用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.compute_loss用法及代碼示例
- Python tf.keras.metrics.SparseCategoricalAccuracy.merge_state用法及代碼示例
- Python tf.keras.metrics.RootMeanSquaredError用法及代碼示例
- Python tf.keras.applications.resnet50.preprocess_input用法及代碼示例
- Python tf.keras.metrics.SparseCategoricalCrossentropy.merge_state用法及代碼示例
- Python tf.keras.metrics.sparse_categorical_accuracy用法及代碼示例
- Python tf.keras.layers.Dropout用法及代碼示例
- Python tf.keras.activations.softplus用法及代碼示例
- Python tf.keras.utils.custom_object_scope用法及代碼示例
- Python tf.keras.optimizers.Optimizer.set_weights用法及代碼示例
- Python tf.keras.Model.compute_loss用法及代碼示例
- Python tf.keras.metrics.FalseNegatives用法及代碼示例
- Python tf.keras.layers.maximum用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.keras.preprocessing.text.text_to_word_sequence。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。