[Spambayes-checkins] spambayes/Outlook2000/dialogs TrainingDialog.py,1.4,1.5

Mark Hammond mhammond@users.sourceforge.net
Fri, 25 Oct 2002 08:20:29 -0700


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

Modified Files:
	TrainingDialog.py 
Log Message:
First step towards incremental training - keep a "message database"
(simply a pickled dictionary of [messageid]=is_spam).  Train
dialog now has a "rebuild" checkbox, defaulting to off - if off,
only messages not already in the database are added (and correctly
untrained if previously in the incorrect category)

This change will force you to do a full retrain - sorry.


Index: TrainingDialog.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/TrainingDialog.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TrainingDialog.py	25 Oct 2002 06:58:20 -0000	1.4
--- TrainingDialog.py	25 Oct 2002 15:20:26 -0000	1.5
***************
*** 20,23 ****
--- 20,24 ----
  IDC_STATIC_SPAM = 1003
  IDC_BROWSE_SPAM = 1004
+ IDC_BUT_REBUILD = 1005
  from AsyncDialog import IDC_START, IDC_PROGRESS, IDC_PROGRESS_TEXT, AsyncDialogBase
  
***************
*** 32,36 ****
      dt = [
          # Dialog itself.
!         ["Training", (0, 0, 241, 118), style, None, (8, "MS Sans Serif")],
          # Children
          [STATIC,          ham_title,            -1,                   (  7,   6, 131,  11), cs ],
--- 33,37 ----
      dt = [
          # Dialog itself.
!         ["Training", (0, 0, 241, 130), style, None, (8, "MS Sans Serif")],
          # Children
          [STATIC,          ham_title,            -1,                   (  7,   6, 131,  11), cs ],
***************
*** 41,53 ****
          [STATIC,          "",                   IDC_STATIC_SPAM,      (  7,  47, 167,  12), cs | win32con.SS_SUNKEN | win32con.SS_LEFTNOWORDWRAP | win32con.SS_CENTERIMAGE],
          [BUTTON,          'Brow&se',            IDC_BROWSE_SPAM,      (184,  47,  50,  14), cs | win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP],
  
!         [BUTTON,         process_start_text,    IDC_START,            (  7,  97,  50,  14), cs | win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP],
!         ["msctls_progress32", '',               IDC_PROGRESS,         (  7,  68, 166,  11), cs | win32con.WS_BORDER],
!         [STATIC,          '',                   IDC_PROGRESS_TEXT,    (  7,  84, 227,  10), cs ],
  
!         [BUTTON,          'Close',              win32con.IDOK,        (184,  97,  50,  14), cs | win32con.BS_DEFPUSHBUTTON | win32con.WS_TABSTOP],
  
      ]
!     disable_while_running_ids = [IDC_BROWSE_HAM, IDC_BROWSE_SPAM, win32con.IDOK]
  
      def __init__ (self, mgr, trainer):
--- 42,55 ----
          [STATIC,          "",                   IDC_STATIC_SPAM,      (  7,  47, 167,  12), cs | win32con.SS_SUNKEN | win32con.SS_LEFTNOWORDWRAP | win32con.SS_CENTERIMAGE],
          [BUTTON,          'Brow&se',            IDC_BROWSE_SPAM,      (184,  47,  50,  14), cs | win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP],
+         [BUTTON,          'Rebuild entire database',IDC_BUT_REBUILD,  (  7,  67, 174,  10), cs | win32con.BS_AUTOCHECKBOX | win32con.WS_TABSTOP],
  
!         [BUTTON,         process_start_text,    IDC_START,            (  7, 109,  50,  14), cs | win32con.BS_DEFPUSHBUTTON | win32con.WS_TABSTOP],
!         ["msctls_progress32", '',               IDC_PROGRESS,         (  7,  82, 166,  11), cs | win32con.WS_BORDER],
!         [STATIC,          '',                   IDC_PROGRESS_TEXT,    (  7,  98, 227,  10), cs ],
  
!         [BUTTON,          'Close',              win32con.IDOK,        (184, 109,  50,  14), cs | win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP],
  
      ]
!     disable_while_running_ids = [IDC_BROWSE_HAM, IDC_BROWSE_SPAM, IDC_BUT_REBUILD, win32con.IDOK]
  
      def __init__ (self, mgr, trainer):
***************
*** 98,105 ****
                  self.UpdateStatus()
  
      def _DoProcess(self):
          self.mgr.WorkerThreadStarting()
          try:
!             self.trainer(self.mgr, self.progress)
          finally:
              self.mgr.WorkerThreadEnding()
--- 100,111 ----
                  self.UpdateStatus()
  
+     def StartProcess(self):
+         self.rebuild = self.GetDlgItem(IDC_BUT_REBUILD).GetCheck() != 0
+         return AsyncDialogBase.StartProcess(self)
+ 
      def _DoProcess(self):
          self.mgr.WorkerThreadStarting()
          try:
!             self.trainer(self.mgr, self.progress, self.rebuild)
          finally:
              self.mgr.WorkerThreadEnding()