1 package org.columba.mail.spam.rules; 19 20 import org.columba.mail.folder.IMailbox; 21 import org.columba.ristretto.message.Header; 22 23 29 public class MixedCharactersAddressRule extends AbstractRule { 30 31 public MixedCharactersAddressRule() { 32 super("MixedCharactersAddressRule"); 33 34 } 35 36 40 public float score(IMailbox folder, Object uid) throws Exception { 41 Header header = folder.getHeaderFields(uid, new String [] { "From"}); 42 String from = header.get("From"); 43 if (from == null) return NEARLY_ZERO; 44 if (from.length() == 0) return NEARLY_ZERO; 45 46 int count = 0; 47 for (int i = 0; i < from.length(); i++) { 48 if (Character.isDigit(from.charAt(i))) count++; 49 } 50 51 if ( count > from.length()/3) return MAX_PROBABILITY; 53 54 return NEARLY_ZERO; 55 } 56 57 } | Popular Tags |