PHP code example of text-utils / n-gram

1. Go to this page and download the library: Download text-utils/n-gram 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/ */

    

text-utils / n-gram example snippets


$n = 1;
$generator = new TextUtils\NGram($n, 'Foo');
$nGram = $generator->get(); // array ('F', 'o', 'o')

$nGram = TextUtils\NGram::for('string', 3); // array ('str', 'tri', 'rin', 'ing')
...
$biGram = bigram('foo'); // array ('fo', 'oo')
$triGram = trigram('foobar'); // array ('foo', 'oob', 'oba', 'bar')