12/09
2015
Wallogit.com
2017 © Pedro Peláez
Content moderation
Static text analysis for inapporiate content., (*2)
Install using composer, (*3)
$ composer.phar require chtombleson\php-moderator
<?php
require_once(__DIR__ . /vendor/autoload.php');
use chtombleson\PHPModerator;
$moderator = new PHPModerator();
$message = "Long message from user you want to statically moderate";
$result = $moderator->moderate($message);
if ($result['status'] == 'pass') {
echo "Message is below the threshold of: " . ($moderator->getThreshold() * 100) . "%";
echo "Messgae contained the following amount of bad words: " . $result['bad_words'];
echo "Message contained the following amount of spam words: " . $result['spam_words'];
ehco "Message contains the following number of words: " . str_word_count($message);
} else {
echo "Message fails static analysis of a threshold of: . ($moderator->getThreshold() * 100) . "%";
echo "Messgae contained the following amount of bad words: " . $result['bad_words'];
echo "Message contained the following amount of spam words: " . $result['spam_words'];
ehco "Message contains the following number of words: " . str_word_count($message);
}
Tests are run by PHPUnit, (*4)
phpunit tests/ModeratorTest.php
See LICENSE, (*5)