Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit a0b46b5

Browse files
feat: add content field in TextAnchor (#787)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 435142243 Source-Link: googleapis/googleapis@721b367 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b627aaeb3afafe7d94d6099a2d1945aa9b4dadad Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjYyN2FhZWIzYWZhZmU3ZDk0ZDYwOTlhMmQxOTQ1YWE5YjRkYWRhZCJ9
1 parent 982d772 commit a0b46b5

File tree

3 files changed

+238
-21
lines changed

3 files changed

+238
-21
lines changed

proto-google-cloud-document-ai-v1beta2/src/main/java/com/google/cloud/documentai/v1beta2/Document.java

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35347,6 +35347,33 @@ public interface TextAnchorOrBuilder
3534735347
*/
3534835348
com.google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegmentOrBuilder
3534935349
getTextSegmentsOrBuilder(int index);
35350+
35351+
/**
35352+
*
35353+
*
35354+
* <pre>
35355+
* Contains the content of the text span so that users do
35356+
* not have to look it up in the text_segments.
35357+
* </pre>
35358+
*
35359+
* <code>string content = 2;</code>
35360+
*
35361+
* @return The content.
35362+
*/
35363+
java.lang.String getContent();
35364+
/**
35365+
*
35366+
*
35367+
* <pre>
35368+
* Contains the content of the text span so that users do
35369+
* not have to look it up in the text_segments.
35370+
* </pre>
35371+
*
35372+
* <code>string content = 2;</code>
35373+
*
35374+
* @return The bytes for content.
35375+
*/
35376+
com.google.protobuf.ByteString getContentBytes();
3535035377
}
3535135378
/**
3535235379
*
@@ -35369,6 +35396,7 @@ private TextAnchor(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
3536935396

3537035397
private TextAnchor() {
3537135398
textSegments_ = java.util.Collections.emptyList();
35399+
content_ = "";
3537235400
}
3537335401

3537435402
@java.lang.Override
@@ -35416,6 +35444,13 @@ private TextAnchor(
3541635444
extensionRegistry));
3541735445
break;
3541835446
}
35447+
case 18:
35448+
{
35449+
java.lang.String s = input.readStringRequireUtf8();
35450+
35451+
content_ = s;
35452+
break;
35453+
}
3541935454
default:
3542035455
{
3542135456
if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
@@ -36217,6 +36252,57 @@ public com.google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment getTe
3621736252
return textSegments_.get(index);
3621836253
}
3621936254

36255+
public static final int CONTENT_FIELD_NUMBER = 2;
36256+
private volatile java.lang.Object content_;
36257+
/**
36258+
*
36259+
*
36260+
* <pre>
36261+
* Contains the content of the text span so that users do
36262+
* not have to look it up in the text_segments.
36263+
* </pre>
36264+
*
36265+
* <code>string content = 2;</code>
36266+
*
36267+
* @return The content.
36268+
*/
36269+
@java.lang.Override
36270+
public java.lang.String getContent() {
36271+
java.lang.Object ref = content_;
36272+
if (ref instanceof java.lang.String) {
36273+
return (java.lang.String) ref;
36274+
} else {
36275+
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
36276+
java.lang.String s = bs.toStringUtf8();
36277+
content_ = s;
36278+
return s;
36279+
}
36280+
}
36281+
/**
36282+
*
36283+
*
36284+
* <pre>
36285+
* Contains the content of the text span so that users do
36286+
* not have to look it up in the text_segments.
36287+
* </pre>
36288+
*
36289+
* <code>string content = 2;</code>
36290+
*
36291+
* @return The bytes for content.
36292+
*/
36293+
@java.lang.Override
36294+
public com.google.protobuf.ByteString getContentBytes() {
36295+
java.lang.Object ref = content_;
36296+
if (ref instanceof java.lang.String) {
36297+
com.google.protobuf.ByteString b =
36298+
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
36299+
content_ = b;
36300+
return b;
36301+
} else {
36302+
return (com.google.protobuf.ByteString) ref;
36303+
}
36304+
}
36305+
3622036306
private byte memoizedIsInitialized = -1;
3622136307

3622236308
@java.lang.Override
@@ -36234,6 +36320,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io
3623436320
for (int i = 0; i < textSegments_.size(); i++) {
3623536321
output.writeMessage(1, textSegments_.get(i));
3623636322
}
36323+
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(content_)) {
36324+
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, content_);
36325+
}
3623736326
unknownFields.writeTo(output);
3623836327
}
3623936328

