softtfidf.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:LLString 作者: mitll 项目源码 文件源码
def compute_query_idf(self,corpus):
        """ Compute IDF from s and t in case you have no externally computed IDF to use """
        cv = CountVectorizer(min_df = 0.0)
        cv.fit_transform(corpus)
        self.logger.debug(cv.vocabulary_)
        freq_term_matrix = cv.transform(corpus)
        tfidf = TfidfTransformer(norm="l2")
        tfidf.fit(freq_term_matrix)
        log_idf = tfidf.idf_
        self.LOG_IDF = log_idf
        self.CORPUS_VOCAB = cv.vocabulary_
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号