Skip to content

Commit 80d0645

Browse files
committed
Updated setType to use Type:PLAIN_TEXT
1. Use Type::PLAIN_TEXT instead of 1.
1 parent 32c81c6 commit 80d0645

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

language/src/analyze_entity_sentiment.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
namespace Google\Cloud\Samples\Language;
2626

2727
use Google\Cloud\Language\V1beta2\Document;
28+
use Google\Cloud\Language\V1beta2\Document\Type;
2829
use Google\Cloud\Language\V1beta2\LanguageServiceClient;
2930

3031
/**
@@ -55,7 +56,7 @@ function analyze_entity_sentiment($text, $projectId = null)
5556
// Create a new Document
5657
$document = new Document();
5758
// Add text as content and set document type to PLAIN_TEXT
58-
$document->setContent($text)->setType(1);
59+
$document->setContent($text)->setType(Type::PLAIN_TEXT);
5960
// Call the analyzeEntitySentiment function
6061
$response = $languageServiceClient->analyzeEntitySentiment($document);
6162
$entities = $response->getEntities();
@@ -69,7 +70,7 @@ function analyze_entity_sentiment($text, $projectId = null)
6970
printf('Entity Magnitude: %s' . PHP_EOL, $sentiment->getMagnitude());
7071
printf('Entity Score: %s' . PHP_EOL, $sentiment->getScore());
7172
}
72-
printf(PHP_EOL);
73+
print(PHP_EOL);
7374
}
7475
} finally {
7576
$languageServiceClient->close();

language/src/analyze_entity_sentiment_from_file.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
namespace Google\Cloud\Samples\Language;
2626

2727
use Google\Cloud\Language\V1beta2\Document;
28+
use Google\Cloud\Language\V1beta2\Document\Type;
2829
use Google\Cloud\Language\V1beta2\LanguageServiceClient;
2930

3031
/**
@@ -56,7 +57,7 @@ function analyze_entity_sentiment_from_file($gcsUri, $projectId = null)
5657
// Create a new Document
5758
$document = new Document();
5859
// Pass GCS URI and set document type to PLAIN_TEXT
59-
$document->setGcsContentUri($gcsUri)->setType(1);
60+
$document->setGcsContentUri($gcsUri)->setType(Type::PLAIN_TEXT);
6061
// Call the analyzeEntitySentiment function
6162
$response = $languageServiceClient->analyzeEntitySentiment($document);
6263
$entities = $response->getEntities();
@@ -70,7 +71,7 @@ function analyze_entity_sentiment_from_file($gcsUri, $projectId = null)
7071
printf('Entity Magnitude: %s' . PHP_EOL, $sentiment->getMagnitude());
7172
printf('Entity Score: %s' . PHP_EOL, $sentiment->getScore());
7273
}
73-
printf(PHP_EOL);
74+
print(PHP_EOL);
7475
}
7576
} finally {
7677
$languageServiceClient->close();

0 commit comments

Comments
 (0)