Commit 3b2c4c53 authored by Romain Loth's avatar Romain Loth

factorize stable part to compute it befor loop

parent ea1f68a4
......@@ -84,11 +84,13 @@ def compute_tfidf_local(corpus):
.all()
)
# ---------------------------------------------
# -------------------------------------------------
tfidfs = {}
log_tot_docs = log(total_docs)
for (ngram_id, tf, nd) in tf_nd:
tfidfs[ngram_id] = tf * log(total_docs/nd)
# ---------------------------------------------
# tfidfs[ngram_id] = tf * log(total_docs/nd)
tfidfs[ngram_id] = tf * (log_tot_docs-log(nd))
# -------------------------------------------------
# create the new TFIDF-CORPUS node
ltfidf = Node()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment