[Spambayes] ZeroDivisionError with hammie.score()

Todd Kennedy todd.kennedy at gmail.com
Fri Jul 14 04:23:56 CEST 2006


Hi.

I'm trying to integrate the spambayes package into my blogging
software as a comment spam filter.  I've read through a bunch of the
source, looked at the scripts provided and stuff and have a
rudimentary understanding of how the software works.  (i think).  but
i'm getting a ZeroDivisionError when I try to run the score method of
hammie.

this is a quick script that will replicate this (on my machine)

from spambayes import hammie

h = hammie.open('host=/tmp dbname=todd user=todd','pgsql','w')
h.train("there comes a time when all good men must come to the aide of
their country", False)
h.store()
h.train('buy cilias',True)
h.store()
h.score('cilias')

The exception occurs at:
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/spambayes/classifier.py",
line 320, in probability
    prob = spamratio / (hamratio + spamratio)
ZeroDivisionError: float division

I put in some simple print statements to print out nham, nspam,
spamcount and hamcount.  this is their output:
22:14:52 (~)
todd at mothra> ./test_sp.py
spamcount 6
hamcount 6
nham 6
nspam 6
spamcount 6
hamcount 6
spamcount 6
hamcount 6
spamcount 6
hamcount 6
spamcount 0
hamcount 0
nham 6
nspam 6

why would spamcount and hamcount go to 0?

any help would be greatly appreciated (i'm using the latest non-alpha release)

Thanks


More information about the SpamBayes mailing list