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

Function getText

document-ai/process-document.js:63–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62 // Extract shards from the text field
63 const getText = textAnchor => {
64 if (!textAnchor.textSegments || textAnchor.textSegments.length === 0) {
65 return '';
66 }
67
68 // First shard in document doesn't have startIndex property
69 const startIndex = textAnchor.textSegments[0].startIndex || 0;
70 const endIndex = textAnchor.textSegments[0].endIndex;
71
72 return text.substring(startIndex, endIndex);
73 };
74
75 // Read the text recognition output from the processor
76 console.log('The document contains the following paragraphs:');

Callers 1

processDocumentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected