Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用标记器函数tensorflow标记标点_Python_Tensorflow_Keras_Nlp_Tokenize - Fatal编程技术网

Python 如何使用标记器函数tensorflow标记标点

Python 如何使用标记器函数tensorflow标记标点,python,tensorflow,keras,nlp,tokenize,Python,Tensorflow,Keras,Nlp,Tokenize,我使用tensorflow.keras.preprocessing.text中的Tokenizer()函数作为: 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, '

我使用
tensorflow.keras.preprocessing.text中的
Tokenizer()
函数作为:

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}

标记器函数不包括标点符号。如何标记标点符号呢?(
,在本例中。)

一种可能性是用空格将标点符号与单词分开。我使用预处理函数
pad\u标点符号
来实现这一点。在此之后,我使用
filter=''

结果:

{'the': 1, 'quick': 2, 'brown': 3, 'fox': 4, 'jumped': 5, 'over': 6, 'lazy': 7, 'dog': 8, '.': 9}
pad\u标点符号
功能对所有标点符号都有效

{'the': 1, 'quick': 2, 'brown': 3, 'fox': 4, 'jumped': 5, 'over': 6, 'lazy': 7, 'dog': 8, '.': 9}