-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
AnalyzeHealthcareEntitiesResult.cs
67 lines (60 loc) · 2.63 KB
/
AnalyzeHealthcareEntitiesResult.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Azure.AI.TextAnalytics
{
/// <summary>
/// A representation of the result of analyzing the healthcare entities in a given document.
/// </summary>
public partial class AnalyzeHealthcareEntitiesResult : TextAnalyticsResult
{
private readonly IReadOnlyCollection<HealthcareEntity> _entities;
/// <summary>
/// Initializes a successful <see cref="AnalyzeHealthcareEntitiesResult"/>.
/// </summary>
internal AnalyzeHealthcareEntitiesResult(
string id,
TextDocumentStatistics statistics,
IList<HealthcareEntity> healthcareEntities,
IList<HealthcareEntityRelation> entityRelations,
IList<TextAnalyticsWarning> warnings)
: base(id, statistics)
{
_entities = new ReadOnlyCollection<HealthcareEntity>(healthcareEntities);
EntityRelations = new ReadOnlyCollection<HealthcareEntityRelation>(entityRelations);
Warnings = (warnings is not null)
? new ReadOnlyCollection<TextAnalyticsWarning>(warnings)
: new List<TextAnalyticsWarning>();
}
/// <summary>
/// Initializes an <see cref="AnalyzeHealthcareEntitiesResult"/> with an error.
/// </summary>
internal AnalyzeHealthcareEntitiesResult(string id, TextAnalyticsError error) : base(id, error) { }
/// <summary>
/// The warnings that resulted from processing the document.
/// </summary>
public IReadOnlyCollection<TextAnalyticsWarning> Warnings { get; }
/// <summary>
/// The collection of healthcare entities that were recognized in this document.
/// </summary>
public IReadOnlyCollection<HealthcareEntity> Entities
{
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 _entities;
}
}
/// <summary>
/// The collection of relations between the healthcare entities that were recognized in this document.
/// </summary>
public IReadOnlyCollection<HealthcareEntityRelation> EntityRelations { get; }
}
}