internal static PreBuiltResult DeserializePreBuiltResult(JsonElement element)
 {
     IList<DocumentError> errors = default;
     Optional<TextDocumentBatchStatistics> statistics = default;
     string modelVersion = default;
     foreach (var property in element.EnumerateObject())
     {
         if (property.NameEquals("errors"))
         {
             List<DocumentError> array = new List<DocumentError>();
             foreach (var item in property.Value.EnumerateArray())
             {
                 array.Add(DocumentError.DeserializeDocumentError(item));
             }
             errors = array;
             continue;
         }
         if (property.NameEquals("statistics"))
         {
             if (property.Value.ValueKind == JsonValueKind.Null)
             {
                 property.ThrowNonNullablePropertyIsNull();
                 continue;
             }
             statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value);
             continue;
         }
         if (property.NameEquals("modelVersion"))
         {
             modelVersion = property.Value.GetString();
             continue;
         }
     }
     return new PreBuiltResult(errors, statistics.Value, modelVersion);
 }
Пример #2
0
        internal static CustomMultiClassificationResult DeserializeCustomMultiClassificationResult(JsonElement element)
        {
            IReadOnlyList <MultiClassificationDocument> documents = default;
            IReadOnlyList <DocumentError>          errors         = default;
            Optional <TextDocumentBatchStatistics> statistics     = default;
            string projectName    = default;
            string deploymentName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("documents"))
                {
                    List <MultiClassificationDocument> array = new List <MultiClassificationDocument>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MultiClassificationDocument.DeserializeMultiClassificationDocument(item));
                    }
                    documents = array;
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    List <DocumentError> array = new List <DocumentError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentError.DeserializeDocumentError(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("projectName"))
                {
                    projectName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deploymentName"))
                {
                    deploymentName = property.Value.GetString();
                    continue;
                }
            }
            return(new CustomMultiClassificationResult(documents, errors, statistics.Value, projectName, deploymentName));
        }
Пример #3
0
        internal static ExtractiveSummarizationResult DeserializeExtractiveSummarizationResult(JsonElement element)
        {
            IReadOnlyList <ExtractedDocumentSummary> documents  = default;
            IReadOnlyList <DocumentError>            errors     = default;
            Optional <TextDocumentBatchStatistics>   statistics = default;
            string modelVersion = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("documents"))
                {
                    List <ExtractedDocumentSummary> array = new List <ExtractedDocumentSummary>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ExtractedDocumentSummary.DeserializeExtractedDocumentSummary(item));
                    }
                    documents = array;
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    List <DocumentError> array = new List <DocumentError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentError.DeserializeDocumentError(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("modelVersion"))
                {
                    modelVersion = property.Value.GetString();
                    continue;
                }
            }
            return(new ExtractiveSummarizationResult(documents, errors, statistics.Value, modelVersion));
        }
Пример #4
0
        internal static LanguageResult DeserializeLanguageResult(JsonElement element)
        {
            IReadOnlyList <DocumentLanguage>       documents  = default;
            IReadOnlyList <DocumentError>          errors     = default;
            Optional <TextDocumentBatchStatistics> statistics = default;
            string modelVersion = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("documents"))
                {
                    List <DocumentLanguage> array = new List <DocumentLanguage>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentLanguage.DeserializeDocumentLanguage(item));
                    }
                    documents = array;
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    List <DocumentError> array = new List <DocumentError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentError.DeserializeDocumentError(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("modelVersion"))
                {
                    modelVersion = property.Value.GetString();
                    continue;
                }
            }
            return(new LanguageResult(documents, errors, statistics.Value, modelVersion));
        }