[Spambayes-checkins] spambayes/spambayes Stats.py, 1.7,
1.8 mboxutils.py, 1.8, 1.9 message.py, 1.55, 1.56
Tony Meyer
anadelonbrin at users.sourceforge.net
Fri Nov 5 04:03:15 CET 2004
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28691/spambayes
Modified Files:
Stats.py mboxutils.py message.py
Log Message:
Make message.insert_exception_string optionally put in the id header, for compatibility
with sb_server and sb_pop3dnd.
Make use of HTML in Stats.GetStats optional.
Index: Stats.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Stats.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Stats.py 2 Nov 2004 06:33:23 -0000 1.7
--- Stats.py 5 Nov 2004 03:03:00 -0000 1.8
***************
*** 93,97 ****
self.trn_ham += 1
! def GetStats(self):
if self.total == 0:
return ["SpamBayes has processed zero messages"]
--- 93,97 ----
self.trn_ham += 1
! def GetStats(self, use_html=True):
if self.total == 0:
return ["SpamBayes has processed zero messages"]
***************
*** 176,179 ****
--- 176,186 ----
else:
format_dict[key] = 'were'
+ # Possibly use HTML for breaks/tabs.
+ if use_html:
+ format_dict["br"] = "<br/>"
+ format_dict["tab"] = " "
+ else:
+ format_dict["br"] = "\r\n"
+ format_dict["tab"] = "\t"
## Our result should look something like this:
***************
*** 200,232 ****
push("SpamBayes has classified a total of " \
"%(num_seen)d message%(sp1)s:" \
! "<br/> %(cls_ham)d " \
"(%(perc_cls_ham).0f%% of total) good" \
! "<br/> %(cls_spam)d " \
"(%(perc_cls_spam).0f%% of total) spam" \
! "<br/> %(cls_unsure)d " \
"(%(perc_cls_unsure).0f%% of total) unsure." % \
format_dict)
push("%(correct)d message%(sp2)s %(wp1)s classified correctly " \
"(%(perc_correct).0f%% of total)" \
! "<br/>%(incorrect)d message%(sp3)s %(wp2)s classified " \
"incorrectly " \
"(%(perc_incorrect).0f%% of total)" \
! "<br/> %(fp)d false positive%(sp4)s " \
"(%(perc_fp).0f%% of total)" \
! "<br/> %(fn)d false negative%(sp5)s " \
"(%(perc_fn).0f%% of total)" % \
format_dict)
push("%(trn_unsure_ham)d unsure%(sp6)s trained as good " \
"(%(unsure_ham_perc).0f%% of unsures)" \
! "<br/>%(trn_unsure_spam)d unsure%(sp7)s trained as spam " \
"(%(unsure_spam_perc).0f%% of unsures)" \
! "<br/>%(not_trn_unsure)d unsure%(sp8)s %(wp3)s not trained " \
"(%(unsure_not_perc).0f%% of unsures)" % \
format_dict)
push("A total of %(trn_total)d message%(sp9)s have been trained:" \
! "<br/> %(trn_ham)d good " \
"(%(trn_perc_ham)0.f%% good, %(trn_perc_unsure_ham)0.f%% " \
"unsure, %(trn_perc_fp).0f%% false positives)" \
! "<br/> %(trn_spam)d spam " \
"(%(trn_perc_spam)0.f%% spam, %(trn_perc_unsure_spam)0.f%% " \
"unsure, %(trn_perc_fn).0f%% false negatives)" % \
--- 207,239 ----
push("SpamBayes has classified a total of " \
"%(num_seen)d message%(sp1)s:" \
! "%(br)s%(tab)s%(cls_ham)d " \
"(%(perc_cls_ham).0f%% of total) good" \
! "%(br)s%(tab)s%(cls_spam)d " \
"(%(perc_cls_spam).0f%% of total) spam" \
! "%(br)s%(tab)s%(cls_unsure)d " \
"(%(perc_cls_unsure).0f%% of total) unsure." % \
format_dict)
push("%(correct)d message%(sp2)s %(wp1)s classified correctly " \
"(%(perc_correct).0f%% of total)" \
! "%(br)s%(incorrect)d message%(sp3)s %(wp2)s classified " \
"incorrectly " \
"(%(perc_incorrect).0f%% of total)" \
! "%(br)s%(tab)s%(fp)d false positive%(sp4)s " \
"(%(perc_fp).0f%% of total)" \
! "%(br)s%(tab)s%(fn)d false negative%(sp5)s " \
"(%(perc_fn).0f%% of total)" % \
format_dict)
push("%(trn_unsure_ham)d unsure%(sp6)s trained as good " \
"(%(unsure_ham_perc).0f%% of unsures)" \
! "%(br)s%(trn_unsure_spam)d unsure%(sp7)s trained as spam " \
"(%(unsure_spam_perc).0f%% of unsures)" \
! "%(br)s%(not_trn_unsure)d unsure%(sp8)s %(wp3)s not trained " \
"(%(unsure_not_perc).0f%% of unsures)" % \
format_dict)
push("A total of %(trn_total)d message%(sp9)s have been trained:" \
! "%(br)s%(tab)s%(trn_ham)d good " \
"(%(trn_perc_ham)0.f%% good, %(trn_perc_unsure_ham)0.f%% " \
"unsure, %(trn_perc_fp).0f%% false positives)" \
! "%(br)s%(tab)s%(trn_spam)d spam " \
"(%(trn_perc_spam)0.f%% spam, %(trn_perc_unsure_spam)0.f%% " \
"unsure, %(trn_perc_fn).0f%% false negatives)" % \
Index: mboxutils.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/mboxutils.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** mboxutils.py 25 May 2004 23:16:40 -0000 1.8
--- mboxutils.py 5 Nov 2004 03:03:00 -0000 1.9
***************
*** 117,121 ****
function is imported by tokenizer, and our message class imports
tokenizer, so we get a circular import problem. In any case, this
! function does need anything that our message class offers, so that
shouldn't matter.
"""
--- 117,121 ----
function is imported by tokenizer, and our message class imports
tokenizer, so we get a circular import problem. In any case, this
! function does not need anything that our message class offers, so that
shouldn't matter.
"""
Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** message.py 1 Oct 2004 00:03:19 -0000 1.55
--- message.py 5 Nov 2004 03:03:00 -0000 1.56
***************
*** 495,499 ****
# This is used by both sb_server and sb_imapfilter, so it's handy to have
# it available separately.
! def insert_exception_header(string_msg, msg_id):
"""Insert an exception header into the given RFC822 message (as text).
--- 495,499 ----
# This is used by both sb_server and sb_imapfilter, so it's handy to have
# it available separately.
! def insert_exception_header(string_msg, msg_id=None):
"""Insert an exception header into the given RFC822 message (as text).
***************
*** 510,520 ****
header = email.Header.Header(dottedDetails, header_name=headerName)
! # Insert the exception header, and also insert the id header,
# otherwise we might keep doing this message over and over again.
# We also ensure that the line endings are /r/n as RFC822 requires.
headers, body = re.split(r'\n\r?\n', string_msg, 1)
header = re.sub(r'\r?\n', '\r\n', str(header))
! headers += "\n%s: %s\r\n%s: %s\r\n\r\n" % \
! (headerName, header,
! options["Headers", "mailid_header_name"], msg_id)
return (headers + body, details)
--- 510,522 ----
header = email.Header.Header(dottedDetails, header_name=headerName)
! # Insert the exception header, and optionally also insert the id header,
# otherwise we might keep doing this message over and over again.
# We also ensure that the line endings are /r/n as RFC822 requires.
headers, body = re.split(r'\n\r?\n', string_msg, 1)
header = re.sub(r'\r?\n', '\r\n', str(header))
! headers += "\n%s: %s\r\n" % \
! (headerName, header)
! if msg_id:
! headers += "%s: %s\r\n" % \
! (options["Headers", "mailid_header_name"], msg_id)
return (headers + body, details)
More information about the Spambayes-checkins
mailing list