@@ -36246,6 +36335,9 @@ public int getSerializedSize() {
3624636335
for (int i = 0; i < textSegments_.size(); i++) {
3624736336
size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, textSegments_.get(i));
3624836337
}
36338+
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(content_)) {
36339+
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, content_);
36340+
}
3624936341
size += unknownFields.getSerializedSize();
3625036342
memoizedSize = size;
3625136343
return size;
@@ -36263,6 +36355,7 @@ public boolean equals(final java.lang.Object obj) {
3626336355
(com.google.cloud.documentai.v1beta2.Document.TextAnchor) obj;
3626436356

3626536357
if (!getTextSegmentsList().equals(other.getTextSegmentsList())) return false;
36358+
if (!getContent().equals(other.getContent())) return false;
3626636359
if (!unknownFields.equals(other.unknownFields)) return false;
3626736360
return true;
3626836361
}
@@ -36278,6 +36371,8 @@ public int hashCode() {
3627836371
hash = (37 * hash) + TEXT_SEGMENTS_FIELD_NUMBER;
3627936372
hash = (53 * hash) + getTextSegmentsList().hashCode();
3628036373
}
36374+
hash = (37 * hash) + CONTENT_FIELD_NUMBER;
36375+
hash = (53 * hash) + getContent().hashCode();
3628136376
hash = (29 * hash) + unknownFields.hashCode();
3628236377
memoizedHashCode = hash;
3628336378
return hash;
@@ -36434,6 +36529,8 @@ public Builder clear() {
3643436529
} else {
3643536530
textSegmentsBuilder_.clear();
3643636531
}
36532+
content_ = "";
36533+
3643736534
return this;
3643836535
}
3643936536

@@ -36471,6 +36568,7 @@ public com.google.cloud.documentai.v1beta2.Document.TextAnchor buildPartial() {
3647136568
} else {
3647236569
result.textSegments_ = textSegmentsBuilder_.build();
3647336570
}
36571+
result.content_ = content_;
3647436572
onBuilt();
3647536573
return result;
3647636574
}
@@ -36550,6 +36648,10 @@ public Builder mergeFrom(com.google.cloud.documentai.v1beta2.Document.TextAnchor
3655036648
}
3655136649
}
3655236650
}
36651+
if (!other.getContent().isEmpty()) {
36652+
content_ = other.content_;
36653+
onChanged();
36654+
}
3655336655
this.mergeUnknownFields(other.unknownFields);
3655436656
onChanged();
3655536657
return this;
@@ -36998,6 +37100,117 @@ public Builder removeTextSegments(int index) {
3699837100
return textSegmentsBuilder_;
3699937101
}
3700037102

