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

Commit 60ef073

Browse files
feat: add method overloads for Document+EncodingType for analyze methods (#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>
1 parent fc8f3f7 commit 60ef073

File tree

5 files changed

+359
-9
lines changed

5 files changed

+359
-9
lines changed

google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
* <code>
3737
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
3838
* Document document = Document.newBuilder().build();
39-
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
39+
* EncodingType encodingType = EncodingType.NONE;
40+
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
4041
* }
4142
* </code>
4243
* </pre>
@@ -146,6 +147,35 @@ public LanguageServiceStub getStub() {
146147
return stub;
147148
}
148149

150+
// AUTO-GENERATED DOCUMENTATION AND METHOD
151+
/**
152+
* Analyzes the sentiment of the provided text.
153+
*
154+
* <p>Sample code:
155+
*
156+
* <pre><code>
157+
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
158+
* Document document = Document.newBuilder().build();
159+
* EncodingType encodingType = EncodingType.NONE;
160+
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
161+
* }
162+
* </code></pre>
163+
*
164+
* @param document Required. Input document.
165+
* @param encodingType The encoding type used by the API to calculate sentence offsets for the
166+
* sentence sentiment.
167+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
168+
*/
169+
public final AnalyzeSentimentResponse analyzeSentiment(
170+
Document document, EncodingType encodingType) {
171+
AnalyzeSentimentRequest request =
172+
AnalyzeSentimentRequest.newBuilder()
173+
.setDocument(document)
174+
.setEncodingType(encodingType)
175+
.build();
176+
return analyzeSentiment(request);
177+
}
178+
149179
// AUTO-GENERATED DOCUMENTATION AND METHOD
150180
/**
151181
* Analyzes the sentiment of the provided text.
@@ -243,6 +273,29 @@ public final AnalyzeEntitiesResponse analyzeEntities(
243273
return analyzeEntities(request);
244274
}
245275

276+
// AUTO-GENERATED DOCUMENTATION AND METHOD
277+
/**
278+
* Finds named entities (currently proper names and common nouns) in the text along with entity
279+
* types, salience, mentions for each entity, and other properties.
280+
*
281+
* <p>Sample code:
282+
*
283+
* <pre><code>
284+
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
285+
* Document document = Document.newBuilder().build();
286+
* AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
287+
* }
288+
* </code></pre>
289+
*
290+
* @param document Required. Input document.
291+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
292+
*/
293+
public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
294+
AnalyzeEntitiesRequest request =
295+
AnalyzeEntitiesRequest.newBuilder().setDocument(document).build();
296+
return analyzeEntities(request);
297+
}
298+
246299
// AUTO-GENERATED DOCUMENTATION AND METHOD
247300
/**
248301
* Finds named entities (currently proper names and common nouns) in the text along with entity
@@ -321,6 +374,30 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
321374
return analyzeEntitySentiment(request);
322375
}
323376

377+
// AUTO-GENERATED DOCUMENTATION AND METHOD
378+
/**
379+
* Finds entities, similar to
380+
* [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
381+
* and analyzes sentiment associated with each entity and its mentions.
382+
*
383+
* <p>Sample code:
384+
*
385+
* <pre><code>
386+
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
387+
* Document document = Document.newBuilder().build();
388+
* AnalyzeEntitySentimentResponse response = languageServiceClient.analyzeEntitySentiment(document);
389+
* }
390+
* </code></pre>
391+
*
392+
* @param document Required. Input document.
393+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
394+
*/
395+
public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document) {
396+
AnalyzeEntitySentimentRequest request =
397+
AnalyzeEntitySentimentRequest.newBuilder().setDocument(document).build();
398+
return analyzeEntitySentiment(request);
399+
}
400+
324401
// AUTO-GENERATED DOCUMENTATION AND METHOD
325402
/**
326403
* Finds entities, similar to
@@ -400,6 +477,28 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType
400477
return analyzeSyntax(request);
401478
}
402479

480+
// AUTO-GENERATED DOCUMENTATION AND METHOD
481+
/**
482+
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
483+
* part-of-speech tags, dependency trees, and other properties.
484+
*
485+
* <p>Sample code:
486+
*
487+
* <pre><code>
488+
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
489+
* Document document = Document.newBuilder().build();
490+
* AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
491+
* }
492+
* </code></pre>
493+
*
494+
* @param document Required. Input document.
495+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
496+
*/
497+
public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
498+
AnalyzeSyntaxRequest request = AnalyzeSyntaxRequest.newBuilder().setDocument(document).build();
499+
return analyzeSyntax(request);
500+
}
501+
403502
// AUTO-GENERATED DOCUMENTATION AND METHOD
404503
/**
405504
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
@@ -545,6 +644,32 @@ public final AnnotateTextResponse annotateText(
545644
return annotateText(request);
546645
}
547646

647+
// AUTO-GENERATED DOCUMENTATION AND METHOD
648+
/**
649+
* A convenience method that provides all syntax, sentiment, entity, and classification features
650+
* in one call.
651+
*
652+
* <p>Sample code:
653+
*
654+
* <pre><code>
655+
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
656+
* Document document = Document.newBuilder().build();
657+
* AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
658+
* AnnotateTextResponse response = languageServiceClient.annotateText(document, features);
659+
* }
660+
* </code></pre>
661+
*
662+
* @param document Required. Input document.
663+
* @param features Required. The enabled features.
664+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
665+
*/
666+
public final AnnotateTextResponse annotateText(
667+
Document document, AnnotateTextRequest.Features features) {
668+
AnnotateTextRequest request =
669+
AnnotateTextRequest.newBuilder().setDocument(document).setFeatures(features).build();
670+
return annotateText(request);
671+
}
672+
548673
// AUTO-GENERATED DOCUMENTATION AND METHOD
549674
/**
550675
* A convenience method that provides all syntax, sentiment, entity, and classification features

google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
* <code>
3131
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
3232
* Document document = Document.newBuilder().build();
33-
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
33+
* EncodingType encodingType = EncodingType.NONE;
34+
* AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
3435
* }
3536
* </code>
3637
* </pre>

0 commit comments

Comments
 (0)