internal static DocumentSentiment DeserializeDocumentSentiment(JsonElement element)
        {
            string id = default;
            DocumentSentimentValue                        sentiment        = default;
            Optional <TextDocumentStatistics>             statistics       = default;
            SentimentConfidenceScorePerLabel              confidenceScores = default;
            IReadOnlyList <SentenceSentiment>             sentences        = default;
            IReadOnlyList <TextAnalyticsWarning_internal> warnings         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sentiment"))
                {
                    sentiment = property.Value.GetString().ToDocumentSentimentValue();
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("confidenceScores"))
                {
                    confidenceScores = SentimentConfidenceScorePerLabel.DeserializeSentimentConfidenceScorePerLabel(property.Value);
                    continue;
                }
                if (property.NameEquals("sentences"))
                {
                    List <SentenceSentiment> array = new List <SentenceSentiment>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SentenceSentiment.DeserializeSentenceSentiment(item));
                    }
                    sentences = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarning_internal> array = new List <TextAnalyticsWarning_internal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarning_internal.DeserializeTextAnalyticsWarning_internal(item));
                    }
                    warnings = array;
                    continue;
                }
            }
            return(new DocumentSentiment(id, sentiment, Optional.ToNullable(statistics), confidenceScores, sentences, warnings));
        }
Beispiel #2
0
        internal static DocumentEntities DeserializeDocumentEntities(JsonElement element)
        {
            string id = default;
            IReadOnlyList <Entity> entities = default;
            IReadOnlyList <TextAnalyticsWarning_internal> warnings   = default;
            Optional <TextDocumentStatistics>             statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("entities"))
                {
                    List <Entity> array = new List <Entity>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Entity.DeserializeEntity(item));
                    }
                    entities = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarning_internal> array = new List <TextAnalyticsWarning_internal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarning_internal.DeserializeTextAnalyticsWarning_internal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentEntities(id, entities, warnings, Optional.ToNullable(statistics)));
        }