import {Entity} from "./entity"; import {DsProjectRoomBlock, DsProjectRoomBlockField, DsProjectRoomData} from "../dynamic-labeling-room/entities"; import {ExampleEntityData} from "./example-entity-data"; export class TitleProgression implements Entity { private _titles_history: OneTitleProgression[] = []; private _pred: number = -1; private _prob: number = -1; private _version: string = ''; private _count: number = -1; private _total: number = -1; private _decision_model: string = ""; private _probability_deep_learning_model: number = -1; private _probability_statistical_model: number = -1; private _threshold: number = 0.353; private _exampleEntityData: ExampleEntityData = new ExampleEntityData('title-progression'); constructor(obj?) { if (obj) { if (obj.titles_history) { for (const i in obj.titles_history) { this._titles_history.push(new OneTitleProgression(obj.titles_history[i])); } } if (parseInt(obj.pred, 0) > -1) { this._pred = parseInt(obj.pred, 0); } if (obj.prob > -1) { this._prob = obj.prob; } if (obj.version) { this._version = obj.version; } if (obj.count > -1) { this._count = obj.count; } if (obj.total > -1) { this._total = obj.total; } if (obj.decision_model) { this._decision_model = obj.decision_model; } if (obj.probability_deep_learning_model) { this._probability_deep_learning_model = obj.probability_deep_learning_model; } if (obj.probability_statistical_model) { this._probability_statistical_model = obj.probability_statistical_model; } if (obj.threshold) { this._threshold = obj.threshold; } } } get titles_history(): OneTitleProgression[] { return this._titles_history; } set titles_history(value: OneTitleProgression[]) { this._titles_history = value; } get pred(): number { return this._pred; } set pred(value: number) { this._pred = value; } get prob(): number { return this._prob; } set prob(value: number) { this._prob = value; } get version(): string { return this._version; } set version(value: string) { this._version = value; } get count(): number { return this._count; } set count(value: number) { this._count = value; } get total(): number { return this._total; } set total(value: number) { this._total = value; } get decision_model(): string { return this._decision_model; } set decision_model(value: string) { this._decision_model = value; } get probability_deep_learning_model(): number { return this._probability_deep_learning_model; } set probability_deep_learning_model(value: number) { this._probability_deep_learning_model = value; } get probability_statistical_model(): number { return this._probability_statistical_model; } set probability_statistical_model(value: number) { this._probability_statistical_model = value; } get threshold(): number { return this._threshold; } set threshold(value: number) { this._threshold = value; } public toJSON() { return { titles_history: this.titles_history, pred: this.pred, prob: this.prob, version: this.version, count: this.count, total: this.total, decision_model: this.decision_model, probability_deep_learning_model: this.probability_deep_learning_model, probability_statistical_model: this.probability_statistical_model, threshold: this._threshold }; } public toNerEntities(type = 1) { return { relationOptions: [], entities: {} }; } 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 titleProgression = { titles_history: historyTitle, pred: '0' }; let block: DsProjectRoomBlock; for (block of obj) { titleProgression.pred = '0'; let field: DsProjectRoomBlockField; for (field of block.fields) { titleProgression.pred = field.value; } } return new TitleProgression(titleProgression); } } export class OneTitleProgression { public title: string = ''; public order: number = -1; public desc: string = ''; public company: string = ''; public company_id: number = -1; public company_size: number = -1; constructor(obj?) { if (obj) { if (obj.title) { this.title = obj.title; } if (obj.order > -1) { this.order = obj.order; } if (obj.desc) { this.desc = obj.desc; } if (obj.company) { this.company = obj.company; } if (obj.company_id > -1) { this.company_id = obj.company_id; } if (obj.company_size > -1) { this.company_size = obj.company_size; } } } }