internal SentenceTarget(TokenSentimentValue sentiment, TargetConfidenceScoreLabel confidenceScores, int offset, int length, string text, IReadOnlyList <TargetRelation> relations) { Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Text = text; Relations = relations; }
internal static SentenceTarget DeserializeSentenceTarget(JsonElement element) { TokenSentimentValue sentiment = default; TargetConfidenceScoreLabel confidenceScores = default; int offset = default; int length = default; string text = default; IReadOnlyList <TargetRelation> relations = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sentiment")) { sentiment = property.Value.GetString().ToTokenSentimentValue(); continue; } if (property.NameEquals("confidenceScores")) { confidenceScores = TargetConfidenceScoreLabel.DeserializeTargetConfidenceScoreLabel(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 <TargetRelation> array = new List <TargetRelation>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TargetRelation.DeserializeTargetRelation(item)); } relations = array; continue; } } return(new SentenceTarget(sentiment, confidenceScores, offset, length, text, relations)); }
internal SentenceAssessment(TokenSentimentValue sentiment, TargetConfidenceScoreLabel confidenceScores, int offset, int length, string text, bool isNegated) { if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (text == null) { throw new ArgumentNullException(nameof(text)); } Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Text = text; IsNegated = isNegated; }
internal static SentenceAssessment DeserializeSentenceAssessment(JsonElement element) { TokenSentimentValue sentiment = default; TargetConfidenceScoreLabel confidenceScores = default; int offset = default; int length = default; string text = default; bool isNegated = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sentiment")) { sentiment = property.Value.GetString().ToTokenSentimentValue(); continue; } if (property.NameEquals("confidenceScores")) { confidenceScores = TargetConfidenceScoreLabel.DeserializeTargetConfidenceScoreLabel(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("isNegated")) { isNegated = property.Value.GetBoolean(); continue; } } return(new SentenceAssessment(sentiment, confidenceScores, offset, length, text, isNegated)); }
internal SentenceTarget(TokenSentimentValue sentiment, TargetConfidenceScoreLabel confidenceScores, int offset, int length, string text, IEnumerable <TargetRelation> 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(); }