MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / getText

Function getText

document-ai/batch-process-document.js:107–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105
106 // Extract shards from the text field
107 const getText = textAnchor => {
108 if (!textAnchor.textSegments || textAnchor.textSegments.length === 0) {
109 return '';
110 }
111
112 // First shard in document doesn't have startIndex property
113 const startIndex = textAnchor.textSegments[0].startIndex || 0;
114 const endIndex = textAnchor.textSegments[0].endIndex;
115
116 return text.substring(startIndex, endIndex);
117 };
118
119 // Read the text recognition output from the processor
120 console.log('The document contains the following paragraphs:');

Callers 1

batchProcessDocumentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected