SpamAnalyzer
Inheritance: java.lang.Object
public class SpamAnalyzer
Class which allows applications to detect spam e-mails with self-learning Bayesian filter.
Constructors
Constructor | Description |
---|---|
SpamAnalyzer() | Initialize a new instance of the SpamAnalyzer class. |
SpamAnalyzer(InputStream stream) | Initialize a new instance of the SpamAnalyzer class. |
SpamAnalyzer(String filePath) | Initialize a new instance of the SpamAnalyzer class. |
Methods
Method | Description |
---|---|
equals(Object arg0) | |
getClass() | |
hashCode() | |
loadDatabase(InputStream stream) | Loads Bayesian database from stream. |
loadDatabase(String filePath) | Loads Bayesian database from file. |
notify() | |
notifyAll() | |
reset() | Clears all statistics (Bayesian database). |
saveDatabase(OutputStream stream) | Saves the Bayesian database to stream. |
saveDatabase(String filePath) | Saves the Bayesian database to file. |
test(MailMessage message) | Analyses the message and returns the probability of the message being spam. |
toString() | |
trainFilter(MailMessage message, boolean isSpam) | Learns from the specified message as from spam or non-spam source. |
trainFilter(MailMessage[] ham, MailMessage[] spam) | Learns from the specified messages as from spam or non-spam source. |
trainFilter(String text, boolean isSpam) | Learns from the specified string as from spam or non-spam source. |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
SpamAnalyzer()
public SpamAnalyzer()
Initialize a new instance of the SpamAnalyzer class.
SpamAnalyzer(InputStream stream)
public SpamAnalyzer(InputStream stream)
Initialize a new instance of the SpamAnalyzer class.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | An input stream containing Bayesian database. |
SpamAnalyzer(String filePath)
public SpamAnalyzer(String filePath)
Initialize a new instance of the SpamAnalyzer class.
Parameters:
Parameter | Type | Description |
---|---|---|
filePath | java.lang.String | The full or relative path to the file containing Bayesian database. |
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
hashCode()
public native int hashCode()
Returns: int
loadDatabase(InputStream stream)
public final void loadDatabase(InputStream stream)
Loads Bayesian database from stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | An input stream containing Bayesian database. |
loadDatabase(String filePath)
public final void loadDatabase(String filePath)
Loads Bayesian database from file.
Parameters:
Parameter | Type | Description |
---|---|---|
filePath | java.lang.String | The full or relative path to the file containing Bayesian database. |
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
reset()
public final void reset()
Clears all statistics (Bayesian database).
saveDatabase(OutputStream stream)
public final void saveDatabase(OutputStream stream)
Saves the Bayesian database to stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.OutputStream | An output stream containing Bayesian database. |
saveDatabase(String filePath)
public final void saveDatabase(String filePath)
Saves the Bayesian database to file.
Parameters:
Parameter | Type | Description |
---|---|---|
filePath | java.lang.String | The full or relative path to the file containing Bayesian database. |
test(MailMessage message)
public final double test(MailMessage message)
Analyses the message and returns the probability of the message being spam.
Parameters:
Parameter | Type | Description |
---|---|---|
message | MailMessage | MailMessage for test the probability of the message being spam. |
Returns: double - A double value in 0-1 range, where 0 corresponds to “definitely non-spam” (0% spam probability) and 1 corresponds to “definitely spam” (100% spam probability).
toString()
public String toString()
Returns: java.lang.String
trainFilter(MailMessage message, boolean isSpam)
public final void trainFilter(MailMessage message, boolean isSpam)
Learns from the specified message as from spam or non-spam source.
Parameters:
Parameter | Type | Description |
---|---|---|
message | MailMessage | A reference to the MailMessage object representing the message to train the Bayesian filter. |
isSpam | boolean | True if the message is a spam; false if it’s a legitimate message. |
trainFilter(MailMessage[] ham, MailMessage[] spam)
public final void trainFilter(MailMessage[] ham, MailMessage[] spam)
Learns from the specified messages as from spam or non-spam source.
Parameters:
Parameter | Type | Description |
---|---|---|
ham | MailMessage[] | The array of MailMessage objects that is non-spam for training the Bayesian filter. |
spam | MailMessage[] | The array of MailMessage objects that is spam for training the Bayesian filter. |
trainFilter(String text, boolean isSpam)
public final void trainFilter(String text, boolean isSpam)
Learns from the specified string as from spam or non-spam source.
Parameters:
Parameter | Type | Description |
---|---|---|
text | java.lang.String | A string value to train the Bayesian filter. |
isSpam | boolean | True if specified text is a spam; false if it’s a legitimate text. |
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |