Skip to content

Commit 03db78e

Browse files
committed
Updates based on comments
1 parent 17f1b5d commit 03db78e

File tree

4 files changed

+22
-37
lines changed

4 files changed

+22
-37
lines changed

language/automl/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=vision/beta/cloud-client/README.md">
44
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
55

6-
[Google Cloud Natural Language API][language] provides feature detection for images.
6+
[Google Cloud AutoML Natural Language API][language] provides feature detection for images.
77
This API is part of the larger collection of Cloud Machine Learning APIs.
88

99
This sample Java application demonstrates how to access the Cloud Natural Language AutoML API
1010
using the [Google Cloud Client Library for Java][google-cloud-java].
1111

12-
[language]: https://cloud.google.com/language/docs/
12+
[language]: https://cloud.google.com/language/automl/docs/
1313
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
1414

1515
## Set the environment variables
@@ -46,7 +46,7 @@ mvn exec:java -Dexec.mainClass="com.google.cloud.language.samples.DatasetApi" -D
4646

4747
#### Import data
4848
```
49-
mvn exec:java -Dexec.mainClass="com.google.cloud.language.samples.DatasetApi" -Dexec.args="import_data gs://java-docs-samples-testing/happiness.csv"
49+
mvn exec:java -Dexec.mainClass="com.google.cloud.language.samples.DatasetApi" -Dexec.args="import_data [dataset-id] gs://java-docs-samples-testing/happiness.csv"
5050
```
5151

5252
### Model API

translate/automl/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=vision/beta/cloud-client/README.md">
44
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
55

6-
[Google Cloud Translate API][translate] provides feature AutoML.
6+
[Google Cloud AutoML Translation API][translate] provides feature AutoML.
77
This API is part of the larger collection of Cloud Machine Learning APIs.
88

99
This sample Java application demonstrates how to access the Cloud Translate AutoML API
1010
using the [Google Cloud Client Library for Java][google-cloud-java].
1111

12+
[translate]: https://cloud.google.com/translate/automl/docs/
13+
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
14+
1215
## Set the environment variables
1316

1417
PROJECT_ID = [Id of the project]
@@ -43,7 +46,7 @@ mvn exec:java -Dexec.mainClass="com.google.cloud.translate.samples.DatasetApi" -
4346

4447
#### Import data
4548
```
46-
mvn exec:java -Dexec.mainClass="com.google.cloud.translate.samples.DatasetApi" -Dexec.args="import_data gs://java-docs-samples-testing/en-ja.csv"
49+
mvn exec:java -Dexec.mainClass="com.google.cloud.translate.samples.DatasetApi" -Dexec.args="import_data [dataset-id] gs://java-docs-samples-testing/en-ja.csv"
4750
```
4851

4952
### Model API

translate/automl/src/main/java/com/google/cloud/translate/automl/PredictionApi.java

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

