UNPKG

@scribelabsai/amazon-trp

Version:

Amazon Textract Response Parser library for Node.

26 lines 846 B
import { Geometry } from './Geometry'; import { Word } from './Word'; export class Line { constructor(block, blockMap) { this.block = block; this.confidence = block.Confidence; this.geometry = new Geometry(block.Geometry); this.id = block.Id; this.text = block.Text ?? ''; this.words = []; block.Relationships.filter((rs) => rs.Type === 'CHILD').forEach((rs) => { rs.Ids.forEach((id) => { const b = blockMap[id]; if (b?.BlockType === 'WORD') { this.words.push(new Word(b)); } }); }); } toString() { return `Line\n==========\n${this.text}\nWords\n----------\n${this.words .map((w) => `[${w}]`) .join('')}`; } } //# sourceMappingURL=Line.js.map