1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.documentai.v1beta2; 18 19import "google/api/field_behavior.proto"; 20import "google/cloud/documentai/v1beta2/barcode.proto"; 21import "google/cloud/documentai/v1beta2/geometry.proto"; 22import "google/protobuf/timestamp.proto"; 23import "google/rpc/status.proto"; 24import "google/type/color.proto"; 25import "google/type/date.proto"; 26import "google/type/datetime.proto"; 27import "google/type/money.proto"; 28import "google/type/postal_address.proto"; 29 30option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; 31option go_package = "cloud.google.com/go/documentai/apiv1beta2/documentaipb;documentaipb"; 32option java_multiple_files = true; 33option java_outer_classname = "DocumentProto"; 34option java_package = "com.google.cloud.documentai.v1beta2"; 35option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; 36option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; 37 38// Document represents the canonical document resource in Document AI. It is an 39// interchange format that provides insights into documents and allows for 40// collaboration between users and Document AI to iterate and optimize for 41// quality. 42message Document { 43 // For a large document, sharding may be performed to produce several 44 // document shards. Each document shard contains this field to detail which 45 // shard it is. 46 message ShardInfo { 47 // The 0-based index of this shard. 48 int64 shard_index = 1; 49 50 // Total number of shards. 51 int64 shard_count = 2; 52 53 // The index of the first character in 54 // [Document.text][google.cloud.documentai.v1beta2.Document.text] in the 55 // overall document global text. 56 int64 text_offset = 3; 57 } 58 59 // Label attaches schema information and/or other metadata to segments within 60 // a [Document][google.cloud.documentai.v1beta2.Document]. Multiple 61 // [Label][google.cloud.documentai.v1beta2.Document.Label]s on a single field 62 // can denote either different labels, different instances of the same label 63 // created at different times, or some combination of both. 64 message Label { 65 // Provenance of the label. 66 oneof source { 67 // Label is generated AutoML model. This field stores the full resource 68 // name of the AutoML model. 69 // 70 // Format: 71 // `projects/{project-id}/locations/{location-id}/models/{model-id}` 72 string automl_model = 2; 73 } 74 75 // Name of the label. 76 // 77 // When the label is generated from AutoML Text Classification model, this 78 // field represents the name of the category. 79 string name = 1; 80 81 // Confidence score between 0 and 1 for label assignment. 82 float confidence = 3; 83 } 84 85 // Annotation for common text style attributes. This adheres to CSS 86 // conventions as much as possible. 87 message Style { 88 // Font size with unit. 89 message FontSize { 90 // Font size for the text. 91 float size = 1; 92 93 // Unit for the font size. Follows CSS naming (such as `in`, `px`, and 94 // `pt`). 95 string unit = 2; 96 } 97 98 // Text anchor indexing into the 99 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 100 TextAnchor text_anchor = 1; 101 102 // Text color. 103 google.type.Color color = 2; 104 105 // Text background color. 106 google.type.Color background_color = 3; 107 108 // [Font weight](https://www.w3schools.com/cssref/pr_font_weight.asp). 109 // Possible values are `normal`, `bold`, `bolder`, and `lighter`. 110 string font_weight = 4; 111 112 // [Text style](https://www.w3schools.com/cssref/pr_font_font-style.asp). 113 // Possible values are `normal`, `italic`, and `oblique`. 114 string text_style = 5; 115 116 // [Text 117 // decoration](https://www.w3schools.com/cssref/pr_text_text-decoration.asp). 118 // Follows CSS standard. <text-decoration-line> <text-decoration-color> 119 // <text-decoration-style> 120 string text_decoration = 6; 121 122 // Font size. 123 FontSize font_size = 7; 124 125 // Font family such as `Arial`, `Times New Roman`. 126 // https://www.w3schools.com/cssref/pr_font_font-family.asp 127 string font_family = 8; 128 } 129 130 // A page in a [Document][google.cloud.documentai.v1beta2.Document]. 131 message Page { 132 // Dimension for the page. 133 message Dimension { 134 // Page width. 135 float width = 1; 136 137 // Page height. 138 float height = 2; 139 140 // Dimension unit. 141 string unit = 3; 142 } 143 144 // Rendered image contents for this page. 145 message Image { 146 // Raw byte content of the image. 147 bytes content = 1; 148 149 // Encoding [media type (MIME 150 // type)](https://www.iana.org/assignments/media-types/media-types.xhtml) 151 // for the image. 152 string mime_type = 2; 153 154 // Width of the image in pixels. 155 int32 width = 3; 156 157 // Height of the image in pixels. 158 int32 height = 4; 159 } 160 161 // Representation for transformation matrix, intended to be compatible and 162 // used with OpenCV format for image manipulation. 163 message Matrix { 164 // Number of rows in the matrix. 165 int32 rows = 1; 166 167 // Number of columns in the matrix. 168 int32 cols = 2; 169 170 // This encodes information about what data type the matrix uses. 171 // For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list 172 // of OpenCV primitive data types, please refer to 173 // https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html 174 int32 type = 3; 175 176 // The matrix data. 177 bytes data = 4; 178 } 179 180 // Visual element describing a layout unit on a page. 181 message Layout { 182 // Detected human reading orientation. 183 enum Orientation { 184 // Unspecified orientation. 185 ORIENTATION_UNSPECIFIED = 0; 186 187 // Orientation is aligned with page up. 188 PAGE_UP = 1; 189 190 // Orientation is aligned with page right. 191 // Turn the head 90 degrees clockwise from upright to read. 192 PAGE_RIGHT = 2; 193 194 // Orientation is aligned with page down. 195 // Turn the head 180 degrees from upright to read. 196 PAGE_DOWN = 3; 197 198 // Orientation is aligned with page left. 199 // Turn the head 90 degrees counterclockwise from upright to read. 200 PAGE_LEFT = 4; 201 } 202 203 // Text anchor indexing into the 204 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 205 TextAnchor text_anchor = 1; 206 207 // Confidence of the current 208 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] within 209 // context of the object this layout is for. e.g. confidence can be for a 210 // single token, a table, a visual element, etc. depending on context. 211 // Range `[0, 1]`. 212 float confidence = 2; 213 214 // The bounding polygon for the 215 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout]. 216 BoundingPoly bounding_poly = 3; 217 218 // Detected orientation for the 219 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout]. 220 Orientation orientation = 4; 221 } 222 223 // A block has a set of lines (collected into paragraphs) that have a 224 // common line-spacing and orientation. 225 message Block { 226 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 227 // [Block][google.cloud.documentai.v1beta2.Document.Page.Block]. 228 Layout layout = 1; 229 230 // A list of detected languages together with confidence. 231 repeated DetectedLanguage detected_languages = 2; 232 233 // The history of this annotation. 234 Provenance provenance = 3 [deprecated = true]; 235 } 236 237 // A collection of lines that a human would perceive as a paragraph. 238 message Paragraph { 239 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 240 // [Paragraph][google.cloud.documentai.v1beta2.Document.Page.Paragraph]. 241 Layout layout = 1; 242 243 // A list of detected languages together with confidence. 244 repeated DetectedLanguage detected_languages = 2; 245 246 // The history of this annotation. 247 Provenance provenance = 3 [deprecated = true]; 248 } 249 250 // A collection of tokens that a human would perceive as a line. 251 // Does not cross column boundaries, can be horizontal, vertical, etc. 252 message Line { 253 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 254 // [Line][google.cloud.documentai.v1beta2.Document.Page.Line]. 255 Layout layout = 1; 256 257 // A list of detected languages together with confidence. 258 repeated DetectedLanguage detected_languages = 2; 259 260 // The history of this annotation. 261 Provenance provenance = 3 [deprecated = true]; 262 } 263 264 // A detected token. 265 message Token { 266 // Detected break at the end of a 267 // [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. 268 message DetectedBreak { 269 // Enum to denote the type of break found. 270 enum Type { 271 // Unspecified break type. 272 TYPE_UNSPECIFIED = 0; 273 274 // A single whitespace. 275 SPACE = 1; 276 277 // A wider whitespace. 278 WIDE_SPACE = 2; 279 280 // A hyphen that indicates that a token has been split across lines. 281 HYPHEN = 3; 282 } 283 284 // Detected break type. 285 Type type = 1; 286 } 287 288 // Font and other text style attributes. 289 message StyleInfo { 290 // Font size in points (`1` point is `¹⁄₇₂` inches). 291 int32 font_size = 1; 292 293 // Font size in pixels, equal to _unrounded 294 // [font_size][google.cloud.documentai.v1beta2.Document.Page.Token.StyleInfo.font_size]_ 295 // * _resolution_ ÷ `72.0`. 296 double pixel_font_size = 2; 297 298 // Letter spacing in points. 299 double letter_spacing = 3; 300 301 // Name or style of the font. 302 string font_type = 4; 303 304 // Whether the text is bold (equivalent to 305 // [font_weight][google.cloud.documentai.v1beta2.Document.Page.Token.StyleInfo.font_weight] 306 // is at least `700`). 307 bool bold = 5; 308 309 // Whether the text is italic. 310 bool italic = 6; 311 312 // Whether the text is underlined. 313 bool underlined = 7; 314 315 // Whether the text is strikethrough. 316 bool strikeout = 8; 317 318 // Whether the text is a subscript. 319 bool subscript = 9; 320 321 // Whether the text is a superscript. 322 bool superscript = 10; 323 324 // Whether the text is in small caps. 325 bool smallcaps = 11; 326 327 // TrueType weight on a scale `100` (thin) to `1000` (ultra-heavy). 328 // Normal is `400`, bold is `700`. 329 int32 font_weight = 12; 330 331 // Whether the text is handwritten. 332 bool handwritten = 13; 333 334 // Color of the text. 335 google.type.Color text_color = 14; 336 337 // Color of the background. 338 google.type.Color background_color = 15; 339 } 340 341 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 342 // [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. 343 Layout layout = 1; 344 345 // Detected break at the end of a 346 // [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. 347 DetectedBreak detected_break = 2; 348 349 // A list of detected languages together with confidence. 350 repeated DetectedLanguage detected_languages = 3; 351 352 // The history of this annotation. 353 Provenance provenance = 4 [deprecated = true]; 354 355 // Text style attributes. 356 StyleInfo style_info = 5; 357 } 358 359 // A detected symbol. 360 message Symbol { 361 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 362 // [Symbol][google.cloud.documentai.v1beta2.Document.Page.Symbol]. 363 Layout layout = 1; 364 365 // A list of detected languages together with confidence. 366 repeated DetectedLanguage detected_languages = 2; 367 } 368 369 // Detected non-text visual elements e.g. checkbox, signature etc. on the 370 // page. 371 message VisualElement { 372 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 373 // [VisualElement][google.cloud.documentai.v1beta2.Document.Page.VisualElement]. 374 Layout layout = 1; 375 376 // Type of the 377 // [VisualElement][google.cloud.documentai.v1beta2.Document.Page.VisualElement]. 378 string type = 2; 379 380 // A list of detected languages together with confidence. 381 repeated DetectedLanguage detected_languages = 3; 382 } 383 384 // A table representation similar to HTML table structure. 385 message Table { 386 // A row of table cells. 387 message TableRow { 388 // Cells that make up this row. 389 repeated TableCell cells = 1; 390 } 391 392 // A cell representation inside the table. 393 message TableCell { 394 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 395 // [TableCell][google.cloud.documentai.v1beta2.Document.Page.Table.TableCell]. 396 Layout layout = 1; 397 398 // How many rows this cell spans. 399 int32 row_span = 2; 400 401 // How many columns this cell spans. 402 int32 col_span = 3; 403 404 // A list of detected languages together with confidence. 405 repeated DetectedLanguage detected_languages = 4; 406 } 407 408 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 409 // [Table][google.cloud.documentai.v1beta2.Document.Page.Table]. 410 Layout layout = 1; 411 412 // Header rows of the table. 413 repeated TableRow header_rows = 2; 414 415 // Body rows of the table. 416 repeated TableRow body_rows = 3; 417 418 // A list of detected languages together with confidence. 419 repeated DetectedLanguage detected_languages = 4; 420 421 // The history of this table. 422 Provenance provenance = 5 [deprecated = true]; 423 } 424 425 // A form field detected on the page. 426 message FormField { 427 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the 428 // [FormField][google.cloud.documentai.v1beta2.Document.Page.FormField] 429 // name. e.g. `Address`, `Email`, `Grand total`, `Phone number`, etc. 430 Layout field_name = 1; 431 432 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the 433 // [FormField][google.cloud.documentai.v1beta2.Document.Page.FormField] 434 // value. 435 Layout field_value = 2; 436 437 // A list of detected languages for name together with confidence. 438 repeated DetectedLanguage name_detected_languages = 3; 439 440 // A list of detected languages for value together with confidence. 441 repeated DetectedLanguage value_detected_languages = 4; 442 443 // If the value is non-textual, this field represents the type. Current 444 // valid values are: 445 // 446 // - blank (this indicates the `field_value` is normal text) 447 // - `unfilled_checkbox` 448 // - `filled_checkbox` 449 string value_type = 5; 450 451 // Created for Labeling UI to export key text. 452 // If corrections were made to the text identified by the 453 // `field_name.text_anchor`, this field will contain the correction. 454 string corrected_key_text = 6; 455 456 // Created for Labeling UI to export value text. 457 // If corrections were made to the text identified by the 458 // `field_value.text_anchor`, this field will contain the correction. 459 string corrected_value_text = 7; 460 461 // The history of this annotation. 462 Provenance provenance = 8; 463 } 464 465 // A detected barcode. 466 message DetectedBarcode { 467 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for 468 // [DetectedBarcode][google.cloud.documentai.v1beta2.Document.Page.DetectedBarcode]. 469 Layout layout = 1; 470 471 // Detailed barcode information of the 472 // [DetectedBarcode][google.cloud.documentai.v1beta2.Document.Page.DetectedBarcode]. 473 Barcode barcode = 2; 474 } 475 476 // Detected language for a structural component. 477 message DetectedLanguage { 478 // The [BCP-47 language 479 // code](https://www.unicode.org/reports/tr35/#Unicode_locale_identifier), 480 // such as `en-US` or `sr-Latn`. 481 string language_code = 1; 482 483 // Confidence of detected language. Range `[0, 1]`. 484 float confidence = 2; 485 } 486 487 // Image quality scores for the page image. 488 message ImageQualityScores { 489 // Image Quality Defects 490 message DetectedDefect { 491 // Name of the defect type. Supported values are: 492 // 493 // - `quality/defect_blurry` 494 // - `quality/defect_noisy` 495 // - `quality/defect_dark` 496 // - `quality/defect_faint` 497 // - `quality/defect_text_too_small` 498 // - `quality/defect_document_cutoff` 499 // - `quality/defect_text_cutoff` 500 // - `quality/defect_glare` 501 string type = 1; 502 503 // Confidence of detected defect. Range `[0, 1]` where `1` indicates 504 // strong confidence that the defect exists. 505 float confidence = 2; 506 } 507 508 // The overall quality score. Range `[0, 1]` where `1` is perfect quality. 509 float quality_score = 1; 510 511 // A list of detected defects. 512 repeated DetectedDefect detected_defects = 2; 513 } 514 515 // 1-based index for current 516 // [Page][google.cloud.documentai.v1beta2.Document.Page] in a parent 517 // [Document][google.cloud.documentai.v1beta2.Document]. Useful when a page 518 // is taken out of a [Document][google.cloud.documentai.v1beta2.Document] 519 // for individual processing. 520 int32 page_number = 1; 521 522 // Rendered image for this page. This image is preprocessed to remove any 523 // skew, rotation, and distortions such that the annotation bounding boxes 524 // can be upright and axis-aligned. 525 Image image = 13; 526 527 // Transformation matrices that were applied to the original document image 528 // to produce 529 // [Page.image][google.cloud.documentai.v1beta2.Document.Page.image]. 530 repeated Matrix transforms = 14; 531 532 // Physical dimension of the page. 533 Dimension dimension = 2; 534 535 // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the 536 // page. 537 Layout layout = 3; 538 539 // A list of detected languages together with confidence. 540 repeated DetectedLanguage detected_languages = 4; 541 542 // A list of visually detected text blocks on the page. 543 // A block has a set of lines (collected into paragraphs) that have a common 544 // line-spacing and orientation. 545 repeated Block blocks = 5; 546 547 // A list of visually detected text paragraphs on the page. 548 // A collection of lines that a human would perceive as a paragraph. 549 repeated Paragraph paragraphs = 6; 550 551 // A list of visually detected text lines on the page. 552 // A collection of tokens that a human would perceive as a line. 553 repeated Line lines = 7; 554 555 // A list of visually detected tokens on the page. 556 repeated Token tokens = 8; 557 558 // A list of detected non-text visual elements e.g. checkbox, 559 // signature etc. on the page. 560 repeated VisualElement visual_elements = 9; 561 562 // A list of visually detected tables on the page. 563 repeated Table tables = 10; 564 565 // A list of visually detected form fields on the page. 566 repeated FormField form_fields = 11; 567 568 // A list of visually detected symbols on the page. 569 repeated Symbol symbols = 12; 570 571 // A list of detected barcodes. 572 repeated DetectedBarcode detected_barcodes = 15; 573 574 // Image quality scores. 575 ImageQualityScores image_quality_scores = 17; 576 577 // The history of this page. 578 Provenance provenance = 16 [deprecated = true]; 579 } 580 581 // An entity that could be a phrase in the text or a property that belongs to 582 // the document. It is a known entity type, such as a person, an organization, 583 // or location. 584 message Entity { 585 // Parsed and normalized entity value. 586 message NormalizedValue { 587 // An optional structured entity value. 588 // Must match entity type defined in schema if 589 // known. If this field is present, the `text` field could also be 590 // populated. 591 oneof structured_value { 592 // Money value. See also: 593 // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto 594 google.type.Money money_value = 2; 595 596 // Date value. Includes year, month, day. See also: 597 // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto 598 google.type.Date date_value = 3; 599 600 // DateTime value. Includes date, time, and timezone. See also: 601 // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto 602 google.type.DateTime datetime_value = 4; 603 604 // Postal address. See also: 605 // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto 606 google.type.PostalAddress address_value = 5; 607 608 // Boolean value. Can be used for entities with binary values, or for 609 // checkboxes. 610 bool boolean_value = 6; 611 612 // Integer value. 613 int32 integer_value = 7; 614 615 // Float value. 616 float float_value = 8; 617 } 618 619 // Optional. An optional field to store a normalized string. 620 // For some entity types, one of respective `structured_value` fields may 621 // also be populated. Also not all the types of `structured_value` will be 622 // normalized. For example, some processors may not generate `float` 623 // or `integer` normalized text by default. 624 // 625 // Below are sample formats mapped to structured values. 626 // 627 // - Money/Currency type (`money_value`) is in the ISO 4217 text format. 628 // - Date type (`date_value`) is in the ISO 8601 text format. 629 // - Datetime type (`datetime_value`) is in the ISO 8601 text format. 630 string text = 1 [(google.api.field_behavior) = OPTIONAL]; 631 } 632 633 // Optional. Provenance of the entity. 634 // Text anchor indexing into the 635 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 636 TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; 637 638 // Required. Entity type from a schema e.g. `Address`. 639 string type = 2 [(google.api.field_behavior) = REQUIRED]; 640 641 // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. 642 string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; 643 644 // Optional. Deprecated. Use `id` field instead. 645 string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; 646 647 // Optional. Confidence of detected Schema entity. Range `[0, 1]`. 648 float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; 649 650 // Optional. Represents the provenance of this entity wrt. the location on 651 // the page where it was found. 652 PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; 653 654 // Optional. Canonical id. This will be a unique value in the entity list 655 // for this document. 656 string id = 7 [(google.api.field_behavior) = OPTIONAL]; 657 658 // Optional. Normalized entity value. Absent if the extracted value could 659 // not be converted or the type (e.g. address) is not supported for certain 660 // parsers. This field is also only populated for certain supported document 661 // types. 662 NormalizedValue normalized_value = 9 663 [(google.api.field_behavior) = OPTIONAL]; 664 665 // Optional. Entities can be nested to form a hierarchical data structure 666 // representing the content in the document. 667 repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; 668 669 // Optional. The history of this annotation. 670 Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; 671 672 // Optional. Whether the entity will be redacted for de-identification 673 // purposes. 674 bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; 675 } 676 677 // Relationship between 678 // [Entities][google.cloud.documentai.v1beta2.Document.Entity]. 679 message EntityRelation { 680 // Subject entity id. 681 string subject_id = 1; 682 683 // Object entity id. 684 string object_id = 2; 685 686 // Relationship description. 687 string relation = 3; 688 } 689 690 // Text reference indexing into the 691 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 692 message TextAnchor { 693 // A text segment in the 694 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. The 695 // indices may be out of bounds which indicate that the text extends into 696 // another document shard for large sharded documents. See 697 // [ShardInfo.text_offset][google.cloud.documentai.v1beta2.Document.ShardInfo.text_offset] 698 message TextSegment { 699 // [TextSegment][google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment] 700 // start UTF-8 char index in the 701 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 702 int64 start_index = 1; 703 704 // [TextSegment][google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment] 705 // half open end UTF-8 char index in the 706 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 707 int64 end_index = 2; 708 } 709 710 // The text segments from the 711 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 712 repeated TextSegment text_segments = 1; 713 714 // Contains the content of the text span so that users do 715 // not have to look it up in the text_segments. It is always 716 // populated for formFields. 717 string content = 2; 718 } 719 720 // Referencing the visual context of the entity in the 721 // [Document.pages][google.cloud.documentai.v1beta2.Document.pages]. Page 722 // anchors can be cross-page, consist of multiple bounding polygons and 723 // optionally reference specific layout element types. 724 message PageAnchor { 725 // Represents a weak reference to a page element within a document. 726 message PageRef { 727 // The type of layout that is being referenced. 728 enum LayoutType { 729 // Layout Unspecified. 730 LAYOUT_TYPE_UNSPECIFIED = 0; 731 732 // References a 733 // [Page.blocks][google.cloud.documentai.v1beta2.Document.Page.blocks] 734 // element. 735 BLOCK = 1; 736 737 // References a 738 // [Page.paragraphs][google.cloud.documentai.v1beta2.Document.Page.paragraphs] 739 // element. 740 PARAGRAPH = 2; 741 742 // References a 743 // [Page.lines][google.cloud.documentai.v1beta2.Document.Page.lines] 744 // element. 745 LINE = 3; 746 747 // References a 748 // [Page.tokens][google.cloud.documentai.v1beta2.Document.Page.tokens] 749 // element. 750 TOKEN = 4; 751 752 // References a 753 // [Page.visual_elements][google.cloud.documentai.v1beta2.Document.Page.visual_elements] 754 // element. 755 VISUAL_ELEMENT = 5; 756 757 // Refrrences a 758 // [Page.tables][google.cloud.documentai.v1beta2.Document.Page.tables] 759 // element. 760 TABLE = 6; 761 762 // References a 763 // [Page.form_fields][google.cloud.documentai.v1beta2.Document.Page.form_fields] 764 // element. 765 FORM_FIELD = 7; 766 } 767 768 // Required. Index into the 769 // [Document.pages][google.cloud.documentai.v1beta2.Document.pages] 770 // element, for example using 771 // `[Document.pages][page_refs.page]` to locate the related page element. 772 // This field is skipped when its value is the default `0`. See 773 // https://developers.google.com/protocol-buffers/docs/proto3#json. 774 int64 page = 1 [(google.api.field_behavior) = REQUIRED]; 775 776 // Optional. The type of the layout element that is being referenced if 777 // any. 778 LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; 779 780 // Optional. Deprecated. Use 781 // [PageRef.bounding_poly][google.cloud.documentai.v1beta2.Document.PageAnchor.PageRef.bounding_poly] 782 // instead. 783 string layout_id = 3 784 [deprecated = true, (google.api.field_behavior) = OPTIONAL]; 785 786 // Optional. Identifies the bounding polygon of a layout element on the 787 // page. If `layout_type` is set, the bounding polygon must be exactly the 788 // same to the layout element it's referring to. 789 BoundingPoly bounding_poly = 4 [(google.api.field_behavior) = OPTIONAL]; 790 791 // Optional. Confidence of detected page element, if applicable. Range 792 // `[0, 1]`. 793 float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; 794 } 795 796 // One or more references to visual page elements 797 repeated PageRef page_refs = 1; 798 } 799 800 // Structure to identify provenance relationships between annotations in 801 // different revisions. 802 message Provenance { 803 // The parent element the current element is based on. Used for 804 // referencing/aligning, removal and replacement operations. 805 message Parent { 806 // The index of the index into current revision's parent_ids list. 807 int32 revision = 1; 808 809 // The index of the parent item in the corresponding item list (eg. list 810 // of entities, properties within entities, etc.) in the parent revision. 811 int32 index = 3; 812 813 // The id of the parent provenance. 814 int32 id = 2 [deprecated = true]; 815 } 816 817 // If a processor or agent does an explicit operation on existing elements. 818 enum OperationType { 819 // Operation type unspecified. If no operation is specified a provenance 820 // entry is simply used to match against a `parent`. 821 OPERATION_TYPE_UNSPECIFIED = 0; 822 823 // Add an element. 824 ADD = 1; 825 826 // Remove an element identified by `parent`. 827 REMOVE = 2; 828 829 // Updates any fields within the given provenance scope of the message. It 830 // overwrites the fields rather than replacing them. Use this when you 831 // want to update a field value of an entity without also updating all the 832 // child properties. 833 UPDATE = 7; 834 835 // Currently unused. Replace an element identified by `parent`. 836 REPLACE = 3; 837 838 // Deprecated. Request human review for the element identified by 839 // `parent`. 840 EVAL_REQUESTED = 4 [deprecated = true]; 841 842 // Deprecated. Element is reviewed and approved at human review, 843 // confidence will be set to 1.0. 844 EVAL_APPROVED = 5 [deprecated = true]; 845 846 // Deprecated. Element is skipped in the validation process. 847 EVAL_SKIPPED = 6 [deprecated = true]; 848 } 849 850 // The index of the revision that produced this element. 851 int32 revision = 1 [deprecated = true]; 852 853 // The Id of this operation. Needs to be unique within the scope of the 854 // revision. 855 int32 id = 2 [deprecated = true]; 856 857 // References to the original elements that are replaced. 858 repeated Parent parents = 3; 859 860 // The type of provenance operation. 861 OperationType type = 4; 862 } 863 864 // Contains past or forward revisions of this document. 865 message Revision { 866 // Human Review information of the document. 867 message HumanReview { 868 // Human review state. e.g. `requested`, `succeeded`, `rejected`. 869 string state = 1; 870 871 // A message providing more details about the current state of processing. 872 // For example, the rejection reason when the state is `rejected`. 873 string state_message = 2; 874 } 875 876 // Who/what made the change 877 oneof source { 878 // If the change was made by a person specify the name or id of that 879 // person. 880 string agent = 4; 881 882 // If the annotation was made by processor identify the processor by its 883 // resource name. 884 string processor = 5; 885 } 886 887 // Id of the revision, internally generated by doc proto storage. 888 // Unique within the context of the document. 889 string id = 1; 890 891 // The revisions that this revision is based on. This can include one or 892 // more parent (when documents are merged.) This field represents the 893 // index into the `revisions` field. 894 repeated int32 parent = 2 [deprecated = true]; 895 896 // The revisions that this revision is based on. Must include all the ids 897 // that have anything to do with this revision - eg. there are 898 // `provenance.parent.revision` fields that index into this field. 899 repeated string parent_ids = 7; 900 901 // The time that the revision was created, internally generated by 902 // doc proto storage at the time of create. 903 google.protobuf.Timestamp create_time = 3; 904 905 // Human Review information of this revision. 906 HumanReview human_review = 6; 907 } 908 909 // This message is used for text changes aka. OCR corrections. 910 message TextChange { 911 // Provenance of the correction. 912 // Text anchor indexing into the 913 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. There 914 // can only be a single `TextAnchor.text_segments` element. If the start 915 // and end index of the text segment are the same, the text change is 916 // inserted before that index. 917 TextAnchor text_anchor = 1; 918 919 // The text that replaces the text identified in the `text_anchor`. 920 string changed_text = 2; 921 922 // The history of this annotation. 923 repeated Provenance provenance = 3 [deprecated = true]; 924 } 925 926 // Original source document from the user. 927 oneof source { 928 // Optional. Currently supports Google Cloud Storage URI of the form 929 // `gs://bucket_name/object_name`. Object versioning is not supported. 930 // For more information, refer to [Google Cloud Storage Request 931 // URIs](https://cloud.google.com/storage/docs/reference-uris). 932 string uri = 1 [(google.api.field_behavior) = OPTIONAL]; 933 934 // Optional. Inline document content, represented as a stream of bytes. 935 // Note: As with all `bytes` fields, protobuffers use a pure binary 936 // representation, whereas JSON representations use base64. 937 bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; 938 } 939 940 // An IANA published [media type (MIME 941 // type)](https://www.iana.org/assignments/media-types/media-types.xhtml). 942 string mime_type = 3; 943 944 // Optional. UTF-8 encoded text in reading order from the document. 945 string text = 4 [(google.api.field_behavior) = OPTIONAL]; 946 947 // Styles for the 948 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. 949 repeated Style text_styles = 5 [deprecated = true]; 950 951 // Visual page layout for the 952 // [Document][google.cloud.documentai.v1beta2.Document]. 953 repeated Page pages = 6; 954 955 // A list of entities detected on 956 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. For 957 // document shards, entities in this list may cross shard boundaries. 958 repeated Entity entities = 7; 959 960 // Placeholder. Relationship among 961 // [Document.entities][google.cloud.documentai.v1beta2.Document.entities]. 962 repeated EntityRelation entity_relations = 8; 963 964 // Placeholder. A list of text corrections made to 965 // [Document.text][google.cloud.documentai.v1beta2.Document.text]. This is 966 // usually used for annotating corrections to OCR mistakes. Text changes for 967 // a given revision may not overlap with each other. 968 repeated TextChange text_changes = 14; 969 970 // Information about the sharding if this document is sharded part of a larger 971 // document. If the document is not sharded, this message is not specified. 972 ShardInfo shard_info = 9; 973 974 // [Label][google.cloud.documentai.v1beta2.Document.Label]s for this document. 975 repeated Label labels = 11; 976 977 // Any error that occurred while processing this document. 978 google.rpc.Status error = 10; 979 980 // Placeholder. Revision history of this document. 981 repeated Revision revisions = 13; 982} 983