monkeylearn/monkeylearn-php
最新稳定版本:3.3.0
Composer 安装命令:
composer require monkeylearn/monkeylearn-php
包简介
Official PHP client for the MonkeyLearn API.
README 文档
README
Official PHP client for the MonkeyLearn API. Build and consume machine learning models for language processing from your PHP apps.
Autoload
The first step to use monkeylearn-php is to download composer:
$ curl -s http://getcomposer.org/installer | php
Then we have to install our dependencies using:
$ php composer.phar install
Now we can use autoloader from Composer by:
{
"require": {
"monkeylearn/monkeylearn-php": "~0.1"
}
}
Or, if you don't want to use composer, clone the code and include this line of code:
require 'autoload.php';
Usage examples
Here are some examples of how to use the library in order to create and use classifiers:
require 'autoload.php'; // Use the API key from your account $ml = new MonkeyLearn\Client('<YOUR API KEY HERE>'); // Create a new classifier $res = $ml->classifiers->create('Test Classifier'); // Get the id of the new module $model_id = $res->result['id']; // Get the classifier detail $res = $ml->classifiers->detail($model_id); // Create two new tags on the classifier $res = $ml->classifiers->tags->create($model_id, 'Negative'); $negative_id = $res->result['id']; $res = $ml->classifiers->tags->create($model_id, 'Positive'); $positive_id = $res->result['id']; // Now let's upload some data $data = array( array('text' => 'The movie was terrible, I hated it.', 'tags' => [$negative_id]), array('text' => 'I love this movie, I want to watch it again!', 'tags' => [$positive_id]) ); $res = $ml->classifiers->upload_data($model_id, $data); // Classify some texts $res = $ml->classifiers->classify($model_id, ['I love the movie', 'I hate the movie']); var_dump($res->result);
You can also use the sdk with extractors:
require 'autoload.php'; $ml = new MonkeyLearn\Client('<YOUR API KEY HERE>'); $res = $ml->extractors->extract('<Extractor ID>', ['Some text to extract.']);
统计信息
- 总下载量: 124.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 51
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-04