internal SentenceSentimentInternal(string text, string sentiment, SentimentConfidenceScores confidenceScores, int offset, int length, IEnumerable <SentenceAspect> aspects, IEnumerable <SentenceOpinion> opinions) { if (text == null) { throw new ArgumentNullException(nameof(text)); } if (sentiment == null) { throw new ArgumentNullException(nameof(sentiment)); } if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (aspects == null) { throw new ArgumentNullException(nameof(aspects)); } if (opinions == null) { throw new ArgumentNullException(nameof(opinions)); } Text = text; Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Aspects = aspects.ToList(); Opinions = opinions.ToList(); }
internal DocumentSentimentInternal(string id, TextSentiment sentiment, TextDocumentStatistics?statistics, SentimentConfidenceScores confidenceScores, IEnumerable <SentenceSentimentInternal> sentences, IEnumerable <TextAnalyticsWarningInternal> 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; Statistics = statistics; ConfidenceScores = confidenceScores; Sentences = sentences.ToList(); Warnings = warnings.ToList(); }
internal SentenceSentiment(TextSentiment sentiment, double positiveScore, double neutralScore, double negativeScore, int offset, int length) { Sentiment = sentiment; ConfidenceScores = new SentimentConfidenceScores(positiveScore, neutralScore, negativeScore); GraphemeOffset = offset; GraphemeLength = length; }
internal static SentenceSentimentInternal DeserializeSentenceSentimentInternal(JsonElement element) { string text = default; string sentiment = default; SentimentConfidenceScores confidenceScores = default; int offset = default; int length = default; Optional <IReadOnlyList <SentenceAspect> > aspects = default; Optional <IReadOnlyList <SentenceOpinion> > opinions = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text")) { text = property.Value.GetString(); continue; } if (property.NameEquals("sentiment")) { sentiment = property.Value.GetString(); continue; } if (property.NameEquals("confidenceScores")) { confidenceScores = SentimentConfidenceScores.DeserializeSentimentConfidenceScores(property.Value); continue; } if (property.NameEquals("offset")) { offset = property.Value.GetInt32(); continue; } if (property.NameEquals("length")) { length = property.Value.GetInt32(); continue; } if (property.NameEquals("aspects")) { List <SentenceAspect> array = new List <SentenceAspect>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(SentenceAspect.DeserializeSentenceAspect(item)); } aspects = array; continue; } if (property.NameEquals("opinions")) { List <SentenceOpinion> array = new List <SentenceOpinion>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(SentenceOpinion.DeserializeSentenceOpinion(item)); } opinions = array; continue; } } return(new SentenceSentimentInternal(text, sentiment, confidenceScores, offset, length, Optional.ToList(aspects), Optional.ToList(opinions))); }
internal SentenceSentimentInternal(string text, string sentiment, SentimentConfidenceScores confidenceScores, int offset, int length, IEnumerable <SentenceTarget> targets, IEnumerable <SentenceAssessment> assessments) { if (text == null) { throw new ArgumentNullException(nameof(text)); } if (sentiment == null) { throw new ArgumentNullException(nameof(sentiment)); } if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (targets == null) { throw new ArgumentNullException(nameof(targets)); } if (assessments == null) { throw new ArgumentNullException(nameof(assessments)); } Text = text; Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Targets = targets.ToList(); Assessments = assessments.ToList(); }
internal static SentimentResponseDocumentsItem DeserializeSentimentResponseDocumentsItem(JsonElement element) { TextSentiment sentiment = default; SentimentConfidenceScores confidenceScores = default; IList <SentenceSentimentInternal> sentences = default; string id = default; IList <DocumentWarning> warnings = default; Optional <TextDocumentStatistics> statistics = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sentiment")) { sentiment = property.Value.GetString().ToTextSentiment(); 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("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("warnings")) { List <DocumentWarning> array = new List <DocumentWarning>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(DocumentWarning.DeserializeDocumentWarning(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 SentimentResponseDocumentsItem(id, warnings, Optional.ToNullable(statistics), sentiment, confidenceScores, sentences)); }
/// <summary> /// 分析結果をコンソールに出力 /// </summary> /// <param name="text"></param> /// <param name="sentiment"></param> /// <param name="scores"></param> private void ConsoleOutput(string text, TextSentiment sentiment, SentimentConfidenceScores scores) { Console.WriteLine($"\tText: \"{text}\""); Console.WriteLine($"\tSentence sentiment: {sentiment}"); Console.WriteLine($"\tPositive score: {scores.Positive:0.00}"); Console.WriteLine($"\tNegative score: {scores.Negative:0.00}"); Console.WriteLine($"\tNeutral score: {scores.Neutral:0.00}\n"); }
internal DocumentSentimentInternal(string id, TextSentiment sentiment, TextDocumentStatistics?statistics, SentimentConfidenceScores confidenceScores, IReadOnlyList <SentenceSentimentInternal> sentences, IReadOnlyList <TextAnalyticsWarningInternal> warnings) { Id = id; Sentiment = sentiment; Statistics = statistics; ConfidenceScores = confidenceScores; Sentences = sentences; Warnings = warnings; }
internal SentenceSentimentInternal(string text, string sentiment, SentimentConfidenceScores confidenceScores, int offset, int length, IReadOnlyList <SentenceAspect> aspects, IReadOnlyList <SentenceOpinion> opinions) { Text = text; Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Aspects = aspects; Opinions = opinions; }
internal SentenceSentimentInternal(string text, string sentiment, SentimentConfidenceScores confidenceScores, int offset, int length, IReadOnlyList <SentenceTarget> targets, IReadOnlyList <SentenceAssessment> assessments) { Text = text; Sentiment = sentiment; ConfidenceScores = confidenceScores; Offset = offset; Length = length; Targets = targets; Assessments = assessments; }
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")) { 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)); }
public SentimentDocumentResult(string id, IEnumerable <DocumentWarning> warnings, TextSentiment sentiment, SentimentConfidenceScores confidenceScores, IEnumerable <SentenceSentimentInternal> sentences) : base(id, warnings) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (warnings == null) { throw new ArgumentNullException(nameof(warnings)); } if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (sentences == null) { throw new ArgumentNullException(nameof(sentences)); } Sentiment = sentiment; ConfidenceScores = confidenceScores; Sentences = sentences.ToList(); }
internal static SentenceSentimentInternal DeserializeSentenceSentimentInternal(JsonElement element) { string text = default; string sentiment = default; SentimentConfidenceScores confidenceScores = default; int offset = default; int length = default; Optional <IReadOnlyList <SentenceTarget> > targets = default; Optional <IReadOnlyList <SentenceAssessment> > assessments = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text")) { text = property.Value.GetString(); continue; } if (property.NameEquals("sentiment")) { sentiment = property.Value.GetString(); continue; } if (property.NameEquals("confidenceScores")) { confidenceScores = SentimentConfidenceScores.DeserializeSentimentConfidenceScores(property.Value); continue; } if (property.NameEquals("offset")) { offset = property.Value.GetInt32(); continue; } if (property.NameEquals("length")) { length = property.Value.GetInt32(); continue; } if (property.NameEquals("targets")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <SentenceTarget> array = new List <SentenceTarget>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(SentenceTarget.DeserializeSentenceTarget(item)); } targets = array; continue; } if (property.NameEquals("assessments")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <SentenceAssessment> array = new List <SentenceAssessment>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(SentenceAssessment.DeserializeSentenceAssessment(item)); } assessments = array; continue; } } return(new SentenceSentimentInternal(text, sentiment, confidenceScores, offset, length, Optional.ToList(targets), Optional.ToList(assessments))); }
private void SetConfidenceScores(SentimentConfidenceScores scores) { Scores = new ConfidenceScores(scores.Positive, scores.Neutral, scores.Negative); }
public SentimentResponseDocumentsItem(string id, IEnumerable <DocumentWarning> warnings, TextSentiment sentiment, SentimentConfidenceScores confidenceScores, IEnumerable <SentenceSentimentInternal> sentences) : base(id, warnings, sentiment, confidenceScores, sentences) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (warnings == null) { throw new ArgumentNullException(nameof(warnings)); } if (confidenceScores == null) { throw new ArgumentNullException(nameof(confidenceScores)); } if (sentences == null) { throw new ArgumentNullException(nameof(sentences)); } }
internal SentimentResponseDocumentsItem(string id, IList <DocumentWarning> warnings, TextDocumentStatistics?statistics, TextSentiment sentiment, SentimentConfidenceScores confidenceScores, IList <SentenceSentimentInternal> sentences) : base(id, warnings, statistics, sentiment, confidenceScores, sentences) { }
internal SentimentDocumentResult(string id, IList <DocumentWarning> warnings, TextDocumentStatistics?statistics, TextSentiment sentiment, SentimentConfidenceScores confidenceScores, IList <SentenceSentimentInternal> sentences) : base(id, warnings, statistics) { Sentiment = sentiment; ConfidenceScores = confidenceScores; Sentences = sentences; }
private bool CheckTotalConfidenceScoreValue(SentimentConfidenceScores scores) { return(scores.Positive + scores.Neutral + scores.Negative == 1d); }
internal SentenceSentiment(TextSentiment sentiment, string text, double positiveScore, double neutralScore, double negativeScore) { Sentiment = sentiment; Text = text; ConfidenceScores = new SentimentConfidenceScores(positiveScore, neutralScore, negativeScore); }