inzanty/perspectiveapi 问题修复 & 功能扩展

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

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

inzanty/perspectiveapi

Composer 安装命令:

composer require inzanty/perspectiveapi

包简介

What if technology could help improve conversations online. Fork of original repository: stajor/perspectiveapi.

README 文档

README

PHP library for Perspective Comment Analyzer API. Minimal PHP version is 7.4.

Installation

Via Composer:

composer require inzanty/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/inzanty/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.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-16