JoggApp/laravel-natural-language
关于
This package makes using the Google Natural Language API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API.
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文THIS PACKAGE IS NO LONGER ACTIVELY MAINTAINED. USERS ARE ADVISED TO REPLACE IT WITH ALTERNATIVES.
Laravel package for the Google Natural language API
This package makes using the Google Natural API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API. All methods accept a string and return an array: Docs below.

Installation
- You can install this package via composer using this command:
composer require joggapp/laravel-natural-language
The package will automatically register itself.
We have documented how to setup the project and get the necessary configurations from the Google Cloud Platform console in a step by step detailed manner over here.
You can publish the config file using the following command:
php artisan vendor:publish --provider="JoggApp\NaturalLanguage\NaturalLanguageServiceProvider"
This will create the package's config file called naturallanguage.php in the config directory. These are the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| The id of project created in the Google Cloud Platform console.
|--------------------------------------------------------------------------
*/
'project_id' => env('NATURAL_LANGUAGE_PROJECT_ID', 'sample-12345'),
/*
|--------------------------------------------------------------------------
| Path to the json file containing the authentication credentials.
|--------------------------------------------------------------------------
*/
'key_file_path' => base_path('composer.json'),
];
How to use
After setting up the config file values you are all set to use the following methods :smile:
Detect the Sentiment: Accepts a string and returns an array.
NaturalLanguage::sentiment(string $text): array
- Detect the Entities: Accepts a string and returns an array.
NaturalLanguage::entities(string $text): array
- Detect the Sentiment per entity basis: Accepts a string and returns an array.
NaturalLanguage::entitySentiment(string $text): array
- Detect the syntax: Accepts a string and returns an array.
NaturalLanguage::syntax(string $text): array
- Detect the categories: Accepts a string and returns an array.
NaturalLanguage::categories(string $text): array
- Annotate text: Accepts a string and an optional
featuresarray & returns an array.
NaturalLanguage::annotateText(string $text, array $features = ['sentiment', 'syntax']): array
Testing
You can run the tests with:
vendor/bin/phpunit
Changelog
Please see the CHANGELOG for more information about what has changed recently.
Security
If you discover any security related issues, please email them to [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see the License File for more information.
探索相关项目
加载中…