我使用asTokenizer()中的函数tensorflow.keras.preprocessing.text:
from tensorflow.keras.preprocessing.text import Tokenizer
s = ["The quick brown fox jumped over the lazy dog."]
t = Tokenizer()
t.fit_on_texts(s)
print(t.word_index)
输出 :
{'the': 1, 'quick': 2, 'brown': 3, 'fox': 4, 'jumped': 5, 'over': 6, 'lazy': 7, 'dog': 8}
Tokenizer 函数排除标点符号。如何标记标点符号?( .,在此示例中。)
12345678_0001
相关分类