[Spambayes-checkins] spambayes/Outlook2000 classify.py,1.9,1.10 manager.py,1.20,1.21 train.py,1.7,1.8

Mark Hammond mhammond@users.sourceforge.net
Fri, 25 Oct 2002 06:10:17 -0700


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory usw-pr-cvs1:/tmp/cvs-serv1158

Modified Files:
	classify.py manager.py train.py 
Log Message:
Catch all errors in the classify and training loops, and remove dead code
from the manager.


Index: classify.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/classify.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** classify.py	24 Oct 2002 13:06:39 -0000	1.9
--- classify.py	25 Oct 2002 13:10:14 -0000	1.10
***************
*** 4,8 ****
  # Copyright PSF, license under the PSF license
  
! import sys, os, os.path, getopt, cPickle, string
  from win32com.client import Dispatch, constants
  import pythoncom
--- 4,8 ----
  # Copyright PSF, license under the PSF license
  
! import sys, os, traceback
  from win32com.client import Dispatch, constants
  import pythoncom
***************
*** 14,20 ****
              break
          progress.tick()
!         prob = mgr.score(message)
!         message.SetField(config.field_name, prob)
!         message.Save()
  
  # Called back from the dialog to do the actual training.
--- 14,24 ----
              break
          progress.tick()
!         try:
!             prob = mgr.score(message)
!             message.SetField(config.field_name, prob)
!             message.Save()
!         except:
!             print "Error classifying message '%s'" % (message,)
!             traceback.print_exc()
  
  # Called back from the dialog to do the actual training.

Index: manager.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/manager.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** manager.py	25 Oct 2002 06:58:20 -0000	1.20
--- manager.py	25 Oct 2002 13:10:14 -0000	1.21
***************
*** 82,88 ****
          bayes = None
          try:
-             # Ooops - Tim did it another way - checking this in before I get more conficts!
- ##            from Options import options
- ##            options.mergefiles([self.ini_filename])
              bayes = cPickle.load(open(self.bayes_filename, 'rb'))
              print "Loaded bayes database from '%s'" % (self.bayes_filename,)
--- 82,85 ----
***************
*** 131,137 ****
  
      def InitNewBayes(self):
-             # Ooops - Tim did it another way - checking this in before I get more conficts!
- ##        from Options import options
- ##        options.mergefiles([self.ini_filename])
          self.bayes = bayes_classifier.Bayes()
          self.bayes_dirty = True
--- 128,131 ----

Index: train.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/train.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** train.py	25 Oct 2002 01:25:56 -0000	1.7
--- train.py	25 Oct 2002 13:10:15 -0000	1.8
***************
*** 4,8 ****
  # Copyright PSF, license under the PSF license
  
! import sys, os
  
  def train_folder( f, isspam, mgr, progress):
--- 4,8 ----
  # Copyright PSF, license under the PSF license
  
! import sys, os, traceback
  
  def train_folder( f, isspam, mgr, progress):
***************
*** 13,18 ****
              break
          progress.tick()
!         stream = message.GetEmailPackageObject()
!         mgr.bayes.learn(tokenize(stream), isspam, False)
          num += 1
      print "Trained over", num, "in folder", f.name
--- 13,22 ----
              break
          progress.tick()
!         try:
!             stream = message.GetEmailPackageObject()
!             mgr.bayes.learn(tokenize(stream), isspam, False)
!         except:
!             print "Error training message '%s'" % (message,)
!             traceback.print_exc()
          num += 1
      print "Trained over", num, "in folder", f.name