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