【发布时间】:2019-08-16 13:12:23
【问题描述】:
如何检查TfidfVertorizer() 中标记的字符串?如果我没有在参数中传递任何内容,TfidfVertorizer() 将使用一些预定义的方法标记字符串。我想观察它是如何标记字符串的,以便我可以更轻松地调整我的模型。
from sklearn.feature_extraction.text import TfidfVectorizer
corpus = ['This is the first document.',
'This document is the second document.',
'And this is the third one.',
'Is this the first document?']
vectorizer = TfidfVectorizer()
X = vectorizer.fit_transform(corpus)
我想要这样的东西:
>>>vectorizer.get_processed_tokens()
[['this', 'is', 'first', 'document'],
['this', 'document', 'is', 'second', 'document'],
['this', 'is', 'the', 'third', 'one'],
['is', 'this', 'the', 'first', 'document']]
我该怎么做?
【问题讨论】:
标签: python scikit-learn nlp tf-idf tfidfvectorizer