Пример #1
0
} else {
    echo 'Error in the taxonomy call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
echo '#   combined Example                       #', PHP_EOL;
echo '############################################', PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo 'Processing text: ', $demo_text, PHP_EOL;
echo PHP_EOL;
$response = $alchemyapi->combined('text', $demo_text, null);
if ($response['status'] == 'OK') {
    echo '## Response Object ##', PHP_EOL;
    echo print_r($response);
    echo PHP_EOL;
    echo '## Keywords ##', PHP_EOL;
    foreach ($response['keywords'] as $keyword) {
        echo $keyword['text'], ' : ', $keyword['relevance'], PHP_EOL;
    }
    echo PHP_EOL;
    echo '## Concepts ##', PHP_EOL;
    foreach ($response['concepts'] as $concept) {
        echo $concept['text'], ' : ', $concept['relevance'], PHP_EOL;
    }
    echo PHP_EOL;
    echo '## Entities ##', PHP_EOL;
Пример #2
0
assert($response['status'] == 'OK');
$response = $alchemyapi->imageExtraction('random', $test_url, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Image extraction tests complete!', PHP_EOL, PHP_EOL;
//taxonomy
echo 'Checking Taxonomy . . . ', PHP_EOL;
$response = $alchemyapi->taxonomy('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->taxonomy('random', $test_text, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Taxonomy tests complete!', PHP_EOL, PHP_EOL;
//combined
echo 'Checking Combined . . . ', PHP_EOL;
$response = $alchemyapi->combined('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->combined('random', $test_text, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Combined tests complete!', PHP_EOL, PHP_EOL;
//Entities
echo 'Checking entities . . . ', PHP_EOL;
$response = $alchemyapi->entities('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->entities('html', $test_html, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->entities('url', $test_url, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->entities('random', $test_url, null);
assert($response['status'] == 'ERROR');