Skip to content

Commit 49adaf6

Browse files
gguusslesv
authored andcommitted
Adds missing dependency until the language library is fixed. (#732)
* Adds missing dependency until the language library is fixed. * Fixes style enforced in parent.
1 parent 324e029 commit 49adaf6

File tree

7 files changed

+78
-54
lines changed

7 files changed

+78
-54
lines changed

language/analysis/pom.xml

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ limitations under the License.
2020
<groupId>com.google.cloud.language.samples</groupId>
2121
<artifactId>language-entities</artifactId>
2222

23+
<parent>
24+
<artifactId>doc-samples</artifactId>
25+
<groupId>com.google.cloud</groupId>
26+
<version>1.0.0</version>
27+
<relativePath>../..</relativePath>
28+
</parent>
29+
2330
<dependencies>
2431
<!-- [START dependencies] -->
2532
<dependency>
@@ -34,6 +41,13 @@ limitations under the License.
3441
</dependency>
3542
<!-- [END dependencies] -->
3643

44+
<!-- FIXME: remove after client fixes depenency issue -->
45+
<dependency>
46+
<groupId>com.google.auth</groupId>
47+
<artifactId>google-auth-library-oauth2-http</artifactId>
48+
<version>0.6.0</version>
49+
</dependency>
50+
3751
<!-- Test Dependencies -->
3852
<dependency>
3953
<groupId>junit</groupId>

language/analysis/src/main/java/com/google/cloud/language/samples/Analyze.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.language.samples;
1818

19-
import com.google.cloud.language.v1.LanguageServiceClient;
2019

2120
import com.google.cloud.language.v1.AnalyzeEntitiesRequest;
2221
import com.google.cloud.language.v1.AnalyzeEntitiesResponse;
@@ -28,6 +27,7 @@
2827
import com.google.cloud.language.v1.EncodingType;
2928
import com.google.cloud.language.v1.Entity;
3029
import com.google.cloud.language.v1.EntityMention;
30+
import com.google.cloud.language.v1.LanguageServiceClient;
3131
import com.google.cloud.language.v1.Sentiment;
3232
import com.google.cloud.language.v1.Token;
3333
import com.google.protobuf.Descriptors;

language/analysis/src/main/java/com/google/cloud/language/samples/AnalyzeBeta.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.language.samples;
1818

19-
import com.google.cloud.language.v1beta2.LanguageServiceClient;
2019

2120
import com.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest;
2221
import com.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse;
@@ -26,8 +25,8 @@
2625
import com.google.cloud.language.v1beta2.EncodingType;
2726
import com.google.cloud.language.v1beta2.Entity;
2827
import com.google.cloud.language.v1beta2.EntityMention;
28+
import com.google.cloud.language.v1beta2.LanguageServiceClient;
2929
import com.google.cloud.language.v1beta2.Sentiment;
30-
import com.google.cloud.language.v1beta2.Token;
3130
import com.google.protobuf.Descriptors;
3231

3332
import java.io.IOException;

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21-
import com.google.cloud.language.v1beta2.LanguageServiceClient;
2221
import com.google.cloud.language.v1beta2.Entity;
2322
import com.google.cloud.language.v1beta2.EntityMention;
23+
import com.google.cloud.language.v1beta2.LanguageServiceClient;
2424
import com.google.cloud.language.v1beta2.Sentiment;
2525

2626
import org.junit.Before;
@@ -58,8 +58,8 @@ public class AnalyzeBetaIT {
5858
}
5959

6060
@Test public void analyzeSyntax_entitySentimentText() throws Exception {
61-
List<Entity> entities = analyzeApp.entitySentimentText("Oranges, grapes, and apples can be " +
62-
"found in the cafeterias located in Mountain View, Seattle, and London.");
61+
List<Entity> entities = analyzeApp.entitySentimentText("Oranges, grapes, and apples can be "
62+
+ "found in the cafeterias located in Mountain View, Seattle, and London.");
6363

6464
List<String> got = entities.stream().map(e -> e.getName()).collect(Collectors.toList());
6565

@@ -73,7 +73,7 @@ public class AnalyzeBetaIT {
7373
List<EntityMention> mentions = entities.listIterator().next().getMentionsList();
7474

7575
// Assert
76-
assertThat(mentions.get(0).getText().getBeginOffset() == 4);
76+
assertThat(mentions.get(0).getText().getBeginOffset()).isEqualTo(4);
7777
}
7878

7979
@Test public void analyzeSyntax_entitySentimentFile() throws Exception {

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

+46-46
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21-
import com.google.cloud.language.v1.LanguageServiceClient;
2221
import com.google.cloud.language.v1.Entity;
22+
import com.google.cloud.language.v1.LanguageServiceClient;
2323
import com.google.cloud.language.v1.PartOfSpeech.Tag;
2424
import com.google.cloud.language.v1.Sentiment;
2525
import com.google.cloud.language.v1.Token;
@@ -62,14 +62,14 @@ public class AnalyzeIT {
6262
}
6363

6464
@Test public void analyzeEntities_withEntitiesFile_containsGod() throws Exception {
65-
// Act
66-
List<Entity> entities =
67-
analyzeApp.analyzeEntitiesFile("gs://" + BUCKET + "/natural-language/gettysburg.txt");
68-
List<String> got = entities.stream().map(e -> e.getName()).collect(Collectors.toList());
65+
// Act
66+
List<Entity> entities =
67+
analyzeApp.analyzeEntitiesFile("gs://" + BUCKET + "/natural-language/gettysburg.txt");
68+
List<String> got = entities.stream().map(e -> e.getName()).collect(Collectors.toList());
6969

70-
// Assert
71-
assertThat(got).named("entity names").contains("God");
72-
}
70+
// Assert
71+
assertThat(got).named("entity names").contains("God");
72+
}
7373

7474
@Test public void analyzeSentimentText_returnPositive() throws Exception {
7575
// Act
@@ -83,15 +83,15 @@ public class AnalyzeIT {
8383
}
8484

8585
@Test public void analyzeSentimentFile_returnPositiveFile() throws Exception {
86-
// Act
87-
Sentiment sentiment =
88-
analyzeApp.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/"
89-
+ "sentiment/bladerunner-pos.txt");
86+
// Act
87+
Sentiment sentiment =
88+
analyzeApp.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/"
89+
+ "sentiment/bladerunner-pos.txt");
9090

91-
// Assert
92-
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
93-
assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
94-
}
91+
// Assert
92+
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
93+
assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
94+
}
9595

