Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(modeldir, locale) {
this._locale = locale;
this._tokenizer = TokenizerService.getLocal();
this._predictor = new Genie.Predictor('local', modeldir, 1);
}
async load() {
if (!this.trained)
return;
await this._download();
this.predictor = new Genie.Predictor(this.id, this._localdir, nprocesses);
await this.predictor.start();
}
};
async reload() {
if (!this.trained)
return;
const oldlocaldir = this._localdir;
await this._download();
const oldpredictor = this.predictor;
this.predictor = new Genie.Predictor(this.id, this._localdir, nprocesses);
await this.predictor.start();
await Promise.all([
oldpredictor ? oldpredictor.stop() : Promise.resolve(),
oldlocaldir ? AbstractFS.removeTemporary(oldlocaldir) : Promise.resolve()
]);
}