Skip to content

Commit 8f2889b

Browse files
feat: [language] Add support for V1 and V2 classification models for the V1Beta2 API (#8431)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 475604619 Source-Link: googleapis/googleapis@044a15c Source-Link: https://github.com/googleapis/googleapis-gen/commit/410020af934c7248f7804770d6f8ec4571bfa551 Copy-Tag: eyJwIjoiamF2YS1sYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiNDEwMDIwYWY5MzRjNzI0OGY3ODA0NzcwZDZmOGVjNDU3MWJmYTU1MSJ9 feat: [language] Add support for V1 and V2 classification models for the V1 API PiperOrigin-RevId: 475599241 Source-Link: googleapis/googleapis@05b99f9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/3dcdbed8d968f634be0a2d3107237d232ee8b061 Copy-Tag: eyJwIjoiamF2YS1sYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiM2RjZGJlZDhkOTY4ZjYzNGJlMGEyZDMxMDcyMzdkMjMyZWU4YjA2MSJ9
1 parent d56d8e4 commit 8f2889b

File tree

60 files changed

+8831
-855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+8831
-855
lines changed

java-language/README.md

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,28 @@ Java idiomatic client for [Natural Language][product-docs].
1111

1212
## Quickstart
1313

14-
If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
1514

16-
```xml
17-
<dependencyManagement>
18-
<dependencies>
19-
<dependency>
20-
<groupId>com.google.cloud</groupId>
21-
<artifactId>libraries-bom</artifactId>
22-
<version>26.1.1</version>
23-
<type>pom</type>
24-
<scope>import</scope>
25-
</dependency>
26-
</dependencies>
27-
</dependencyManagement>
28-
29-
<dependencies>
30-
<dependency>
31-
<groupId>com.google.cloud</groupId>
32-
<artifactId>google-cloud-language</artifactId>
33-
</dependency>
34-
35-
```
36-
37-
If you are using Maven without BOM, add this to your dependencies:
15+
If you are using Maven, add this to your pom.xml file:
3816

3917

4018
```xml
4119
<dependency>
4220
<groupId>com.google.cloud</groupId>
4321
<artifactId>google-cloud-language</artifactId>
44-
<version>2.3.2</version>
22+
<version>2.3.4</version>
4523
</dependency>
46-
4724
```
4825

49-
If you are using Gradle 5.x or later, add this to your dependencies:
50-
51-
```Groovy
52-
implementation platform('com.google.cloud:libraries-bom:26.1.1')
53-
54-
implementation 'com.google.cloud:google-cloud-language'
55-
```
5626
If you are using Gradle without BOM, add this to your dependencies:
5727

5828
```Groovy
59-
implementation 'com.google.cloud:google-cloud-language:2.3.3'
29+
implementation 'com.google.cloud:google-cloud-language:2.3.4'
6030
```
6131

6232
If you are using SBT, add this to your dependencies:
6333

6434
```Scala
65-
libraryDependencies += "com.google.cloud" % "google-cloud-language" % "2.3.3"
35+
libraryDependencies += "com.google.cloud" % "google-cloud-language" % "2.3.4"
6636
```
6737

6838
## Authentication
@@ -132,18 +102,6 @@ In [AnalyzeSentiment.java](https://github.com/googleapis/google-cloud-java/blob/
132102

133103

134104

135-
## Samples
136-
137-
Samples are in the [`samples/`](https://github.com/googleapis/java-language/tree/main/samples) directory.
138-
139-
| Sample | Source Code | Try it |
140-
| --------------------------- | --------------------------------- | ------ |
141-
| Analyze Beta | [source code](https://github.com/googleapis/java-language/blob/main/samples/snippets/src/main/java/beta/example/language/AnalyzeBeta.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-language&page=editor&open_in_editor=samples/snippets/src/main/java/beta/example/language/AnalyzeBeta.java) |
142-
| Analyze | [source code](https://github.com/googleapis/java-language/blob/main/samples/snippets/src/main/java/com/example/language/Analyze.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-language&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/language/Analyze.java) |
143-
| Quickstart Sample | [source code](https://github.com/googleapis/java-language/blob/main/samples/snippets/src/main/java/com/example/language/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-language&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/language/QuickstartSample.java) |
144-
| Set Endpoint | [source code](https://github.com/googleapis/java-language/blob/main/samples/snippets/src/main/java/com/example/language/SetEndpoint.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-language&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/language/SetEndpoint.java) |
145-
146-
147105

148106
## Troubleshooting
149107

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public LanguageServiceStub getStub() {
189189
* }
190190
* }</pre>
191191
*
192-
* @param document Input document.
192+
* @param document Required. Input document.
193193
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
194194
*/
195195
public final AnalyzeSentimentResponse analyzeSentiment(Document document) {
@@ -218,7 +218,7 @@ public final AnalyzeSentimentResponse analyzeSentiment(Document document) {
218218
* }
219219
* }</pre>
220220
*
221-
* @param document Input document.
221+
* @param document Required. Input document.
222222
* @param encodingType The encoding type used by the API to calculate sentence offsets.
223223
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
224224
*/
@@ -310,7 +310,7 @@ public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest r
310310
* }
311311
* }</pre>
312312
*
313-
* @param document Input document.
313+
* @param document Required. Input document.
314314
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
315315
*/
316316
public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
@@ -340,7 +340,7 @@ public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
340340
* }
341341
* }</pre>
342342
*
343-
* @param document Input document.
343+
* @param document Required. Input document.
344344
* @param encodingType The encoding type used by the API to calculate offsets.
345345
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
346346
*/
@@ -436,7 +436,7 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ
436436
* }
437437
* }</pre>
438438
*
439-
* @param document Input document.
439+
* @param document Required. Input document.
440440
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
441441
*/
442442
public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document) {
@@ -467,7 +467,7 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document docu
467467
* }
468468
* }</pre>
469469
*
470-
* @param document Input document.
470+
* @param document Required. Input document.
471471
* @param encodingType The encoding type used by the API to calculate offsets.
472472
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
473473
*/
@@ -565,7 +565,7 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
565565
* }
566566
* }</pre>
567567
*
568-
* @param document Input document.
568+
* @param document Required. Input document.
569569
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
570570
*/
571571
public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
@@ -593,7 +593,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
593593
* }
594594
* }</pre>
595595
*
596-
* @param document Input document.
596+
* @param document Required. Input document.
597597
* @param encodingType The encoding type used by the API to calculate offsets.
598598
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
599599
*/
@@ -684,7 +684,7 @@ public final UnaryCallable<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse> analyzeS
684684
* }
685685
* }</pre>
686686
*
687-
* @param document Input document.
687+
* @param document Required. Input document.
688688
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
689689
*/
690690
public final ClassifyTextResponse classifyText(Document document) {
@@ -706,7 +706,10 @@ public final ClassifyTextResponse classifyText(Document document) {
706706
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
707707
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
708708
* ClassifyTextRequest request =
709-
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
709+
* ClassifyTextRequest.newBuilder()
710+
* .setDocument(Document.newBuilder().build())
711+
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
712+
* .build();
710713
* ClassifyTextResponse response = languageServiceClient.classifyText(request);
711714
* }
712715
* }</pre>
@@ -732,7 +735,10 @@ public final ClassifyTextResponse classifyText(ClassifyTextRequest request) {
732735
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
733736
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
734737
* ClassifyTextRequest request =
735-
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
738+
* ClassifyTextRequest.newBuilder()
739+
* .setDocument(Document.newBuilder().build())
740+
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
741+
* .build();
736742
* ApiFuture<ClassifyTextResponse> future =
737743
* languageServiceClient.classifyTextCallable().futureCall(request);
738744
* // Do something.
@@ -764,8 +770,8 @@ public final UnaryCallable<ClassifyTextRequest, ClassifyTextResponse> classifyTe
764770
* }
765771
* }</pre>
766772
*
767-
* @param document Input document.
768-
* @param features The enabled features.
773+
* @param document Required. Input document.
774+
* @param features Required. The enabled features.
769775
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
770776
*/
771777
public final AnnotateTextResponse annotateText(
@@ -797,8 +803,8 @@ public final AnnotateTextResponse annotateText(
797803
* }
798804
* }</pre>
799805
*
800-
* @param document Input document.
801-
* @param features The enabled features.
806+
* @param document Required. Input document.
807+
* @param features Required. The enabled features.
802808
* @param encodingType The encoding type used by the API to calculate offsets.
803809
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
804810
*/

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
/**
18-
* The interfaces provided are listed below, along with usage samples.
18+
* A client to Cloud Natural Language API
19+
*
20+
* <p>The interfaces provided are listed below, along with usage samples.
1921
*
2022
* <p>======================= LanguageServiceClient =======================
2123
*

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
552552
// AUTO-GENERATED DOCUMENTATION AND METHOD.
553553
/**
554554
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
555-
* part-of-speech tags, dependency trees, and other properties.
555+
* part of speech tags, dependency trees, and other properties.
556556
*
557557
* <p>Sample code:
558558
*
@@ -579,7 +579,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
579579
// AUTO-GENERATED DOCUMENTATION AND METHOD.
580580
/**
581581
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
582-
* part-of-speech tags, dependency trees, and other properties.
582+
* part of speech tags, dependency trees, and other properties.
583583
*
584584
* <p>Sample code:
585585
*
@@ -612,7 +612,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType
612612
// AUTO-GENERATED DOCUMENTATION AND METHOD.
613613
/**
614614
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
615-
* part-of-speech tags, dependency trees, and other properties.
615+
* part of speech tags, dependency trees, and other properties.
616616
*
617617
* <p>Sample code:
618618
*
@@ -642,7 +642,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(AnalyzeSyntaxRequest request) {
642642
// AUTO-GENERATED DOCUMENTATION AND METHOD.
643643
/**
644644
* Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
645-
* part-of-speech tags, dependency trees, and other properties.
645+
* part of speech tags, dependency trees, and other properties.
646646
*
647647
* <p>Sample code:
648648
*
@@ -709,7 +709,10 @@ public final ClassifyTextResponse classifyText(Document document) {
709709
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
710710
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
711711
* ClassifyTextRequest request =
712-
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
712+
* ClassifyTextRequest.newBuilder()
713+
* .setDocument(Document.newBuilder().build())
714+
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
715+
* .build();
713716
* ClassifyTextResponse response = languageServiceClient.classifyText(request);
714717
* }
715718
* }</pre>
@@ -735,7 +738,10 @@ public final ClassifyTextResponse classifyText(ClassifyTextRequest request) {
735738
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
736739
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
737740
* ClassifyTextRequest request =
738-
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
741+
* ClassifyTextRequest.newBuilder()
742+
* .setDocument(Document.newBuilder().build())
743+
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
744+
* .build();
739745
* ApiFuture<ClassifyTextResponse> future =
740746
* languageServiceClient.classifyTextCallable().futureCall(request);
741747
* // Do something.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
/**
18-
* The interfaces provided are listed below, along with usage samples.
18+
* A client to Cloud Natural Language API
19+
*
20+
* <p>The interfaces provided are listed below, along with usage samples.
1921
*
2022
* <p>======================= LanguageServiceClient =======================
2123
*

java-language/grpc-google-cloud-language-v1/src/main/java/com/google/cloud/language/v1/LanguageServiceGrpc.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,10 @@ public void analyzeEntities(
408408
*
409409
*
410410
* <pre>
411-
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
412-
* sentiment associated with each entity and its mentions.
411+
* Finds entities, similar to
412+
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
413+
* in the text and analyzes sentiment associated with each entity and its
414+
* mentions.
413415
* </pre>
414416
*/
415417
public void analyzeEntitySentiment(
@@ -576,8 +578,10 @@ public void analyzeEntities(
576578
*
577579
*
578580
* <pre>
579-
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
580-
* sentiment associated with each entity and its mentions.
581+
* Finds entities, similar to
582+
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
583+
* in the text and analyzes sentiment associated with each entity and its
584+
* mentions.
581585
* </pre>
582586
*/
583587
public void analyzeEntitySentiment(
@@ -697,8 +701,10 @@ public com.google.cloud.language.v1.AnalyzeEntitiesResponse analyzeEntities(
697701
*
698702
*
699703
* <pre>
700-
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
701-
* sentiment associated with each entity and its mentions.
704+
* Finds entities, similar to
705+
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
706+
* in the text and analyzes sentiment associated with each entity and its
707+
* mentions.
702708
* </pre>
703709
*/
704710
public com.google.cloud.language.v1.AnalyzeEntitySentimentResponse analyzeEntitySentiment(
@@ -804,8 +810,10 @@ protected LanguageServiceFutureStub build(
804810
*
805811
*
806812
* <pre>
807-
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
808-
* sentiment associated with each entity and its mentions.
813+
* Finds entities, similar to
814+
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
815+
* in the text and analyzes sentiment associated with each entity and its
816+
* mentions.
809817
* </pre>
810818
*/
811819
public com.google.common.util.concurrent.ListenableFuture<

java-language/grpc-google-cloud-language-v1beta2/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceGrpc.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public void analyzeEntitySentiment(
426426
*
427427
* <pre>
428428
* Analyzes the syntax of the text and provides sentence boundaries and
429-
* tokenization along with part-of-speech tags, dependency trees, and other
429+
* tokenization along with part of speech tags, dependency trees, and other
430430
* properties.
431431
* </pre>
432432
*/
@@ -597,7 +597,7 @@ public void analyzeEntitySentiment(
597597
*
598598
* <pre>
599599
* Analyzes the syntax of the text and provides sentence boundaries and
600-
* tokenization along with part-of-speech tags, dependency trees, and other
600+
* tokenization along with part of speech tags, dependency trees, and other
601601
* properties.
602602
* </pre>
603603
*/
@@ -714,7 +714,7 @@ public com.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse analyzeE
714714
*
715715
* <pre>
716716
* Analyzes the syntax of the text and provides sentence boundaries and
717-
* tokenization along with part-of-speech tags, dependency trees, and other
717+
* tokenization along with part of speech tags, dependency trees, and other
718718
* properties.
719719
* </pre>
720720
*/
@@ -823,7 +823,7 @@ protected LanguageServiceFutureStub build(
823823
*
824824
* <pre>
825825
* Analyzes the syntax of the text and provides sentence boundaries and
826-
* tokenization along with part-of-speech tags, dependency trees, and other
826+
* tokenization along with part of speech tags, dependency trees, and other
827827
* properties.
828828
* </pre>
829829
*/

0 commit comments

Comments
 (0)