Commit 11a413f1 authored by PkSM3's avatar PkSM3

[BUGFIX] math domain error

parent a4c676fe
...@@ -374,6 +374,7 @@ def compute_tfidf(corpus): ...@@ -374,6 +374,7 @@ def compute_tfidf(corpus):
''' % (Node.__table__.name, Node_Ngram.__table__.name, corpus.id, )) ''' % (Node.__table__.name, Node_Ngram.__table__.name, corpus.id, ))
cursor.execute('SELECT COUNT(*) FROM tmp__st') cursor.execute('SELECT COUNT(*) FROM tmp__st')
D = cursor.fetchone()[0] D = cursor.fetchone()[0]
if D>0:
lnD = log(D) lnD = log(D)
cursor.execute('UPDATE tmp__idf SET idf = idf + %f' % (lnD, )) cursor.execute('UPDATE tmp__idf SET idf = idf + %f' % (lnD, ))
# show off # show off
......
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