Skip to content

Commit

Permalink
feat: Added shadow removal and rotation correction options to Documen…
Browse files Browse the repository at this point in the history
…t Translation and Batch Document Translation API (#6540)

PiperOrigin-RevId: 554540978
Source-Link: googleapis/googleapis@8cf2ae1
Source-Link: googleapis/googleapis-gen@5a136eb
Copy-Tag: eyJwIjoiVHJhbnNsYXRlLy5Pd2xCb3QueWFtbCIsImgiOiI1YTEzNmViYmVkODQ3ZWI5ZTcyZGViNjcyZDA0ODFmZjA0YWIwMzk4In0=
  • Loading branch information
gcf-owl-bot[bot] authored Aug 8, 2023
1 parent d70642c commit c0f7a1b
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 28 deletions.
Binary file modified Translate/metadata/V3/TranslationService.php
Binary file not shown.
80 changes: 80 additions & 0 deletions Translate/src/V3/BatchTranslateDocumentRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 27 additions & 5 deletions Translate/src/V3/Gapic/TranslationServiceGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ public function __construct(array $options = [])
* If not provided, the default is `Machine Translated by Google`.
* Customized attribution should follow rules in
* https://cloud.google.com/translate/attribution#attribution_and_logos
* @type bool $enableShadowRemovalNativePdf
* Optional. If true, use the text removal server to remove the shadow text on
* background image for native pdf translation.
* Shadow removal feature can only be enabled when
* is_translate_native_pdf_only: false && pdf_native_only: false
* @type bool $enableRotationCorrection
* Optional. If true, enable auto rotation correction in DVS.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
Expand Down Expand Up @@ -504,6 +511,14 @@ public function batchTranslateDocument($parent, $sourceLanguageCode, $targetLang
$request->setCustomizedAttribution($optionalArgs['customizedAttribution']);
}

if (isset($optionalArgs['enableShadowRemovalNativePdf'])) {
$request->setEnableShadowRemovalNativePdf($optionalArgs['enableShadowRemovalNativePdf']);
}

if (isset($optionalArgs['enableRotationCorrection'])) {
$request->setEnableRotationCorrection($optionalArgs['enableRotationCorrection']);
}

$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startOperationsCall('BatchTranslateDocument', $optionalArgs, $request, $this->getOperationsClient())->wait();
Expand Down Expand Up @@ -1157,13 +1172,16 @@ public function listGlossaries($parent, array $optionalArgs = [])
* Customized attribution should follow rules in
* https://cloud.google.com/translate/attribution#attribution_and_logos
* @type bool $isTranslateNativePdfOnly
* Optional. If true, the page limit of online native pdf translation is 300
* and only native pdf pages will be translated.
* Optional. is_translate_native_pdf_only field for external customers.
* If true, the page limit of online native pdf translation is 300 and only
* native pdf pages will be translated.
* @type bool $enableShadowRemovalNativePdf
* Optional. If true, use the text removal to remove the shadow text on
* Optional. If true, use the text removal server to remove the shadow text on
* background image for native pdf translation.
* Shadow removal feature can only be enabled when
* is_translate_native_pdf_only is false
* is_translate_native_pdf_only: false && pdf_native_only: false
* @type bool $enableRotationCorrection
* Optional. If true, enable auto rotation correction in DVS.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
Expand Down Expand Up @@ -1214,6 +1232,10 @@ public function translateDocument($parent, $targetLanguageCode, $documentInputCo
$request->setEnableShadowRemovalNativePdf($optionalArgs['enableShadowRemovalNativePdf']);
}

if (isset($optionalArgs['enableRotationCorrection'])) {
$request->setEnableRotationCorrection($optionalArgs['enableRotationCorrection']);
}

$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startCall('TranslateDocument', TranslateDocumentResponse::class, $optionalArgs, $request)->wait();
Expand Down Expand Up @@ -1282,7 +1304,7 @@ public function translateDocument($parent, $targetLanguageCode, $documentInputCo
* For example,
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
*
* If not provided, the default Google model (NMT) will be used.
* If not provided, the default Google model (NMT) will be used
* @type TranslateTextGlossaryConfig $glossaryConfig
* Optional. Glossary to be applied. The glossary must be
* within the same region (have the same location-id) as the model, otherwise
Expand Down
70 changes: 54 additions & 16 deletions Translate/src/V3/TranslateDocumentRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Translate/src/V3/TranslateTextGlossaryConfig.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Translate/src/V3/TranslateTextRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0f7a1b

Please sign in to comment.