public void batchAdd(int intentID, List <Sample> samples) { Intent intent = lstmDb.Intents.Find(intentID); intent.batchStatus = 1; lstmDb.SaveChanges(); bool success = true; try { foreach (Sample sample in samples) { sample.intentID = intent.id; lstmDb.Samples.Add(sample); } lstmDb.SaveChanges(); } catch { success = false; intent.batchStatus = 3; } if (success == true) { intent.batchStatus = 2; } lstmDb.SaveChanges(); }
public void StartTrain(int intentID, int number, string textTrainPath, string svTrainPath, string svDictPath, string tokenPath, string modelPath) { Intent intent = lstmDb.Intents.Find(intentID); intent.modelStatus = 1; lstmDb.SaveChanges(); bool success = true; try { FileOperation.ExecutePython(workDir, number); } catch { success = false; intent.modelStatus = 3; } if (success == true) { intent.modelStatus = 2; intent.sv_dict = System.IO.File.ReadAllBytes(svDictPath); intent.token = System.IO.File.ReadAllBytes(tokenPath); intent.model = System.IO.File.ReadAllBytes(modelPath); } intent.lastTrainTime = DateTime.UtcNow; lstmDb.SaveChanges(); Directory.Delete(workDir + @"\" + number, true); }