停止词与sklearn CountVectorizer中的预处理不一致

问题描述

我一直在尝试使用sklearn库中的Count Vectorizer,但是我收到警告,我正在使用的西班牙语停用词列表与预处理不一致。

这是编码问题吗?

stopwords.txt文件每行有一个单词,例如:

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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...