Пример #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)));
        }
        internal static TrainResult_internal DeserializeTrainResult_internal(JsonElement element)
        {
            TrainResult_internal result = new TrainResult_internal();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("trainingDocuments"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.TrainingDocuments.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item));
                    }
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Fields = new List <FieldPredictionAccuracy>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Fields.Add(FieldPredictionAccuracy.DeserializeFieldPredictionAccuracy(item));
                    }
                    continue;
                }
                if (property.NameEquals("averageModelAccuracy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.AverageModelAccuracy = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Errors = new List <FormRecognizerError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Errors.Add(FormRecognizerError.DeserializeFormRecognizerError(item));
                    }
                    continue;
                }
            }
            return(result);
        }
        internal static TrainResult DeserializeTrainResult(JsonElement element)
        {
            IReadOnlyList <TrainingDocumentInfo> trainingDocuments = default;
            IReadOnlyList <FormFieldsReport>     fields            = default;
            float?averageModelAccuracy = default;
            IReadOnlyList <ErrorInformation> 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())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item));
                        }
                    }
                    trainingDocuments = array;
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FormFieldsReport> array = new List <FormFieldsReport>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(FormFieldsReport.DeserializeFormFieldsReport(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 <ErrorInformation> array = new List <ErrorInformation>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ErrorInformation.DeserializeErrorInformation(item));
                        }
                    }
                    errors = array;
                    continue;
                }
            }
            return(new TrainResult(trainingDocuments, fields, averageModelAccuracy, errors));
        }