【发布时间】:2018-08-05 15:32:50
【问题描述】:
我必须计算两个或多个文本的距离/相似度。有些文本真的很小或不能形成正确的英文单词等,“A1024515”。这意味着它应该接受列表中的每个单词。
作为一个测试用例,我使用了以下列表作为语料库。
words= ['A', 'A', 'A']
vect = TfidfVectorizer(min_df =0)
dtm = vect.fit_transform(words)
df_tf_idf = pd.DataFrame(dtm.toarray(), columns=vect.get_feature_names())
但是,我收到以下错误
ValueError: empty vocabulary; perhaps the documents only contain stop words
如何确保列表被接受为可能的词,并确保不从语料库中删除停用词?
【问题讨论】:
-
我不认为这是重复的,因为他们不处理停用词的删除。
标签: python scikit-learn nlp tf-idf tfidfvectorizer