UNPKG

mindee

Version:

Mindee Client Library for Node.js

70 lines (69 loc) 2.92 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 _ResumeV1Language_instances, _ResumeV1Language_printableValues; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResumeV1Language = void 0; const common_1 = require("../../parsing/common"); const geometry_1 = require("../../geometry"); /** * The list of languages that the candidate is proficient in. */ 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 geometry_1.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) + " |"); } } exports.ResumeV1Language = ResumeV1Language; _ResumeV1Language_instances = new WeakSet(), _ResumeV1Language_printableValues = function _ResumeV1Language_printableValues() { return { language: this.language ? this.language.length <= 8 ? (0, common_1.cleanSpecialChars)(this.language) : (0, common_1.cleanSpecialChars)(this.language).slice(0, 5) + "..." : "", level: this.level ? this.level.length <= 20 ? (0, common_1.cleanSpecialChars)(this.level) : (0, common_1.cleanSpecialChars)(this.level).slice(0, 17) + "..." : "", }; };