mindee
Version:
Mindee Client Library for Node.js
89 lines (88 loc) • 3.63 kB
JavaScript
"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 _ResumeV1Certificate_instances, _ResumeV1Certificate_printableValues;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResumeV1Certificate = void 0;
const common_1 = require("../../parsing/common");
/**
* The list of certificates obtained by the candidate.
*/
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 = [];
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) +
" |");
}
}
exports.ResumeV1Certificate = ResumeV1Certificate;
_ResumeV1Certificate_instances = new WeakSet(), _ResumeV1Certificate_printableValues = function _ResumeV1Certificate_printableValues() {
return {
grade: this.grade ?
this.grade.length <= 10 ?
(0, common_1.cleanSpecialChars)(this.grade) :
(0, common_1.cleanSpecialChars)(this.grade).slice(0, 7) + "..." :
"",
name: this.name ?
this.name.length <= 30 ?
(0, common_1.cleanSpecialChars)(this.name) :
(0, common_1.cleanSpecialChars)(this.name).slice(0, 27) + "..." :
"",
provider: this.provider ?
this.provider.length <= 25 ?
(0, common_1.cleanSpecialChars)(this.provider) :
(0, common_1.cleanSpecialChars)(this.provider).slice(0, 22) + "..." :
"",
year: this.year ?
this.year.length <= 4 ?
(0, common_1.cleanSpecialChars)(this.year) :
(0, common_1.cleanSpecialChars)(this.year).slice(0, 1) + "..." :
"",
};
};