|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.demo.SpamFilterDemo
public class SpamFilterDemo
Instances of this class can be used to demonstrate the how statistical spam
filtering works. This class supports only the
Winnow
classifier and subclasses.
Field Summary | |
---|---|
static String |
CLASS_NONSPAM
Name of the nonspam (ham) class: "nonspam". |
static String |
CLASS_SPAM
Name of the spam class: "spam". |
Constructor Summary | |
---|---|
SpamFilterDemo(File trainingSetFile,
File testSetFile)
Creates a new instance. |
|
SpamFilterDemo(SampleMails myTrainingSet,
SampleMails myTestSet)
Creates a new instance. |
|
SpamFilterDemo(String trainingSetFile,
String testSetFile)
Creates a new instance. |
Method Summary | |
---|---|
FilterResult |
classify(String text)
Classifies a text. |
void |
clearModel()
Completely resets the internal classification model. |
SampleMails |
getTestSet()
Returns the set of mails used for testing. |
SampleMails |
getTrainingSet()
Returns the set of mails used for training. |
static void |
main(String[] args)
Main method for testing. |
void |
reloadModel()
Reloads the inital state of the internal classification model. |
String |
toString()
Returns a string representation of this object. |
void |
trainNonspam(String text)
Trains a text as ham. |
void |
trainSpam(String text)
Trains a text as spam. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CLASS_SPAM
public static final String CLASS_NONSPAM
Constructor Detail |
---|
public SpamFilterDemo(String trainingSetFile, String testSetFile) throws IOException, ProcessingException
SampleMails
conventions.
trainingSetFile
- a ZIP file containing the mails used for trainingtestSetFile
- a ZIP file containing the mails used for testing
IOException
- if one of the files cannot be read or is not a
valid ZIP file
ProcessingException
- if an error occurs while initializing the
classifierpublic SpamFilterDemo(File trainingSetFile, File testSetFile) throws IOException, ProcessingException
SampleMails
conventions.
trainingSetFile
- a ZIP file containing the mails used for trainingtestSetFile
- a ZIP file containing the mails used for testing
IOException
- if one of the files cannot be read or is not a
valid ZIP file
ProcessingException
- if an error occurs while initializing the
classifierpublic SpamFilterDemo(SampleMails myTrainingSet, SampleMails myTestSet) throws ProcessingException, IOException
myTrainingSet
- the set of mails used for trainingmyTestSet
- the set of mails used for testing
ProcessingException
- if an error occurs while initializing the
classifier
IOException
- if an I/O error occursMethod Detail |
---|
public static void main(String[] args) throws IOException, ProcessingException
args
- the command-line arguments (ignored)
IOException
- if an I/O error occurs
ProcessingException
- if an error orrurs while processing the taskspublic FilterResult classify(String text) throws ProcessingException, IOException
text
- the text to train
FilterResult
containing detailed results of
the classification
ProcessingException
- if an error occurs during classification
IOException
- if an I/O error occurspublic void clearModel() throws ProcessingException
ProcessingException
- if an error occurs during resetpublic SampleMails getTestSet()
public SampleMails getTrainingSet()
public void reloadModel() throws ProcessingException, IOException
cleared
and then re-trained from the
sample mails contained the training set
(shuffled in pseudo-random order).
ProcessingException
- if an error occurs during reset
IOException
- if an I/O error occurspublic String toString()
toString
in class Object
public void trainNonspam(String text) throws ProcessingException, IOException
text
- the text to train
ProcessingException
- if an error occurs during training
IOException
- if an I/O error occurspublic void trainSpam(String text) throws ProcessingException, IOException
text
- the text to train
ProcessingException
- if an error occurs during training
IOException
- if an I/O error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |