Skip to content

Commit a82597e

Browse files
committed
Updated setType to use Type:PLAIN_TEXT
1 parent cf18d2d commit a82597e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

language/src/analyze_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
/**
@@ -44,7 +45,7 @@ function analyze_sentiment($text, $projectId = null)
4445
// Create a new Document
4546
$document = new Document();
4647
// Pass GCS URI and set document type to PLAIN_TEXT
47-
$document->setContent($text)->setType(1);
48+
$document->setContent($text)->setType(Type::PLAIN_TEXT);
4849
// Call the analyzeSentiment function
4950
$response = $languageServiceClient->analyzeSentiment($document);
5051
$document_sentiment = $response->getDocumentSentiment();
@@ -62,7 +63,7 @@ function analyze_sentiment($text, $projectId = null)
6263
printf('Entity Magnitude: %s' . PHP_EOL, $sentiment->getMagnitude());
6364
printf('Entity Score: %s' . PHP_EOL, $sentiment->getScore());
6465
}
65-
printf(PHP_EOL);
66+
print(PHP_EOL);
6667
}
6768
} finally {
6869
$languageServiceClient->close();

language/src/analyze_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
/**
@@ -44,7 +45,7 @@ function analyze_sentiment_from_file($gcsUri, $projectId = null)
4445
// Create a new Document
4546
$document = new Document();
4647
// Pass GCS URI and set document type to PLAIN_TEXT
47-
$document->setGcsContentUri($gcsUri)->setType(1);
48+
$document->setGcsContentUri($gcsUri)->setType(Type::PLAIN_TEXT);
4849
// Call the analyzeSentiment function
4950
$response = $languageServiceClient->analyzeSentiment($document);
5051
$document_sentiment = $response->getDocumentSentiment();
@@ -62,7 +63,7 @@ function analyze_sentiment_from_file($gcsUri, $projectId = null)
6263
printf('Entity Magnitude: %s' . PHP_EOL, $sentiment->getMagnitude());
6364
printf('Entity Score: %s' . PHP_EOL, $sentiment->getScore());
6465
}
65-
printf(PHP_EOL);
66+
print(PHP_EOL);
6667
}
6768
} finally {
6869
$languageServiceClient->close();

0 commit comments

Comments
 (0)