这是我所拥有的:

vocab_processor = skflow.preprocessing.VocabularyProcessor(MAX_DOCUMENT_LENGTH)
X_train = np.array(list(vocab_processor.fit_transform(X_train)))
X_test = np.array(list(vocab_processor.transform(X_test)))


现在,它在单词字典中创建一个numpy的单词ID数组。
如果我想从字典中找回那些单词怎么办?

有一个名为reverese(document)的函数,但在这种情况下不起作用。它正在返回包含标记的列表。

['What is most beautiful in <UNK> men is something feminine'
"The camera makes everyone a tourist in other people's reality"
'<UNK> in reality is the worst of all evils because' ...,
'<UNK> aware that no bank would do this as they'
'<UNK> keep sending you many details through the post like'
'<UNK> banking transactions should be conducted in a secure place']

最佳答案

这会给你id:字

w_dict = {v:k for k,v in vocab_processor.vocabulary_._mapping.items()}


然后,您可以得到以下信息:

words = w_dict.values()

08-24 14:15