TF-IDF算法
TF-IDF算法可用来提取文档的关键词,其主要思想是:如果某个单词在某篇文档中出现的频率很高,并且在其他文章中很少出现,则认为此词为该文档关键词。计算公式如下:

Python实现
TfidfVectorizer是sklearn中的库,可以用来计算TF-IDF值。
from sklearn.feature_extraction.text import TfidfVectorizer
corpus = [
'This is the first document.',
'This document is the second document.',
'And this