UNPKG

mindee

Version:

Mindee Client Library for Node.js

66 lines (65 loc) 2.73 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 _ResumeV1Language_instances, _ResumeV1Language_printableValues; import { cleanSpecialChars } from "../../../v1/parsing/common/index.js"; import { Polygon } from "../../../geometry/index.js"; /** * The list of languages that the candidate is proficient in. */ export class ResumeV1Language { constructor({ prediction = {} }) { _ResumeV1Language_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.language = prediction["language"]; this.level = prediction["level"]; 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, _ResumeV1Language_instances, "m", _ResumeV1Language_printableValues).call(this); return ("Language: " + printable.language + ", Level: " + printable.level); } /** * Output in a format suitable for inclusion in an rST table. */ toTableLine() { const printable = __classPrivateFieldGet(this, _ResumeV1Language_instances, "m", _ResumeV1Language_printableValues).call(this); return ("| " + printable.language.padEnd(8) + " | " + printable.level.padEnd(20) + " |"); } } _ResumeV1Language_instances = new WeakSet(), _ResumeV1Language_printableValues = function _ResumeV1Language_printableValues() { return { language: this.language ? this.language.length <= 8 ? cleanSpecialChars(this.language) : cleanSpecialChars(this.language).slice(0, 5) + "..." : "", level: this.level ? this.level.length <= 20 ? cleanSpecialChars(this.level) : cleanSpecialChars(this.level).slice(0, 17) + "..." : "", }; };