Exemple #1
0
 internal SingleClassificationDocument(string id, ClassificationResult classification, IReadOnlyList <TextAnalyticsWarning> warnings, DocumentStatistics statistics)
 {
     Id             = id;
     Classification = classification;
     Warnings       = warnings;
     Statistics     = statistics;
 }
Exemple #2
0
        internal static MultiClassificationDocument DeserializeMultiClassificationDocument(JsonElement element)
        {
            string id = default;
            IReadOnlyList <ClassificationResult> classifications = default;
            IReadOnlyList <TextAnalyticsWarning> warnings        = default;
            Optional <DocumentStatistics>        statistics      = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("classifications"))
                {
                    List <ClassificationResult> array = new List <ClassificationResult>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ClassificationResult.DeserializeClassificationResult(item));
                    }
                    classifications = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarning> array = new List <TextAnalyticsWarning>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarning.DeserializeTextAnalyticsWarning(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = DocumentStatistics.DeserializeDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new MultiClassificationDocument(id, classifications, warnings, statistics.Value));
        }
Exemple #3
0
        internal SingleClassificationDocument(string id, ClassificationResult classification, IEnumerable <TextAnalyticsWarning> warnings)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (classification == null)
            {
                throw new ArgumentNullException(nameof(classification));
            }
            if (warnings == null)
            {
                throw new ArgumentNullException(nameof(warnings));
            }

            Id             = id;
            Classification = classification;
            Warnings       = warnings.ToList();
        }