如何解决如何使用二元词扩展停用词列表?
我想使用 TfidfVectorizer
来提取 bigrams
。但是扩展停用词列表不适用于二元组。我该如何解决这个问题?
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction import text
import pandas as pd
content = CORPUS
my_stop_words = text.ENGLISH_STOP_WORDS.union(['don kNow','good morning','happy birthday'])
vectorizer = TfidfVectorizer(stop_words=my_stop_words,max_features=25,ngram_range=(2,2))
X = vectorizer.fit_transform(content).todense()
df = pd.DataFrame(X,columns=vectorizer.get_feature_names())
df.to_csv('test.csv')
我收到了这个警告,结果没有任何改变:
Your stop_words may be inconsistent with your preprocessing. Tokenizing the stop words generated tokens ['birthday','don',...] not in stop_words.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。