Skip to content

Commit 55ca49e

Browse files
committed
added model parameter
1 parent 4d98005 commit 55ca49e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

translate/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We can then run the assembled JAR file with the `java` command. The variable
4747
$COMMAND takes three values `langsupport`, `detect` and `translate`.
4848

4949
```
50-
JAR_FILE=target/translate-1.0-SNAPSHOT-jar-with-dependencies.jar
50+
JAR_FILE=target/translate-1.0-jar-with-dependencies.jar
5151
java -jar $JAR_FILE <detect|translate|langsupport> <text>
5252
<optional_source> <optional_target>
5353
```

translate/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
<modelVersion>4.0.0</modelVersion>
1818
<groupId>com.google.cloud.translate.samples</groupId>
1919
<artifactId>translate</artifactId>
20-
<version>1.0-SNAPSHOT</version>
20+
<version>1.0</version>
2121
<name>translate</name>
2222
<url>http://maven.apache.org</url>
2323
<properties>
@@ -38,7 +38,7 @@ limitations under the License.
3838
<dependency>
3939
<groupId>com.google.cloud</groupId>
4040
<artifactId>google-cloud-translate</artifactId>
41-
<version>0.5.1</version>
41+
<version>0.6.0</version>
4242
</dependency>
4343
<dependency>
4444
<groupId>junit</groupId>

translate/src/main/java/com/google/cloud/translate/samples/TranslateText.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ public static void translateTextWithOptions(
7777
TranslateOption srcLang = TranslateOption.sourceLanguage(sourceLang);
7878
TranslateOption tgtLang = TranslateOption.targetLanguage(targetLang);
7979

80-
Translation translation = translate.translate(sourceText, srcLang, tgtLang);
80+
//Use translate `model` parameter with `base` and `nmt` options
81+
TranslateOption model = TranslateOption.model("nmt");
82+
83+
Translation translation = translate.translate(sourceText, srcLang, tgtLang, model);
8184
out.printf("Source Text:\n\tLang: %s, Text: %s\n", sourceLang, sourceText);
8285
out.printf("TranslatedText:\n\tLang: %s, Text: %s\n", targetLang, translation.translatedText());
8386
}

0 commit comments

Comments
 (0)