import {Entity} from "./entity"; import {DsProjectRoomBlock, DsProjectRoomBlockField, DsProjectRoomData} from "../dynamic-labeling-room/entities"; import {ExampleEntityData} from "./example-entity-data"; export enum Pred { Change = 'change', Promotion = 'promotion', Less_Specific_Title = 'less_specific_title', More_Specific_Title = 'more_specific_title', Same = 'same', // Junk = 'junk', // Change = 'change', Unknown = 'unknown' } export class TrackPromotionChanges implements Entity { private _title_changes: OneTrackPromotionChange[] = []; private _class_results: ClassificationResObject = new ClassificationResObject(); private _version: string = ''; private _pred = Pred.Unknown; private _exampleEntityData: ExampleEntityData = new ExampleEntityData('track-promotion-changes'); constructor(obj?) { if (obj) { if (obj.title_changes) { for (const i in obj.title_changes) { this._title_changes.push(new OneTrackPromotionChange(obj.title_changes[i])); } } if (obj.class_results) { this._class_results = new ClassificationResObject(obj.class_results) } if (obj.version) { this._version = obj.version; } if (obj.pred) { this._pred = obj.pred; } } } get title_changes(): OneTrackPromotionChange[] { return this._title_changes; } set title_changes(value: OneTrackPromotionChange[]) { this._title_changes = value; } get class_results(): ClassificationResObject { return this._class_results; } set class_results(value: ClassificationResObject) { this._class_results = value; } get pred(): Pred { return this._pred; } set pred(value: Pred) { this._pred = value; } get version(): string { return this._version; } set version(value: string) { this._version = value; } public toJSON() { return { title_changes: this.title_changes, class_results: this.class_results, pred: this.pred, // version: this.version, }; } public toNerEntities(type = 1) { return { relationOptions: [], entities: { change: '', promotion: '', less_specific_title: '', more_specific_title: '', same: '', } }; } nerEntityTypeOptions(): any[] { return []; } public toDsProjectRoom() { const data: DsProjectRoomData = new DsProjectRoomData({ text: this._exampleEntityData.getExampleData(), url: '', showInIframe: false }); const blocks = [ { blockName: '', blockDesc: '', numColumns: 1, fields: [ {label: 'pred', inputType: 'select', selectOptions: ['0', '1']}, ] }]; const final = []; for (const i in blocks) { final.push(new DsProjectRoomBlock(blocks[i])); } return {blocks: final, data: data}; } public fromDsProjectRoom(obj: DsProjectRoomBlock[], data: DsProjectRoomData) { const titles = data.text.split('TO'); const historyTitle = []; for (const title of titles) { historyTitle.push({title: title}); } const trackPromotionChanges = { titles_history: historyTitle, pred: 'unknown' }; let block: DsProjectRoomBlock; for (block of obj) { trackPromotionChanges.pred = 'unknown'; let field: DsProjectRoomBlockField; for (field of block.fields) { trackPromotionChanges.pred = field.value; } } return new TrackPromotionChanges(trackPromotionChanges); } } export class ClassificationResObject { public change_but_not_a_promotion: ClassificationStruct = new ClassificationStruct(); public promotion: ClassificationStruct = new ClassificationStruct(); public less_specific_title_but_not_a_promotion: ClassificationStruct = new ClassificationStruct(); public more_specific_title_but_not_promotion: ClassificationStruct = new ClassificationStruct(); public same: ClassificationStruct = new ClassificationStruct(); constructor(obj?) { if (obj) { if (obj.change_but_not_a_promotion) { this.change_but_not_a_promotion = obj.change_but_not_a_promotion; } if (obj.promotion) { this.promotion = obj.promotion; } if (obj.less_specific_title_but_not_a_promotion) { this.less_specific_title_but_not_a_promotion = obj.less_specific_title_but_not_a_promotion; } if (obj.more_specific_title_but_not_promotion) { this.more_specific_title_but_not_promotion = obj.more_specific_title_but_not_promotion; } if (obj.same) { this.same = obj.same; } } } public toJSON() { return { change: this.change_but_not_a_promotion, promotion: this.promotion, less_specific_title: this.less_specific_title_but_not_a_promotion, more_specific_title: this.more_specific_title_but_not_promotion, same: this.same }; } } export class ClassificationStruct { public probability: number = -1; public threshold: number = -1; constructor(obj?) { if (obj) { if (obj.probability) { this.probability = obj.probability; } if (obj.threshold) { this.threshold = obj.threshold; } } } public toJSON() { return { probability: this.probability, threshold: this.threshold, }; } } export class TrackPromotionChangesTitleData { id = ''; displayString = ''; constructor(obj?) { if (obj) { if (obj.id) { this.id = obj.id; } if (obj.displayString) { this.displayString = obj.displayString; } } } } export class TrackPromotionChangesInput { title = ''; departments: TrackPromotionChangesTitleData[] = []; job_functions: TrackPromotionChangesTitleData[] = []; seniorities: TrackPromotionChangesTitleData[] = []; org_chart_tier = -1; constructor(obj?) { if (obj) { if (obj.title) { this.title = obj.title; } if (obj.departments) { for (const i in obj.departments) { this.departments.push(new TrackPromotionChangesTitleData(obj.departments[i])); } } if (obj.job_functions) { for (const i in obj.job_functions) { this.job_functions.push(new TrackPromotionChangesTitleData(obj.job_functions[i])); } } if (obj.seniorities) { for (const i in obj.seniorities) { this.seniorities.push(new TrackPromotionChangesTitleData(obj.seniorities[i])); } } if (obj.org_chart_tier >= 0) { this.org_chart_tier = obj.org_chart_tier; } } } } export class OneTrackPromotionChange { public individual_id: string = ''; public raw_record_id: string = ''; public title_prev: TrackPromotionChangesInput; public title_current: TrackPromotionChangesInput; constructor(obj?) { if (obj) { if (obj.individual_id) { this.individual_id = obj.individual_id; } if (obj.raw_record_id) { this.raw_record_id = obj.raw_record_id; } if (obj.title_prev) { this.title_prev = obj.title_prev; } if (obj.title_current) { this.title_current = obj.title_current; } } } public toJSON() { return { individual_id: this.individual_id, raw_record_id: this.raw_record_id, title_prev: this.title_prev, title_current: this.title_current }; } }