[Spambayes-checkins] spambayes/Outlook2000 addin.py,1.49,1.50

Mark Hammond mhammond at users.sourceforge.net
Mon Mar 3 21:46:38 EST 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv7425

Modified Files:
	addin.py 
Log Message:
Show all tokens in the message when showing clues, and when restoring a
message, ensure that we are not attempting to restore to the source!


Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** addin.py	14 Feb 2003 01:24:20 -0000	1.49
--- addin.py	4 Mar 2003 05:46:35 -0000	1.50
***************
*** 254,259 ****
      push(escape(msg.as_string(), True))
      push("</PRE>\n")
      body = ''.join(body)
- 
      new_msg.Subject = "Spam Clues: " + item.Subject
      # As above, use HTMLBody else Outlook refuses to behave.
--- 254,276 ----
      push(escape(msg.as_string(), True))
      push("</PRE>\n")
+     # Show all the tokens in the message
+     from spambayes.tokenizer import tokenize
+     from spambayes.classifier import Set # whatever classifier uses
+     push("<h2>Message Tokens:</h2><br>")
+     # need to re-fetch, as the tokens we see may be different based on
+     # header stripping.
+     toks = Set(tokenize(
+         msgstore_message.GetEmailPackageObject(strip_mime_headers=True)))
+     # create a sorted list
+     toks = [tok for tok in toks]
+     toks.sort()
+     push("%d unique tokens<br>" % len(toks))
+     # Use <code> instead of <pre>, as <pre> is not word-wrapped by IE
+     # However, <code> does not require escaping.
+     # could use pprint, but not worth it.
+     for token in toks:
+         push("<code>" + repr(token) + "</code>, ")
+     # Put the body together, then the rest of the message.
      body = ''.join(body)
      new_msg.Subject = "Spam Clues: " + item.Subject
      # As above, use HTMLBody else Outlook refuses to behave.
***************
*** 347,352 ****
          for msgstore_message in msgstore_messages:
              # Recover where they were moved from
              restore_folder = msgstore_message.GetRememberedFolder()
!             if restore_folder is None:
                  restore_folder = inbox_folder
  
--- 364,373 ----
          for msgstore_message in msgstore_messages:
              # Recover where they were moved from
+             # During experimenting/playing/debugging, it is possible
+             # that the source folder == dest folder - restore to
+             # the inbox in this case.
              restore_folder = msgstore_message.GetRememberedFolder()
!             if restore_folder is None or \
!                msgstore_message.GetFolder() == restore_folder:
                  restore_folder = inbox_folder
  
***************
*** 359,363 ****
                  print "already was trained as ham"
              # Now move it.
-             # XXX - still don't write the source, so no point looking :(
              msgstore_message.MoveTo(restore_folder)
              # Note the move will possibly also trigger a re-train
--- 380,383 ----





More information about the Spambayes-checkins mailing list