Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate with model param changes #410

Merged
merged 5 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ We can then run the assembled JAR file with the `java` command. The variable
$COMMAND takes three values `langsupport`, `detect` and `translate`.

```
JAR_FILE=target/translate-1.0-SNAPSHOT-jar-with-dependencies.jar
JAR_FILE=target/translate-1.0-jar-with-dependencies.jar
java -jar $JAR_FILE <detect|translate|langsupport> <text>
<optional_source> <optional_target>
```
Expand Down
4 changes: 2 additions & 2 deletions translate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud.translate.samples</groupId>
<artifactId>translate</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
<name>translate</name>
<url>http://maven.apache.org</url>
<properties>
Expand All @@ -38,7 +38,7 @@ limitations under the License.
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
<version>0.5.1</version>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public static void translateTextWithOptions(
TranslateOption srcLang = TranslateOption.sourceLanguage(sourceLang);
TranslateOption tgtLang = TranslateOption.targetLanguage(targetLang);

Translation translation = translate.translate(sourceText, srcLang, tgtLang);
// Use translate `model` parameter with `base` and `nmt` options.
TranslateOption model = TranslateOption.model("base");

Translation translation = translate.translate(sourceText, srcLang, tgtLang, model);
out.printf("Source Text:\n\tLang: %s, Text: %s\n", sourceLang, sourceText);
out.printf("TranslatedText:\n\tLang: %s, Text: %s\n", targetLang, translation.translatedText());
}
Expand Down