chtombleson/php-moderator

v0.1 2014-05-05 22:46 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:47:27 UTC


README

Build Status

静态文本分析,用于检测不适当内容。

设置

使用 composer 安装

$ 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);
}

测试

测试由 PHPUnit 运行

phpunit tests/ModeratorTest.php

许可

查看 LICENSE