9696
@Test public void analyzeSentiment_returnNegative() throws Exception {
9797
// Act
@@ -105,26 +105,26 @@ public class AnalyzeIT {
105105
}
106106

107107
@Test public void analyzeSentiment_returnNegativeFile() throws Exception {
108-
// Act
109-
Sentiment sentiment =
110-
analyzeApp.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/"
111-
+ "sentiment/bladerunner-neg.txt");
108+
// Act
109+
Sentiment sentiment =
110+
analyzeApp.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/"
111+
+ "sentiment/bladerunner-neg.txt");
112112

113-
// Assert
114-
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
115-
assertThat((double)sentiment.getScore()).isLessThan(0.0);
116-
}
113+
// Assert
114+
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
115+
assertThat((double)sentiment.getScore()).isLessThan(0.0);
116+
}
117117

118118
@Test public void analyzeSentiment_returnNeutralFile() throws Exception {
119-
// Act
120-
Sentiment sentiment =
121-
analyzeApp.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/"
122-
+ "sentiment/bladerunner-neutral.txt");
119+
// Act
120+
Sentiment sentiment =
121+
analyzeApp.analyzeSentimentFile("gs://" + BUCKET + "/natural-language/"
122+
+ "sentiment/bladerunner-neutral.txt");
123123

124-
// Assert
125-
assertThat((double)sentiment.getMagnitude()).isGreaterThan(1.0);
126-
assertThat((double)sentiment.getScore()).isWithin(0.1);
127-
}
124+
// Assert
125+
assertThat((double)sentiment.getMagnitude()).isGreaterThan(1.0);
126+
assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
127+
}
128128

129129
@Test public void analyzeSyntax_partOfSpeech() throws Exception {
130130
// Act
@@ -141,18 +141,18 @@ public class AnalyzeIT {
141141
}
142142

143143
@Test public void analyzeSyntax_partOfSpeechFile() throws Exception {
144-
// Act
145-
List<Token> token =
146-
analyzeApp.analyzeSyntaxFile("gs://" + BUCKET + "/natural-language/"
147-
+ "sentiment/bladerunner-neutral.txt");
148-
149-
List<Tag> got = token.stream().map(e -> e.getPartOfSpeech().getTag())
150-
.collect(Collectors.toList());
151-
152-
// Assert
153-
assertThat(got).containsExactly(Tag.PRON, Tag.CONJ, Tag.VERB, Tag.CONJ, Tag.VERB,
154-
Tag.DET, Tag.NOUN, Tag.PUNCT, Tag.NOUN, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.CONJ,
155-
Tag.ADV, Tag.PRON, Tag.VERB, Tag.VERB, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.DET,
156-
Tag.NOUN, Tag.VERB, Tag.ADV, Tag.ADJ,Tag.PUNCT).inOrder();
157-
}
144+
// Act
145+
List<Token> token =
146+
analyzeApp.analyzeSyntaxFile("gs://" + BUCKET + "/natural-language/"
147+
+ "sentiment/bladerunner-neutral.txt");
148+
149+
List<Tag> got = token.stream().map(e -> e.getPartOfSpeech().getTag())
150+
.collect(Collectors.toList());
151+
152+
// Assert
153+
assertThat(got).containsExactly(Tag.PRON, Tag.CONJ, Tag.VERB, Tag.CONJ, Tag.VERB,
154+
Tag.DET, Tag.NOUN, Tag.PUNCT, Tag.NOUN, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.CONJ,
155+
Tag.ADV, Tag.PRON, Tag.VERB, Tag.VERB, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.DET,
156+
Tag.NOUN, Tag.VERB, Tag.ADV, Tag.ADJ,Tag.PUNCT).inOrder();
157+
}
158158
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020

2121
import com.google.cloud.language.v1.Entity;
22-
import com.google.cloud.language.v1.Entity.Builder;
2322
import com.google.cloud.language.v1.Entity.Type;
2423
import com.google.common.collect.ImmutableList;
2524
import com.google.common.collect.ImmutableMap;

language/cloud-client/pom.xml

+12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
<artifactId>google-cloud-language</artifactId>
4040
<version>0.20.0-beta</version>
4141
</dependency>
42+
<dependency>
43+
<groupId>com.google.guava</groupId>
44+
<artifactId>guava</artifactId>
45+
<version>20.0</version>
46+
</dependency>
47+
48+
<!-- FIXME: remove after client fixes depenency issue -->
49+
<dependency>
50+
<groupId>com.google.auth</groupId>
51+
<artifactId>google-auth-library-oauth2-http</artifactId>
52+
<version>0.6.0</version>
53+
</dependency>
4254

4355
<!-- Test dependencies -->
4456
<dependency>

0 commit comments

Comments
 (0)