internal DocumentSentiment(string id, DocumentSentimentValue sentiment, DocumentStatistics statistics, SentimentConfidenceScorePerLabel documentScores, IReadOnlyList <SentenceSentiment> sentences) { Id = id; Sentiment = sentiment; Statistics = statistics; DocumentScores = documentScores; Sentences = sentences; }
internal SentenceSentiment(SentenceSentimentValue sentiment, SentimentConfidenceScorePerLabel sentenceScores, int offset, int length, IReadOnlyList <string> warnings) { Sentiment = sentiment; SentenceScores = sentenceScores; Offset = offset; Length = length; 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 static SentenceSentiment DeserializeSentenceSentiment(JsonElement element) { SentenceSentimentValue sentiment = default; SentimentConfidenceScorePerLabel sentenceScores = default; int offset = default; int length = default; IReadOnlyList <string> warnings = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sentiment")) { sentiment = property.Value.GetString().ToSentenceSentimentValue(); continue; } if (property.NameEquals("sentenceScores")) { sentenceScores = SentimentConfidenceScorePerLabel.DeserializeSentimentConfidenceScorePerLabel(property.Value); continue; } if (property.NameEquals("offset")) { offset = property.Value.GetInt32(); continue; } if (property.NameEquals("length")) { length = property.Value.GetInt32(); continue; } if (property.NameEquals("warnings")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } warnings = array; continue; } } return(new SentenceSentiment(sentiment, sentenceScores, offset, length, warnings)); }
internal SentenceSentiment(SentenceSentimentValue sentiment, SentimentConfidenceScorePerLabel sentenceScores, int offset, int length) { if (sentenceScores == null) { throw new ArgumentNullException(nameof(sentenceScores)); } Sentiment = sentiment; SentenceScores = sentenceScores; Offset = offset; Length = length; }
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(); }