Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: add method overloads for Document+EncodingType for analyze meth…
…ods (#120)

Committer: @miraleung
PiperOrigin-RevId: 306297639

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Apr 13 13:28:34 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: df955af5d9508cf9215de6f1fbdad033d5b8fef6
Source-Link: googleapis/googleapis@df955af

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
yoshi-automation and chingor13 committed Apr 20, 2020
1 parent fc8f3f7 commit 60ef073
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 9 deletions.
Expand Up @@ -36,7 +36,8 @@
* <code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
* EncodingType encodingType = EncodingType.NONE;
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
* }
* </code>
* </pre>
Expand Down Expand Up @@ -146,6 +147,35 @@ public LanguageServiceStub getStub() {
return stub;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Analyzes the sentiment of the provided text.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* EncodingType encodingType = EncodingType.NONE;
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
* }
* </code></pre>
*
* @param document Required. Input document.
* @param encodingType The encoding type used by the API to calculate sentence offsets for the
* sentence sentiment.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeSentimentResponse analyzeSentiment(
Document document, EncodingType encodingType) {
AnalyzeSentimentRequest request =
AnalyzeSentimentRequest.newBuilder()
.setDocument(document)
.setEncodingType(encodingType)
.build();
return analyzeSentiment(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Analyzes the sentiment of the provided text.
Expand Down Expand Up @@ -243,6 +273,29 @@ public final AnalyzeEntitiesResponse analyzeEntities(
return analyzeEntities(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Finds named entities (currently proper names and common nouns) in the text along with entity
* types, salience, mentions for each entity, and other properties.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
* }
* </code></pre>
*
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
AnalyzeEntitiesRequest request =
AnalyzeEntitiesRequest.newBuilder().setDocument(document).build();
return analyzeEntities(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Finds named entities (currently proper names and common nouns) in the text along with entity
Expand Down Expand Up @@ -321,6 +374,30 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
return analyzeEntitySentiment(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Finds entities, similar to
* [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
* and analyzes sentiment associated with each entity and its mentions.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* AnalyzeEntitySentimentResponse response = languageServiceClient.analyzeEntitySentiment(document);
* }
* </code></pre>
*
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document) {
AnalyzeEntitySentimentRequest request =
AnalyzeEntitySentimentRequest.newBuilder().setDocument(document).build();
return analyzeEntitySentiment(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Finds entities, similar to
Expand Down Expand Up @@ -400,6 +477,28 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType
return analyzeSyntax(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
* part-of-speech tags, dependency trees, and other properties.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
* }
* </code></pre>
*
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
AnalyzeSyntaxRequest request = AnalyzeSyntaxRequest.newBuilder().setDocument(document).build();
return analyzeSyntax(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
Expand Down Expand Up @@ -545,6 +644,32 @@ public final AnnotateTextResponse annotateText(
return annotateText(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* A convenience method that provides all syntax, sentiment, entity, and classification features
* in one call.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
* AnnotateTextResponse response = languageServiceClient.annotateText(document, features);
* }
* </code></pre>
*
* @param document Required. Input document.
* @param features Required. The enabled features.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnnotateTextResponse annotateText(
Document document, AnnotateTextRequest.Features features) {
AnnotateTextRequest request =
AnnotateTextRequest.newBuilder().setDocument(document).setFeatures(features).build();
return annotateText(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* A convenience method that provides all syntax, sentiment, entity, and classification features
Expand Down
Expand Up @@ -30,7 +30,8 @@
* <code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
* EncodingType encodingType = EncodingType.NONE;
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
* }
* </code>
* </pre>
Expand Down

0 comments on commit 60ef073

Please sign in to comment.