| | 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 detect language operation on a single document, |
| | 10 | | /// containing a prediction of what language the document is written in. |
| | 11 | | /// </summary> |
| | 12 | | public class DetectLanguageResult : TextAnalyticsResult |
| | 13 | | { |
| | 14 | | private readonly DetectedLanguage _primaryLanguage; |
| | 15 | |
|
| | 16 | | internal DetectLanguageResult(string id, TextDocumentStatistics statistics, DetectedLanguage detectedLanguage) |
| 60 | 17 | | : base(id, statistics) |
| | 18 | | { |
| 60 | 19 | | _primaryLanguage = detectedLanguage; |
| 60 | 20 | | } |
| | 21 | |
|
| 8 | 22 | | internal DetectLanguageResult(string id, TextAnalyticsError error) : base(id, error) { } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// The primary language detected in the document. |
| | 26 | | /// </summary> |
| | 27 | | public DetectedLanguage PrimaryLanguage |
| | 28 | | { |
| | 29 | | get |
| | 30 | | { |
| 56 | 31 | | if (HasError) |
| | 32 | | { |
| | 33 | | #pragma warning disable CA1065 // Do not raise exceptions in unexpected locations |
| 4 | 34 | | throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.Er |
| | 35 | | #pragma warning restore CA1065 // Do not raise exceptions in unexpected locations |
| | 36 | | } |
| 52 | 37 | | return _primaryLanguage; |
| | 38 | | } |
| | 39 | | } |
| | 40 | | } |
| | 41 | | } |