UNPKG

mindee

Version:

Mindee Client Library for Node.js

86 lines (85 loc) 3.45 kB
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 _ResumeV1Certificate_instances, _ResumeV1Certificate_printableValues; import { cleanSpecialChars } from "../../../v1/parsing/common/index.js"; import { Polygon } from "../../../geometry/index.js"; /** * The list of certificates obtained by the candidate. */ export class ResumeV1Certificate { constructor({ prediction = {} }) { _ResumeV1Certificate_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 Polygon(); this.grade = prediction["grade"]; this.name = prediction["name"]; this.provider = prediction["provider"]; this.year = prediction["year"]; 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, _ResumeV1Certificate_instances, "m", _ResumeV1Certificate_printableValues).call(this); return ("Grade: " + printable.grade + ", Name: " + printable.name + ", Provider: " + printable.provider + ", Year: " + printable.year); } /** * Output in a format suitable for inclusion in an rST table. */ toTableLine() { const printable = __classPrivateFieldGet(this, _ResumeV1Certificate_instances, "m", _ResumeV1Certificate_printableValues).call(this); return ("| " + printable.grade.padEnd(10) + " | " + printable.name.padEnd(30) + " | " + printable.provider.padEnd(25) + " | " + printable.year.padEnd(4) + " |"); } } _ResumeV1Certificate_instances = new WeakSet(), _ResumeV1Certificate_printableValues = function _ResumeV1Certificate_printableValues() { return { grade: this.grade ? this.grade.length <= 10 ? cleanSpecialChars(this.grade) : cleanSpecialChars(this.grade).slice(0, 7) + "..." : "", name: this.name ? this.name.length <= 30 ? cleanSpecialChars(this.name) : cleanSpecialChars(this.name).slice(0, 27) + "..." : "", provider: this.provider ? this.provider.length <= 25 ? cleanSpecialChars(this.provider) : cleanSpecialChars(this.provider).slice(0, 22) + "..." : "", year: this.year ? this.year.length <= 4 ? cleanSpecialChars(this.year) : cleanSpecialChars(this.year).slice(0, 1) + "..." : "", }; };