37103+
private java.lang.Object content_ = "";
37104+
/**
37105+
*
37106+
*
37107+
* <pre>
37108+
* Contains the content of the text span so that users do
37109+
* not have to look it up in the text_segments.
37110+
* </pre>
37111+
*
37112+
* <code>string content = 2;</code>
37113+
*
37114+
* @return The content.
37115+
*/
37116+
public java.lang.String getContent() {
37117+
java.lang.Object ref = content_;
37118+
if (!(ref instanceof java.lang.String)) {
37119+
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
37120+
java.lang.String s = bs.toStringUtf8();
37121+
content_ = s;
37122+
return s;
37123+
} else {
37124+
return (java.lang.String) ref;
37125+
}
37126+
}
37127+
/**
37128+
*
37129+
*
37130+
* <pre>
37131+
* Contains the content of the text span so that users do
37132+
* not have to look it up in the text_segments.
37133+
* </pre>
37134+
*
37135+
* <code>string content = 2;</code>
37136+
*
37137+
* @return The bytes for content.
37138+
*/
37139+
public com.google.protobuf.ByteString getContentBytes() {
37140+
java.lang.Object ref = content_;
37141+
if (ref instanceof String) {
37142+
com.google.protobuf.ByteString b =
37143+
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
37144+
content_ = b;
37145+
return b;
37146+
} else {
37147+
return (com.google.protobuf.ByteString) ref;
37148+
}
37149+
}
37150+
/**
37151+
*
37152+
*
37153+
* <pre>
37154+
* Contains the content of the text span so that users do
37155+
* not have to look it up in the text_segments.
37156+
* </pre>
37157+
*
37158+
* <code>string content = 2;</code>
37159+
*
37160+
* @param value The content to set.
37161+
* @return This builder for chaining.
37162+
*/
37163+
public Builder setContent(java.lang.String value) {
37164+
if (value == null) {
37165+
throw new NullPointerException();
37166+
}
37167+
37168+
content_ = value;
37169+
onChanged();
37170+
return this;
37171+
}
37172+
/**
37173+
*
37174+
*
37175+
* <pre>
37176+
* Contains the content of the text span so that users do
37177+
* not have to look it up in the text_segments.
37178+
* </pre>
37179+
*
37180+
* <code>string content = 2;</code>
37181+
*
37182+
* @return This builder for chaining.
37183+
*/
37184+
public Builder clearContent() {
37185+
37186+
content_ = getDefaultInstance().getContent();
37187+
onChanged();
37188+
return this;
37189+
}
37190+
/**
37191+
*
37192+
*
37193+
* <pre>
37194+
* Contains the content of the text span so that users do
37195+
* not have to look it up in the text_segments.
37196+
* </pre>
37197+
*
37198+
* <code>string content = 2;</code>
37199+
*
37200+
* @param value The bytes for content to set.
37201+
* @return This builder for chaining.
37202+
*/
37203+
public Builder setContentBytes(com.google.protobuf.ByteString value) {
37204+
if (value == null) {
37205+
throw new NullPointerException();
37206+
}
37207+
checkByteStringIsUtf8(value);
37208+
37209+
content_ = value;
37210+
onChanged();
37211+
return this;
37212+
}
37213+
3700137214
@java.lang.Override
3700237215
public final Builder setUnknownFields(
3700337216
final com.google.protobuf.UnknownFieldSet unknownFields) {

proto-google-cloud-document-ai-v1beta2/src/main/java/com/google/cloud/documentai/v1beta2/DocumentProto.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
142142
+ "le/cloud/documentai/v1beta2/geometry.pro"
143143
+ "to\032\027google/rpc/status.proto\032\027google/type"
144144
+ "/color.proto\032\034google/api/annotations.pro"
145-
+ "to\"\302+\n\010Document\022\r\n\003uri\030\001 \001(\tH\000\022\021\n\007conten"
145+
+ "to\"\323+\n\010Document\022\r\n\003uri\030\001 \001(\tH\000\022\021\n\007conten"
146146
+ "t\030\002 \001(\014H\000\022\021\n\tmime_type\030\003 \001(\t\022\014\n\004text\030\004 \001"
147147
+ "(\t\022D\n\013text_styles\030\005 \003(\0132/.google.cloud.d"
148148
+ "ocumentai.v1beta2.Document.Style\022=\n\005page"
@@ -267,27 +267,27 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
267267
+ "ntend\030\010 \001(\0132-.google.cloud.documentai.v1"
268268
+ "beta2.BoundingPolyB\003\340A\001\032I\n\016EntityRelatio"
269269
+ "n\022\022\n\nsubject_id\030\001 \001(\t\022\021\n\tobject_id\030\002 \001(\t"
270-
+ "\022\020\n\010relation\030\003 \001(\t\032\234\001\n\nTextAnchor\022W\n\rtex"
270+
+ "\022\020\n\010relation\030\003 \001(\t\032\255\001\n\nTextAnchor\022W\n\rtex"
271271
+ "t_segments\030\001 \003(\0132@.google.cloud.document"
272272
+ "ai.v1beta2.Document.TextAnchor.TextSegme"
273-
+ "nt\0325\n\013TextSegment\022\023\n\013start_index\030\001 \001(\003\022\021"
274-
+ "\n\tend_index\030\002 \001(\003\032\201\003\n\nPageAnchor\022O\n\tpage"
275-
+ "_refs\030\001 \003(\0132<.google.cloud.documentai.v1"
276-
+ "beta2.Document.PageAnchor.PageRef\032\241\002\n\007Pa"
277-
+ "geRef\022\021\n\004page\030\001 \001(\003B\003\340A\002\022a\n\013layout_type\030"
278-
+ "\002 \001(\0162G.google.cloud.documentai.v1beta2."
279-
+ "Document.PageAnchor.PageRef.LayoutTypeB\003"
280-
+ "\340A\001\022\026\n\tlayout_id\030\003 \001(\tB\003\340A\001\"\207\001\n\nLayoutTy"
281-
+ "pe\022\033\n\027LAYOUT_TYPE_UNSPECIFIED\020\000\022\t\n\005BLOCK"
282-
+ "\020\001\022\r\n\tPARAGRAPH\020\002\022\010\n\004LINE\020\003\022\t\n\005TOKEN\020\004\022\022"
283-
+ "\n\016VISUAL_ELEMENT\020\005\022\t\n\005TABLE\020\006\022\016\n\nFORM_FI"
284-
+ "ELD\020\007B\010\n\006sourceB\352\001\n#com.google.cloud.doc"
285-
+ "umentai.v1beta2B\rDocumentProtoP\001ZIgoogle"
286-
+ ".golang.org/genproto/googleapis/cloud/do"
287-
+ "cumentai/v1beta2;documentai\252\002\037Google.Clo"
288-
+ "ud.DocumentAI.V1Beta2\312\002\037Google\\Cloud\\Doc"
289-
+ "umentAI\\V1beta2\352\002\"Google::Cloud::Documen"
290-
+ "tAI::V1beta2b\006proto3"
273+
+ "nt\022\017\n\007content\030\002 \001(\t\0325\n\013TextSegment\022\023\n\013st"
274+
+ "art_index\030\001 \001(\003\022\021\n\tend_index\030\002 \001(\003\032\201\003\n\nP"
275+
+ "ageAnchor\022O\n\tpage_refs\030\001 \003(\0132<.google.cl"
276+
+ "oud.documentai.v1beta2.Document.PageAnch"
277+
+ "or.PageRef\032\241\002\n\007PageRef\022\021\n\004page\030\001 \001(\003B\003\340A"
278+
+ "\002\022a\n\013layout_type\030\002 \001(\0162G.google.cloud.do"
279+
+ "cumentai.v1beta2.Document.PageAnchor.Pag"
280+
+ "eRef.LayoutTypeB\003\340A\001\022\026\n\tlayout_id\030\003 \001(\tB"
281+
+ "\003\340A\001\"\207\001\n\nLayoutType\022\033\n\027LAYOUT_TYPE_UNSPE"
282+
+ "CIFIED\020\000\022\t\n\005BLOCK\020\001\022\r\n\tPARAGRAPH\020\002\022\010\n\004LI"
283+
+ "NE\020\003\022\t\n\005TOKEN\020\004\022\022\n\016VISUAL_ELEMENT\020\005\022\t\n\005T"
284+
+ "ABLE\020\006\022\016\n\nFORM_FIELD\020\007B\010\n\006sourceB\352\001\n#com"
285+
+ ".google.cloud.documentai.v1beta2B\rDocume"
286+
+ "ntProtoP\001ZIgoogle.golang.org/genproto/go"
287+
+ "ogleapis/cloud/documentai/v1beta2;docume"
288+
+ "ntai\252\002\037Google.Cloud.DocumentAI.V1Beta2\312\002"
289+
+ "\037Google\\Cloud\\DocumentAI\\V1beta2\352\002\"Googl"
290+
+ "e::Cloud::DocumentAI::V1beta2b\006proto3"
291291
};
292292
descriptor =
293293
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
@@ -541,7 +541,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
541541
new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
542542
internal_static_google_cloud_documentai_v1beta2_Document_TextAnchor_descriptor,
543543
new java.lang.String[] {
544-
"TextSegments",
544+
"TextSegments", "Content",
545545
});
546546
internal_static_google_cloud_documentai_v1beta2_Document_TextAnchor_TextSegment_descriptor =
547547
internal_static_google_cloud_documentai_v1beta2_Document_TextAnchor_descriptor

proto-google-cloud-document-ai-v1beta2/src/main/proto/google/cloud/documentai/v1beta2/document.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ message Document {
421421

422422
// The text segments from the [Document.text][google.cloud.documentai.v1beta2.Document.text].
423423
repeated TextSegment text_segments = 1;
424+
425+
// Contains the content of the text span so that users do
426+
// not have to look it up in the text_segments.
427+
string content = 2;
424428
}
425429

426430
// Referencing elements in [Document.pages][google.cloud.documentai.v1beta2.Document.pages].

0 commit comments

Comments
 (0)