Laravel Grammar allows you detect the part of speech of a word. It returns an array of parts of speech a word belong to.
You can install the package via composer:
composer require djunehor/laravel-grammar
The package will automatically register itself, so you can start using it immediately.
In Laravel version 5.4 and older, you have to add the service provider in config/app.php file manually:
'providers' => [
// ...
Djunehor\Grammar\GrammarServiceProvider::class,
];
After installing the package, you will have to register it in bootstrap/app.php file manually:
// Register Service Providers
// ...
$app->register(Djunehor\Grammar\GrammarServiceProvider::class);
];
Run:
php artisan vendor:publish --tag=laravel-grammar
This will move the migration file, seeder file and config file to your app. You can change the entries table name in config/laravel-grammar.php
php artisan migrate to create the table.php artisan db:seed --class=LaravelGrammarSeeder to seed tableuse Djunehor\Grammar\Word;`
$grammar = new Word();
$partsOfSpeech = $grammar->getPartsOfSpeech();
// ['Preposition', 'Noun', 'Pronoun', 'Adverb', 'Adjective', 'Verb', 'Interjection', 'Conjunction']
$word = 'boy';
$partsOfSpeech = $grammar->getWordPartOfSpeech($word);
// ['Noun']
$word = 'boy';
$grammar = new Word($string);
$isNoun = $grammar->isNoun();
// true
In order to use the Grammar facade:
'Grammar' => GrammarFacade::class, to aliases in config/app.php\Grammar::getPartsOfSpeech();composer testHow can I help you explore Laravel packages today?