Пример #1
0
        internal static TrainResult_internal DeserializeTrainResult_internal(JsonElement element)
        {
            IReadOnlyList <TrainingDocumentInfo> trainingDocuments = default;
            IReadOnlyList <CustomFormModelField> fields            = default;
            float?averageModelAccuracy = default;
            IReadOnlyList <FormRecognizerError> errors = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("trainingDocuments"))
                {
                    List <TrainingDocumentInfo> array = new List <TrainingDocumentInfo>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item));
                    }
                    trainingDocuments = array;
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <CustomFormModelField> array = new List <CustomFormModelField>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(CustomFormModelField.DeserializeCustomFormModelField(item));
                    }
                    fields = array;
                    continue;
                }
                if (property.NameEquals("averageModelAccuracy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    averageModelAccuracy = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FormRecognizerError> array = new List <FormRecognizerError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FormRecognizerError.DeserializeFormRecognizerError(item));
                    }
                    errors = array;
                    continue;
                }
            }
            return(new TrainResult_internal(trainingDocuments, fields, averageModelAccuracy, errors));
        }
        internal static TrainResult DeserializeTrainResult(JsonElement element)
        {
            IReadOnlyList <TrainingDocumentInfo>             trainingDocuments = default;
            Optional <IReadOnlyList <CustomFormModelField> > fields            = default;
            Optional <float> averageModelAccuracy = default;
            Optional <Guid>  modelId = default;
            Optional <IReadOnlyList <FormRecognizerError> > errors = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("trainingDocuments"))
                {
                    List <TrainingDocumentInfo> array = new List <TrainingDocumentInfo>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item));
                    }
                    trainingDocuments = array;
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    List <CustomFormModelField> array = new List <CustomFormModelField>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(CustomFormModelField.DeserializeCustomFormModelField(item));
                    }
                    fields = array;
                    continue;
                }
                if (property.NameEquals("averageModelAccuracy"))
                {
                    averageModelAccuracy = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("modelId"))
                {
                    modelId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    List <FormRecognizerError> array = new List <FormRecognizerError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FormRecognizerError.DeserializeFormRecognizerError(item));
                    }
                    errors = array;
                    continue;
                }
            }
            return(new TrainResult(trainingDocuments, Optional.ToList(fields), Optional.ToNullable(averageModelAccuracy), Optional.ToNullable(modelId), Optional.ToList(errors)));
        }