private static List <PredictionIntentModel> Build(IQueryable <PredictionIntent> records) { var list = new List <PredictionIntentModel>(); foreach (var r in records) { var model = PredictionIntentModel.New(); model.Id = r.Id; model.SynAppsDeviceId = r.SynAppsDeviceId; model.LuisExampleId = r.LuisExampleId; model.Intent = r.Intent; model.CreatedAt = r.CreatedAt; model.UpdatedAt = r.UpdatedAt; list.Add(model); } return(list); }
public static List <PredictionIntentModel> FindAllBySynAppsDeviceIdAndIntentOrderByLuisExampleId(string _synappsDeviceId, string _intent) { List <PredictionIntentModel> list = new List <PredictionIntentModel>(); var dc = new PredictionExamplesDataContext(SqlConnectionString); var records = from n in dc.PredictionIntents join b in dc.PredictionEntities on n.LuisExampleId equals b.LuisExampleId where n.SynAppsDeviceId == _synappsDeviceId where n.Intent == _intent where b.SynAppsDeviceId == _synappsDeviceId orderby n.LuisExampleId select new { Id = n.Id, SynAppsDeviceId = n.SynAppsDeviceId, LuisExampleId = n.LuisExampleId, Intent = n.Intent, EntityName = b.EntityName, EntityValue = b.EntityValue, CreatedAt = n.CreatedAt, UpdatedAt = n.UpdatedAt }; foreach (var r in records) { var model = PredictionIntentModel.New(); model.Id = r.Id; model.SynAppsDeviceId = r.SynAppsDeviceId; model.LuisExampleId = r.LuisExampleId; model.Intent = r.Intent; model.EntityName = r.EntityName; model.EntityValue = r.EntityValue; model.CreatedAt = r.CreatedAt; model.UpdatedAt = r.UpdatedAt; list.Add(model); } return(list); }
public ApiResult RefreshPredictions() { var apiResult = new ApiResult { StatusCode = StatusCode.Success }; var intentList = new List <PredictionIntentModel>(); var entityList = new List <PredictionEntityModel>(); var list = new List <PreviewLabeledExampleDto>(); var r = GetPreviewLabeledExamples(); list.AddRange(r); while (r.Count >= 500) { r = GetPreviewLabeledExamples(list.Count); list.AddRange(r); } foreach (var l in list) { var intentModel = PredictionIntentModel.New(); intentModel.SynAppsDeviceId = this.DeviceId; intentModel.LuisExampleId = l.Id; intentModel.Intent = l.IntentLabel; intentList.Add(intentModel); foreach (var e in l.EntityLabels) { var entityModel = PredictionEntityModel.New(); entityModel.SynAppsDeviceId = this.DeviceId; entityModel.LuisExampleId = l.Id; entityModel.EntityName = e.EntityName; entityModel.EntityValue = e.EntityValue; entityList.Add(entityModel); } } var intentResult = PredictionIntentModel.Refresh(this.DeviceId, intentList); if (intentResult.StatusCode == StatusCode.Success) { var entityResult = PredictionEntityModel.Refresh(this.DeviceId, entityList); if (entityResult.StatusCode == StatusCode.Success) { var status = SynAppsSyncStatusModel.FindBySynAppsDeviceId(this.DeviceId); status.LastTrainingDateTime = DateTime.UtcNow; status.Save(); } else { apiResult.StatusCode = StatusCode.Error; apiResult.Message = entityResult.Message; } } else { apiResult.StatusCode = StatusCode.Error; apiResult.Message = intentResult.Message; } return(apiResult); }