tootootltd/azure-text-analytics 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tootootltd/azure-text-analytics

Composer 安装命令:

composer require tootootltd/azure-text-analytics

包简介

A Laravel wrapper around Azure's Text Analytics API. Including; Sentiment Analysis, Key Phrase Extraction, Named Entity Recognition, and Language Detection

README 文档

README

Latest Version on Packagist MIT Licensed run-tests

A very simple wrapper around version 3.0 of Azure Cognitive Services' Text Analytics API: https://docs.microsoft.com/en-gb/azure/cognitive-services/text-analytics/

Installation

You can install the package via composer:

composer require tootootltd/azure-text-analytics

Publish the config file and put your Azure Cognitive Services endpoint and key in your env file.

php artisan vendor:publish --provider="Tootootltd\AzureTextAnalytics\AzureTextAnalyticsServiceProvider"

Requirements

  1. An Azure Cognitive Services endpoint and key.
  2. PHP 7.4

Usage

This package supports all 5 Text Analytics endpoints and each return the full raw response body.

You can pass your text into the constructor in a few different formats:

String

$myText = 'Example';

String and ID

$myText = [
	'id' => 1,
	'text' => 'Example'
];

Multiple strings and ID's

$myText = [
	[
		'id' => 1,
		'text' => 'Example one'
	],
	[
		'id' => 2,
		'text' => 'Example two'
	],
	[
		'id' => 3,
		'text' => 'Example three'
	]
];

Just pass any of these into the constructor.

$text = new AzureTextAnalytics($myText)

This package will do a bit of validation on your text before hitting Azure's API, such as;

  1. Checking the length of each document (string of text) and the number of documents per request to ensure they aren't above the Azure API's limits (5,120 characters and 1,000 documents at time of writing respectively). In both these instances an ExceededApiLimit exception will be thrown. More info on these limits can be found on Azure's documentation.
  2. Ensuring that the required fields are present when passing an array (id and text at time of writing). More info on these can be found on Azure's documentation.

Methods:

Sentiment Analysis - View example response

$text = new AzureTextAnalytics($myText)
$text->sentimentAnalsis();

Key Phrases - View example response

$text = new AzureTextAnalytics($myText)
$text->keyPhrases();

Language Detection - View example response

$text = new AzureTextAnalytics($myText)
$text->detectLanguage();

Named Entity Recognition - View example response

$text = new AzureTextAnalytics($myText)
$text->namedEntityRecognition();

Entity Linking - View example response

$text = new AzureTextAnalytics($myText)
$text->entityLinking();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固