【发布时间】:2019-04-03 15:37:38
【问题描述】:
我正在尝试使用 TfidfVectorizer 处理取自关于葡萄牙历史的维基百科页面的一句话。但是我注意到TfidfVec.fit_transform 方法忽略了某些单词。这是我试过的句子:
sentence = "The oldest human fossil is the skull discovered in the Cave of Aroeira in Almonda."
TfidfVec = TfidfVectorizer()
tfidf = TfidfVec.fit_transform([sentence])
cols = [words[idx] for idx in tfidf.indices]
matrix = tfidf.todense()
pd.DataFrame(matrix,columns = cols,index=["Tf-Idf"])
数据框的输出:
本质上,它忽略了“Aroeira”和“Almonda”这两个词。
但我不想让它忽略这些词,我该怎么办?我在他们谈论这个的文档上找不到任何地方。
另一个问题是为什么重复“the”这个词?算法是否应该只考虑一个“the”并计算其 tf-idf?
【问题讨论】:
-
您的代码中的“单词”是什么?
标签: python scikit-learn nlp tf-idf tfidfvectorizer