【发布时间】:2021-07-24 05:34:55
【问题描述】:
我正在尝试将停用词添加到我的停用词列表中,但是,我使用的代码似乎不起作用:
创建停用词列表:
stopwords = nltk.corpus.stopwords.words('english')
CustomListofWordstoExclude = ['rt']
stopwords1 = stopwords.extend(CustomListofWordstoExclude)
在这里,我将文本转换为具有 tfidf 权重的 dtm(文档术语矩阵):
vect = TfidfVectorizer(stop_words = 'english', min_df=150, token_pattern=u'\\b[^\\d\\W]+\\b')
dtm = vect.fit_transform(df['tweets'])
dtm.shape
但是当我这样做时,我得到了这个错误:
FutureWarning:将 input=None 作为关键字参数传递。从 0.25 版开始,将这些作为位置参数传递将导致错误 warnings.warn("将 {} 作为关键字参数传递。从 0.25 版开始"
这是什么意思?有没有更简单的方法来添加停用词?
【问题讨论】:
标签: python-3.x stop-words