document.proto 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. // Copyright 2021 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. syntax = "proto3";
  15. package google.cloud.documentai.v1;
  16. import "google/api/field_behavior.proto";
  17. import "google/cloud/documentai/v1/geometry.proto";
  18. import "google/protobuf/timestamp.proto";
  19. import "google/rpc/status.proto";
  20. import "google/type/color.proto";
  21. import "google/type/date.proto";
  22. import "google/type/datetime.proto";
  23. import "google/type/money.proto";
  24. import "google/type/postal_address.proto";
  25. import "google/api/annotations.proto";
  26. option csharp_namespace = "Google.Cloud.DocumentAI.V1";
  27. option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai";
  28. option java_multiple_files = true;
  29. option java_outer_classname = "DocumentProto";
  30. option java_package = "com.google.cloud.documentai.v1";
  31. option php_namespace = "Google\\Cloud\\DocumentAI\\V1";
  32. option ruby_package = "Google::Cloud::DocumentAI::V1";
  33. // Document represents the canonical document resource in Document Understanding
  34. // AI.
  35. // It is an interchange format that provides insights into documents and allows
  36. // for collaboration between users and Document Understanding AI to iterate and
  37. // optimize for quality.
  38. message Document {
  39. // For a large document, sharding may be performed to produce several
  40. // document shards. Each document shard contains this field to detail which
  41. // shard it is.
  42. message ShardInfo {
  43. // The 0-based index of this shard.
  44. int64 shard_index = 1;
  45. // Total number of shards.
  46. int64 shard_count = 2;
  47. // The index of the first character in [Document.text][google.cloud.documentai.v1.Document.text] in the overall
  48. // document global text.
  49. int64 text_offset = 3;
  50. }
  51. // Annotation for common text style attributes. This adheres to CSS
  52. // conventions as much as possible.
  53. message Style {
  54. // Font size with unit.
  55. message FontSize {
  56. // Font size for the text.
  57. float size = 1;
  58. // Unit for the font size. Follows CSS naming (in, px, pt, etc.).
  59. string unit = 2;
  60. }
  61. // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text].
  62. TextAnchor text_anchor = 1;
  63. // Text color.
  64. google.type.Color color = 2;
  65. // Text background color.
  66. google.type.Color background_color = 3;
  67. // Font weight. Possible values are normal, bold, bolder, and lighter.
  68. // https://www.w3schools.com/cssref/pr_font_weight.asp
  69. string font_weight = 4;
  70. // Text style. Possible values are normal, italic, and oblique.
  71. // https://www.w3schools.com/cssref/pr_font_font-style.asp
  72. string text_style = 5;
  73. // Text decoration. Follows CSS standard.
  74. // <text-decoration-line> <text-decoration-color> <text-decoration-style>
  75. // https://www.w3schools.com/cssref/pr_text_text-decoration.asp
  76. string text_decoration = 6;
  77. // Font size.
  78. FontSize font_size = 7;
  79. }
  80. // A page in a [Document][google.cloud.documentai.v1.Document].
  81. message Page {
  82. // Dimension for the page.
  83. message Dimension {
  84. // Page width.
  85. float width = 1;
  86. // Page height.
  87. float height = 2;
  88. // Dimension unit.
  89. string unit = 3;
  90. }
  91. // Rendered image contents for this page.
  92. message Image {
  93. // Raw byte content of the image.
  94. bytes content = 1;
  95. // Encoding mime type for the image.
  96. string mime_type = 2;
  97. // Width of the image in pixels.
  98. int32 width = 3;
  99. // Height of the image in pixels.
  100. int32 height = 4;
  101. }
  102. // Representation for transformation matrix, intended to be compatible and
  103. // used with OpenCV format for image manipulation.
  104. message Matrix {
  105. // Number of rows in the matrix.
  106. int32 rows = 1;
  107. // Number of columns in the matrix.
  108. int32 cols = 2;
  109. // This encodes information about what data type the matrix uses.
  110. // For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list
  111. // of OpenCV primitive data types, please refer to
  112. // https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html
  113. int32 type = 3;
  114. // The matrix data.
  115. bytes data = 4;
  116. }
  117. // Visual element describing a layout unit on a page.
  118. message Layout {
  119. // Detected human reading orientation.
  120. enum Orientation {
  121. // Unspecified orientation.
  122. ORIENTATION_UNSPECIFIED = 0;
  123. // Orientation is aligned with page up.
  124. PAGE_UP = 1;
  125. // Orientation is aligned with page right.
  126. // Turn the head 90 degrees clockwise from upright to read.
  127. PAGE_RIGHT = 2;
  128. // Orientation is aligned with page down.
  129. // Turn the head 180 degrees from upright to read.
  130. PAGE_DOWN = 3;
  131. // Orientation is aligned with page left.
  132. // Turn the head 90 degrees counterclockwise from upright to read.
  133. PAGE_LEFT = 4;
  134. }
  135. // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text].
  136. TextAnchor text_anchor = 1;
  137. // Confidence of the current [Layout][google.cloud.documentai.v1.Document.Page.Layout] within context of the object this
  138. // layout is for. e.g. confidence can be for a single token, a table,
  139. // a visual element, etc. depending on context. Range [0, 1].
  140. float confidence = 2;
  141. // The bounding polygon for the [Layout][google.cloud.documentai.v1.Document.Page.Layout].
  142. BoundingPoly bounding_poly = 3;
  143. // Detected orientation for the [Layout][google.cloud.documentai.v1.Document.Page.Layout].
  144. Orientation orientation = 4;
  145. }
  146. // A block has a set of lines (collected into paragraphs) that have a
  147. // common line-spacing and orientation.
  148. message Block {
  149. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Block][google.cloud.documentai.v1.Document.Page.Block].
  150. Layout layout = 1;
  151. // A list of detected languages together with confidence.
  152. repeated DetectedLanguage detected_languages = 2;
  153. // The history of this annotation.
  154. Provenance provenance = 3;
  155. }
  156. // A collection of lines that a human would perceive as a paragraph.
  157. message Paragraph {
  158. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1.Document.Page.Paragraph].
  159. Layout layout = 1;
  160. // A list of detected languages together with confidence.
  161. repeated DetectedLanguage detected_languages = 2;
  162. // The history of this annotation.
  163. Provenance provenance = 3;
  164. }
  165. // A collection of tokens that a human would perceive as a line.
  166. // Does not cross column boundaries, can be horizontal, vertical, etc.
  167. message Line {
  168. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Line][google.cloud.documentai.v1.Document.Page.Line].
  169. Layout layout = 1;
  170. // A list of detected languages together with confidence.
  171. repeated DetectedLanguage detected_languages = 2;
  172. // The history of this annotation.
  173. Provenance provenance = 3;
  174. }
  175. // A detected token.
  176. message Token {
  177. // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token].
  178. message DetectedBreak {
  179. // Enum to denote the type of break found.
  180. enum Type {
  181. // Unspecified break type.
  182. TYPE_UNSPECIFIED = 0;
  183. // A single whitespace.
  184. SPACE = 1;
  185. // A wider whitespace.
  186. WIDE_SPACE = 2;
  187. // A hyphen that indicates that a token has been split across lines.
  188. HYPHEN = 3;
  189. }
  190. // Detected break type.
  191. Type type = 1;
  192. }
  193. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Token][google.cloud.documentai.v1.Document.Page.Token].
  194. Layout layout = 1;
  195. // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token].
  196. DetectedBreak detected_break = 2;
  197. // A list of detected languages together with confidence.
  198. repeated DetectedLanguage detected_languages = 3;
  199. // The history of this annotation.
  200. Provenance provenance = 4;
  201. }
  202. // Detected non-text visual elements e.g. checkbox, signature etc. on the
  203. // page.
  204. message VisualElement {
  205. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement].
  206. Layout layout = 1;
  207. // Type of the [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement].
  208. string type = 2;
  209. // A list of detected languages together with confidence.
  210. repeated DetectedLanguage detected_languages = 3;
  211. }
  212. // A table representation similar to HTML table structure.
  213. message Table {
  214. // A row of table cells.
  215. message TableRow {
  216. // Cells that make up this row.
  217. repeated TableCell cells = 1;
  218. }
  219. // A cell representation inside the table.
  220. message TableCell {
  221. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1.Document.Page.Table.TableCell].
  222. Layout layout = 1;
  223. // How many rows this cell spans.
  224. int32 row_span = 2;
  225. // How many columns this cell spans.
  226. int32 col_span = 3;
  227. // A list of detected languages together with confidence.
  228. repeated DetectedLanguage detected_languages = 4;
  229. }
  230. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Table][google.cloud.documentai.v1.Document.Page.Table].
  231. Layout layout = 1;
  232. // Header rows of the table.
  233. repeated TableRow header_rows = 2;
  234. // Body rows of the table.
  235. repeated TableRow body_rows = 3;
  236. // A list of detected languages together with confidence.
  237. repeated DetectedLanguage detected_languages = 4;
  238. }
  239. // A form field detected on the page.
  240. message FormField {
  241. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] name. e.g. `Address`, `Email`,
  242. // `Grand total`, `Phone number`, etc.
  243. Layout field_name = 1;
  244. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] value.
  245. Layout field_value = 2;
  246. // A list of detected languages for name together with confidence.
  247. repeated DetectedLanguage name_detected_languages = 3;
  248. // A list of detected languages for value together with confidence.
  249. repeated DetectedLanguage value_detected_languages = 4;
  250. // If the value is non-textual, this field represents the type. Current
  251. // valid values are:
  252. // - blank (this indicates the field_value is normal text)
  253. // - "unfilled_checkbox"
  254. // - "filled_checkbox"
  255. string value_type = 5;
  256. // The history of this annotation.
  257. Provenance provenance = 8;
  258. }
  259. // Detected language for a structural component.
  260. message DetectedLanguage {
  261. // The BCP-47 language code, such as "en-US" or "sr-Latn". For more
  262. // information, see
  263. // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
  264. string language_code = 1;
  265. // Confidence of detected language. Range [0, 1].
  266. float confidence = 2;
  267. }
  268. // 1-based index for current [Page][google.cloud.documentai.v1.Document.Page] in a parent [Document][google.cloud.documentai.v1.Document].
  269. // Useful when a page is taken out of a [Document][google.cloud.documentai.v1.Document] for individual
  270. // processing.
  271. int32 page_number = 1;
  272. // Rendered image for this page. This image is preprocessed to remove any
  273. // skew, rotation, and distortions such that the annotation bounding boxes
  274. // can be upright and axis-aligned.
  275. Image image = 13;
  276. // Transformation matrices that were applied to the original document image
  277. // to produce [Page.image][google.cloud.documentai.v1.Document.Page.image].
  278. repeated Matrix transforms = 14;
  279. // Physical dimension of the page.
  280. Dimension dimension = 2;
  281. // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the page.
  282. Layout layout = 3;
  283. // A list of detected languages together with confidence.
  284. repeated DetectedLanguage detected_languages = 4;
  285. // A list of visually detected text blocks on the page.
  286. // A block has a set of lines (collected into paragraphs) that have a common
  287. // line-spacing and orientation.
  288. repeated Block blocks = 5;
  289. // A list of visually detected text paragraphs on the page.
  290. // A collection of lines that a human would perceive as a paragraph.
  291. repeated Paragraph paragraphs = 6;
  292. // A list of visually detected text lines on the page.
  293. // A collection of tokens that a human would perceive as a line.
  294. repeated Line lines = 7;
  295. // A list of visually detected tokens on the page.
  296. repeated Token tokens = 8;
  297. // A list of detected non-text visual elements e.g. checkbox,
  298. // signature etc. on the page.
  299. repeated VisualElement visual_elements = 9;
  300. // A list of visually detected tables on the page.
  301. repeated Table tables = 10;
  302. // A list of visually detected form fields on the page.
  303. repeated FormField form_fields = 11;
  304. // The history of this page.
  305. Provenance provenance = 16;
  306. }
  307. // A phrase in the text that is a known entity type, such as a person, an
  308. // organization, or location.
  309. message Entity {
  310. // Parsed and normalized entity value.
  311. message NormalizedValue {
  312. // Structured entity value. Must match entity type defined in schema if
  313. // known. If this field is present, the 'text' field is still populated.
  314. oneof structured_value {
  315. // Money value. See also:
  316. // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto
  317. google.type.Money money_value = 2;
  318. // Date value. Includes year, month, day. See also:
  319. // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
  320. google.type.Date date_value = 3;
  321. // DateTime value. Includes date, time, and timezone. See also:
  322. // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto
  323. google.type.DateTime datetime_value = 4;
  324. // Postal address. See also:
  325. // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto
  326. google.type.PostalAddress address_value = 5;
  327. // Boolean value. Can be used for entities with binary values, or for
  328. // checkboxes.
  329. bool boolean_value = 6;
  330. }
  331. // Required. Normalized entity value stored as a string. This field is populated for
  332. // supported document type (e.g. Invoice). For some entity types, one of
  333. // respective 'structured_value' fields may also be populated.
  334. //
  335. // - Money/Currency type (`money_value`) is in the ISO 4217 text format.
  336. // - Date type (`date_value`) is in the ISO 8601 text format.
  337. // - Datetime type (`datetime_value`) is in the ISO 8601 text format.
  338. string text = 1 [(google.api.field_behavior) = REQUIRED];
  339. }
  340. // Optional. Provenance of the entity.
  341. // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text].
  342. TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL];
  343. // Entity type from a schema e.g. `Address`.
  344. string type = 2;
  345. // Optional. Text value in the document e.g. `1600 Amphitheatre Pkwy`.
  346. string mention_text = 3 [(google.api.field_behavior) = OPTIONAL];
  347. // Optional. Deprecated. Use `id` field instead.
  348. string mention_id = 4 [(google.api.field_behavior) = OPTIONAL];
  349. // Optional. Confidence of detected Schema entity. Range [0, 1].
  350. float confidence = 5 [(google.api.field_behavior) = OPTIONAL];
  351. // Optional. Represents the provenance of this entity wrt. the location on the
  352. // page where it was found.
  353. PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL];
  354. // Optional. Canonical id. This will be a unique value in the entity list
  355. // for this document.
  356. string id = 7 [(google.api.field_behavior) = OPTIONAL];
  357. // Optional. Normalized entity value. Absent if the extracted value could not be
  358. // converted or the type (e.g. address) is not supported for certain
  359. // parsers. This field is also only populated for certain supported document
  360. // types.
  361. NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL];
  362. // Optional. Entities can be nested to form a hierarchical data structure representing
  363. // the content in the document.
  364. repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL];
  365. // Optional. The history of this annotation.
  366. Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL];
  367. // Optional. Whether the entity will be redacted for de-identification purposes.
  368. bool redacted = 12 [(google.api.field_behavior) = OPTIONAL];
  369. }
  370. // Relationship between [Entities][google.cloud.documentai.v1.Document.Entity].
  371. message EntityRelation {
  372. // Subject entity id.
  373. string subject_id = 1;
  374. // Object entity id.
  375. string object_id = 2;
  376. // Relationship description.
  377. string relation = 3;
  378. }
  379. // Text reference indexing into the [Document.text][google.cloud.documentai.v1.Document.text].
  380. message TextAnchor {
  381. // A text segment in the [Document.text][google.cloud.documentai.v1.Document.text]. The indices may be out of bounds
  382. // which indicate that the text extends into another document shard for
  383. // large sharded documents. See [ShardInfo.text_offset][google.cloud.documentai.v1.Document.ShardInfo.text_offset]
  384. message TextSegment {
  385. // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1.Document.text].
  386. int64 start_index = 1;
  387. // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the
  388. // [Document.text][google.cloud.documentai.v1.Document.text].
  389. int64 end_index = 2;
  390. }
  391. // The text segments from the [Document.text][google.cloud.documentai.v1.Document.text].
  392. repeated TextSegment text_segments = 1;
  393. // Contains the content of the text span so that users do
  394. // not have to look it up in the text_segments.
  395. string content = 2;
  396. }
  397. // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1.Document.pages].
  398. // Page anchors can be cross-page, consist of multiple bounding polygons and
  399. // optionally reference specific layout element types.
  400. message PageAnchor {
  401. // Represents a weak reference to a page element within a document.
  402. message PageRef {
  403. // The type of layout that is being referenced.
  404. enum LayoutType {
  405. // Layout Unspecified.
  406. LAYOUT_TYPE_UNSPECIFIED = 0;
  407. // References a [Page.blocks][google.cloud.documentai.v1.Document.Page.blocks] element.
  408. BLOCK = 1;
  409. // References a [Page.paragraphs][google.cloud.documentai.v1.Document.Page.paragraphs] element.
  410. PARAGRAPH = 2;
  411. // References a [Page.lines][google.cloud.documentai.v1.Document.Page.lines] element.
  412. LINE = 3;
  413. // References a [Page.tokens][google.cloud.documentai.v1.Document.Page.tokens] element.
  414. TOKEN = 4;
  415. // References a [Page.visual_elements][google.cloud.documentai.v1.Document.Page.visual_elements] element.
  416. VISUAL_ELEMENT = 5;
  417. // Refrrences a [Page.tables][google.cloud.documentai.v1.Document.Page.tables] element.
  418. TABLE = 6;
  419. // References a [Page.form_fields][google.cloud.documentai.v1.Document.Page.form_fields] element.
  420. FORM_FIELD = 7;
  421. }
  422. // Required. Index into the [Document.pages][google.cloud.documentai.v1.Document.pages] element, for example using
  423. // [Document.pages][page_refs.page] to locate the related page element.
  424. // This field is skipped when its value is the default 0. See
  425. // https://developers.google.com/protocol-buffers/docs/proto3#json.
  426. int64 page = 1 [(google.api.field_behavior) = REQUIRED];
  427. // Optional. The type of the layout element that is being referenced if any.
  428. LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL];
  429. // Optional. Deprecated. Use [PageRef.bounding_poly][google.cloud.documentai.v1.Document.PageAnchor.PageRef.bounding_poly] instead.
  430. string layout_id = 3 [
  431. deprecated = true,
  432. (google.api.field_behavior) = OPTIONAL
  433. ];
  434. // Optional. Identifies the bounding polygon of a layout element on the page.
  435. BoundingPoly bounding_poly = 4 [(google.api.field_behavior) = OPTIONAL];
  436. // Optional. Confidence of detected page element, if applicable. Range [0, 1].
  437. float confidence = 5 [(google.api.field_behavior) = OPTIONAL];
  438. }
  439. // One or more references to visual page elements
  440. repeated PageRef page_refs = 1;
  441. }
  442. // Structure to identify provenance relationships between annotations in
  443. // different revisions.
  444. message Provenance {
  445. // Structure for referencing parent provenances. When an element replaces
  446. // one of more other elements parent references identify the elements that
  447. // are replaced.
  448. message Parent {
  449. // The index of the [Document.revisions] identifying the parent revision.
  450. int32 revision = 1;
  451. // The index of the parent revisions corresponding collection of items
  452. // (eg. list of entities, properties within entities, etc.)
  453. int32 index = 3;
  454. // The id of the parent provenance.
  455. int32 id = 2 [deprecated = true];
  456. }
  457. // If a processor or agent does an explicit operation on existing elements.
  458. enum OperationType {
  459. // Operation type unspecified.
  460. OPERATION_TYPE_UNSPECIFIED = 0;
  461. // Add an element. Implicit if no `parents` are set for the provenance.
  462. ADD = 1;
  463. // The element is removed. No `parents` should be set.
  464. REMOVE = 2;
  465. // Explicitly replaces the element(s) identified by `parents`.
  466. REPLACE = 3;
  467. // Element is requested for human review.
  468. EVAL_REQUESTED = 4;
  469. // Element is reviewed and approved at human review, confidence will be
  470. // set to 1.0.
  471. EVAL_APPROVED = 5;
  472. // Element is skipped in the validation process.
  473. EVAL_SKIPPED = 6;
  474. }
  475. // The index of the revision that produced this element.
  476. int32 revision = 1;
  477. // The Id of this operation. Needs to be unique within the scope of the
  478. // revision.
  479. int32 id = 2 [deprecated = true];
  480. // References to the original elements that are replaced.
  481. repeated Parent parents = 3;
  482. // The type of provenance operation.
  483. OperationType type = 4;
  484. }
  485. // Contains past or forward revisions of this document.
  486. message Revision {
  487. // Human Review information of the document.
  488. message HumanReview {
  489. // Human review state. e.g. `requested`, `succeeded`, `rejected`.
  490. string state = 1;
  491. // A message providing more details about the current state of processing.
  492. // For example, the rejection reason when the state is `rejected`.
  493. string state_message = 2;
  494. }
  495. // Who/what made the change
  496. oneof source {
  497. // If the change was made by a person specify the name or id of that
  498. // person.
  499. string agent = 4;
  500. // If the annotation was made by processor identify the processor by its
  501. // resource name.
  502. string processor = 5;
  503. }
  504. // Id of the revision. Unique within the context of the document.
  505. string id = 1;
  506. // The revisions that this revision is based on. This can include one or
  507. // more parent (when documents are merged.) This field represents the
  508. // index into the `revisions` field.
  509. repeated int32 parent = 2;
  510. // The time that the revision was created.
  511. google.protobuf.Timestamp create_time = 3;
  512. // Human Review information of this revision.
  513. HumanReview human_review = 6;
  514. }
  515. // This message is used for text changes aka. OCR corrections.
  516. message TextChange {
  517. // Provenance of the correction.
  518. // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. There can only be a
  519. // single `TextAnchor.text_segments` element. If the start and
  520. // end index of the text segment are the same, the text change is inserted
  521. // before that index.
  522. TextAnchor text_anchor = 1;
  523. // The text that replaces the text identified in the `text_anchor`.
  524. string changed_text = 2;
  525. // The history of this annotation.
  526. repeated Provenance provenance = 3;
  527. }
  528. // Original source document from the user.
  529. oneof source {
  530. // Optional. Currently supports Google Cloud Storage URI of the form
  531. // `gs://bucket_name/object_name`. Object versioning is not supported.
  532. // See [Google Cloud Storage Request
  533. // URIs](https://cloud.google.com/storage/docs/reference-uris) for more
  534. // info.
  535. string uri = 1 [(google.api.field_behavior) = OPTIONAL];
  536. // Optional. Inline document content, represented as a stream of bytes.
  537. // Note: As with all `bytes` fields, protobuffers use a pure binary
  538. // representation, whereas JSON representations use base64.
  539. bytes content = 2 [(google.api.field_behavior) = OPTIONAL];
  540. }
  541. // An IANA published MIME type (also referred to as media type). For more
  542. // information, see
  543. // https://www.iana.org/assignments/media-types/media-types.xhtml.
  544. string mime_type = 3;
  545. // Optional. UTF-8 encoded text in reading order from the document.
  546. string text = 4 [(google.api.field_behavior) = OPTIONAL];
  547. // Styles for the [Document.text][google.cloud.documentai.v1.Document.text].
  548. repeated Style text_styles = 5;
  549. // Visual page layout for the [Document][google.cloud.documentai.v1.Document].
  550. repeated Page pages = 6;
  551. // A list of entities detected on [Document.text][google.cloud.documentai.v1.Document.text]. For document shards,
  552. // entities in this list may cross shard boundaries.
  553. repeated Entity entities = 7;
  554. // Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities].
  555. repeated EntityRelation entity_relations = 8;
  556. // A list of text corrections made to [Document.text]. This is usually
  557. // used for annotating corrections to OCR mistakes. Text changes for a given
  558. // revision may not overlap with each other.
  559. repeated TextChange text_changes = 14;
  560. // Information about the sharding if this document is sharded part of a larger
  561. // document. If the document is not sharded, this message is not specified.
  562. ShardInfo shard_info = 9;
  563. // Any error that occurred while processing this document.
  564. google.rpc.Status error = 10;
  565. // Revision history of this document.
  566. repeated Revision revisions = 13;
  567. }