Skip to content

Commit 3a5fdc1

Browse files
authored
[text analytics] Healthcare n-ary relations (#16997)
1 parent 3c48ef0 commit 3a5fdc1

File tree

91 files changed

+1473
-9130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1473
-9130
lines changed

eng/.docsettings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ known_content_issues:
105105
- ['sdk/monitor/azure-monitor-opentelemetry-exporter/swagger/README.md', '#4554']
106106
- ['sdk/monitor/azure-monitor-opentelemetry-exporter/README.md', '#4554']
107107
- ['sdk/digitaltwins/azure-digitaltwins-core/swagger/README.md', '#4554']
108+
- ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554']
108109
- ['sdk/media/azure-media-nspkg/README.md', '#4554']
109110

110111
# nspckg and common.

sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
**Breaking Changes**
66

7+
- Removed property `related_entities` on `HealthcareEntity` and added `entity_relations` onto the document response level for healthcare
78
- Renamed properties `aspect` and `opinions` to `target` and `assessments` respectively in class `MinedOpinion`.
89
- Renamed classes `AspectSentiment` and `OpinionSentiment` to `TargetSentiment` and `AssessmentSentiment` respectively.
910

@@ -87,7 +88,7 @@ used in conjunction with the Bing Entity Search API to fetch additional relevant
8788
- Removed `grapheme_offset` and `grapheme_length` from `CategorizedEntity`, `SentenceSentiment`, and `LinkedEntityMatch`
8889
- `TextDocumentStatistics` attribute `grapheme_count` has been renamed to `character_count`
8990

90-
## 1.0.0b5
91+
## 1.0.0b5
9192

9293
- This was a broken release
9394

sdk/textanalytics/azure-ai-textanalytics/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,14 @@ for idx, doc in enumerate(docs):
476476
for data_source in entity.data_sources:
477477
print("......Entity ID: {}".format(data_source.entity_id))
478478
print("......Name: {}".format(data_source.name))
479-
if len(entity.related_entities) > 0:
480-
print("...Related Entities:")
481-
for related_entity, relation_type in entity.related_entities.items():
482-
print("......Entity Text: {}".format(related_entity.text))
483-
print("......Relation Type: {}".format(relation_type))
479+
for relation in doc.entity_relations:
480+
print("Relation of type: {} has the following roles".format(relation.relation_type))
481+
for role in relation.roles:
482+
print("...Role '{}' with entity '{}'".format(role.name, role.entity.text))
484483
print("------------------------------------------")
485484
```
486485

487-
Note: The Healthcare Entities Analysis service is currently available only in API version v3.1-preview.3 in gated preview. Since this is a gated preview, AAD is not supported. More information [here](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).
486+
Note: The Healthcare Entities Analysis service is currently available only in the API v3.1 preview versions and is in gated preview. Since this is a gated preview, AAD is not supported. More information [here](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).
488487

489488
### Batch Analysis
490489

@@ -559,7 +558,7 @@ for idx, doc in enumerate(docs):
559558

560559
The returned response is an object encapsulating multiple iterables, each representing results of individual analyses.
561560

562-
Note: Batch analysis is currently available only in API version v3.1-preview.3.
561+
Note: Batch analysis is currently available only in the v3.1-preview API version.
563562

564563
## Optional Configuration
565564

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
RequestStatistics,
4343
AnalyzeBatchActionsType,
4444
AnalyzeBatchActionsError,
45+
HealthcareEntityRelationRoleType,
4546
)
4647
from ._paging import AnalyzeHealthcareEntitiesResult
48+
from ._generated.v3_1_preview_4.models import RelationType as HealthcareEntityRelationType
4749

4850
__all__ = [
4951
'TextAnalyticsApiVersion',
@@ -83,6 +85,8 @@
8385
'RequestStatistics',
8486
'AnalyzeBatchActionsType',
8587
"AnalyzeBatchActionsError",
88+
"HealthcareEntityRelationType",
89+
"HealthcareEntityRelationRoleType",
8690
]
8791

8892
__version__ = VERSION

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_async_lro.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(self, *args, **kwargs):
8585

8686
@property
8787
def _current_body(self):
88-
from ._generated.v3_1_preview_3.models import JobMetadata
88+
from ._generated.v3_1_preview_4.models import JobMetadata
8989
return JobMetadata.deserialize(self._pipeline_response)
9090

9191
@property
@@ -170,7 +170,7 @@ class AsyncAnalyzeBatchActionsLROPollingMethod(TextAnalyticsAsyncLROPollingMetho
170170

171171
@property
172172
def _current_body(self):
173-
from ._generated.v3_1_preview_3.models import AnalyzeJobMetadata
173+
from ._generated.v3_1_preview_4.models import AnalyzeJobMetadata
174174
return AnalyzeJobMetadata.deserialize(self._pipeline_response)
175175

176176
@property
@@ -265,4 +265,3 @@ def total_actions_count(self):
265265
@property
266266
def id(self):
267267
return self._polling_method.id
268-

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class TextAnalyticsApiVersion(str, Enum):
1515

1616
#: this is the default version
1717
V3_1_PREVIEW = "v3.1-preview.4"
18-
V3_1_PREVIEW_3 = "v3.1-preview.3"
1918
V3_0 = "v3.0"
2019

2120
def _authentication_policy(credential):

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_operations_mixin.py

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ def analyze_status(
5454
:type skip: int
5555
:keyword callable cls: A custom type or function that will be passed the direct response
5656
:return: AnalyzeJobState, or the result of cls(response)
57-
:rtype: ~azure.ai.textanalytics.v3_1_preview_3.models.AnalyzeJobState
57+
:rtype: ~azure.ai.textanalytics.v3_1_preview_4.models.AnalyzeJobState
5858
:raises: ~azure.core.exceptions.HttpResponseError
5959
"""
6060
api_version = self._get_api_version('analyze_status')
61-
if api_version == 'v3.1-preview.3':
62-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
63-
elif api_version == 'v3.1-preview.4':
61+
if api_version == 'v3.1-preview.4':
6462
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
6563
else:
6664
raise ValueError("API version {} does not have operation 'analyze_status'".format(api_version))
@@ -83,21 +81,19 @@ def begin_analyze(
8381
executed.
8482
8583
:param body: Collection of documents to analyze and tasks to execute.
86-
:type body: ~azure.ai.textanalytics.v3_1_preview_3.models.AnalyzeBatchInput
84+
:type body: ~azure.ai.textanalytics.v3_1_preview_4.models.AnalyzeBatchInput
8785
:keyword callable cls: A custom type or function that will be passed the direct response
8886
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
8987
:keyword polling: Pass in True if you'd like the AnalyzeBatchActionsLROPollingMethod polling method,
9088
False for no polling, or your own initialized polling object for a personal polling strategy.
9189
:paramtype polling: bool or ~azure.core.polling.PollingMethod
9290
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
9391
:return: An instance of AnalyzeBatchActionsLROPoller that returns either AnalyzeJobState or the result of cls(response)
94-
:rtype: ~...._lro.AnalyzeBatchActionsLROPoller[~azure.ai.textanalytics.v3_1_preview_3.models.AnalyzeJobState]
92+
:rtype: ~...._lro.AnalyzeBatchActionsLROPoller[~azure.ai.textanalytics.v3_1_preview_4.models.AnalyzeJobState]
9593
:raises ~azure.core.exceptions.HttpResponseError:
9694
"""
9795
api_version = self._get_api_version('begin_analyze')
98-
if api_version == 'v3.1-preview.3':
99-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
100-
elif api_version == 'v3.1-preview.4':
96+
if api_version == 'v3.1-preview.4':
10197
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
10298
else:
10399
raise ValueError("API version {} does not have operation 'begin_analyze'".format(api_version))
@@ -131,9 +127,7 @@ def begin_cancel_health_job(
131127
:raises ~azure.core.exceptions.HttpResponseError:
132128
"""
133129
api_version = self._get_api_version('begin_cancel_health_job')
134-
if api_version == 'v3.1-preview.3':
135-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
136-
elif api_version == 'v3.1-preview.4':
130+
if api_version == 'v3.1-preview.4':
137131
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
138132
else:
139133
raise ValueError("API version {} does not have operation 'begin_cancel_health_job'".format(api_version))
@@ -158,28 +152,26 @@ def begin_health(
158152
symptoms, etc) and their relations.
159153
160154
:param documents: The set of documents to process as part of this batch.
161-
:type documents: list[~azure.ai.textanalytics.v3_1_preview_3.models.MultiLanguageInput]
155+
:type documents: list[~azure.ai.textanalytics.v3_1_preview_4.models.MultiLanguageInput]
162156
:param model_version: (Optional) This value indicates which model will be used for scoring. If
163157
a model-version is not specified, the API should default to the latest, non-preview version.
164158
:type model_version: str
165159
:param string_index_type: (Optional) Specifies the method used to interpret string offsets.
166160
Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information
167161
see https://aka.ms/text-analytics-offsets.
168-
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_3.models.StringIndexType
162+
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_4.models.StringIndexType
169163
:keyword callable cls: A custom type or function that will be passed the direct response
170164
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
171165
:keyword polling: Pass in True if you'd like the AnalyzeHealthcareEntitiesLROPollingMethod polling method,
172166
False for no polling, or your own initialized polling object for a personal polling strategy.
173167
:paramtype polling: bool or ~azure.core.polling.PollingMethod
174168
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
175169
:return: An instance of AnalyzeHealthcareEntitiesLROPoller that returns either HealthcareJobState or the result of cls(response)
176-
:rtype: ~...._lro.AnalyzeHealthcareEntitiesLROPoller[~azure.ai.textanalytics.v3_1_preview_3.models.HealthcareJobState]
170+
:rtype: ~...._lro.AnalyzeHealthcareEntitiesLROPoller[~azure.ai.textanalytics.v3_1_preview_4.models.HealthcareJobState]
177171
:raises ~azure.core.exceptions.HttpResponseError:
178172
"""
179173
api_version = self._get_api_version('begin_health')
180-
if api_version == 'v3.1-preview.3':
181-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
182-
elif api_version == 'v3.1-preview.4':
174+
if api_version == 'v3.1-preview.4':
183175
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
184176
else:
185177
raise ValueError("API version {} does not have operation 'begin_health'".format(api_version))
@@ -220,8 +212,6 @@ def entities_linking(
220212
api_version = self._get_api_version('entities_linking')
221213
if api_version == 'v3.0':
222214
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
223-
elif api_version == 'v3.1-preview.3':
224-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
225215
elif api_version == 'v3.1-preview.4':
226216
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
227217
else:
@@ -264,8 +254,6 @@ def entities_recognition_general(
264254
api_version = self._get_api_version('entities_recognition_general')
265255
if api_version == 'v3.0':
266256
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
267-
elif api_version == 'v3.1-preview.3':
268-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
269257
elif api_version == 'v3.1-preview.4':
270258
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
271259
else:
@@ -285,6 +273,7 @@ def entities_recognition_pii(
285273
show_stats=None, # type: Optional[bool]
286274
domain=None, # type: Optional[str]
287275
string_index_type="TextElements_v8", # type: Optional[Union[str, "_models.StringIndexType"]]
276+
pii_categories=None, # type: Optional[List[Union[str, "_models.PiiCategory"]]]
288277
**kwargs # type: Any
289278
):
290279
"""Entities containing personal information.
@@ -296,7 +285,7 @@ def entities_recognition_pii(
296285
list of enabled languages.
297286
298287
:param documents: The set of documents to process as part of this batch.
299-
:type documents: list[~azure.ai.textanalytics.v3_1_preview_3.models.MultiLanguageInput]
288+
:type documents: list[~azure.ai.textanalytics.v3_1_preview_4.models.MultiLanguageInput]
300289
:param model_version: (Optional) This value indicates which model will be used for scoring. If
301290
a model-version is not specified, the API should default to the latest, non-preview version.
302291
:type model_version: str
@@ -309,16 +298,16 @@ def entities_recognition_pii(
309298
:param string_index_type: (Optional) Specifies the method used to interpret string offsets.
310299
Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information
311300
see https://aka.ms/text-analytics-offsets.
312-
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_3.models.StringIndexType
301+
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_4.models.StringIndexType
302+
:param pii_categories: (Optional) describes the PII categories to return.
303+
:type pii_categories: list[str or ~azure.ai.textanalytics.v3_1_preview_4.models.PiiCategory]
313304
:keyword callable cls: A custom type or function that will be passed the direct response
314305
:return: PiiResult, or the result of cls(response)
315-
:rtype: ~azure.ai.textanalytics.v3_1_preview_3.models.PiiResult
306+
:rtype: ~azure.ai.textanalytics.v3_1_preview_4.models.PiiResult
316307
:raises: ~azure.core.exceptions.HttpResponseError
317308
"""
318309
api_version = self._get_api_version('entities_recognition_pii')
319-
if api_version == 'v3.1-preview.3':
320-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
321-
elif api_version == 'v3.1-preview.4':
310+
if api_version == 'v3.1-preview.4':
322311
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
323312
else:
324313
raise ValueError("API version {} does not have operation 'entities_recognition_pii'".format(api_version))
@@ -328,7 +317,7 @@ def entities_recognition_pii(
328317
mixin_instance._serialize = Serializer(self._models_dict(api_version))
329318
mixin_instance._serialize.client_side_validation = False
330319
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
331-
return mixin_instance.entities_recognition_pii(documents, model_version, show_stats, domain, string_index_type, **kwargs)
320+
return mixin_instance.entities_recognition_pii(documents, model_version, show_stats, domain, string_index_type, pii_categories, **kwargs)
332321

333322
def health_status(
334323
self,
@@ -355,13 +344,11 @@ def health_status(
355344
:type show_stats: bool
356345
:keyword callable cls: A custom type or function that will be passed the direct response
357346
:return: HealthcareJobState, or the result of cls(response)
358-
:rtype: ~azure.ai.textanalytics.v3_1_preview_3.models.HealthcareJobState
347+
:rtype: ~azure.ai.textanalytics.v3_1_preview_4.models.HealthcareJobState
359348
:raises: ~azure.core.exceptions.HttpResponseError
360349
"""
361350
api_version = self._get_api_version('health_status')
362-
if api_version == 'v3.1-preview.3':
363-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
364-
elif api_version == 'v3.1-preview.4':
351+
if api_version == 'v3.1-preview.4':
365352
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
366353
else:
367354
raise ValueError("API version {} does not have operation 'health_status'".format(api_version))
@@ -402,8 +389,6 @@ def key_phrases(
402389
api_version = self._get_api_version('key_phrases')
403390
if api_version == 'v3.0':
404391
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
405-
elif api_version == 'v3.1-preview.3':
406-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
407392
elif api_version == 'v3.1-preview.4':
408393
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
409394
else:
@@ -446,8 +431,6 @@ def languages(
446431
api_version = self._get_api_version('languages')
447432
if api_version == 'v3.0':
448433
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
449-
elif api_version == 'v3.1-preview.3':
450-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
451434
elif api_version == 'v3.1-preview.4':
452435
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
453436
else:
@@ -490,8 +473,6 @@ def sentiment(
490473
api_version = self._get_api_version('sentiment')
491474
if api_version == 'v3.0':
492475
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
493-
elif api_version == 'v3.1-preview.3':
494-
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
495476
elif api_version == 'v3.1-preview.4':
496477
from .v3_1_preview_4.operations import TextAnalyticsClientOperationsMixin as OperationClass
497478
else:

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_text_analytics_client.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from typing import Any, Optional
2525

2626
from azure.core.credentials import TokenCredential
27+
from azure.core.pipeline.transport import HttpRequest, HttpResponse
2728

2829
class _SDKClient(object):
2930
def __init__(self, *args, **kwargs):
@@ -73,8 +74,6 @@ def __init__(
7374
):
7475
if api_version == 'v3.0':
7576
base_url = '{Endpoint}/text/analytics/v3.0'
76-
elif api_version == 'v3.1-preview.3':
77-
base_url = '{Endpoint}/text/analytics/v3.1-preview.3'
7877
elif api_version == 'v3.1-preview.4':
7978
base_url = '{Endpoint}/text/analytics/v3.1-preview.4'
8079
else:
@@ -95,15 +94,11 @@ def models(cls, api_version=DEFAULT_API_VERSION):
9594
"""Module depends on the API version:
9695
9796
* v3.0: :mod:`v3_0.models<azure.ai.textanalytics.v3_0.models>`
98-
* v3.1-preview.3: :mod:`v3_1_preview_3.models<azure.ai.textanalytics.v3_1_preview_3.models>`
9997
* v3.1-preview.4: :mod:`v3_1_preview_4.models<azure.ai.textanalytics.v3_1_preview_4.models>`
10098
"""
10199
if api_version == 'v3.0':
102100
from .v3_0 import models
103101
return models
104-
elif api_version == 'v3.1-preview.3':
105-
from .v3_1_preview_3 import models
106-
return models
107102
elif api_version == 'v3.1-preview.4':
108103
from .v3_1_preview_4 import models
109104
return models

0 commit comments

Comments
 (0)