internal DocumentSentiment(string id, DocumentSentimentValue sentiment, SentimentConfidenceScorePerLabel confidenceScores, IEnumerable <SentenceSentiment> sentences, IEnumerable <TextAnalyticsWarning_internal> warnings) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (sentences == null) { throw new ArgumentNullException(nameof(sentences)); } if (warnings == null) { throw new ArgumentNullException(nameof(warnings)); } Id = id; Sentiment = sentiment; ConfidenceScores = confidenceScores; Sentences = sentences.ToList(); Warnings = warnings.ToList(); }
internal static DocumentSentiment DeserializeDocumentSentiment(JsonElement element) { string id = default; DocumentSentimentValue sentiment = default; Optional <DocumentStatistics> statistics = default; SentimentConfidenceScorePerLabel confidenceScores = default; IReadOnlyList <SentenceSentiment> sentences = default; IReadOnlyList <TextAnalyticsWarning> 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")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } statistics = DocumentStatistics.DeserializeDocumentStatistics(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> array = new List <TextAnalyticsWarning>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TextAnalyticsWarning.DeserializeTextAnalyticsWarning(item)); } warnings = array; continue; } } return(new DocumentSentiment(id, sentiment, statistics.Value, confidenceScores, sentences, warnings)); }
internal DocumentSentiment(string id, DocumentSentimentValue sentiment, DocumentStatistics statistics, SentimentConfidenceScorePerLabel documentScores, IReadOnlyList <SentenceSentiment> sentences) { Id = id; Sentiment = sentiment; Statistics = statistics; DocumentScores = documentScores; Sentences = sentences; }
internal DocumentSentiment(string id, DocumentSentimentValue sentiment, TextDocumentStatistics?statistics, SentimentConfidenceScorePerLabel confidenceScores, IReadOnlyList <SentenceSentiment> sentences, IReadOnlyList <TextAnalyticsWarning_internal> warnings) { Id = id; Sentiment = sentiment; Statistics = statistics; ConfidenceScores = confidenceScores; Sentences = sentences; Warnings = warnings; }
internal static DocumentSentiment DeserializeDocumentSentiment(JsonElement element) { string id = default; DocumentSentimentValue sentiment = default; DocumentStatistics statistics = default; SentimentConfidenceScorePerLabel documentScores = default; IReadOnlyList <SentenceSentiment> sentences = 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")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } statistics = DocumentStatistics.DeserializeDocumentStatistics(property.Value); continue; } if (property.NameEquals("documentScores")) { documentScores = SentimentConfidenceScorePerLabel.DeserializeSentimentConfidenceScorePerLabel(property.Value); continue; } if (property.NameEquals("sentences")) { List <SentenceSentiment> array = new List <SentenceSentiment>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(SentenceSentiment.DeserializeSentenceSentiment(item)); } } sentences = array; continue; } } return(new DocumentSentiment(id, sentiment, statistics, documentScores, sentences)); }
internal DocumentSentiment(string id, DocumentSentimentValue sentiment, SentimentConfidenceScorePerLabel documentScores, IEnumerable <SentenceSentiment> sentences) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (documentScores == null) { throw new ArgumentNullException(nameof(documentScores)); } if (sentences == null) { throw new ArgumentNullException(nameof(sentences)); } Id = id; Sentiment = sentiment; DocumentScores = documentScores; Sentences = sentences.ToArray(); }
public static string ToSerialString(this DocumentSentimentValue value) => value switch {