Skip to content

Commit 09bcada

Browse files
committed
2 parents ce0adb3 + 0b783b7 commit 09bcada

File tree

10 files changed

+34
-135
lines changed

10 files changed

+34
-135
lines changed

appengine/firebase-tictactoe/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ for realtime notifications when the board changes.
2727
[sdk]: https://cloud.google.com/sdk
2828
[creds]: https://console.firebase.google.com/iam-admin/serviceaccounts/project?project=_&consoleReturnUrl=https:%2F%2Fconsole.firebase.google.com%2Fproject%2F_%2Fsettings%2Fgeneral%2F
2929
[fb-overview]: https://console.firebase.google.com/project/_/overview
30+
[maven]: https://maven.apache.org
3031

3132

3233
## Run the sample

language/analysis/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ three values `entities`, `sentiment` or `syntax`.
3434

3535
```
3636
MAIN_CLASS=com.google.cloud.language.samples.Analyze
37-
JAR_FILE=target/language-entities-1.0-SNAPSHOT-jar-with-dependencies.jar
37+
JAR_FILE=target/language-entities-1.0-jar-with-dependencies.jar
3838
java -cp $JAR_FILE $MAIN_CLASS <sentiment|entities|syntax> <text>
3939
```
4040

language/analysis/pom.xml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,21 @@ limitations under the License.
1616
<project>
1717
<modelVersion>4.0.0</modelVersion>
1818
<packaging>jar</packaging>
19-
<version>1.0-SNAPSHOT</version>
19+
<version>1.0</version>
2020
<groupId>com.google.cloud.language.samples</groupId>
2121
<artifactId>language-entities</artifactId>
2222

23-
<repositories>
24-
<repository>
25-
<id>project.local</id>
26-
<name>project</name>
27-
<url>file://${project.basedir}/repo</url>
28-
</repository>
29-
</repositories>
3023
<dependencies>
3124
<!-- [START dependencies] -->
3225
<dependency>
3326
<groupId>com.google.apis</groupId>
3427
<artifactId>google-api-services-language</artifactId>
35-
<version>v1-rev20161103-1.22.0-SNAPSHOT</version>
28+
<version>v1-rev1-1.21.0</version>
3629
</dependency>
3730
<dependency>
3831
<groupId>com.google.api-client</groupId>
3932
<artifactId>google-api-client</artifactId>
40-
<version>1.22.0</version>
33+
<version>1.21.0</version>
4134
</dependency>
4235
<dependency>
4336
<groupId>com.google.guava</groupId>

language/analysis/repo/com/google/apis/google-api-services-language/maven-metadata.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

language/analysis/repo/com/google/apis/google-api-services-language/v1-rev20161109-1.22.0-SNAPSHOT/google-api-services-language-v1-rev20161109-1.22.0-20161110.231925-1.pom

Lines changed: 0 additions & 84 deletions
This file was deleted.

language/analysis/repo/com/google/apis/google-api-services-language/v1-rev20161109-1.22.0-SNAPSHOT/maven-metadata.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

language/analysis/src/test/java/com/google/cloud/language/samples/AnalyzeIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class AnalyzeIT {
7676

7777
// Assert
7878
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
79-
assertThat((double)sentiment.getPolarity()).isLessThan(0.0);
79+
assertThat((double)sentiment.getScore()).isLessThan(0.0);
8080
}
8181

8282
@Test public void analyzeSyntax_partOfSpeech() throws Exception {

translate/cloud-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>com.google.cloud</groupId>
3939
<artifactId>google-cloud-translate</artifactId>
40-
<version>0.5.1</version>
40+
<version>0.6.0</version>
4141
</dependency>
4242

4343
<!-- Test dependencies -->

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ public static void translateText(String sourceText, PrintStream out) {
6161

6262
/**
6363
* Translate the source text from source to target language.
64+
* Make sure that your project is whitelisted.
6465
*
6566
* @param sourceText source text to be translated
6667
* @param sourceLang source language of the text
6768
* @param targetLang target language of translated text
6869
* @param out print stream
6970
*/
70-
public static void translateTextWithOptions(
71+
public static void translateTextWithOptionsAndModel(
7172
String sourceText,
7273
String sourceLang,
7374
String targetLang,
@@ -77,14 +78,38 @@ public static void translateTextWithOptions(
7778
TranslateOption srcLang = TranslateOption.sourceLanguage(sourceLang);
7879
TranslateOption tgtLang = TranslateOption.targetLanguage(targetLang);
7980

80-
//Use translate `model` parameter with `base` and `nmt` options
81+
// Use translate `model` parameter with `base` and `nmt` options.
8182
TranslateOption model = TranslateOption.model("base");
8283

8384
Translation translation = translate.translate(sourceText, srcLang, tgtLang, model);
8485
out.printf("Source Text:\n\tLang: %s, Text: %s\n", sourceLang, sourceText);
8586
out.printf("TranslatedText:\n\tLang: %s, Text: %s\n", targetLang, translation.getTranslatedText());
8687
}
8788

89+
90+
/**
91+
* Translate the source text from source to target language.
92+
*
93+
* @param sourceText source text to be translated
94+
* @param sourceLang source language of the text
95+
* @param targetLang target language of translated text
96+
* @param out print stream
97+
*/
98+
public static void translateTextWithOptions(
99+
String sourceText,
100+
String sourceLang,
101+
String targetLang,
102+
PrintStream out) {
103+
104+
Translate translate = createTranslateService();
105+
TranslateOption srcLang = TranslateOption.sourceLanguage(sourceLang);
106+
TranslateOption tgtLang = TranslateOption.targetLanguage(targetLang);
107+
108+
Translation translation = translate.translate(sourceText, srcLang, tgtLang);
109+
out.printf("Source Text:\n\tLang: %s, Text: %s\n", sourceLang, sourceText);
110+
out.printf("TranslatedText:\n\tLang: %s, Text: %s\n", targetLang, translation.translatedText());
111+
}
112+
88113
/**
89114
* Displays a list of supported languages and codes.
90115
*

0 commit comments

Comments
 (0)