-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathentities.php
More file actions
31 lines (27 loc) · 1.54 KB
/
entities.php
File metadata and controls
31 lines (27 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* Example code to call Analytics API to get entities from a piece of text.
**/
require_once dirname(__FILE__) . '/../vendor/autoload.php';
use rosette\api\Api;
use rosette\api\DocumentParameters;
use rosette\api\RosetteException;
$options = getopt('', array('key:', 'url::'));
if (!isset($options['key'])) {
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
exit();
}
$entities_text_data = "The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country.";
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$content = $entities_text_data;
$params->set('content', $content);
// Starting with 1.29.0, an alternate, in-document coreference server was added. It can be accessed
// using the option below. See the documentation for more information.
// $api->setOption('useIndocServer', true);
try {
$result = $api->entities($params);
var_dump($result);
} catch (RosetteException $e) {
error_log($e);
}