The official cortical.io PHP library is deprecated and no-longer maintained (https://github.com/cortical-io/php-client-sdk). So, since I needed to use the API with a PHP service, I decided to create this library so that others could use it.
- REST API documentation: https://www.cortical.io/resources_apidocumentation.html
- REST API console: https://api.cortical.io/
- Cortical.io website: https://cortical.io/
PHP >= 7.0
Recommended technique is to use composer
composer require ollieparsley/corticalio
$client = new \Corticalio\Client([
'api_key' => 'MY_API_KEY',
]);
echo "List retinas: \n";
print_r($client->retinas->listRetinas());
echo "\n\n";
echo "Show retina en_associative: \n";
print_r($client->retinas->getRetina('en_associative'));
echo "\n\n";
$client = new \Corticalio\Client([
'api_key' => 'MY_API_KEY',
]);
echo "List terms: \n";
print_r($client->terms->listTerms('en_associative'));
echo "\n\n";
echo "Show term soccer using en_associative: \n";
print_r($client->terms->getTerm('en_associative', 'soccer'));
echo "\n\n";
echo "Show term contexts for soccer using en_associative: \n";
print_r($client->terms->listTermContexts('en_associative', 'soccer'));
echo "\n\n";
echo "Show similar terms to soccer using en_associative: \n";
print_r($client->terms->listSimilarTerms('en_associative', 'soccer'));
echo "\n\n";
$client = new \Corticalio\Client([
'api_key' => 'MY_API_KEY',
]);
echo "Compare 2 elements using en_associative: \n";
$element1 = new \Corticalio\Model\ExpressionElement();
$element1->text = 'Manchester City lost the football match';
$element2 = new \Corticalio\Model\ExpressionElement();
$element2->text = 'Manchester United won the football match';
print_r($client->compare->compare('en_associative', $element1, $element2));
echo "\n\n";
echo "Bulk compare element pairs en_associative: \n";
$elementPairs = new \Corticalio\Model\ExpressionElementArray();
$elementPairs->addPair($element1, $element2);
$elementPairs->addPair($element2, $element1);
print_r($client->compare->bulkCompare('en_associative', $elementPairs));
echo "\n\n";
There is a generic Corticalio\Exception
class that is extended for some specific reasons to use. Anything that does not throw from this base exception will most-likely be coming from a dependency such a Guzzle.
These API sections are covered by the client library
- Retinas
- Terms
- Compare
These haven't been done yet. I do want to complete the library with these though
- Text
- Expression
- Image
- Classify
We use SemVer for versioning. For the versions available, see the tags on this repository.
Please do contribute to this library. Please submit pull requests and I'll do my best to review them and merge if appropriate.
This project is licensed under the MIT License - see the LICENSE file for details