UNPKG

mindee

Version:

Mindee Client Library for Node.js

199 lines (198 loc) 10.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResumeV1Document = void 0; const common_1 = require("../../parsing/common"); const resumeV1SocialNetworksUrl_1 = require("./resumeV1SocialNetworksUrl"); const resumeV1Language_1 = require("./resumeV1Language"); const resumeV1Education_1 = require("./resumeV1Education"); const resumeV1ProfessionalExperience_1 = require("./resumeV1ProfessionalExperience"); const resumeV1Certificate_1 = require("./resumeV1Certificate"); const standard_1 = require("../../parsing/standard"); /** * Resume API version 1.2 document data. */ class ResumeV1Document { constructor(rawPrediction, pageId) { /** The list of certificates obtained by the candidate. */ this.certificates = []; /** The list of the candidate's educational background. */ this.education = []; /** The candidate's first or given names. */ this.givenNames = []; /** The list of the candidate's technical abilities and knowledge. */ this.hardSkills = []; /** The list of languages that the candidate is proficient in. */ this.languages = []; /** The list of the candidate's professional experiences. */ this.professionalExperiences = []; /** The list of social network profiles of the candidate. */ this.socialNetworksUrls = []; /** The list of the candidate's interpersonal and communication abilities. */ this.softSkills = []; /** The candidate's last names. */ this.surnames = []; this.address = new standard_1.StringField({ prediction: rawPrediction["address"], pageId: pageId, }); rawPrediction["certificates"] && rawPrediction["certificates"].map((itemPrediction) => this.certificates.push(new resumeV1Certificate_1.ResumeV1Certificate({ prediction: itemPrediction, pageId: pageId, }))); this.documentLanguage = new standard_1.StringField({ prediction: rawPrediction["document_language"], pageId: pageId, }); this.documentType = new standard_1.ClassificationField({ prediction: rawPrediction["document_type"], }); rawPrediction["education"] && rawPrediction["education"].map((itemPrediction) => this.education.push(new resumeV1Education_1.ResumeV1Education({ prediction: itemPrediction, pageId: pageId, }))); this.emailAddress = new standard_1.StringField({ prediction: rawPrediction["email_address"], pageId: pageId, }); rawPrediction["given_names"] && rawPrediction["given_names"].map((itemPrediction) => this.givenNames.push(new standard_1.StringField({ prediction: itemPrediction, pageId: pageId, }))); rawPrediction["hard_skills"] && rawPrediction["hard_skills"].map((itemPrediction) => this.hardSkills.push(new standard_1.StringField({ prediction: itemPrediction, pageId: pageId, }))); this.jobApplied = new standard_1.StringField({ prediction: rawPrediction["job_applied"], pageId: pageId, }); rawPrediction["languages"] && rawPrediction["languages"].map((itemPrediction) => this.languages.push(new resumeV1Language_1.ResumeV1Language({ prediction: itemPrediction, pageId: pageId, }))); this.nationality = new standard_1.StringField({ prediction: rawPrediction["nationality"], pageId: pageId, }); this.phoneNumber = new standard_1.StringField({ prediction: rawPrediction["phone_number"], pageId: pageId, }); this.profession = new standard_1.StringField({ prediction: rawPrediction["profession"], pageId: pageId, }); rawPrediction["professional_experiences"] && rawPrediction["professional_experiences"].map((itemPrediction) => this.professionalExperiences.push(new resumeV1ProfessionalExperience_1.ResumeV1ProfessionalExperience({ prediction: itemPrediction, pageId: pageId, }))); rawPrediction["social_networks_urls"] && rawPrediction["social_networks_urls"].map((itemPrediction) => this.socialNetworksUrls.push(new resumeV1SocialNetworksUrl_1.ResumeV1SocialNetworksUrl({ prediction: itemPrediction, pageId: pageId, }))); rawPrediction["soft_skills"] && rawPrediction["soft_skills"].map((itemPrediction) => this.softSkills.push(new standard_1.StringField({ prediction: itemPrediction, pageId: pageId, }))); rawPrediction["surnames"] && rawPrediction["surnames"].map((itemPrediction) => this.surnames.push(new standard_1.StringField({ prediction: itemPrediction, pageId: pageId, }))); } /** * Default string representation. */ toString() { const givenNames = this.givenNames.join("\n "); const surnames = this.surnames.join("\n "); let socialNetworksUrlsSummary = ""; if (this.socialNetworksUrls && this.socialNetworksUrls.length > 0) { const socialNetworksUrlsColSizes = [22, 52]; socialNetworksUrlsSummary += "\n" + (0, common_1.lineSeparator)(socialNetworksUrlsColSizes, "-") + "\n "; socialNetworksUrlsSummary += "| Name "; socialNetworksUrlsSummary += "| URL "; socialNetworksUrlsSummary += "|\n" + (0, common_1.lineSeparator)(socialNetworksUrlsColSizes, "="); socialNetworksUrlsSummary += this.socialNetworksUrls.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(socialNetworksUrlsColSizes, "-")).join(""); } let languagesSummary = ""; if (this.languages && this.languages.length > 0) { const languagesColSizes = [10, 22]; languagesSummary += "\n" + (0, common_1.lineSeparator)(languagesColSizes, "-") + "\n "; languagesSummary += "| Language "; languagesSummary += "| Level "; languagesSummary += "|\n" + (0, common_1.lineSeparator)(languagesColSizes, "="); languagesSummary += this.languages.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(languagesColSizes, "-")).join(""); } const hardSkills = this.hardSkills.join("\n "); const softSkills = this.softSkills.join("\n "); let educationSummary = ""; if (this.education && this.education.length > 0) { const educationColSizes = [17, 27, 11, 10, 27, 13, 12]; educationSummary += "\n" + (0, common_1.lineSeparator)(educationColSizes, "-") + "\n "; educationSummary += "| Domain "; educationSummary += "| Degree "; educationSummary += "| End Month "; educationSummary += "| End Year "; educationSummary += "| School "; educationSummary += "| Start Month "; educationSummary += "| Start Year "; educationSummary += "|\n" + (0, common_1.lineSeparator)(educationColSizes, "="); educationSummary += this.education.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(educationColSizes, "-")).join(""); } let professionalExperiencesSummary = ""; if (this.professionalExperiences && this.professionalExperiences.length > 0) { const professionalExperiencesColSizes = [17, 12, 38, 27, 11, 10, 22, 13, 12]; professionalExperiencesSummary += "\n" + (0, common_1.lineSeparator)(professionalExperiencesColSizes, "-") + "\n "; professionalExperiencesSummary += "| Contract Type "; professionalExperiencesSummary += "| Department "; professionalExperiencesSummary += "| Description "; professionalExperiencesSummary += "| Employer "; professionalExperiencesSummary += "| End Month "; professionalExperiencesSummary += "| End Year "; professionalExperiencesSummary += "| Role "; professionalExperiencesSummary += "| Start Month "; professionalExperiencesSummary += "| Start Year "; professionalExperiencesSummary += "|\n" + (0, common_1.lineSeparator)(professionalExperiencesColSizes, "="); professionalExperiencesSummary += this.professionalExperiences.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(professionalExperiencesColSizes, "-")).join(""); } let certificatesSummary = ""; if (this.certificates && this.certificates.length > 0) { const certificatesColSizes = [12, 32, 27, 6]; certificatesSummary += "\n" + (0, common_1.lineSeparator)(certificatesColSizes, "-") + "\n "; certificatesSummary += "| Grade "; certificatesSummary += "| Name "; certificatesSummary += "| Provider "; certificatesSummary += "| Year "; certificatesSummary += "|\n" + (0, common_1.lineSeparator)(certificatesColSizes, "="); certificatesSummary += this.certificates.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(certificatesColSizes, "-")).join(""); } const outStr = `:Document Language: ${this.documentLanguage} :Document Type: ${this.documentType} :Given Names: ${givenNames} :Surnames: ${surnames} :Nationality: ${this.nationality} :Email Address: ${this.emailAddress} :Phone Number: ${this.phoneNumber} :Address: ${this.address} :Social Networks: ${socialNetworksUrlsSummary} :Profession: ${this.profession} :Job Applied: ${this.jobApplied} :Languages: ${languagesSummary} :Hard Skills: ${hardSkills} :Soft Skills: ${softSkills} :Education: ${educationSummary} :Professional Experiences: ${professionalExperiencesSummary} :Certificates: ${certificatesSummary}`.trimEnd(); return (0, common_1.cleanOutString)(outStr); } } exports.ResumeV1Document = ResumeV1Document;