[spambayes-dev] [Spambayes] ZeroDivisionError with hammie.score()
Todd Kennedy
todd.kennedy at gmail.com
Sun Jul 16 09:47:12 CEST 2006
Tony,
That seems to have solved the issue. By changing the _wordinfoget
function for the SQLClassifier class to return None on the else case
I'm no longer getting a traceback, but rather:
X-Spambayes-Classification: ham; 0.02
do you want some viagra
As output of the h.filter() function.
Thanks much!!
On 7/16/06, Tony Meyer <tameyer at ihug.co.nz> wrote:
> > I've included the full traceback that you get when you run the script
> > I provided. Hopefully this will provide some information. Any ideas
> > on how to resolve this would be great -- I'm moderately new to Python.
> > Also, I upgraded to 1.1a2 and it's still occuring...
> [...]
>
> I believe the problem is in _wordinfoget, which should return None if
> the word is not in the database (and this is how _worddistanceget
> decides whether to use the 'unknown token' probability).
>
> PGClassifier's _wordinfoget method (actually the base
> SQLClassifier's), which, as Kenny said, isn't widely used, is:
>
> def _wordinfoget(self, word):
> if isinstance(word, unicode):
> word = word.encode("utf-8")
>
> row = self._get_row(word)
> if row:
> item = self.WordInfoClass()
> item.__setstate__((row["nspam"], row["nham"]))
> return item
> else:
> return self.WordInfoClass()
>
> I believe this should be:
>
> def _wordinfoget(self, word):
> if isinstance(word, unicode):
> word = word.encode("utf-8")
>
> row = self._get_row(word)
> if row:
> item = self.WordInfoClass()
> item.__setstate__((row["nspam"], row["nham"]))
> return item
> else:
> return None
>
> (This is more-or-less what the mySQL storage option does).
>
> Try that change (just changing the final return from
> "self.WordInfoClass()" to "None"), and see if it fixes the problem.
> If it does, please let us know so that we can make the change in the
> repository as well.
>
> =Tony.Meyer
>
>
>
More information about the spambayes-dev
mailing list