internal SentenceAspect(SentenceAspectSentiment sentiment, AspectConfidenceScoreLabel confidenceScores, int offset, int length, string text, IReadOnlyList <AspectRelation> relations) { Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Text = text; Relations = relations; }
internal static SentenceAspect DeserializeSentenceAspect(JsonElement element) { SentenceAspectSentiment sentiment = default; AspectConfidenceScoreLabel confidenceScores = default; int offset = default; int length = default; string text = default; IReadOnlyList <AspectRelation> relations = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sentiment")) { sentiment = new SentenceAspectSentiment(property.Value.GetString()); continue; } if (property.NameEquals("confidenceScores")) { confidenceScores = AspectConfidenceScoreLabel.DeserializeAspectConfidenceScoreLabel(property.Value); continue; } if (property.NameEquals("offset")) { offset = property.Value.GetInt32(); continue; } if (property.NameEquals("length")) { length = property.Value.GetInt32(); continue; } if (property.NameEquals("text")) { text = property.Value.GetString(); continue; } if (property.NameEquals("relations")) { List <AspectRelation> array = new List <AspectRelation>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(AspectRelation.DeserializeAspectRelation(item)); } relations = array; continue; } } return(new SentenceAspect(sentiment, confidenceScores, offset, length, text, relations)); }
internal SentenceAspect(SentenceAspectSentiment sentiment, AspectConfidenceScoreLabel confidenceScores, int offset, int length, string text, IEnumerable <AspectRelation> relations) { if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (text == null) { throw new ArgumentNullException(nameof(text)); } if (relations == null) { throw new ArgumentNullException(nameof(relations)); } Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Text = text; Relations = relations.ToList(); }