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

Update NL client lib. #398

Merged
merged 1 commit into from
Nov 4, 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 language/analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-language</artifactId>
<version>v1beta1-rev11-1.22.0</version>
<version>v1beta1-rev13-1.22.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.language.v1beta1.CloudNaturalLanguageAPI;
import com.google.api.services.language.v1beta1.CloudNaturalLanguageAPIScopes;
import com.google.api.services.language.v1beta1.CloudNaturalLanguage;
import com.google.api.services.language.v1beta1.CloudNaturalLanguageScopes;
import com.google.api.services.language.v1beta1.model.AnalyzeEntitiesRequest;
import com.google.api.services.language.v1beta1.model.AnalyzeEntitiesResponse;
import com.google.api.services.language.v1beta1.model.AnalyzeSentimentRequest;
Expand Down Expand Up @@ -136,12 +136,12 @@ public static void printSyntax(PrintStream out, List<Token> tokens) {
/**
* Connects to the Natural Language API using Application Default Credentials.
*/
public static CloudNaturalLanguageAPI getLanguageService()
public static CloudNaturalLanguage getLanguageService()
throws IOException, GeneralSecurityException {
GoogleCredential credential =
GoogleCredential.getApplicationDefault().createScoped(CloudNaturalLanguageAPIScopes.all());
GoogleCredential.getApplicationDefault().createScoped(CloudNaturalLanguageScopes.all());
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
return new CloudNaturalLanguageAPI.Builder(
return new CloudNaturalLanguage.Builder(
GoogleNetHttpTransport.newTrustedTransport(),
jsonFactory, new HttpRequestInitializer() {
@Override
Expand All @@ -153,12 +153,12 @@ public void initialize(HttpRequest request) throws IOException {
.build();
}

private final CloudNaturalLanguageAPI languageApi;
private final CloudNaturalLanguage languageApi;

/**
* Constructs a {@link Analyze} which connects to the Cloud Natural Language API.
*/
public Analyze(CloudNaturalLanguageAPI languageApi) {
public Analyze(CloudNaturalLanguage languageApi) {
this.languageApi = languageApi;
}

Expand All @@ -170,7 +170,7 @@ public List<Entity> analyzeEntities(String text) throws IOException {
new AnalyzeEntitiesRequest()
.setDocument(new Document().setContent(text).setType("PLAIN_TEXT"))
.setEncodingType("UTF16");
CloudNaturalLanguageAPI.Documents.AnalyzeEntities analyze =
CloudNaturalLanguage.Documents.AnalyzeEntities analyze =
languageApi.documents().analyzeEntities(request);

AnalyzeEntitiesResponse response = analyze.execute();
Expand All @@ -184,7 +184,7 @@ public Sentiment analyzeSentiment(String text) throws IOException {
AnalyzeSentimentRequest request =
new AnalyzeSentimentRequest()
.setDocument(new Document().setContent(text).setType("PLAIN_TEXT"));
CloudNaturalLanguageAPI.Documents.AnalyzeSentiment analyze =
CloudNaturalLanguage.Documents.AnalyzeSentiment analyze =
languageApi.documents().analyzeSentiment(request);

AnalyzeSentimentResponse response = analyze.execute();
Expand All @@ -200,7 +200,7 @@ public List<Token> analyzeSyntax(String text) throws IOException {
.setDocument(new Document().setContent(text).setType("PLAIN_TEXT"))
.setFeatures(new Features().setExtractSyntax(true))
.setEncodingType("UTF16");
CloudNaturalLanguageAPI.Documents.AnnotateText analyze =
CloudNaturalLanguage.Documents.AnnotateText analyze =
languageApi.documents().annotateText(request);

AnnotateTextResponse response = analyze.execute();
Expand Down