Bug #237151 --> Make the junk mail filter support the ability to reset the training data. This code is not called by anyone yet but is part of the build.

sr=bienvenu
a=asa
This commit is contained in:
scott%scott-macgregor.org 2004-03-12 19:14:50 +00:00
Родитель 2db2e48465
Коммит 8d40fad5c3
3 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -288,3 +288,7 @@ passwordTitle=Mail Server Password Required
# for checking if the user really wants to open lots of messages
openWindowWarningTitle=Confirm
openWindowWarningText=Opening %S messages may be slow. Continue?
# for checking if the user really wants to delete the adaptive filter training set
confirmResetJunkTrainingTitle=Confirm
confirmResetJunkTrainingText=Are you sure you want to reset the adaptive filter training data?

Просмотреть файл

@ -120,4 +120,9 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
in nsIJunkMailClassificationListener aListener);
readonly attribute boolean userHasClassified;
/** Removes the training file and clears out any in memory training tokens.
User must retrain after doing this.
**/
void resetTrainingData();
};

Просмотреть файл

@ -1010,3 +1010,27 @@ NS_IMETHODIMP nsBayesianFilter::SetMessageClassification(const char *aMsgURL,
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMsgURL, aMsgWindow, analyzer);
}
NS_IMETHODIMP nsBayesianFilter::ResetTrainingData()
{
// clear out our in memory training tokens...
if (mGoodCount && mGoodTokens.countTokens())
{
mGoodTokens.clearTokens();
mGoodCount = 0;
}
if (mBadCount && mBadTokens.countTokens())
{
mBadTokens.clearTokens();
mBadCount = 0;
}
// now remove training.dat
nsCOMPtr<nsILocalFile> file;
nsresult rv = getTrainingFile(file);
if (file)
file->Remove(PR_FALSE);
return NS_OK;
}