承接 coxlr/laravel-natural-language 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coxlr/laravel-natural-language

最新稳定版本:1.1.3

Composer 安装命令:

composer require coxlr/laravel-natural-language

包简介

Laravel package for the Google Natural language API

README 文档

README

Latest Version Tests 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.

It builds upon JoggApp/laravel-natural-language, a package initially developed by Harish Toshniwal which is no longer activly maintained.

natural

Installation

This package requires PHP 8.1 and Laravel 10 or higher.

You can install this package via composer using this command:

composer require coxlr/laravel-natural-language
  • The package will automatically register itself.

  • You can find documentation on how to set up the project and get the necessary configurations from the Google Cloud Platform console in a step by step detailed manner here.

  • You can publish the config file using the following command:

php artisan vendor:publish --provider="Coxlr\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' => env('NATURAL_LANGUAGE_KEY_FILE_PATH', base_path('google-credentials.json')),
];

Add the following to your .env file:

NATURAL_LANGUAGE_PROJECT_ID=your-google-project-id
NATURAL_LANGUAGE_KEY_FILE_PATH=/full/path/to/your/google-credentials.json

Important: If you previously published the config file, you will need to update key_file_path to use the env() helper as shown above. Older versions of the config file had a hardcoded default path that did not read from the environment.

Usage

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:

composer test

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 hello@leecox.dev instead of using the issue tracker.

Credits

License

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

统计信息

  • 总下载量: 1.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固