nv/semtools
Composer 安装命令:
composer require nv/semtools
包简介
A tool for classifying and enriching English language text based on publicly available semantic API services.
README 文档
README
Provides read access wrappers to public semantic API services. Version 0.0.4 supports classification using the uClassify.com service and annotation (enrichment) using Reuters OpenCalais API.
Visit OpenCalais and uClassify homepages for more information about their services and to obtain an API key.
Features
- uClassify API reader enables use of all available public classifiers.
- OpenCalais API reader enables use of the powerful enrichment service from Reuters.
How-to & Examples
Below is a basic example, also available in examples/index.php file. For detailed options, please see the API documentation.
Classification
use nv\semtools\Classifiers\uClassify; header('Content-type: text/xml'); // Instantiate the reader with your API key (provided by uClassify) $classifier = new uClassify\UclassifyReader('YOUR_API_KEY'); // Create a new request with the text to be classified and the classifier to use $classifierRequest = new uClassify\UclassifyRequest( 'My happy text', 'prfekt/Myers Briggs Attitude' ); // Execute and return the request $classifierResponse = $classifier->read($classifierRequest); echo $classifierResponse->getResponse();
Prints:
<?xml version="1.0" encoding="UTF-8" ?> <uclassify xmlns="http://api.uclassify.com/1/ResponseSchema" version="1.01"> <status success="true" statusCode="2000"/> <readCalls> <classify id="cls1"> <classification textCoverage="1"> <class className="Extraversion" p="0.99998"/> <class className="Introversion" p="2.0456e-005"/> </classification> </classify> </readCalls> </uclassify>
Annotation
use nv\semtools\Annotators\OpenCalais; // The content to process $content = ''; // Instantiate a new annotator instance with your API key (provided by OpenCalais) $annotator = new OpenCalais\OpenCalaisReader('YOUR_API_KEY'); // Create a new request with passing the content as parameter $annotatorRequest = new OpenCalais\OpenCalaisRequest($content); // Execute request, recieve response $annotatorResponse = $annotator->read($annotatorRequest); // To get the raw response $annotatorResponse->getResponse(); // To get the response parsed to php array print_r($annotatorResponse->getEntities());
Prints:
...
Check out OpenCalais homepage for details on different response formats.
License
Copyright 2014 Vladimir Stračkovski. MIT license. For more information please see the license file included in this project.
统计信息
- 总下载量: 50
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-12