我正在尝试使用 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?