问题描述
我一直在尝试使用sklearn库中的Count Vectorizer,但是我收到警告,我正在使用的西班牙语停用词列表与预处理不一致。
这是编码问题吗?
a 埃尔 洛斯 ...
custom_stop_words = []
with open( "stopwords.txt","r",encoding='latin_1') as fin:
for line in fin.readlines():
custom_stop_words.append( line.strip() )
# note that we need to make it hashable
print("Stopword list has %d entries" % len(custom_stop_words) )
from sklearn.feature_extraction.text import CountVectorizer
# use a custom stopwords list,set the minimum term-document frequency to 20
vectorizer = CountVectorizer(stop_words = custom_stop_words,min_df = 2,strip_accents='unicode',encoding="latin-1")
A = vectorizer.fit_transform(df_final['visita'])
print( "Created %d X %d document-term matrix" % (A.shape[0],A.shape[1]) )
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)