Skip to content

Commit

Permalink
samples: added default value for undefined (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
galz10 authored Dec 14, 2021
1 parent 1e2f11b commit b3a3780
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion document-ai/process-document-specialized.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ async function main(projectId, location, processorId, filePath) {
const key = entity.type;
// some other value formats in addition to text are availible
// e.g. dates: `entity.normalizedValue.dateValue.year`
const textValue = entity.textAnchor.content;
const textValue =
entity.textAnchor !== null ? entity.textAnchor.content : '';
const conf = entity.confidence * 100;
console.log(
`* ${JSON.stringify(key)}: ${JSON.stringify(textValue)}(${conf.toFixed(
Expand Down

0 comments on commit b3a3780

Please sign in to comment.