diff --git a/language/api/src/functions/annotation_to_string.php b/language/api/src/functions/annotation_to_string.php index c83405abee..60316eaad0 100644 --- a/language/api/src/functions/annotation_to_string.php +++ b/language/api/src/functions/annotation_to_string.php @@ -35,11 +35,9 @@ function annotation_to_string(Annotation $annotation) if (isset($info['documentSentiment'])) { $magnitude = $info['documentSentiment']['magnitude']; - $polarity = $info['documentSentiment']['polarity']; - if ($polarity < 0) { - $magnitude = -$magnitude; - } - $ret .= sprintf('sentiment: %s' . PHP_EOL, $magnitude); + $score = $info['documentSentiment']['score']; + $ret .= sprintf('sentiment magnitude: %s score: %s' . PHP_EOL, + $magnitude, $score); } if (isset($info['sentences'])) { diff --git a/language/api/test/SentimentCommandTest.php b/language/api/test/SentimentCommandTest.php index 1e1a6d9a88..e5049a8d38 100644 --- a/language/api/test/SentimentCommandTest.php +++ b/language/api/test/SentimentCommandTest.php @@ -57,7 +57,7 @@ public function testSentiment() ); $output = $this->commandTester->getDisplay(); - $this->assertRegExp('/sentiment: /', $output); + $this->assertRegExp('/sentiment/', $output); } public function testSentimentFromStorageObject()