lok0613/alchemyapi

AlchempyApi PHP 包装器

v1.0 2016-11-30 19:06 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:59:55 UTC


README

例如,为了获取“情感分析”的结果,请访问http://www.ibm.com/watson/developercloud/alchemy-language/api/v1/?curl#emotion_analysis。选择输入类型,然后在右侧可以找到这些选项。

POST /text/TextGetEmotion

实现如下,

use Lok0613\AlchemyApi\AlchemyApi;

$alchemyApi = new AlchemyApi('api-key');
$res = $alchemyApi->getEmotion('text', [
	'text' => 'I go to school by bus',
]);

返回结果将是,

{
    "status": "OK",
    "usage": "By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html",
    "totalTransactions": "1",
    "language": "english",
    "docEmotions": {
        "anger": "0.196838",
        "disgust": "0.088342",
        "fear": "0.491799",
        "joy": "0.069452",
        "sadness": "0.222289"
    }
}