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_
评论列表
文章目录