import {Entity} from "./entity"; import {DsProjectRoomBlock, DsProjectRoomBlockField, DsProjectRoomData} from "../dynamic-labeling-room/entities"; import {ExampleEntityData} from "./example-entity-data"; export class RecruiterSearch implements Entity { private _version = ''; private _job_title = ''; private _job_description = ''; private _trex_input: PyDsTrexInput = new PyDsTrexInput(); private _records: RecruiterSearchRecord = new RecruiterSearchRecord(); private _exampleEntityData: ExampleEntityData = new ExampleEntityData('recruiter-search'); constructor(obj?) { if (obj) { if (obj.version) { this._version = obj.version; } if (obj.job_title) { this._job_title = obj.job_title; } if (obj.job_description) { this._job_description = obj.job_description; } if (obj.trex_input) { this._trex_input = new PyDsTrexInput(obj.trex_input); } if (obj.records) { this._records = new RecruiterSearchRecord(obj.records); } } } get version(): string { return this._version; } set version(value: string) { this._version = value; } get job_title(): string { return this._job_title; } set job_title(value: string) { this._job_title = value; } get job_description(): string { return this._job_description; } set job_description(value: string) { this._job_description = value; } get trex_input(): PyDsTrexInput { return this._trex_input; } set trex_input(value: PyDsTrexInput) { this._trex_input = value; } get records(): RecruiterSearchRecord { return this._records; } set records(value: RecruiterSearchRecord) { this._records = value; } public toJSON() { return { version: this.version, job_title: this.job_title, job_description: this.job_description, trex_input: this.trex_input, }; } public toNerEntities(type = 1) { return { relationOptions: [], entities: { unclassified_skill: '', mandatory_skill: '', non_mandatory_skill: '', one_of: '' } }; } nerEntityTypeOptions(): any[] { return []; } public toDsProjectRoom() { const data: DsProjectRoomData = new DsProjectRoomData({ }); const blocks = [ { } ]; } public fromDsProjectRoom(obj: DsProjectRoomBlock[], data: DsProjectRoomData) { return new RecruiterSearch({}); } } class PyDsTrexInput { hints = []; url = ''; html = ''; helper_url_list: string[] = []; helper_html_list: string[] = []; constructor(obj?) { if (obj) { if (obj.hints) { for (const i in obj.hints) { this.hints.push(obj.hints[i]); } } if (obj.url) { this.url = obj.url; } if (obj.html) { this.html = obj.html; } if (obj.helper_url_list) { for (const i in obj.helper_url_list) { this.helper_url_list.push(obj.helper_url_list[i]); } } if (obj.helper_html_list) { for (const i in obj.helper_html_list) { this.helper_html_list.push(obj.helper_html_list[i]); } } } } } export class PyDsRecruiterAttribute { value: string[] = []; confidence_score : number[] = [] constructor(obj?) { if (obj) { if (obj.value) { for (const i in obj.value) { this.value.push(obj.value[i]); } } if (obj.confidence_score) { for (const i in obj.confidence_score) { this.confidence_score.push(obj.confidence_score[i]); } } } this.sort(); } private sort() { // relative arrays const arr1: any = this.value; const arr2: any = this.confidence_score; // Wrap original positions and values: const withPos = arr1.map((v, i) => ({v, i})); // Sort withPos.sort((a, b) => { a = (a.v).toLowerCase(); b = (b.v).toLowerCase(); if (a < b) { return -1; } if (a > b) { return 1; } return 0; }); // Unwrap & apply sort to second array: this.value = withPos.map(e => e.v); this.confidence_score = withPos.map(e => arr2[e.i]); } } export class JobLocation { full_location: string[] = []; country: string[] = []; state: string[] = []; city: string[] = []; address: string[] = []; confidence_score = 0.0 constructor(obj?) { if (obj) { if (obj.full_location) { for (const i in obj.full_location) { this.full_location.push(obj.full_location[i]); } } if (obj.country) { for (const i in obj.country) { this.country.push(obj.country[i]); } } if (obj.state) { for (const i in obj.state) { this.state.push(obj.state[i]); } } if (obj.city) { for (const i in obj.city) { this.city.push(obj.city[i]); } } if (obj.address) { this.address = obj.address; } if (obj.confidence_score) { this.confidence_score = obj.confidence_score; } } } } export class RecruiterSearchRecord { version = ''; debug_text = ''; job_title: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); location: JobLocation[] = []; tech_skills: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); keywords: any; experience: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); // Remove for Niv (Modle owner) requsets // department: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); // management_level: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); // company_name: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); // industry: PyDsRecruiterAttribute = new PyDsRecruiterAttribute(); constructor(obj?) { if (obj) { if (obj.version) { this.version = obj.version; } if (obj.debug_text) { this.debug_text = obj.debug_text; } if (obj.job_title) { this.job_title = new PyDsRecruiterAttribute(obj.job_title); } if (obj.location) { for (const i in obj.location) { this.location.push(new JobLocation(obj.location[i])); } } if (obj.tech_skills) { this.tech_skills = new PyDsRecruiterAttribute(obj.tech_skills); } if (obj.keywords) { if (obj.keywords.mandatory || obj.keywords.non_mandatory || obj.keywords.unclassified) { this.keywords = new Keywords(obj.keywords); } else if (obj.keywords.value) { this.keywords = new PyDsRecruiterAttribute(obj.keywords); } } // if (obj.industry) { // this.industry = new PyDsRecruiterAttribute(obj.industry); // } if (obj.experience) { this.experience = new PyDsRecruiterAttribute(obj.experience); } // if (obj.department) { // this.department = new PyDsRecruiterAttribute(obj.department); // } // if (obj.management_level) { // this.management_level = new PyDsRecruiterAttribute(obj.management_level); // } // if (obj.company_name) { // this.company_name = new PyDsRecruiterAttribute(obj.company_name); // } } } } export class Keywords { mandatory: KeywordsAttribute; non_mandatory: KeywordsAttribute; unclassified: KeywordsAttribute; constructor(obj?) { if (obj) { if (obj.mandatory) { this.mandatory = new KeywordsAttribute(obj.mandatory); } if (obj.non_mandatory) { this.non_mandatory = new KeywordsAttribute(obj.non_mandatory); } if (obj.unclassified) { this.unclassified = new KeywordsAttribute(obj.unclassified); } } } } type KeywordsValueType = KeywordsValueString | KeywordsValueArray; export class KeywordsAttribute { value: Array = []; confidence_score : number[] = []; constructor(obj?) { if (obj) { if (obj.value) { for (const i in obj.value) { if (obj.value[i]?.type === 'one_of') { this.value.push(new KeywordsValueArray(obj.value[i])); } else { this.value.push(new KeywordsValueString(obj.value[i])); } } } if (obj.confidence_score) { for (const i in obj.confidence_score) { this.confidence_score.push(obj.confidence_score[i]); } } } } } export class KeywordsValueString { type = ''; value = ''; constructor(obj?) { if (obj) { if (obj.type) { this.type = obj.type; } if (obj.value) { this.value = obj.value; } } } } export class KeywordsValueArray { type = ''; value: string[] = []; constructor(obj?) { if (obj) { if (obj.type) { this.type = obj.type; } if (obj.value) { for (const i in obj.value) { this.value.push(obj.value[i]); } this.value.sort() } } } }