PHP code example of pg-momik / no-nepali-profanity
1. Go to this page and download the library: Download pg-momik/no-nepali-profanity library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pg-momik / no-nepali-profanity example snippets
use NoNepaliProfanity\Profanity;
// boolean check — fastest
Profanity::containsProfanity("Great teacher!"); // false
Profanity::containsProfanity("muji"); // true
Profanity::containsProfanity("मुजीको कक्षा"); // true (Devanagari + postposition)
// which words — returns normalised matches as they appeared
Profanity::findProfanity("f.u.c.k this sh1t"); // ["fuck", "shit"]
Profanity::findProfanity("f u c k this"); // ["fuck"]
Profanity::findProfanity("Randip Thapa"); // []
Profanity::findProfanity("*ss teacher"); // ["*ss"]
// debugging — see what the matcher actually splits into
Profanity::tokenize("Great teacher!"); // ["great", "teacher"]