Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: becc038f71
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (32 sloc) 0.945 kb
<?php
require_once 'lib/antispam.class.php';
require_once 'lib/corpus.class.php';
function getMessages() {
$dirs = array('spam', 'nospam');
$messages = array();
foreach($dirs as $dir) {
$files = glob($dir.'/*.txt');
foreach($files as $file) {
$message = array();
$content = file_get_contents($file);
$message['content'] = $content;
$message['category'] = $dir;
$messages[] = $message;
}
}
return $messages;
}
$messages = getMessages();
$separators = '/[-, ]/';
$corpus = new Corpus($messages, $separators);
$antispam = new Antispam($corpus);
$antispam->setMethod(Antispam::GRAHAM_METHOD);
$message = 'This promotion is sponsored exclusively by Vindale Research';
$spamProbability = $antispam->isSpam($message);
var_dump($spamProbability);
if($spamProbability < 0.9) {
echo PHP_EOL . 'no spam' . PHP_EOL;
} else {
echo PHP_EOL . 'spam' . PHP_EOL;
}
?>
Jump to Line
Something went wrong with that request. Please try again.