| | 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 recognize entities operation on a document, |
| | 10 | | /// containing a collection of the <see cref="CategorizedEntity"/> objects |
| | 11 | | /// identified in that document. |
| | 12 | | /// </summary> |
| | 13 | | public class RecognizeEntitiesResult : TextAnalyticsResult |
| | 14 | | { |
| | 15 | | private readonly CategorizedEntityCollection _entities; |
| | 16 | |
|
| | 17 | | internal RecognizeEntitiesResult(string id, TextDocumentStatistics statistics, CategorizedEntityCollection entit |
| 84 | 18 | | : base(id, statistics) |
| | 19 | | { |
| 84 | 20 | | _entities = entities; |
| 84 | 21 | | } |
| | 22 | |
|
| 40 | 23 | | internal RecognizeEntitiesResult(string id, TextAnalyticsError error) : base(id, error) { } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Gets the collection of named entities identified in the document. |
| | 27 | | /// </summary> |
| | 28 | | public CategorizedEntityCollection Entities |
| | 29 | | { |
| | 30 | | get |
| | 31 | | { |
| 88 | 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 | | } |
| 84 | 38 | | return _entities; |
| | 39 | | } |
| | 40 | | } |
| | 41 | | } |
| | 42 | | } |