Sentiment Analysis
, (*1)
Various analysis tools using the Datumbox API., (*2)
Prerequisites
As this API uses web services from Datumbox you'll need to register an account with them to obtain an API key., (*3)
http://www.datumbox.com/users/register/, (*4)
Installation
Installation is a cinch with composer.., (*5)
composer require choccybiccy/sentiment
Usage
use Choccybiccy\Sentiment\Factory;
$factory = new Factory();
$sentiment = $factory->create(
Factory::ENDPOINT_ANALYSIS_SENTIMENT,
"MyApiKey"
);
$result = $sentiment->analyse("I don't like her, I love her!");
echo "The sentiment is " . $result->getResult(); # Will return: The sentiment is positive
Available endpoints
Service |
Constant |
Class |
Method |
Sentiment |
\Choccybiccy\Sentiment\Factory::ENDPOINT_ANALYSIS_SENTIMENT |
Choccybiccy\Sentiment\Analysis\Sentiment |
analyse(str $text) |
Subject analysis |
\Choccybiccy\Sentiment\Factory::ENDPOINT_ANALYSIS_SUBJECTIVITY |
Choccybiccy\Sentiment\Analysis\Subjectivity |
analyse(str $text) |
Readability assessment |
\Choccybiccy\Sentiment\Factory::ENDPOINT_ASSESSMENT_READABILITY |
Choccybiccy\Sentiment\Assessment\Readability |
assess(str $text) |
Topic classification |
\Choccybiccy\Sentiment\Factory::ENDPOINT_CLASSIFICATION_TOPIC |
Choccybiccy\Sentiment\Classification\Topic |
classify(str $text) |
Similarity |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_SIMILARITY |
Choccybiccy\Sentiment\Comparison\Similarity |
compare(str $original, str $copy) |
Adult content detection |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_ADULT |
Choccybiccy\Sentiment\Detection\Adult |
detect(str $text) |
Commercial detection |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_COMMERCIAL |
Choccybiccy\Sentiment\Detection\Commercial |
detect(str $text) |
Educational detection |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_EDUCATIONAL |
Choccybiccy\Sentiment\Detection\Educational |
detect(str $text) |
Gender detection |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_GENDER |
Choccybiccy\Sentiment\Detection\Gender |
detect(str $text) |
Language detection |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_LANGUAGE |
Choccybiccy\Sentiment\Detection\Language |
detect(str $text) |
Spam detection |
\Choccybiccy\Sentiment\Factory::ENDPOINT_COMPARISON_SPAM |
Choccybiccy\Sentiment\Detection\Spam |
detect(str $text) |
Keyword extraction |
\Choccybiccy\Sentiment\Factory::ENDPOINT_EXTRACTION_KEYWORD |
Choccybiccy\Sentiment\Extraction\Keyword |
extract(str $text) |
Text extraction |
\Choccybiccy\Sentiment\Factory::ENDPOINT_EXTRACTION_TEXT |
Choccybiccy\Sentiment\Extraction\Text |
extract(str $text) |
Testing
vendor/bin/phpunit
Authors
Written and maintained by Martin Hughes., (*6)
Thanks
Thanks to Datumbox for providing the web services., (*7)
Copyright & licensing
See LICENSE, (*8)