定制 stajor/perspectiveapi 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

stajor/perspectiveapi

最新稳定版本:2.0.0

Composer 安装命令:

composer require stajor/perspectiveapi

包简介

What if technology could help improve conversations online

README 文档

README

Minimal PHP version

PHP library for Perspective Comment Analyzer API.

Installation

Via Composer:

composer require stajor/perspectiveapi

Usage

Scoring comments: AnalyzeComment

<?php

$commentsClient = new PerspectiveApi\CommentsClient('PERSPECTIVE-API-TOKEN');
$commentsClient->comment(['text' => 'What kind of idiot name is foo? Sorry, I like your name.']);
$commentsClient->languages(['en']);
$commentsClient->context(['entries' => ['text' => 'off-topic', 'type' => 'PLAIN_TEXT']]);
$commentsClient->requestedAttributes(['TOXICITY' => ['scoreType' => 'PROBABILITY', 'scoreThreshold' => 0]]);

// Analyze and get response
$response = $commentsClient->analyze();

// Print scores
print_r($response->attributeScores());

Sending feedback: SuggestCommentScore

<?php

$commentsClient = new PerspectiveApi\CommentsClient('PERSPECTIVE-API-TOKEN');
$commentsClient->comment(['text' => 'What kind of idiot name is foo? Sorry, I like your name.']);
$commentsClient->languages(['en']);
$commentsClient->context(['entries' => ['text' => 'off-topic', 'type' => 'PLAIN_TEXT']]);
$commentsClient->clientToken('some-token');
$commentsClient->communityId('unit-test');
$commentsClient->attributeScores(['TOXICITY' => [
    'summaryScore' => ['value' => 0.83785176, 'type' => 'PROBABILITY'],
    'spanScores' => [['begin' => 0, 'end' => 32, 'score' => ['value' => 0.9208521, 'type' => 'PROBABILITY']]]]
]);

// Suggest Score and get response
$response = $commentsClient->suggestScore();

// Print scores
print_r($response->attributeScores());

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Stajor/perspectiveapi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-16