Sklearn库计算TFIDF
Sklearn库计算TFIDF贴代码from sklearn.feature_extraction.text import CountVectorizer,TfidfTransformer# 定义函数def TF_IDF(corpus): vectorizer=CountVectorizer()#该类会将文本中的词语转换为词频矩阵 transformer=TfidfTransformer()#该类会统计每个词语的tf-idf权值 x = vectorizer.fit_tr