-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
AnalyzeSentimentResult.cs
45 lines (40 loc) · 1.48 KB
/
AnalyzeSentimentResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
namespace Azure.AI.TextAnalytics
{
/// <summary>
/// The result of the analyze sentiment operation on a single document,
/// containing the predicted sentiment for each sentence as well as for
/// the full document.
/// </summary>
public class AnalyzeSentimentResult : TextAnalyticsResult
{
private readonly DocumentSentiment _documentSentiment;
internal AnalyzeSentimentResult(
string id,
TextDocumentStatistics statistics,
DocumentSentiment documentSentiment)
: base(id, statistics)
{
_documentSentiment = documentSentiment;
}
internal AnalyzeSentimentResult(string id, TextAnalyticsError error) : base(id, error) { }
/// <summary>
/// Gets the predicted sentiment for the full document.
/// </summary>
public DocumentSentiment DocumentSentiment
{
get
{
if (HasError)
{
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.ErrorCode}: {Error.Message}");
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
}
return _documentSentiment;
}
}
}
}