Aspose::Email::AntiSpam::SpamAnalyzer Class Reference

Class which allows applications to detect spam e-mails with self-learning Bayesian filter. More...

Inherits Object.

Public Member Functions

System::SharedPtr< BayesianFilter > get_Filter () const
 For testing only. More...
 
 SpamAnalyzer ()
 Initialize a new instance of the Aspose::Email::AntiSpam::SpamAnalyzer class. More...
 
 SpamAnalyzer (System::SharedPtr< System::IO::Stream > stream)
 Initialize a new instance of the Aspose::Email::AntiSpam::SpamAnalyzer class. More...
 
 SpamAnalyzer (System::String filePath)
 Initialize a new instance of the Aspose::Email::AntiSpam::SpamAnalyzer class. More...
 
void TrainFilter (System::ArrayPtr< System::SharedPtr< MailMessage >> ham, System::ArrayPtr< System::SharedPtr< MailMessage >> spam)
 Learns from the specified messages as from spam or non-spam source. More...
 
void TrainFilter (System::SharedPtr< MailMessage > message, bool isSpam)
 Learns from the specified message as from spam or non-spam source. More...
 
void TrainFilter (System::String text, bool isSpam)
 Learns from the specified string as from spam or non-spam source. More...
 
double Test (System::SharedPtr< MailMessage > message)
 Analyses the message and returns the probability of the message being spam. More...
 
void LoadDatabase (System::String filePath)
 Loads Bayesian database from file. More...
 
void LoadDatabase (System::SharedPtr< System::IO::Stream > stream)
 Loads Bayesian database from stream. More...
 
void SaveDatabase (System::String filePath)
 Saves the Bayesian database to file. More...
 
void SaveDatabase (System::SharedPtr< System::IO::Stream > stream)
 Saves the Bayesian database to stream. More...
 
void Reset ()
 Clears all statistics (Bayesian database). More...
 

Detailed Description

Class which allows applications to detect spam e-mails with self-learning Bayesian filter.

Constructor & Destructor Documentation

◆ SpamAnalyzer() [1/3]

Aspose::Email::AntiSpam::SpamAnalyzer::SpamAnalyzer ( )

Initialize a new instance of the Aspose::Email::AntiSpam::SpamAnalyzer class.

◆ SpamAnalyzer() [2/3]

Aspose::Email::AntiSpam::SpamAnalyzer::SpamAnalyzer ( System::SharedPtr< System::IO::Stream >  stream)

Initialize a new instance of the Aspose::Email::AntiSpam::SpamAnalyzer class.

Parameters
streamAn input stream containing Bayesian database.
Exceptions
ArgumentNullExceptionIf stream is null.

◆ SpamAnalyzer() [3/3]

Aspose::Email::AntiSpam::SpamAnalyzer::SpamAnalyzer ( System::String  filePath)

Initialize a new instance of the Aspose::Email::AntiSpam::SpamAnalyzer class.

Parameters
filePathThe full or relative path to the file containing Bayesian database.
Exceptions
ArgumentExceptionIf filePath is null or an empty string.

Member Function Documentation

◆ get_Filter()

System::SharedPtr<BayesianFilter> Aspose::Email::AntiSpam::SpamAnalyzer::get_Filter ( ) const

For testing only.

◆ LoadDatabase() [1/2]

void Aspose::Email::AntiSpam::SpamAnalyzer::LoadDatabase ( System::SharedPtr< System::IO::Stream >  stream)

Loads Bayesian database from stream.

Parameters
streamAn input stream containing Bayesian database.
Exceptions
ArgumentNullExceptionIf stream is null.

◆ LoadDatabase() [2/2]

void Aspose::Email::AntiSpam::SpamAnalyzer::LoadDatabase ( System::String  filePath)

Loads Bayesian database from file.

Parameters
filePathThe full or relative path to the file containing Bayesian database.
Exceptions
ArgumentExceptionIf filePath is null or an empty string.

◆ Reset()

void Aspose::Email::AntiSpam::SpamAnalyzer::Reset ( )

Clears all statistics (Bayesian database).

◆ SaveDatabase() [1/2]

void Aspose::Email::AntiSpam::SpamAnalyzer::SaveDatabase ( System::SharedPtr< System::IO::Stream >  stream)

Saves the Bayesian database to stream.

Parameters
streamAn output stream containing Bayesian database.
Exceptions
ArgumentNullExceptionIf stream is null.

◆ SaveDatabase() [2/2]

void Aspose::Email::AntiSpam::SpamAnalyzer::SaveDatabase ( System::String  filePath)

Saves the Bayesian database to file.

Parameters
filePathThe full or relative path to the file containing Bayesian database.
Exceptions
ArgumentExceptionIf filePath is null or an empty string.

◆ Test()

double Aspose::Email::AntiSpam::SpamAnalyzer::Test ( System::SharedPtr< MailMessage message)

Analyses the message and returns the probability of the message being spam.

Parameters
messageMailMessage for test the probability of the message being spam.
Returns
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).
Exceptions
ArgumentNullExceptionIf message is null.

◆ TrainFilter() [1/3]

void Aspose::Email::AntiSpam::SpamAnalyzer::TrainFilter ( System::ArrayPtr< System::SharedPtr< MailMessage >>  ham,
System::ArrayPtr< System::SharedPtr< MailMessage >>  spam 
)

Learns from the specified messages as from spam or non-spam source.

Parameters
hamThe array of MailMessage objects that is non-spam for training the Bayesian filter.
spamThe array of MailMessage objects that is spam for training the Bayesian filter.
Exceptions
ArgumentNullExceptionIf ham or spam is null.

◆ TrainFilter() [2/3]

void Aspose::Email::AntiSpam::SpamAnalyzer::TrainFilter ( System::SharedPtr< MailMessage message,
bool  isSpam 
)

Learns from the specified message as from spam or non-spam source.

Parameters
messageA reference to the MailMessage object representing the message to train the Bayesian filter.
isSpamTrue if the message is a spam; false if it's a legitimate message.
Exceptions
ArgumentNullExceptionIf message is null.

◆ TrainFilter() [3/3]

void Aspose::Email::AntiSpam::SpamAnalyzer::TrainFilter ( System::String  text,
bool  isSpam 
)

Learns from the specified string as from spam or non-spam source.

Parameters
textA string value to train the Bayesian filter.
isSpamTrue if specified text is a spam; false if it's a legitimate text.
Exceptions
ArgumentNullExceptionIf text is null.