[Spambayes-checkins] spambayes/contrib tte.py,1.8,1.9
Skip Montanaro
montanaro at users.sourceforge.net
Tue Apr 27 23:29:48 EDT 2004
Update of /cvsroot/spambayes/spambayes/contrib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12083
Modified Files:
tte.py
Log Message:
add -R/--reverse flag to iterate over the mailboxes in reverse
Index: tte.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/contrib/tte.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** tte.py 16 Mar 2004 01:05:33 -0000 1.8
--- tte.py 28 Apr 2004 03:29:46 -0000 1.9
***************
*** 34,37 ****
--- 34,39 ----
-v Be very verbose, spewing all sorts of stuff out to stderr.
+ -R Walk backwards through the mailbox.
+
Note: The -c command line argument isn't quite as benign as it might first
***************
*** 81,85 ****
print >> sys.stderr, __doc__.strip() % globals()
! def train(store, ham, spam, maxmsgs, maxrounds, tdict, verbose):
smisses = hmisses = round = 0
ham_cutoff = Options.options["Categorization", "ham_cutoff"]
--- 83,87 ----
print >> sys.stderr, __doc__.strip() % globals()
! def train(store, ham, spam, maxmsgs, maxrounds, tdict, reverse, verbose):
smisses = hmisses = round = 0
ham_cutoff = Options.options["Categorization", "ham_cutoff"]
***************
*** 89,92 ****
--- 91,97 ----
hambone = mboxutils.getmbox(ham)
spamcan = mboxutils.getmbox(spam)
+ if reverse:
+ hambone = reversed(list(hambone))
+ spamcan = reversed(list(spamcan))
round += 1
***************
*** 153,161 ****
def main(args):
try:
! opts, args = getopt.getopt(args, "hg:s:d:p:o:m:r:c:v",
["help", "good=", "spam=",
"database=", "pickle=", "verbose",
"option=", "max=", "maxrounds=",
! "cullext="])
except getopt.GetoptError, msg:
usage(msg)
--- 158,166 ----
def main(args):
try:
! opts, args = getopt.getopt(args, "hg:s:d:p:o:m:r:c:vR",
["help", "good=", "spam=",
"database=", "pickle=", "verbose",
"option=", "max=", "maxrounds=",
! "cullext=", "reverse"])
except getopt.GetoptError, msg:
usage(msg)
***************
*** 166,169 ****
--- 171,175 ----
maxrounds = MAXROUNDS
verbose = False
+ reverse = False
for opt, arg in opts:
if opt in ("-h", "--help"):
***************
*** 182,185 ****
--- 188,193 ----
elif opt in ("-r", "--maxrounds"):
maxrounds = int(arg)
+ elif opt in ("-R", "--reverse"):
+ reverse = True
elif opt in ('-o', '--option'):
Options.options.set_from_cmdline(arg, sys.stderr)
***************
*** 199,203 ****
tdict = {}
! train(store, ham, spam, maxmsgs, maxrounds, tdict, verbose)
store.store()
--- 207,211 ----
tdict = {}
! train(store, ham, spam, maxmsgs, maxrounds, tdict, reverse, verbose)
store.store()
More information about the Spambayes-checkins
mailing list