Skip to content

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.

License

Notifications You must be signed in to change notification settings

JoggApp/laravel-natural-language

Repository files navigation

THIS PACKAGE IS NO LONGER ACTIVELY MAINTAINED. USERS ARE ADVISED TO REPLACE IT WITH ALTERNATIVES.

Laravel package for the Google Natural language API

Latest Version Total Downloads

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.

natural

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 😄

  • 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 features array & 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 harish@jogg.co instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see the License File for more information.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages