2024-03-28 17:44:20 发布
网友
我尝试使用scikit learn的Tf idf Vectorizer,使用NLTK的西班牙语stopwords:
from nltk.corpus import stopwords vectorizer = TfidfVectorizer(stop_words=stopwords.words("spanish"))
问题是我收到了以下警告:
有没有简单的方法来解决这个问题?在
实际上这个问题比我想象的要容易解决。这里的问题是NLTK不返回unicode对象,而是返回str对象。所以在使用它们之前,我需要从utf-8解码它们:
stopwords = [word.decode('utf-8') for word in stopwords.words('spanish')]
实际上这个问题比我想象的要容易解决。这里的问题是NLTK不返回unicode对象,而是返回str对象。所以在使用它们之前,我需要从utf-8解码它们:
相关问题 更多 >
编程相关推荐