Strategy driven spam- and badword detection.
$analyzer = new Profanity\Analyzer($config);
The base config may contain the following parameters:
aliases: array of letters or words which should be changed, eg. '0' => 'o' badwords: array of words which should be detected, eg. 'asshole'
$analyzer->addStrategy($strategy1, $config);
$analyzer->addStrategy($strategy2, $config);
The strategies will be executed in the order they have been added to the analyzer.
$badwordFound = $analyzer->execute($string);
If a badword has been found, the analyzer will stop the execution and return 'true'. If nothing is found, it will return 'false'.
Profanity has following build in strategies: 'simple', 'strict', 'smart', 'similar', 'sound'
Matches each badword against the string.
Matches each badword against the string and ignores spaces or punctuation marks.
Compares each word of the string with each badword. Accepts an 'index' (default = 80) which stands for the comparation rate in percent.
Compares each word of the string with each badword by using the Levenshtein distance. Accepts an 'index' (default = 3) which stands for the distance.
Comparres each word of the string with each given badword by using the Metaphone key. However, this strategy is only recommended for the english language.
You may also write your own strategies and pass them into the analyzer, eg. 'MyCustomStrategy' Custom strategies must extend the 'Profanity\AbstractStrategy' and implement the 'Profanity\StragegyInterface' in order wo work.