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

feat: [language] Add support for V1 and V2 classification models for the V1Beta2 API #8431

Merged
merged 4 commits into from
Sep 21, 2022
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
50 changes: 4 additions & 46 deletions java-language/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,28 @@ Java idiomatic client for [Natural Language][product-docs].

## Quickstart

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

```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.1.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-language</artifactId>
</dependency>

```

If you are using Maven without BOM, add this to your dependencies:
If you are using Maven, add this to your pom.xml file:


```xml
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-language</artifactId>
<version>2.3.2</version>
<version>2.3.4</version>
</dependency>

```

If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.1.1')

implementation 'com.google.cloud:google-cloud-language'
```
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-language:2.3.3'
implementation 'com.google.cloud:google-cloud-language:2.3.4'
```

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

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-language" % "2.3.3"
libraryDependencies += "com.google.cloud" % "google-cloud-language" % "2.3.4"
```

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



## Samples

Samples are in the [`samples/`](https://github.com/googleapis/java-language/tree/main/samples) directory.

| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| 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) |
| 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) |
| 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) |
| 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) |



## Troubleshooting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public LanguageServiceStub getStub() {
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeSentimentResponse analyzeSentiment(Document document) {
Expand Down Expand Up @@ -218,7 +218,7 @@ public final AnalyzeSentimentResponse analyzeSentiment(Document document) {
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @param encodingType The encoding type used by the API to calculate sentence offsets.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -310,7 +310,7 @@ public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest r
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
Expand Down Expand Up @@ -340,7 +340,7 @@ public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @param encodingType The encoding type used by the API to calculate offsets.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -436,7 +436,7 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document) {
Expand Down Expand Up @@ -467,7 +467,7 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document docu
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @param encodingType The encoding type used by the API to calculate offsets.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -565,7 +565,7 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
Expand Down Expand Up @@ -593,7 +593,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @param encodingType The encoding type used by the API to calculate offsets.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -684,7 +684,7 @@ public final UnaryCallable<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse> analyzeS
* }
* }</pre>
*
* @param document Input document.
* @param document Required. Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ClassifyTextResponse classifyText(Document document) {
Expand All @@ -706,7 +706,10 @@ public final ClassifyTextResponse classifyText(Document document) {
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* ClassifyTextRequest request =
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
* ClassifyTextRequest.newBuilder()
* .setDocument(Document.newBuilder().build())
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
* .build();
* ClassifyTextResponse response = languageServiceClient.classifyText(request);
* }
* }</pre>
Expand All @@ -732,7 +735,10 @@ public final ClassifyTextResponse classifyText(ClassifyTextRequest request) {
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* ClassifyTextRequest request =
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
* ClassifyTextRequest.newBuilder()
* .setDocument(Document.newBuilder().build())
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
* .build();
* ApiFuture<ClassifyTextResponse> future =
* languageServiceClient.classifyTextCallable().futureCall(request);
* // Do something.
Expand Down Expand Up @@ -764,8 +770,8 @@ public final UnaryCallable<ClassifyTextRequest, ClassifyTextResponse> classifyTe
* }
* }</pre>
*
* @param document Input document.
* @param features The enabled features.
* @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(
Expand Down Expand Up @@ -797,8 +803,8 @@ public final AnnotateTextResponse annotateText(
* }
* }</pre>
*
* @param document Input document.
* @param features The enabled features.
* @param document Required. Input document.
* @param features Required. The enabled features.
* @param encodingType The encoding type used by the API to calculate offsets.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

/**
* The interfaces provided are listed below, along with usage samples.
* A client to Cloud Natural Language API
*
* <p>The interfaces provided are listed below, along with usage samples.
*
* <p>======================= LanguageServiceClient =======================
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
// 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.
* part of speech tags, dependency trees, and other properties.
*
* <p>Sample code:
*
Expand All @@ -579,7 +579,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
// 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.
* part of speech tags, dependency trees, and other properties.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -612,7 +612,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType
// 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.
* part of speech tags, dependency trees, and other properties.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -642,7 +642,7 @@ public final AnalyzeSyntaxResponse analyzeSyntax(AnalyzeSyntaxRequest 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.
* part of speech tags, dependency trees, and other properties.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -709,7 +709,10 @@ public final ClassifyTextResponse classifyText(Document document) {
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* ClassifyTextRequest request =
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
* ClassifyTextRequest.newBuilder()
* .setDocument(Document.newBuilder().build())
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
* .build();
* ClassifyTextResponse response = languageServiceClient.classifyText(request);
* }
* }</pre>
Expand All @@ -735,7 +738,10 @@ public final ClassifyTextResponse classifyText(ClassifyTextRequest request) {
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* ClassifyTextRequest request =
* ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
* ClassifyTextRequest.newBuilder()
* .setDocument(Document.newBuilder().build())
* .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
* .build();
* ApiFuture<ClassifyTextResponse> future =
* languageServiceClient.classifyTextCallable().futureCall(request);
* // Do something.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

/**
* The interfaces provided are listed below, along with usage samples.
* A client to Cloud Natural Language API
*
* <p>The interfaces provided are listed below, along with usage samples.
*
* <p>======================= LanguageServiceClient =======================
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,10 @@ public void analyzeEntities(
*
*
* <pre>
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
* sentiment associated with each entity and its mentions.
* Finds entities, similar to
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
* in the text and analyzes sentiment associated with each entity and its
* mentions.
* </pre>
*/
public void analyzeEntitySentiment(
Expand Down Expand Up @@ -576,8 +578,10 @@ public void analyzeEntities(
*
*
* <pre>
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
* sentiment associated with each entity and its mentions.
* Finds entities, similar to
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
* in the text and analyzes sentiment associated with each entity and its
* mentions.
* </pre>
*/
public void analyzeEntitySentiment(
Expand Down Expand Up @@ -697,8 +701,10 @@ public com.google.cloud.language.v1.AnalyzeEntitiesResponse analyzeEntities(
*
*
* <pre>
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
* sentiment associated with each entity and its mentions.
* Finds entities, similar to
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
* in the text and analyzes sentiment associated with each entity and its
* mentions.
* </pre>
*/
public com.google.cloud.language.v1.AnalyzeEntitySentimentResponse analyzeEntitySentiment(
Expand Down Expand Up @@ -804,8 +810,10 @@ protected LanguageServiceFutureStub build(
*
*
* <pre>
* Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes
* sentiment associated with each entity and its mentions.
* Finds entities, similar to
* [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
* in the text and analyzes sentiment associated with each entity and its
* mentions.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public void analyzeEntitySentiment(
*
* <pre>
* Analyzes the syntax of the text and provides sentence boundaries and
* tokenization along with part-of-speech tags, dependency trees, and other
* tokenization along with part of speech tags, dependency trees, and other
* properties.
* </pre>
*/
Expand Down Expand Up @@ -597,7 +597,7 @@ public void analyzeEntitySentiment(
*
* <pre>
* Analyzes the syntax of the text and provides sentence boundaries and
* tokenization along with part-of-speech tags, dependency trees, and other
* tokenization along with part of speech tags, dependency trees, and other
* properties.
* </pre>
*/
Expand Down Expand Up @@ -714,7 +714,7 @@ public com.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse analyzeE
*
* <pre>
* Analyzes the syntax of the text and provides sentence boundaries and
* tokenization along with part-of-speech tags, dependency trees, and other
* tokenization along with part of speech tags, dependency trees, and other
* properties.
* </pre>
*/
Expand Down Expand Up @@ -823,7 +823,7 @@ protected LanguageServiceFutureStub build(
*
* <pre>
* Analyzes the syntax of the text and provides sentence boundaries and
* tokenization along with part-of-speech tags, dependency trees, and other
* tokenization along with part of speech tags, dependency trees, and other
* properties.
* </pre>
*/
Expand Down
Loading