PHP code example of daikazu / gibberish-name-detector
1. Go to this page and download the library: Download daikazu/gibberish-name-detector 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/ */
daikazu / gibberish-name-detector example snippets
use Daikazu\GibberishNameDetector\GibberishDetector;
$detector = new GibberishDetector(); // works without the container
$detector->probability('asdfgh'); // 1.0
$detector->probability('Okonkwo'); // 0.0 (whitelisted by the gazetteer)
$detector->isLikelyGibberish('xkjqwz'); // true
$detector->threshold(); // 0.4586 (the model's calibrated default)
$analysis = $detector->analyze('asdfgh');
$analysis->probability; // 1.0
$analysis->gibberish; // true
$analysis->reason; // Reason::Heuristic (too_short | gazetteer | heuristic | model)
$analysis->features; // raw feature values that fed the decision
use Daikazu\GibberishNameDetector\Laravel\Facades\Gibberish;
Gibberish::isLikelyGibberish('asdfgh'); // true
Gibberish::analyze('Nguyen')->reason; // Reason::Gazetteer
use Daikazu\GibberishNameDetector\Laravel\Rules\NotGibberish;
$request->validate([
'first_name' => [' new NotGibberish(threshold: 0.7, minLength: 2, message: 'That :attribute looks off.')],
]);