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.')],
]);

$request->validate([
    'name' => ['
bash
php artisan vendor:publish --tag=gibberish-config
text
$ php artisan gibberish:check asdfgh
value:       asdfgh
letters:     asdfgh
probability: 1.0000
gibberish:   yes
reason:      heuristic
threshold:   0.4586
bash
php scripts/prepare-corpus.php          # merge + dedup, split off a held-out calibration set
php scripts/train.php resources/corpora/training.txt --max-train=40000 --epochs=3000 --seed=1
# or: php artisan gibberish:train resources/corpora/training.txt --max-train=40000 --epochs=3000
bash
php scripts/build-gazetteer.php \
  resources/corpora/first-names.txt resources/corpora/us-surnames.txt \
  resources/names/multilocale.txt --p=0.001 --seed=1
# or: php artisan gibberish:build-gazetteer <lists...> --p=0.001