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: [translate] Added shadow removal and rotation correction options to Document Translation and Batch Document Translation API #9740

Merged
merged 4 commits into from
Aug 8, 2023
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
2 changes: 1 addition & 1 deletion java-translate/README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading