-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmorphology_complete.php
More file actions
28 lines (25 loc) · 958 Bytes
/
morphology_complete.php
File metadata and controls
28 lines (25 loc) · 958 Bytes
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
<?php
/**
* Example code to call Analytics API to get the complete set of morphological analysis
* results for a piece of text.
**/
require_once dirname(__FILE__) . '/../vendor/autoload.php';
use rosette\api\Api;
use rosette\api\DocumentParameters;
use rosette\api\RosetteConstants;
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();
}
$morphology_complete_data = "The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)";
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$params->set('content', $morphology_complete_data);
try {
$result = $api->morphology($params, RosetteConstants::$MorphologyOutput['COMPLETE']);
var_dump($result);
} catch (RosetteException $e) {
error_log($e);
}