[Spambayes-checkins] spambayes/Outlook2000 oastats.py, 1.4, 1.5 train.py, 1.36, 1.37

Tony Meyer anadelonbrin at users.sourceforge.net
Fri Oct 15 01:44:40 CEST 2004


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14100/Outlook2000

Modified Files:
	oastats.py train.py 
Log Message:
If we rebuild the database from scratch, that would be a good time to reset the statistics,
 so do so.

Index: oastats.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/oastats.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** oastats.py	14 Oct 2004 23:36:12 -0000	1.4
--- oastats.py	14 Oct 2004 23:44:36 -0000	1.5
***************
*** 14,23 ****
              self.Load()
          else:
!             # Reset totals
!             self.totals = {}
!             for stat in ["num_ham", "num_spam", "num_unsure",
!                          "num_deleted_spam", "num_deleted_spam_fn",
!                          "num_recovered_good", "num_recovered_good_fp",]:
!                 self.totals[stat] = 0
          self.Reset()
      def Reset(self):
--- 14,18 ----
              self.Load()
          else:
!             self.ResetTotal()
          self.Reset()
      def Reset(self):
***************
*** 25,28 ****
--- 20,36 ----
          self.num_deleted_spam = self.num_deleted_spam_fn  = 0
          self.num_recovered_good = self.num_recovered_good_fp = 0
+     def ResetTotal(self, permanently=False):
+         self.totals = {}
+         for stat in ["num_ham", "num_spam", "num_unsure",
+                      "num_deleted_spam", "num_deleted_spam_fn",
+                      "num_recovered_good", "num_recovered_good_fp",]:
+             self.totals[stat] = 0
+         if permanently:
+             # Also remove the file.
+             try:
+                 os.remove(self.stored_statistics_fn)
+             except OSError:
+                 # Maybe we had never saved it.
+                 pass
      def Load(self):
          store = open(self.stored_statistics_fn, 'rb')

Index: train.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/train.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** train.py	25 Jul 2004 23:43:33 -0000	1.36
--- train.py	14 Oct 2004 23:44:36 -0000	1.37
***************
*** 169,172 ****
--- 169,178 ----
          mgr.classifier_data.Adopt(classifier_data)
          classifier_data = mgr.classifier_data
+         # If we are rebuilding, then we reset the statistics, too.
+         # (But output them to the log for reference).
+         mgr.LogDebug(1, "Session:" + "\r\n".join(mgr.stats.GetStats(False))
+         mgr.LogDebug(1, "Total:" + "\r\n".join(mgr.stats.GetStats())
+         mgr.stats.Reset()
+         mgr.stats.ResetTotal(True)
  
      progress.tick()



More information about the Spambayes-checkins mailing list