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