|
|
@ -1,4 +1,5 @@ |
|
|
|
import * as path from 'path'; |
|
|
|
import * as path from 'path'; |
|
|
|
|
|
|
|
import * as fs from 'fs'; |
|
|
|
import { getJsonDataSync, writeJsonDataSync } from './json'; |
|
|
|
import { getJsonDataSync, writeJsonDataSync } from './json'; |
|
|
|
import { SEGMENTS_PATH } from '../config'; |
|
|
|
import { SEGMENTS_PATH } from '../config'; |
|
|
|
import { AnomalyId, loadAnomalyById, saveAnomaly } from './anomalyType'; |
|
|
|
import { AnomalyId, loadAnomalyById, saveAnomaly } from './anomalyType'; |
|
|
@ -8,19 +9,18 @@ import * as _ from 'lodash'; |
|
|
|
function getLabeledSegments(anomalyId: AnomalyId) { |
|
|
|
function getLabeledSegments(anomalyId: AnomalyId) { |
|
|
|
let filename = path.join(SEGMENTS_PATH, `${anomalyId}_labeled.json`); |
|
|
|
let filename = path.join(SEGMENTS_PATH, `${anomalyId}_labeled.json`); |
|
|
|
|
|
|
|
|
|
|
|
let segments = []; |
|
|
|
if(!fs.existsSync(filename)) { |
|
|
|
try { |
|
|
|
return []; |
|
|
|
segments = getJsonDataSync(filename); |
|
|
|
} else { |
|
|
|
|
|
|
|
let segments = getJsonDataSync(filename); |
|
|
|
for(let segment of segments) { |
|
|
|
for(let segment of segments) { |
|
|
|
if(segment.labeled === undefined) { |
|
|
|
if(segment.labeled === undefined) { |
|
|
|
segment.labeled = false; |
|
|
|
segment.labeled = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch(e) { |
|
|
|
|
|
|
|
segments = []; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return segments; |
|
|
|
return segments; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getPredictedSegments(anomalyId: AnomalyId) { |
|
|
|
function getPredictedSegments(anomalyId: AnomalyId) { |
|
|
|
let filename = path.join(SEGMENTS_PATH, `${anomalyId}_segments.json`); |
|
|
|
let filename = path.join(SEGMENTS_PATH, `${anomalyId}_segments.json`); |
|
|
|