4848
/**
4949
* Google Cloud AutoML Translate API sample application. Example usage: mvn package exec:java
50-
* -Dexec.mainClass ='com.google.cloud.vision.samples.automl.PredictionApi' -Dexec.args='predict
51-
* [modelId] [path-to-image] [scoreThreshold]'
50+
* -Dexec.mainClass ='com.google.cloud.translate.automl.PredictionApi' -Dexec.args='predict
51+
* [modelId] [file-path]'
5252
*/
5353
public class PredictionApi {
5454

@@ -61,16 +61,10 @@ public class PredictionApi {
6161
* @param computeRegion the Region name.
6262
* @param modelId the Id of the model which will be used for text classification.
6363
* @param filePath the Local text file path of the content to be classified.
64-
* @param translationAllowFallback set to true to use a Google translation.
6564
* @throws IOException on Input/Output errors.
6665
*/
6766
public static void predict(
68-
String projectId,
69-
String computeRegion,
70-
String modelId,
71-
String filePath,
72-
boolean translationAllowFallback)
73-
throws IOException {
67+
String projectId, String computeRegion, String modelId, String filePath) throws IOException {
7468
// Instantiate client for prediction service.
7569
PredictionServiceClient predictionClient = PredictionServiceClient.create();
7670

@@ -87,9 +81,6 @@ public static void predict(
8781

8882
// Additional parameters that can be provided for prediction
8983
Map<String, String> params = new HashMap<>();
90-
if (translationAllowFallback) {
91-
params.put("translation_allow_fallback", "True");//Allow Google Translation Model
92-
}
9384

9485
PredictResponse response = predictionClient.predict(name, payload, params);
9586
TextSnippet translatedContent = response.getPayload(0).getTranslation().getTranslatedContent();
@@ -104,20 +95,16 @@ public static void main(String[] args) throws IOException {
10495
}
10596

10697
public static void argsHelper(String[] args, PrintStream out) throws IOException {
107-
ArgumentParser parser = ArgumentParsers.newFor("PredictionApi")
108-
.build()
109-
.defaultHelp(true)
110-
.description("Prediction API Operation");
98+
ArgumentParser parser =
99+
ArgumentParsers.newFor("PredictionApi")
100+
.build()
101+
.defaultHelp(true)
102+
.description("Prediction API Operation");
111103
Subparsers subparsers = parser.addSubparsers().dest("command");
112104

113105
Subparser predictParser = subparsers.addParser("predict");
114106
predictParser.addArgument("modelId");
115107
predictParser.addArgument("filePath");
116-
predictParser
117-
.addArgument("translationAllowFallback")
118-
.nargs("?")
119-
.type(Boolean.class)
120-
.setDefault(Boolean.FALSE);
121108

122109
String projectId = System.getenv("PROJECT_ID");
123110
String computeRegion = System.getenv("REGION_NAME");
@@ -126,12 +113,7 @@ public static void argsHelper(String[] args, PrintStream out) throws IOException
126113
try {
127114
ns = parser.parseArgs(args);
128115
if (ns.get("command").equals("predict")) {
129-
predict(
130-
projectId,
131-
computeRegion,
132-
ns.getString("modelId"),
133-
ns.getString("filePath"),
134-
ns.getBoolean("translationAllowFallback"));
116+
predict(projectId, computeRegion, ns.getString("modelId"), ns.getString("filePath"));
135117
}
136118
} catch (ArgumentParserException e) {
137119
parser.handleError(e);

vision/automl/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=vision/beta/cloud-client/README.md">
44
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
55

6-
[Google Cloud Vision API][vision] provides feature detection for images.
6+
[Google Cloud AutoML Vision API][vision] provides feature detection for images.
77
This API is part of the larger collection of Cloud Machine Learning APIs.
88

99
This sample Java application demonstrates how to access the Cloud Vision API
1010
using the [Google Cloud Client Library for Java][google-cloud-java].
1111

12-
[vision]: https://cloud.google.com/vision/docs/
12+
[vision]: https://cloud.google.com/vision/automl/docs/
1313
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
1414

1515
## Set the environment variables
@@ -45,14 +45,14 @@ mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetAp
4545

4646
#### Import data
4747
```
48-
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetApi" -Dexec.args="import_data gs://java-docs-samples-testing/flower_traindata.csv"
48+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetApi" -Dexec.args="import_data [dataset-id] gs://java-docs-samples-testing/flower_traindata.csv"
4949
```
5050

5151
### Model API
5252

5353
#### Create Model
5454
```
55-
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="create_model test_model"
55+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="create_model [dataset-id] test_model [training-budget] "
5656
```
5757

5858
#### List Models
@@ -77,7 +77,7 @@ mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi"
7777

7878
#### Delete Model
7979
```
80-
mvn exec:java-Dexec.mainClass="com.google.cloud.vision.samples.automl.ModeltApi" -Dexec.args="delete_model [model-id]"
80+
mvn exec:java-Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="delete_model [model-id]"
8181
```
8282
### Predict API
8383

0 commit comments

Comments
 (0)