diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java
index 592ea973..7136714c 100644
--- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java
+++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java
@@ -36,7 +36,8 @@
*
* 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);
* }
*
*
@@ -146,6 +147,35 @@ public LanguageServiceStub getStub() {
return stub;
}
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Analyzes the sentiment of the provided text.
+ *
+ *
Sample code:
+ *
+ *
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ * Document document = Document.newBuilder().build();
+ * EncodingType encodingType = EncodingType.NONE;
+ * AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document, encodingType);
+ * }
+ *
+ *
+ * @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.
@@ -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.
+ *
+ * Sample code:
+ *
+ *
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ * Document document = Document.newBuilder().build();
+ * AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
+ * }
+ *
+ *
+ * @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
@@ -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.
+ *
+ * Sample code:
+ *
+ *
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ * Document document = Document.newBuilder().build();
+ * AnalyzeEntitySentimentResponse response = languageServiceClient.analyzeEntitySentiment(document);
+ * }
+ *
+ *
+ * @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
@@ -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.
+ *
+ * Sample code:
+ *
+ *
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ * Document document = Document.newBuilder().build();
+ * AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
+ * }
+ *
+ *
+ * @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
@@ -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.
+ *
+ * Sample code:
+ *
+ *
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ * Document document = Document.newBuilder().build();
+ * AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+ * AnnotateTextResponse response = languageServiceClient.annotateText(document, 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(
+ 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
diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java
index ec6666fd..d45907c2 100644
--- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java
+++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java
@@ -30,7 +30,8 @@
*
* 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);
* }
*
*
diff --git a/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceClientTest.java b/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceClientTest.java
index 3b5d1248..92d97947 100644
--- a/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceClientTest.java
+++ b/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceClientTest.java
@@ -83,8 +83,9 @@ public void analyzeSentimentTest() {
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
- AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document);
+ AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List actualRequests = mockLanguageService.getRequests();
@@ -92,6 +93,7 @@ public void analyzeSentimentTest() {
AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
+ Assert.assertEquals(encodingType, actualRequest.getEncodingType());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -106,8 +108,52 @@ public void analyzeSentimentExceptionTest() throws Exception {
try {
Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
- client.analyzeSentiment(document);
+ client.analyzeSentiment(document, encodingType);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception
+ }
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeSentimentTest2() {
+ String language = "language-1613589672";
+ AnalyzeSentimentResponse expectedResponse =
+ AnalyzeSentimentResponse.newBuilder().setLanguage(language).build();
+ mockLanguageService.addResponse(expectedResponse);
+
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document, encodingType);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockLanguageService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0);
+
+ Assert.assertEquals(document, actualRequest.getDocument());
+ Assert.assertEquals(encodingType, actualRequest.getEncodingType());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeSentimentExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
+ mockLanguageService.addException(exception);
+
+ try {
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ client.analyzeSentiment(document, encodingType);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
@@ -157,6 +203,49 @@ public void analyzeEntitiesExceptionTest() throws Exception {
}
}
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeEntitiesTest2() {
+ String language = "language-1613589672";
+ AnalyzeEntitiesResponse expectedResponse =
+ AnalyzeEntitiesResponse.newBuilder().setLanguage(language).build();
+ mockLanguageService.addResponse(expectedResponse);
+
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ AnalyzeEntitiesResponse actualResponse = client.analyzeEntities(document, encodingType);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockLanguageService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ AnalyzeEntitiesRequest actualRequest = (AnalyzeEntitiesRequest) actualRequests.get(0);
+
+ Assert.assertEquals(document, actualRequest.getDocument());
+ Assert.assertEquals(encodingType, actualRequest.getEncodingType());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeEntitiesExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
+ mockLanguageService.addException(exception);
+
+ try {
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ client.analyzeEntities(document, encodingType);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception
+ }
+ }
+
@Test
@SuppressWarnings("all")
public void analyzeEntitySentimentTest() {
@@ -202,6 +291,51 @@ public void analyzeEntitySentimentExceptionTest() throws Exception {
}
}
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeEntitySentimentTest2() {
+ String language = "language-1613589672";
+ AnalyzeEntitySentimentResponse expectedResponse =
+ AnalyzeEntitySentimentResponse.newBuilder().setLanguage(language).build();
+ mockLanguageService.addResponse(expectedResponse);
+
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ AnalyzeEntitySentimentResponse actualResponse =
+ client.analyzeEntitySentiment(document, encodingType);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockLanguageService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ AnalyzeEntitySentimentRequest actualRequest =
+ (AnalyzeEntitySentimentRequest) actualRequests.get(0);
+
+ Assert.assertEquals(document, actualRequest.getDocument());
+ Assert.assertEquals(encodingType, actualRequest.getEncodingType());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeEntitySentimentExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
+ mockLanguageService.addException(exception);
+
+ try {
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ client.analyzeEntitySentiment(document, encodingType);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception
+ }
+ }
+
@Test
@SuppressWarnings("all")
public void analyzeSyntaxTest() {
@@ -245,6 +379,49 @@ public void analyzeSyntaxExceptionTest() throws Exception {
}
}
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeSyntaxTest2() {
+ String language = "language-1613589672";
+ AnalyzeSyntaxResponse expectedResponse =
+ AnalyzeSyntaxResponse.newBuilder().setLanguage(language).build();
+ mockLanguageService.addResponse(expectedResponse);
+
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ AnalyzeSyntaxResponse actualResponse = client.analyzeSyntax(document, encodingType);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockLanguageService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ AnalyzeSyntaxRequest actualRequest = (AnalyzeSyntaxRequest) actualRequests.get(0);
+
+ Assert.assertEquals(document, actualRequest.getDocument());
+ Assert.assertEquals(encodingType, actualRequest.getEncodingType());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void analyzeSyntaxExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
+ mockLanguageService.addException(exception);
+
+ try {
+ Document document = Document.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ client.analyzeSyntax(document, encodingType);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception
+ }
+ }
+
@Test
@SuppressWarnings("all")
public void classifyTextTest() {
@@ -328,4 +505,50 @@ public void annotateTextExceptionTest() throws Exception {
// Expected exception
}
}
+
+ @Test
+ @SuppressWarnings("all")
+ public void annotateTextTest2() {
+ String language = "language-1613589672";
+ AnnotateTextResponse expectedResponse =
+ AnnotateTextResponse.newBuilder().setLanguage(language).build();
+ mockLanguageService.addResponse(expectedResponse);
+
+ Document document = Document.newBuilder().build();
+ AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ AnnotateTextResponse actualResponse = client.annotateText(document, features, encodingType);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockLanguageService.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ AnnotateTextRequest actualRequest = (AnnotateTextRequest) actualRequests.get(0);
+
+ Assert.assertEquals(document, actualRequest.getDocument());
+ Assert.assertEquals(features, actualRequest.getFeatures());
+ Assert.assertEquals(encodingType, actualRequest.getEncodingType());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ @SuppressWarnings("all")
+ public void annotateTextExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
+ mockLanguageService.addException(exception);
+
+ try {
+ Document document = Document.newBuilder().build();
+ AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+ EncodingType encodingType = EncodingType.NONE;
+
+ client.annotateText(document, features, encodingType);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception
+ }
+ }
}
diff --git a/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceSmokeTest.java b/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceSmokeTest.java
index e659741a..c41c8a2f 100644
--- a/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceSmokeTest.java
+++ b/google-cloud-language/src/test/java/com/google/cloud/language/v1beta2/LanguageServiceSmokeTest.java
@@ -47,8 +47,9 @@ public static void executeNoCatch() throws Exception {
String content = "Hello, world!";
Document.Type type = Document.Type.PLAIN_TEXT;
Document document = Document.newBuilder().setContent(content).setType(type).build();
+ EncodingType encodingType = EncodingType.NONE;
- AnalyzeSentimentResponse response = client.analyzeSentiment(document);
+ AnalyzeSentimentResponse response = client.analyzeSentiment(document, encodingType);
}
}
diff --git a/synth.metadata b/synth.metadata
index 52645f1a..a38339c7 100644
--- a/synth.metadata
+++ b/synth.metadata
@@ -11,16 +11,16 @@
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
- "sha": "d741cd976975c745d0199987aff0e908b8352992",
- "internalRef": "305561906"
+ "sha": "df955af5d9508cf9215de6f1fbdad033d5b8fef6",
+ "internalRef": "306297639"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
- "sha": "d741cd976975c745d0199987aff0e908b8352992",
- "internalRef": "305561906"
+ "sha": "df955af5d9508cf9215de6f1fbdad033d5b8fef6",
+ "internalRef": "306297639"
}
},
{