Skip to content

Commit

Permalink
feat: [translate] Added shadow removal and rotation correction option…
Browse files Browse the repository at this point in the history
…s to Document Translation and Batch Document Translation API (#9740)

* feat: Added shadow removal and rotation correction options to Document Translation and Batch Document Translation API

PiperOrigin-RevId: 554540042

Source-Link: googleapis/googleapis@a3aded7

Source-Link: googleapis/googleapis-gen@07b1ee5
Copy-Tag: eyJwIjoiamF2YS10cmFuc2xhdGUvLk93bEJvdC55YW1sIiwiaCI6IjA3YjFlZTU0NGZmMTg4Zjk2ZThlMDhiMzkxODZjZDFlMTA0ZTE5ODQifQ==

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Added shadow removal and rotation correction options to Document Translation and Batch Document Translation API

PiperOrigin-RevId: 554540978

Source-Link: googleapis/googleapis@8cf2ae1

Source-Link: googleapis/googleapis-gen@5a136eb
Copy-Tag: eyJwIjoiamF2YS10cmFuc2xhdGUvLk93bEJvdC55YW1sIiwiaCI6IjVhMTM2ZWJiZWQ4NDdlYjllNzJkZWI2NzJkMDQ4MWZmMDRhYjAzOTgifQ==

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Aug 8, 2023
1 parent e580ede commit 2b945d1
Show file tree
Hide file tree
Showing 37 changed files with 2,161 additions and 621 deletions.
2 changes: 1 addition & 1 deletion java-translate/README.md
Expand Up @@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.20.0</version>
<version>26.21.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Expand Up @@ -343,7 +343,7 @@ public final TranslateTextResponse translateText(
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* <p>For global (non-regionalized) requests, use `location-id` `global`. For example,
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
* <p>If not provided, the default Google model (NMT) will be used.
* <p>If not provided, the default Google model (NMT) will be used
* @param mimeType Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
* @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for
Expand Down Expand Up @@ -417,7 +417,7 @@ public final TranslateTextResponse translateText(
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* <p>For global (non-regionalized) requests, use `location-id` `global`. For example,
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
* <p>If not provided, the default Google model (NMT) will be used.
* <p>If not provided, the default Google model (NMT) will be used
* @param mimeType Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
* @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for
Expand Down Expand Up @@ -880,6 +880,7 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque
* .setCustomizedAttribution("customizedAttribution557650238")
* .setIsTranslateNativePdfOnly(true)
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
* }
Expand Down Expand Up @@ -918,6 +919,7 @@ public final TranslateDocumentResponse translateDocument(TranslateDocumentReques
* .setCustomizedAttribution("customizedAttribution557650238")
* .setIsTranslateNativePdfOnly(true)
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* ApiFuture<TranslateDocumentResponse> future =
* translationServiceClient.translateDocumentCallable().futureCall(request);
Expand Down Expand Up @@ -1219,6 +1221,8 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* BatchTranslateDocumentResponse response =
* translationServiceClient.batchTranslateDocumentAsync(request).get();
Expand Down Expand Up @@ -1263,6 +1267,8 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
* translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
Expand Down Expand Up @@ -1309,6 +1315,8 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* ApiFuture<Operation> future =
* translationServiceClient.batchTranslateDocumentCallable().futureCall(request);
Expand Down
Expand Up @@ -636,6 +636,10 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque
* .setModel("model104069929")
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
* .putAllLabels(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setIsTranslateNativePdfOnly(true)
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
* }
Expand Down Expand Up @@ -671,6 +675,10 @@ public final TranslateDocumentResponse translateDocument(TranslateDocumentReques
* .setModel("model104069929")
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
* .putAllLabels(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setIsTranslateNativePdfOnly(true)
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* ApiFuture<TranslateDocumentResponse> future =
* translationServiceClient.translateDocumentCallable().futureCall(request);
Expand Down Expand Up @@ -810,7 +818,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
Expand Down Expand Up @@ -877,7 +885,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
Expand Down Expand Up @@ -944,7 +952,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
Expand All @@ -971,6 +979,9 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* BatchTranslateDocumentResponse response =
* translationServiceClient.batchTranslateDocumentAsync(request).get();
Expand All @@ -987,7 +998,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
Expand All @@ -1014,6 +1025,9 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
* translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
Expand All @@ -1032,7 +1046,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
Expand All @@ -1059,6 +1073,9 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setEnableShadowRemovalNativePdf(true)
* .setEnableRotationCorrection(true)
* .build();
* ApiFuture<Operation> future =
* translationServiceClient.batchTranslateDocumentCallable().futureCall(request);
Expand Down
Expand Up @@ -515,6 +515,7 @@ public void translateDocumentTest() throws Exception {
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();

TranslateDocumentResponse actualResponse = client.translateDocument(request);
Expand Down Expand Up @@ -556,6 +557,7 @@ public void translateDocumentExceptionTest() throws Exception {
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();
client.translateDocument(request);
Assert.fail("No exception raised");
Expand Down
Expand Up @@ -497,6 +497,7 @@ public void translateDocumentTest() throws Exception {
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();

TranslateDocumentResponse actualResponse = client.translateDocument(request);
Expand All @@ -520,6 +521,8 @@ public void translateDocumentTest() throws Exception {
request.getIsTranslateNativePdfOnly(), actualRequest.getIsTranslateNativePdfOnly());
Assert.assertEquals(
request.getEnableShadowRemovalNativePdf(), actualRequest.getEnableShadowRemovalNativePdf());
Assert.assertEquals(
request.getEnableRotationCorrection(), actualRequest.getEnableRotationCorrection());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -545,6 +548,7 @@ public void translateDocumentExceptionTest() throws Exception {
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();
client.translateDocument(request);
Assert.fail("No exception raised");
Expand Down
Expand Up @@ -357,6 +357,10 @@ public void translateDocumentTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();

TranslateDocumentResponse actualResponse = client.translateDocument(request);
Expand Down Expand Up @@ -395,6 +399,10 @@ public void translateDocumentExceptionTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();
client.translateDocument(request);
Assert.fail("No exception raised");
Expand Down
Expand Up @@ -348,6 +348,10 @@ public void translateDocumentTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();

TranslateDocumentResponse actualResponse = client.translateDocument(request);
Expand All @@ -365,6 +369,14 @@ public void translateDocumentTest() throws Exception {
Assert.assertEquals(request.getModel(), actualRequest.getModel());
Assert.assertEquals(request.getGlossaryConfig(), actualRequest.getGlossaryConfig());
Assert.assertEquals(request.getLabelsMap(), actualRequest.getLabelsMap());
Assert.assertEquals(
request.getCustomizedAttribution(), actualRequest.getCustomizedAttribution());
Assert.assertEquals(
request.getIsTranslateNativePdfOnly(), actualRequest.getIsTranslateNativePdfOnly());
Assert.assertEquals(
request.getEnableShadowRemovalNativePdf(), actualRequest.getEnableShadowRemovalNativePdf());
Assert.assertEquals(
request.getEnableRotationCorrection(), actualRequest.getEnableRotationCorrection());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -387,6 +399,10 @@ public void translateDocumentExceptionTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.setEnableRotationCorrection(true)
.build();
client.translateDocument(request);
Assert.fail("No exception raised");
Expand Down
Expand Up @@ -643,7 +643,7 @@ default void batchTranslateText(
*
*
* <pre>
* Translates a large volume of documents in asynchronous batch mode.
* Translates a large volume of document in asynchronous batch mode.
* This function provides real-time output as the inputs are being processed.
* If caller cancels a request, the partial results (for an input file, it's
* all or nothing) may still be available on the specified output location.
Expand Down Expand Up @@ -849,7 +849,7 @@ public void batchTranslateText(
*
*
* <pre>
* Translates a large volume of documents in asynchronous batch mode.
* Translates a large volume of document in asynchronous batch mode.
* This function provides real-time output as the inputs are being processed.
* If caller cancels a request, the partial results (for an input file, it's
* all or nothing) may still be available on the specified output location.
Expand Down Expand Up @@ -1031,7 +1031,7 @@ public com.google.longrunning.Operation batchTranslateText(
*
*
* <pre>
* Translates a large volume of documents in asynchronous batch mode.
* Translates a large volume of document in asynchronous batch mode.
* This function provides real-time output as the inputs are being processed.
* If caller cancels a request, the partial results (for an input file, it's
* all or nothing) may still be available on the specified output location.
Expand Down Expand Up @@ -1201,7 +1201,7 @@ protected TranslationServiceFutureStub build(
*
*
* <pre>
* Translates a large volume of documents in asynchronous batch mode.
* Translates a large volume of document in asynchronous batch mode.
* This function provides real-time output as the inputs are being processed.
* If caller cancels a request, the partial results (for an input file, it's
* all or nothing) may still be available on the specified output location.
Expand Down

0 comments on commit 2b945d1

Please sign in to comment.