Generate n-grams for your string.
Why does this project exist? Come on, don't delete this part. Fill it. Yes it's hard, but it's perhaps the most important part of the README.
As to why this project exist, it's to serve as a template for future open source PHP projects. Of course, feel free to fork it and make your own recipe.
composer install text-utils/n-gram
You can start using the n-gram generator by instantiating a new NGram
class:
$n = 1;
$generator = new TextUtils\NGram($n, 'Foo');
$nGram = $generator->get(); // array ('F', 'o', 'o')
We also provide a static wrapper (the for
method) and two helper functions (bigram
and trigram
) for quick usage
$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')
See the CONTRIBUTING file.
MIT. Please refer to the LICENSE file in this repository.