Skip to content

Commit 4b73bce

Browse files
Merge pull request GoogleCloudPlatform#244 from GoogleCloudPlatform/language
Report score, not polarity, which is obsolete.
2 parents b903bfd + 1008f02 commit 4b73bce

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

language/api/src/functions/annotation_to_string.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ function annotation_to_string(Annotation $annotation)
3535

3636
if (isset($info['documentSentiment'])) {
3737
$magnitude = $info['documentSentiment']['magnitude'];
38-
$polarity = $info['documentSentiment']['polarity'];
39-
if ($polarity < 0) {
40-
$magnitude = -$magnitude;
41-
}
42-
$ret .= sprintf('sentiment: %s' . PHP_EOL, $magnitude);
38+
$score = $info['documentSentiment']['score'];
39+
$ret .= sprintf('sentiment magnitude: %s score: %s' . PHP_EOL,
40+
$magnitude, $score);
4341
}
4442

4543
if (isset($info['sentences'])) {

language/api/test/SentimentCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testSentiment()
5757
);
5858

5959
$output = $this->commandTester->getDisplay();
60-
$this->assertRegExp('/sentiment: /', $output);
60+
$this->assertRegExp('/sentiment/', $output);
6161
}
6262

6363
public function testSentimentFromStorageObject()

0 commit comments

Comments
 (0)