Skip to content

Commit 7966012

Browse files
munkhuushmglchingor13
authored andcommitted
samples: samples:added docs links to predict samples (#3266)
Fixes #1730
1 parent 4624473 commit 7966012

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

automl/snippets/src/main/java/com/example/automl/LanguageEntityExtractionPredict.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ static void predict(String projectId, String modelId, String content) throws IOE
4444
try (PredictionServiceClient client = PredictionServiceClient.create()) {
4545
// Get the full path of the model.
4646
ModelName name = ModelName.of(projectId, "us-central1", modelId);
47+
48+
// For available mime types, see:
49+
// https://cloud.google.com/automl/docs/reference/rest/v1/projects.locations.models/predict#textsnippet
4750
TextSnippet textSnippet =
48-
TextSnippet.newBuilder().setContent(content).setMimeType("text/plain").build();
51+
TextSnippet.newBuilder()
52+
.setContent(content)
53+
.setMimeType("text/plain") // Types: text/plain, text/html
54+
.build();
4955
ExamplePayload payload = ExamplePayload.newBuilder().setTextSnippet(textSnippet).build();
5056
PredictRequest predictRequest =
5157
PredictRequest.newBuilder().setName(name.toString()).setPayload(payload).build();

automl/snippets/src/main/java/com/example/automl/LanguageSentimentAnalysisPredict.java

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ static void predict(String projectId, String modelId, String content) throws IOE
4343
try (PredictionServiceClient client = PredictionServiceClient.create()) {
4444
// Get the full path of the model.
4545
ModelName name = ModelName.of(projectId, "us-central1", modelId);
46+
47+
// For available mime types, see:
48+
// https://cloud.google.com/automl/docs/reference/rest/v1/projects.locations.models/predict#textsnippet
4649
TextSnippet textSnippet =
4750
TextSnippet.newBuilder()
4851
.setContent(content)

automl/snippets/src/main/java/com/example/automl/LanguageTextClassificationPredict.java

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ static void predict(String projectId, String modelId, String content) throws IOE
4343
try (PredictionServiceClient client = PredictionServiceClient.create()) {
4444
// Get the full path of the model.
4545
ModelName name = ModelName.of(projectId, "us-central1", modelId);
46+
47+
// For available mime types, see:
48+
// https://cloud.google.com/automl/docs/reference/rest/v1/projects.locations.models/predict#textsnippet
4649
TextSnippet textSnippet =
4750
TextSnippet.newBuilder()
4851
.setContent(content)

0 commit comments

Comments
 (0)