Skip to content

Commit 489b166

Browse files
feat: [contentwarehouse] Make Layout Parser generally available in V1 (#5394)
* feat: Make Layout Parser generally available in V1 PiperOrigin-RevId: 638041158 Source-Link: googleapis/googleapis@1e41378 Source-Link: googleapis/googleapis-gen@1d34c97 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRlbnR3YXJlaG91c2UvLk93bEJvdC55YW1sIiwiaCI6IjFkMzRjOTdhZGQwOTNkZjU2MmZhNTA3MzJkYTM2NTZjNzZiODNlZGUifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * build: update gapic generator to allow individual location mixin generation PiperOrigin-RevId: 638462084 Source-Link: googleapis/googleapis@e5d5636 Source-Link: googleapis/googleapis-gen@d02b2f9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRlbnR3YXJlaG91c2UvLk93bEJvdC55YW1sIiwiaCI6ImQwMmIyZjkyMzljM2UxZGU2NDdlZjM3ZmIxMGE1ZTQyNGFhMGI3YTUifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Make Layout Parser generally available in V1 PiperOrigin-RevId: 638924855 Source-Link: googleapis/googleapis@0cea717 Source-Link: googleapis/googleapis-gen@ba9bd19 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRlbnR3YXJlaG91c2UvLk93bEJvdC55YW1sIiwiaCI6ImJhOWJkMTlhNjc4N2I2YmUxNzUwYjE4MTU3YjMwNDY3YThjZTY3MzAifQ== * 🦉 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 4f1e0b6 commit 489b166

File tree

8 files changed

+5618
-2
lines changed

8 files changed

+5618
-2
lines changed

packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/document.proto

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,160 @@ message Document {
893893
repeated Provenance provenance = 3 [deprecated = true];
894894
}
895895

896+
// Represents the parsed layout of a document as a collection of blocks that
897+
// the document is divided into.
898+
message DocumentLayout {
899+
// Represents a block. A block could be one of the various types (text,
900+
// table, list) supported.
901+
message DocumentLayoutBlock {
902+
// Represents where the block starts and ends in the document.
903+
message LayoutPageSpan {
904+
// Page where block starts in the document.
905+
int32 page_start = 1;
906+
907+
// Page where block ends in the document.
908+
int32 page_end = 2;
909+
}
910+
911+
// Represents a text type block.
912+
message LayoutTextBlock {
913+
// Text content stored in the block.
914+
string text = 1;
915+
916+
// Type of the text in the block. Available options are: `paragraph`,
917+
// `subtitle`, `heading-1`, `heading-2`, `heading-3`, `heading-4`,
918+
// `heading-5`, `header`, `footer`.
919+
string type = 2;
920+
921+
// A text block could further have child blocks.
922+
// Repeated blocks support further hierarchies and nested blocks.
923+
repeated DocumentLayoutBlock blocks = 3;
924+
}
925+
926+
// Represents a table type block.
927+
message LayoutTableBlock {
928+
// Header rows at the top of the table.
929+
repeated LayoutTableRow header_rows = 1;
930+
931+
// Body rows containing main table content.
932+
repeated LayoutTableRow body_rows = 2;
933+
934+
// Table caption/title.
935+
string caption = 3;
936+
}
937+
938+
// Represents a row in a table.
939+
message LayoutTableRow {
940+
// A table row is a list of table cells.
941+
repeated LayoutTableCell cells = 1;
942+
}
943+
944+
// Represents a cell in a table row.
945+
message LayoutTableCell {
946+
// A table cell is a list of blocks.
947+
// Repeated blocks support further hierarchies and nested blocks.
948+
repeated DocumentLayoutBlock blocks = 1;
949+
950+
// How many rows this cell spans.
951+
int32 row_span = 2;
952+
953+
// How many columns this cell spans.
954+
int32 col_span = 3;
955+
}
956+
957+
// Represents a list type block.
958+
message LayoutListBlock {
959+
// List entries that constitute a list block.
960+
repeated LayoutListEntry list_entries = 1;
961+
962+
// Type of the list_entries (if exist). Available options are `ordered`
963+
// and `unordered`.
964+
string type = 2;
965+
}
966+
967+
// Represents an entry in the list.
968+
message LayoutListEntry {
969+
// A list entry is a list of blocks.
970+
// Repeated blocks support further hierarchies and nested blocks.
971+
repeated DocumentLayoutBlock blocks = 1;
972+
}
973+
974+
oneof block {
975+
// Block consisting of text content.
976+
LayoutTextBlock text_block = 2;
977+
978+
// Block consisting of table content/structure.
979+
LayoutTableBlock table_block = 3;
980+
981+
// Block consisting of list content/structure.
982+
LayoutListBlock list_block = 4;
983+
}
984+
985+
// ID of the block.
986+
string block_id = 1;
987+
988+
// Page span of the block.
989+
LayoutPageSpan page_span = 5;
990+
}
991+
992+
// List of blocks in the document.
993+
repeated DocumentLayoutBlock blocks = 1;
994+
}
995+
996+
// Represents the chunks that the document is divided into.
997+
message ChunkedDocument {
998+
// Represents a chunk.
999+
message Chunk {
1000+
// Represents where the chunk starts and ends in the document.
1001+
message ChunkPageSpan {
1002+
// Page where chunk starts in the document.
1003+
int32 page_start = 1;
1004+
1005+
// Page where chunk ends in the document.
1006+
int32 page_end = 2;
1007+
}
1008+
1009+
// Represents the page header associated with the chunk.
1010+
message ChunkPageHeader {
1011+
// Header in text format.
1012+
string text = 1;
1013+
1014+
// Page span of the header.
1015+
ChunkPageSpan page_span = 2;
1016+
}
1017+
1018+
// Represents the page footer associated with the chunk.
1019+
message ChunkPageFooter {
1020+
// Footer in text format.
1021+
string text = 1;
1022+
1023+
// Page span of the footer.
1024+
ChunkPageSpan page_span = 2;
1025+
}
1026+
1027+
// ID of the chunk.
1028+
string chunk_id = 1;
1029+
1030+
// Unused.
1031+
repeated string source_block_ids = 2;
1032+
1033+
// Text content of the chunk.
1034+
string content = 3;
1035+
1036+
// Page span of the chunk.
1037+
ChunkPageSpan page_span = 4;
1038+
1039+
// Page headers associated with the chunk.
1040+
repeated ChunkPageHeader page_headers = 5;
1041+
1042+
// Page footers associated with the chunk.
1043+
repeated ChunkPageFooter page_footers = 6;
1044+
}
1045+
1046+
// List of chunks.
1047+
repeated Chunk chunks = 1;
1048+
}
1049+
8961050
// Original source document from the user.
8971051
oneof source {
8981052
// Optional. Currently supports Google Cloud Storage URI of the form
@@ -944,4 +1098,10 @@ message Document {
9441098

9451099
// Placeholder. Revision history of this document.
9461100
repeated Revision revisions = 13;
1101+
1102+
// Parsed layout of the document.
1103+
DocumentLayout document_layout = 17;
1104+
1105+
// Document chunked based on chunking config.
1106+
ChunkedDocument chunked_document = 18;
9471107
}

packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/document_processor_service.proto

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,23 @@ service DocumentProcessorService {
328328

329329
// Options for Process API
330330
message ProcessOptions {
331+
// Serving config for layout parser processor.
332+
message LayoutConfig {
333+
// Serving config for chunking.
334+
message ChunkingConfig {
335+
// Optional. The chunk sizes to use when splitting documents, in order of
336+
// level.
337+
int32 chunk_size = 1 [(google.api.field_behavior) = OPTIONAL];
338+
339+
// Optional. Whether or not to include ancestor headings when splitting.
340+
bool include_ancestor_headings = 2
341+
[(google.api.field_behavior) = OPTIONAL];
342+
}
343+
344+
// Optional. Config for chunking in layout parser processor.
345+
ChunkingConfig chunking_config = 1 [(google.api.field_behavior) = OPTIONAL];
346+
}
347+
331348
// A list of individual page numbers.
332349
message IndividualPageSelector {
333350
// Optional. Indices of the pages (starting from 1).
@@ -356,6 +373,10 @@ message ProcessOptions {
356373
// Returns error if set on other processor types.
357374
OcrConfig ocr_config = 1;
358375

376+
// Optional. Only applicable to `LAYOUT_PARSER_PROCESSOR`.
377+
// Returns error if set on other processor types.
378+
LayoutConfig layout_config = 9 [(google.api.field_behavior) = OPTIONAL];
379+
359380
// Optional. Override the schema of the
360381
// [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]. Will
361382
// return an Invalid Argument error if this field is set when the underlying

packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/processor.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ message ProcessorVersion {
128128

129129
// Output only. The model type of this processor version.
130130
ModelType model_type = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
131+
132+
// Output only. Reserved for future use.
133+
bool satisfies_pzs = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
134+
135+
// Output only. Reserved for future use.
136+
bool satisfies_pzi = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
131137
}
132138

133139
// Contains the alias and the aliased resource name of processor version.
@@ -224,4 +230,10 @@ message Processor {
224230
// The [KMS key](https://cloud.google.com/security-key-management) used for
225231
// encryption and decryption in CMEK scenarios.
226232
string kms_key_name = 8;
233+
234+
// Output only. Reserved for future use.
235+
bool satisfies_pzs = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
236+
237+
// Output only. Reserved for future use.
238+
bool satisfies_pzi = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
227239
}

0 commit comments

Comments
 (0)