NLTK 是否实现了 TF-IDF?

Does NLTK have TF-IDF implemented?

scikit-learngensim 中有 TF-IDF 实现。

有简单的实现Simple implementation of N-Gram, tf-idf and Cosine similarity in Python

为了避免重新发明轮子,

在这篇博文中,它说 NLTK 没有它。 这是真的吗? http://www.bogotobogo.com/python/NLTK/tf_idf_with_scikit-learn_NLTK.php

NLTK TextCollection class 有一种计算术语 tf-idf 的方法。文档是 here, and the source is here。但是,它显示 "may be slow to load",因此使用 scikit-learn 可能更可取。

我想,有足够的证据可以断定 NLTK 中不存在 TF-IDF:

  1. Unfortunately, calculating tf-idf is not available in NLTK so we'll use another data analysis library, scikit-learn

    来自 COMPSCI 290-01 Spring 2014 lab

  2. 更重要的是,源代码不包含任何与 TF-IDF tfidf (or tf-idf). Exceptions are NLTK-contrib, which contains map-reduce implementation 相关的内容。

related question 中提到了几个 tf-idf 库。

更新:通过 tf idf or tf_idf 搜索可以找到@yvespeirsman

已经找到的函数