Example #1
0
        internal static DocumentSentimentInternal DeserializeDocumentSentimentInternal(JsonElement element)
        {
            string        id        = default;
            TextSentiment sentiment = default;
            Optional <TextDocumentStatistics>            statistics       = default;
            SentimentConfidenceScores                    confidenceScores = default;
            IReadOnlyList <SentenceSentimentInternal>    sentences        = default;
            IReadOnlyList <TextAnalyticsWarningInternal> 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().ToTextSentiment();
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("confidenceScores"))
                {
                    confidenceScores = SentimentConfidenceScores.DeserializeSentimentConfidenceScores(property.Value);
                    continue;
                }
                if (property.NameEquals("sentences"))
                {
                    List <SentenceSentimentInternal> array = new List <SentenceSentimentInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SentenceSentimentInternal.DeserializeSentenceSentimentInternal(item));
                    }
                    sentences = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
            }
            return(new DocumentSentimentInternal(id, sentiment, Optional.ToNullable(statistics), confidenceScores, sentences, warnings));
        }
Example #2
0
        internal static DocumentHealthcareEntitiesInternal DeserializeDocumentHealthcareEntitiesInternal(JsonElement element)
        {
            string id = default;
            IReadOnlyList <HealthcareEntityInternal>     entities   = default;
            IReadOnlyList <HealthcareRelationInternal>   relations  = default;
            IReadOnlyList <TextAnalyticsWarningInternal> 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 <HealthcareEntityInternal> array = new List <HealthcareEntityInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(HealthcareEntityInternal.DeserializeHealthcareEntityInternal(item));
                    }
                    entities = array;
                    continue;
                }
                if (property.NameEquals("relations"))
                {
                    List <HealthcareRelationInternal> array = new List <HealthcareRelationInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(HealthcareRelationInternal.DeserializeHealthcareRelationInternal(item));
                    }
                    relations = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentHealthcareEntitiesInternal(id, entities, relations, warnings, Optional.ToNullable(statistics)));
        }
        internal static PiiDocumentEntities DeserializePiiDocumentEntities(JsonElement element)
        {
            string id                       = default;
            string redactedText             = default;
            IReadOnlyList <Entity> entities = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings   = default;
            Optional <TextDocumentStatistics>            statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("redactedText"))
                {
                    redactedText = 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 <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new PiiDocumentEntities(id, redactedText, entities, warnings, Optional.ToNullable(statistics)));
        }
Example #4
0
        internal static ExtractedDocumentSummary DeserializeExtractedDocumentSummary(JsonElement element)
        {
            string id = default;
            IReadOnlyList <ExtractedSummarySentence>     sentences  = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings   = default;
            Optional <TextDocumentStatistics>            statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sentences"))
                {
                    List <ExtractedSummarySentence> array = new List <ExtractedSummarySentence>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ExtractedSummarySentence.DeserializeExtractedSummarySentence(item));
                    }
                    sentences = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new ExtractedDocumentSummary(id, sentences, warnings, Optional.ToNullable(statistics)));
        }
Example #5
0
        internal static MultiClassificationDocument DeserializeMultiClassificationDocument(JsonElement element)
        {
            string id = default;
            IReadOnlyList <ClassificationResult>         classifications = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings        = default;
            Optional <TextDocumentStatistics>            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 <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new MultiClassificationDocument(id, classifications, warnings, Optional.ToNullable(statistics)));
        }
        internal static DocumentKeyPhrases DeserializeDocumentKeyPhrases(JsonElement element)
        {
            string id = default;
            IReadOnlyList <string> keyPhrases = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings   = default;
            Optional <TextDocumentStatistics>            statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyPhrases"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    keyPhrases = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentKeyPhrases(id, keyPhrases, warnings, Optional.ToNullable(statistics)));
        }
Example #7
0
        internal static DocumentLanguage DeserializeDocumentLanguage(JsonElement element)
        {
            string id = default;
            DetectedLanguageInternal detectedLanguage               = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings   = default;
            Optional <TextDocumentStatistics>            statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("detectedLanguage"))
                {
                    detectedLanguage = DetectedLanguageInternal.DeserializeDetectedLanguageInternal(property.Value);
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentLanguage(id, detectedLanguage, warnings, Optional.ToNullable(statistics)));
        }