UNPKG

mindee

Version:

Mindee Client Library for Node.js

55 lines (54 loc) 2.59 kB
"use strict"; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _InvoiceSplitterV1InvoicePageGroup_instances, _InvoiceSplitterV1InvoicePageGroup_printableValues; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvoiceSplitterV1InvoicePageGroup = void 0; const geometry_1 = require("../../geometry"); /** * List of page groups. Each group represents a single invoice within a multi-invoice document. */ class InvoiceSplitterV1InvoicePageGroup { constructor({ prediction = {} }) { _InvoiceSplitterV1InvoicePageGroup_instances.add(this); /** Confidence score */ this.confidence = 0.0; /** * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ this.polygon = new geometry_1.Polygon(); this.pageIndexes = prediction["page_indexes"]; this.pageId = prediction["page_id"]; this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; if (prediction["polygon"]) { this.polygon = prediction.polygon; } } /** * Default string representation. */ toString() { const printable = __classPrivateFieldGet(this, _InvoiceSplitterV1InvoicePageGroup_instances, "m", _InvoiceSplitterV1InvoicePageGroup_printableValues).call(this); return ("Page Indexes: " + printable.pageIndexes); } /** * Output in a format suitable for inclusion in an rST table. */ toTableLine() { const printable = __classPrivateFieldGet(this, _InvoiceSplitterV1InvoicePageGroup_instances, "m", _InvoiceSplitterV1InvoicePageGroup_printableValues).call(this); return ("| " + printable.pageIndexes.padEnd(72) + " |"); } } exports.InvoiceSplitterV1InvoicePageGroup = InvoiceSplitterV1InvoicePageGroup; _InvoiceSplitterV1InvoicePageGroup_instances = new WeakSet(), _InvoiceSplitterV1InvoicePageGroup_printableValues = function _InvoiceSplitterV1InvoicePageGroup_printableValues() { return { pageIndexes: this.pageIndexes?.join(", ") ?? "", }; };