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

Adds missing dependency until the language library is fixed. #732

Merged
merged 2 commits into from
Jun 28, 2017
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
14 changes: 14 additions & 0 deletions language/analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ limitations under the License.
<groupId>com.google.cloud.language.samples</groupId>
<artifactId>language-entities</artifactId>

<parent>
<artifactId>doc-samples</artifactId>
<groupId>com.google.cloud</groupId>
<version>1.0.0</version>
<relativePath>../..</relativePath>
</parent>

<dependencies>
<!-- [START dependencies] -->
<dependency>
Expand All @@ -34,6 +41,13 @@ limitations under the License.
</dependency>
<!-- [END dependencies] -->

<!-- FIXME: remove after client fixes depenency issue -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gus, can you link the tracking issue : googleapis/google-cloud-java#2192, just so we can track when to remove

<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>0.6.0</version>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.cloud.language.samples;

import com.google.cloud.language.v1.LanguageServiceClient;

import com.google.cloud.language.v1.AnalyzeEntitiesRequest;
import com.google.cloud.language.v1.AnalyzeEntitiesResponse;
Expand All @@ -28,6 +27,7 @@
import com.google.cloud.language.v1.EncodingType;
import com.google.cloud.language.v1.Entity;
import com.google.cloud.language.v1.EntityMention;
import com.google.cloud.language.v1.LanguageServiceClient;
import com.google.cloud.language.v1.Sentiment;
import com.google.cloud.language.v1.Token;
import com.google.protobuf.Descriptors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.cloud.language.samples;

import com.google.cloud.language.v1beta2.LanguageServiceClient;

import com.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest;
import com.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse;
Expand All @@ -26,8 +25,8 @@
import com.google.cloud.language.v1beta2.EncodingType;
import com.google.cloud.language.v1beta2.Entity;
import com.google.cloud.language.v1beta2.EntityMention;
import com.google.cloud.language.v1beta2.LanguageServiceClient;
import com.google.cloud.language.v1beta2.Sentiment;
import com.google.cloud.language.v1beta2.Token;
import com.google.protobuf.Descriptors;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

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

import com.google.cloud.language.v1beta2.LanguageServiceClient;
import com.google.cloud.language.v1beta2.Entity;
import com.google.cloud.language.v1beta2.EntityMention;
import com.google.cloud.language.v1beta2.LanguageServiceClient;
import com.google.cloud.language.v1beta2.Sentiment;

import org.junit.Before;
Expand Down Expand Up @@ -58,8 +58,8 @@ public class AnalyzeBetaIT {
}

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

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

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

// Assert
assertThat(mentions.get(0).getText().getBeginOffset() == 4);
assertThat(mentions.get(0).getText().getBeginOffset()).isEqualTo(4);
}

@Test public void analyzeSyntax_entitySentimentFile() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

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

import com.google.cloud.language.v1.LanguageServiceClient;
import com.google.cloud.language.v1.Entity;
import com.google.cloud.language.v1.LanguageServiceClient;
import com.google.cloud.language.v1.PartOfSpeech.Tag;
import com.google.cloud.language.v1.Sentiment;
import com.google.cloud.language.v1.Token;
Expand Down Expand Up @@ -62,14 +62,14 @@ public class AnalyzeIT {
}

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

// Assert
assertThat(got).named("entity names").contains("God");
}
// Assert
assertThat(got).named("entity names").contains("God");
}

@Test public void analyzeSentimentText_returnPositive() throws Exception {
// Act
Expand All @@ -83,15 +83,15 @@ public class AnalyzeIT {
}

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

// Assert
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
}
// Assert
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
}

@Test public void analyzeSentiment_returnNegative() throws Exception {
// Act
Expand All @@ -105,26 +105,26 @@ public class AnalyzeIT {
}

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

// Assert
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
assertThat((double)sentiment.getScore()).isLessThan(0.0);
}
// Assert
assertThat((double)sentiment.getMagnitude()).isGreaterThan(0.0);
assertThat((double)sentiment.getScore()).isLessThan(0.0);
}

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

// Assert
assertThat((double)sentiment.getMagnitude()).isGreaterThan(1.0);
assertThat((double)sentiment.getScore()).isWithin(0.1);
}
// Assert
assertThat((double)sentiment.getMagnitude()).isGreaterThan(1.0);
assertThat((double)sentiment.getScore()).isGreaterThan(0.0);
}

@Test public void analyzeSyntax_partOfSpeech() throws Exception {
// Act
Expand All @@ -141,18 +141,18 @@ public class AnalyzeIT {
}

@Test public void analyzeSyntax_partOfSpeechFile() throws Exception {
// Act
List<Token> token =
analyzeApp.analyzeSyntaxFile("gs://" + BUCKET + "/natural-language/"
+ "sentiment/bladerunner-neutral.txt");

List<Tag> got = token.stream().map(e -> e.getPartOfSpeech().getTag())
.collect(Collectors.toList());

// Assert
assertThat(got).containsExactly(Tag.PRON, Tag.CONJ, Tag.VERB, Tag.CONJ, Tag.VERB,
Tag.DET, Tag.NOUN, Tag.PUNCT, Tag.NOUN, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.CONJ,
Tag.ADV, Tag.PRON, Tag.VERB, Tag.VERB, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.DET,
Tag.NOUN, Tag.VERB, Tag.ADV, Tag.ADJ,Tag.PUNCT).inOrder();
}
// Act
List<Token> token =
analyzeApp.analyzeSyntaxFile("gs://" + BUCKET + "/natural-language/"
+ "sentiment/bladerunner-neutral.txt");

List<Tag> got = token.stream().map(e -> e.getPartOfSpeech().getTag())
.collect(Collectors.toList());

// Assert
assertThat(got).containsExactly(Tag.PRON, Tag.CONJ, Tag.VERB, Tag.CONJ, Tag.VERB,
Tag.DET, Tag.NOUN, Tag.PUNCT, Tag.NOUN, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.CONJ,
Tag.ADV, Tag.PRON, Tag.VERB, Tag.VERB, Tag.VERB, Tag.ADJ, Tag.PUNCT, Tag.DET,
Tag.NOUN, Tag.VERB, Tag.ADV, Tag.ADJ,Tag.PUNCT).inOrder();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.language.v1.Entity;
import com.google.cloud.language.v1.Entity.Builder;
import com.google.cloud.language.v1.Entity.Type;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down
12 changes: 12 additions & 0 deletions language/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
<artifactId>google-cloud-language</artifactId>
<version>0.20.0-beta</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>

<!-- FIXME: remove after client fixes depenency issue -->
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>0.6.0</version>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down