public Mail(String fileName) // read a mail from file
{
- fileName = "emails/email41";
- System.out.println("fileName= " + fileName);
+ //System.out.println("DEBUG: fileName= " + fileName);
FileInputStream fileinput = new FileInputStream(fileName);
String line;
{
cc = (String)splittedLine.elementAt(1);
}
- else if(((String)(splittedLine.elementAt(0))).equals("Title:")) // Subject
+ else if(((String)(splittedLine.elementAt(0))).equals("Subject:")) // Subject
{
subject = (String)splittedLine.elementAt(1);
break;
String tmpStr = new String();
tmpStr += charArray[0];
- //System.out.println("tmpStr= " + tmpStr);
-
for(int i=1; i< noURLBody.length(); i++)
{
if((i % size) == 0) {
if (sig != null) {
String hash = engineNo + ":" + sig;
printableSigs.addElement(hash);
- // System.out.println("mail= " +mail + " hash= " + hash);
+
+ //System.out.println("DEBUG: mail= " +mail + " hash= " + hash);
+
} else {
// we didn't produce a signature for the mail.
}
Vector getURLs = (Vector)(EmailParts.elementAt(1));
for (int mailIndex = 0; mailIndex < getURLs.size(); mailIndex++) {
String mail = (String) (getURLs.elementAt(mailIndex));
- System.out.println("from GETURLS mail= " + mail);
/*
* Compute Sig for bodyparts that are cleaned.
}
Random rand = new Random(thid);
- Random myrand = new Random(0);
for(int i=0; i<niter; i++) {
correct =0;
// System.out.println("userAnswer= " + userAnswer + " filterAnswer= " + filterAnswer);
if(filterAnswer != userAnswer) {
+ /* wrong answer from the spam filter */
wrong++;
atomic {
- sendFeedBack(signatures, userAnswer, thid);
+ sendFeedBack(signatures, userAnswer, thid, rand);
}
}
- else
+ else {
+ /* Correct answer from the spam filter */
correct++;
+ }
} //end num emails
System.out.println((i+1)+"th iteration correct = " + correct + " Wrong = " + wrong + " percentage = " + ((float)correct/(float)nemails));
}//end num iter
* spam database and trains the spam database to check future
* emails and detect spam
**/
- public void sendFeedBack(Vector signatures, boolean isSpam, int id) {
+ public void sendFeedBack(Vector signatures, boolean isSpam, int id, Random myrand) {
for(int i=0;i<signatures.size();i++) {
String part = (String)(signatures.elementAt(i));
//System.out.println(fs.toString());
- //TODO: Allow users to give incorrect feedback
-
- //Increment spam or ham value
- if(isSpam) {
- tmphe.stats.incSpamCount(id);
- fs.increaseSpam();
+ //Allow users to give incorrect feedback
+ int pickemail = myrand.nextInt(100);
+ /* Randomly allow user to provide incorrect feedback */
+ if(pickemail < 95) {
+ //give correct feedback 95% of times
+ //Increment spam or ham value
+ if(isSpam) {
+ tmphe.stats.incSpamCount(id);
+ fs.increaseSpam();
+ } else {
+ tmphe.stats.incHamCount(id);
+ fs.increaseHam();
+ }
} else {
- tmphe.stats.incHamCount(id);
- fs.increaseHam();
- }
+ // Give incorrect feedback 5% of times
+ if(isSpam) {
+ tmphe.stats.incHamCount(id);
+ fs.increaseHam();
+ } else {
+ tmphe.stats.incSpamCount(id);
+ fs.increaseSpam();
+ }
+ } //end of pickemail
}
}
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- $Id: WhiplashSignature.java,v 1.3 2009/11/14 02:10:08 adash Exp $
+ $Id: WhiplashSignature.java,v 1.4 2009/11/15 00:03:04 adash Exp $
*/
public class WhiplashSignature {
char[] b64table;
Vector hosts = new Vector();
String buf = new String(text);
- System.out.println("DEBUG: extractHosts() string= " + buf);
+ //System.out.println("DEBUG: extractHosts() string= " + buf);
/* Extract hosts from http:// links */
int idx;
buf = buf.subString(startidx);
int endidx = buf.indexOf(strcom);
String host = buf.subString(0, endidx);
- System.out.println("http links extracted host= " + host);
+ //System.out.println("DEBUG: http links extracted host= " + host);
hosts.addElement(host);
buf = buf.subString(endidx+strcom.length());
}
buf = buf.subString(startidx);
int endidx = buf.indexOf(strdot);
String host = buf.subString(0, endidx);
- System.out.println("email addr extracted host= " + host);
+ //System.out.println("DEBUG: email addr extracted host= " + host);
hosts.addElement(host);
buf = buf.subString(endidx+strdot.length());
}