Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 285059a

Browse files
feat: Added shadow removal and rotation correction options to Document Translation and Batch Document Translation API (#511)
* 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: https://github.com/googleapis/googleapis-gen/commit/07b1ee544ff188f96e8e08b39186cd1e104e1984 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDdiMWVlNTQ0ZmYxODhmOTZlOGUwOGIzOTE4NmNkMWUxMDRlMTk4NCJ9 * 🦉 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: https://github.com/googleapis/googleapis-gen/commit/5a136ebbed847eb9e72deb672d0481ff04ab0398 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWExMzZlYmJlZDg0N2ViOWU3MmRlYjY3MmQwNDgxZmYwNGFiMDM5OCJ9 * 🦉 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>
1 parent 440c434 commit 285059a

File tree

10 files changed

+133
-46
lines changed

10 files changed

+133
-46
lines changed

google/cloud/translate_v3/services/translation_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ async def sample_translate_text():
322322
``projects/{project-number-or-id}/locations/global/models/general/nmt``.
323323
324324
If not provided, the default Google model (NMT) will be
325-
used.
325+
used
326326
327327
This corresponds to the ``model`` field
328328
on the ``request`` instance; if ``request`` is provided, this

google/cloud/translate_v3/services/translation_service/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def sample_translate_text():
550550
``projects/{project-number-or-id}/locations/global/models/general/nmt``.
551551
552552
If not provided, the default Google model (NMT) will be
553-
used.
553+
used
554554
555555
This corresponds to the ``model`` field
556556
on the ``request`` instance; if ``request`` is provided, this

google/cloud/translate_v3/types/translation_service.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767

6868

6969
class TranslateTextGlossaryConfig(proto.Message):
70-
r"""Configures which glossary should be used for a specific
71-
target language, and defines options for applying that glossary.
70+
r"""Configures which glossary is used for a specific target
71+
language and defines options for applying that glossary.
7272
7373
Attributes:
7474
glossary (str):
@@ -152,8 +152,7 @@ class TranslateTextRequest(proto.Message):
152152
``global``. For example,
153153
``projects/{project-number-or-id}/locations/global/models/general/nmt``.
154154
155-
If not provided, the default Google model (NMT) will be
156-
used.
155+
If not provided, the default Google model (NMT) will be used
157156
glossary_config (google.cloud.translate_v3.types.TranslateTextGlossaryConfig):
158157
Optional. Glossary to be applied. The glossary must be
159158
within the same region (have the same location-id) as the
@@ -904,14 +903,19 @@ class TranslateDocumentRequest(proto.Message):
904903
should follow rules in
905904
https://cloud.google.com/translate/attribution#attribution_and_logos
906905
is_translate_native_pdf_only (bool):
907-
Optional. If true, the page limit of online
908-
native pdf translation is 300 and only native
909-
pdf pages will be translated.
906+
Optional. is_translate_native_pdf_only field for external
907+
customers. If true, the page limit of online native pdf
908+
translation is 300 and only native pdf pages will be
909+
translated.
910910
enable_shadow_removal_native_pdf (bool):
911-
Optional. If true, use the text removal to remove the shadow
912-
text on background image for native pdf translation. Shadow
913-
removal feature can only be enabled when
914-
is_translate_native_pdf_only is false
911+
Optional. If true, use the text removal server to remove the
912+
shadow text on background image for native pdf translation.
913+
Shadow removal feature can only be enabled when
914+
is_translate_native_pdf_only: false && pdf_native_only:
915+
false
916+
enable_rotation_correction (bool):
917+
Optional. If true, enable auto rotation
918+
correction in DVS.
915919
"""
916920

917921
parent: str = proto.Field(
@@ -962,6 +966,10 @@ class TranslateDocumentRequest(proto.Message):
962966
proto.BOOL,
963967
number=12,
964968
)
969+
enable_rotation_correction: bool = proto.Field(
970+
proto.BOOL,
971+
number=13,
972+
)
965973

966974

967975
class DocumentTranslation(proto.Message):
@@ -1807,6 +1815,15 @@ class BatchTranslateDocumentRequest(proto.Message):
18071815
``Machine Translated by Google``. Customized attribution
18081816
should follow rules in
18091817
https://cloud.google.com/translate/attribution#attribution_and_logos
1818+
enable_shadow_removal_native_pdf (bool):
1819+
Optional. If true, use the text removal server to remove the
1820+
shadow text on background image for native pdf translation.
1821+
Shadow removal feature can only be enabled when
1822+
is_translate_native_pdf_only: false && pdf_native_only:
1823+
false
1824+
enable_rotation_correction (bool):
1825+
Optional. If true, enable auto rotation
1826+
correction in DVS.
18101827
"""
18111828

18121829
parent: str = proto.Field(
@@ -1851,6 +1868,14 @@ class BatchTranslateDocumentRequest(proto.Message):
18511868
proto.STRING,
18521869
number=10,
18531870
)
1871+
enable_shadow_removal_native_pdf: bool = proto.Field(
1872+
proto.BOOL,
1873+
number=11,
1874+
)
1875+
enable_rotation_correction: bool = proto.Field(
1876+
proto.BOOL,
1877+
number=12,
1878+
)
18541879

18551880

18561881
class BatchDocumentInputConfig(proto.Message):

google/cloud/translate_v3beta1/services/translation_service/async_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,12 @@ async def batch_translate_document(
824824
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
825825
metadata: Sequence[Tuple[str, str]] = (),
826826
) -> operation_async.AsyncOperation:
827-
r"""Translates a large volume of documents in
828-
asynchronous batch mode. This function provides
829-
real-time output as the inputs are being processed. If
830-
caller cancels a request, the partial results (for an
831-
input file, it's all or nothing) may still be available
832-
on the specified output location.
827+
r"""Translates a large volume of document in asynchronous
828+
batch mode. This function provides real-time output as
829+
the inputs are being processed. If caller cancels a
830+
request, the partial results (for an input file, it's
831+
all or nothing) may still be available on the specified
832+
output location.
833833
This call returns immediately and you can use
834834
google.longrunning.Operation.name to poll the status of
835835
the call.

google/cloud/translate_v3beta1/services/translation_service/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,12 +1045,12 @@ def batch_translate_document(
10451045
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10461046
metadata: Sequence[Tuple[str, str]] = (),
10471047
) -> operation.Operation:
1048-
r"""Translates a large volume of documents in
1049-
asynchronous batch mode. This function provides
1050-
real-time output as the inputs are being processed. If
1051-
caller cancels a request, the partial results (for an
1052-
input file, it's all or nothing) may still be available
1053-
on the specified output location.
1048+
r"""Translates a large volume of document in asynchronous
1049+
batch mode. This function provides real-time output as
1050+
the inputs are being processed. If caller cancels a
1051+
request, the partial results (for an input file, it's
1052+
all or nothing) may still be available on the specified
1053+
output location.
10541054
This call returns immediately and you can use
10551055
google.longrunning.Operation.name to poll the status of
10561056
the call.

google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,12 @@ def batch_translate_document(
407407
]:
408408
r"""Return a callable for the batch translate document method over gRPC.
409409
410-
Translates a large volume of documents in
411-
asynchronous batch mode. This function provides
412-
real-time output as the inputs are being processed. If
413-
caller cancels a request, the partial results (for an
414-
input file, it's all or nothing) may still be available
415-
on the specified output location.
410+
Translates a large volume of document in asynchronous
411+
batch mode. This function provides real-time output as
412+
the inputs are being processed. If caller cancels a
413+
request, the partial results (for an input file, it's
414+
all or nothing) may still be available on the specified
415+
output location.
416416
This call returns immediately and you can use
417417
google.longrunning.Operation.name to poll the status of
418418
the call.

google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,12 @@ def batch_translate_document(
414414
]:
415415
r"""Return a callable for the batch translate document method over gRPC.
416416
417-
Translates a large volume of documents in
418-
asynchronous batch mode. This function provides
419-
real-time output as the inputs are being processed. If
420-
caller cancels a request, the partial results (for an
421-
input file, it's all or nothing) may still be available
422-
on the specified output location.
417+
Translates a large volume of document in asynchronous
418+
batch mode. This function provides real-time output as
419+
the inputs are being processed. If caller cancels a
420+
request, the partial results (for an input file, it's
421+
all or nothing) may still be available on the specified
422+
output location.
423423
This call returns immediately and you can use
424424
google.longrunning.Operation.name to poll the status of
425425
the call.

google/cloud/translate_v3beta1/types/translation_service.py

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ class OutputConfig(proto.Message):
630630
Since index.csv will be keeping updated during the process,
631631
please make sure there is no custom retention policy applied
632632
on the output bucket that may avoid file updating.
633-
(https://cloud.google.com/storage/docs/bucket-lock?hl=en#retention-policy)
633+
(https://cloud.google.com/storage/docs/bucket-lock#retention-policy)
634634
635635
The format of translations_file (for target language code
636636
'trg') is:
@@ -887,6 +887,26 @@ class TranslateDocumentRequest(proto.Message):
887887
See
888888
https://cloud.google.com/translate/docs/advanced/labels
889889
for more information.
890+
customized_attribution (str):
891+
Optional. This flag is to support user customized
892+
attribution. If not provided, the default is
893+
``Machine Translated by Google``. Customized attribution
894+
should follow rules in
895+
https://cloud.google.com/translate/attribution#attribution_and_logos
896+
is_translate_native_pdf_only (bool):
897+
Optional. is_translate_native_pdf_only field for external
898+
customers. If true, the page limit of online native pdf
899+
translation is 300 and only native pdf pages will be
900+
translated.
901+
enable_shadow_removal_native_pdf (bool):
902+
Optional. If true, use the text removal server to remove the
903+
shadow text on background image for native pdf translation.
904+
Shadow removal feature can only be enabled when
905+
is_translate_native_pdf_only: false && pdf_native_only:
906+
false
907+
enable_rotation_correction (bool):
908+
Optional. If true, enable auto rotation
909+
correction in DVS.
890910
"""
891911

892912
parent: str = proto.Field(
@@ -925,6 +945,22 @@ class TranslateDocumentRequest(proto.Message):
925945
proto.STRING,
926946
number=8,
927947
)
948+
customized_attribution: str = proto.Field(
949+
proto.STRING,
950+
number=10,
951+
)
952+
is_translate_native_pdf_only: bool = proto.Field(
953+
proto.BOOL,
954+
number=11,
955+
)
956+
enable_shadow_removal_native_pdf: bool = proto.Field(
957+
proto.BOOL,
958+
number=12,
959+
)
960+
enable_rotation_correction: bool = proto.Field(
961+
proto.BOOL,
962+
number=13,
963+
)
928964

929965

930966
class DocumentTranslation(proto.Message):
@@ -1266,10 +1302,9 @@ class GlossaryInputConfig(proto.Message):
12661302
For equivalent term sets glossaries:
12671303
12681304
- CSV (``.csv``): Multi-column CSV file defining equivalent
1269-
glossary terms in multiple languages. The format is
1270-
defined for Google Translation Toolkit and documented in
1271-
`Use a
1272-
glossary <https://support.google.com/translatortoolkit/answer/6306379?hl=en>`__.
1305+
glossary terms in multiple languages. See documentation
1306+
for more information -
1307+
`glossaries <https://cloud.google.com/translate/docs/advanced/glossary>`__.
12731308
12741309
This field is a member of `oneof`_ ``source``.
12751310
"""
@@ -1760,6 +1795,21 @@ class BatchTranslateDocumentRequest(proto.Message):
17601795
17611796
If nothing specified, output files will be in the same
17621797
format as the original file.
1798+
customized_attribution (str):
1799+
Optional. This flag is to support user customized
1800+
attribution. If not provided, the default is
1801+
``Machine Translated by Google``. Customized attribution
1802+
should follow rules in
1803+
https://cloud.google.com/translate/attribution#attribution_and_logos
1804+
enable_shadow_removal_native_pdf (bool):
1805+
Optional. If true, use the text removal server to remove the
1806+
shadow text on background image for native pdf translation.
1807+
Shadow removal feature can only be enabled when
1808+
is_translate_native_pdf_only: false && pdf_native_only:
1809+
false
1810+
enable_rotation_correction (bool):
1811+
Optional. If true, enable auto rotation
1812+
correction in DVS.
17631813
"""
17641814

17651815
parent: str = proto.Field(
@@ -1800,6 +1850,18 @@ class BatchTranslateDocumentRequest(proto.Message):
18001850
proto.STRING,
18011851
number=8,
18021852
)
1853+
customized_attribution: str = proto.Field(
1854+
proto.STRING,
1855+
number=10,
1856+
)
1857+
enable_shadow_removal_native_pdf: bool = proto.Field(
1858+
proto.BOOL,
1859+
number=11,
1860+
)
1861+
enable_rotation_correction: bool = proto.Field(
1862+
proto.BOOL,
1863+
number=12,
1864+
)
18031865

18041866

18051867
class BatchDocumentInputConfig(proto.Message):

scripts/fixup_translate_v3_keywords.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ def partition(
3939
class translateCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'batch_translate_document': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'format_conversions', 'customized_attribution', ),
42+
'batch_translate_document': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'format_conversions', 'customized_attribution', 'enable_shadow_removal_native_pdf', 'enable_rotation_correction', ),
4343
'batch_translate_text': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'labels', ),
4444
'create_glossary': ('parent', 'glossary', ),
4545
'delete_glossary': ('name', ),
4646
'detect_language': ('parent', 'model', 'content', 'mime_type', 'labels', ),
4747
'get_glossary': ('name', ),
4848
'get_supported_languages': ('parent', 'display_language_code', 'model', ),
4949
'list_glossaries': ('parent', 'page_size', 'page_token', 'filter', ),
50-
'translate_document': ('parent', 'target_language_code', 'document_input_config', 'source_language_code', 'document_output_config', 'model', 'glossary_config', 'labels', 'customized_attribution', 'is_translate_native_pdf_only', 'enable_shadow_removal_native_pdf', ),
50+
'translate_document': ('parent', 'target_language_code', 'document_input_config', 'source_language_code', 'document_output_config', 'model', 'glossary_config', 'labels', 'customized_attribution', 'is_translate_native_pdf_only', 'enable_shadow_removal_native_pdf', 'enable_rotation_correction', ),
5151
'translate_text': ('contents', 'target_language_code', 'parent', 'mime_type', 'source_language_code', 'model', 'glossary_config', 'labels', ),
5252
}
5353

scripts/fixup_translate_v3beta1_keywords.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ def partition(
3939
class translateCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'batch_translate_document': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'format_conversions', ),
42+
'batch_translate_document': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'format_conversions', 'customized_attribution', 'enable_shadow_removal_native_pdf', 'enable_rotation_correction', ),
4343
'batch_translate_text': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'labels', ),
4444
'create_glossary': ('parent', 'glossary', ),
4545
'delete_glossary': ('name', ),
4646
'detect_language': ('parent', 'model', 'content', 'mime_type', 'labels', ),
4747
'get_glossary': ('name', ),
4848
'get_supported_languages': ('parent', 'display_language_code', 'model', ),
4949
'list_glossaries': ('parent', 'page_size', 'page_token', 'filter', ),
50-
'translate_document': ('parent', 'target_language_code', 'document_input_config', 'source_language_code', 'document_output_config', 'model', 'glossary_config', 'labels', ),
50+
'translate_document': ('parent', 'target_language_code', 'document_input_config', 'source_language_code', 'document_output_config', 'model', 'glossary_config', 'labels', 'customized_attribution', 'is_translate_native_pdf_only', 'enable_shadow_removal_native_pdf', 'enable_rotation_correction', ),
5151
'translate_text': ('contents', 'target_language_code', 'parent', 'mime_type', 'source_language_code', 'model', 'glossary_config', 'labels', ),
5252
}
5353

0 commit comments

Comments
 (0)