Skip to content

Commit 8cb17c0

Browse files
apiview / anna feedback (Azure#19473)
1 parent 52109c4 commit 8cb17c0

13 files changed

+79
-94
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Note: this version will be the last to officially support Python 3.5, future ver
1818
- Removed: `AnalyzeActionsType`
1919
- Removed: `AnalyzeActionsResult`
2020
- Removed: `AnalyzeActionsError`
21+
- Removed: `HealthcareEntityRelationRoleType`
22+
- Changed: renamed `HealthcareEntityRelationType` to `HealthcareEntityRelation`
23+
- Changed: renamed `PiiEntityCategoryType` to `PiiEntityCategory`
24+
- Changed: renamed `PiiEntityDomainType` to `PiiEntityDomain`
2125

2226
## 5.1.0b7 (2021-05-18)
2327

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
AssessmentSentiment,
3232
RecognizePiiEntitiesResult,
3333
PiiEntity,
34-
PiiEntityDomainType,
34+
PiiEntityDomain,
3535
AnalyzeHealthcareEntitiesResult,
3636
HealthcareEntity,
3737
HealthcareEntityDataSource,
@@ -40,13 +40,12 @@
4040
RecognizePiiEntitiesAction,
4141
ExtractKeyPhrasesAction,
4242
_AnalyzeActionsType,
43-
HealthcareEntityRelationRoleType,
4443
HealthcareRelation,
4544
HealthcareRelationRole,
4645
HealthcareEntityAssertion,
4746
AnalyzeSentimentAction,
48-
PiiEntityCategoryType,
49-
HealthcareEntityRelationType,
47+
PiiEntityCategory,
48+
HealthcareEntityRelation,
5049
EntityConditionality,
5150
EntityCertainty,
5251
EntityAssociation,
@@ -81,7 +80,7 @@
8180
'AssessmentSentiment',
8281
'RecognizePiiEntitiesResult',
8382
'PiiEntity',
84-
'PiiEntityDomainType',
83+
'PiiEntityDomain',
8584
'AnalyzeHealthcareEntitiesResult',
8685
'HealthcareEntity',
8786
'HealthcareEntityDataSource',
@@ -90,9 +89,8 @@
9089
'RecognizePiiEntitiesAction',
9190
'ExtractKeyPhrasesAction',
9291
'_AnalyzeActionsType',
93-
"PiiEntityCategoryType",
94-
"HealthcareEntityRelationType",
95-
"HealthcareEntityRelationRoleType",
92+
"PiiEntityCategory",
93+
"HealthcareEntityRelation",
9694
"HealthcareRelation",
9795
"HealthcareRelationRole",
9896
"HealthcareEntityAssertion",

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

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class EntityConditionality(str, Enum):
9797
CONDITIONAL = "conditional"
9898

9999

100-
class HealthcareEntityRelationType(str, Enum):
100+
class HealthcareEntityRelation(str, Enum):
101101
"""Type of relation. Examples include: ``DosageOfMedication`` or 'FrequencyOfMedication', etc.
102102
"""
103103

@@ -124,7 +124,7 @@ class HealthcareEntityRelationType(str, Enum):
124124
VALUE_OF_EXAMINATION = "ValueOfExamination"
125125

126126

127-
class PiiEntityCategoryType(str, Enum):
127+
class PiiEntityCategory(str, Enum):
128128

129129
ABA_ROUTING_NUMBER = "ABARoutingNumber"
130130
AR_NATIONAL_IDENTITY_NUMBER = "ARNationalIdentityNumber"
@@ -333,30 +333,10 @@ class HealthcareEntityCategory(str, Enum):
333333
TREATMENT_NAME = "TreatmentName"
334334

335335

336-
class PiiEntityDomainType(str, Enum):
336+
class PiiEntityDomain(str, Enum):
337337
"""The different domains of PII entities that users can filter by"""
338338
PROTECTED_HEALTH_INFORMATION = "phi" # See https://aka.ms/tanerpii for more information.
339339

340-
class HealthcareEntityRelationRoleType(str, Enum):
341-
"""Type of roles entities can have in `entity_relations`. There may be roles not covered in this enum"""
342-
ABBREVIATED_TERM = "AbbreviatedTerm"
343-
FULL_TERM = "FullTerm"
344-
DIRECTION = "Direction"
345-
BODY_STRUCTURE = "BodyStructure"
346-
CONDITION = "Condition"
347-
EXAMINATION = "Examination"
348-
TREATMENT = "Treatment"
349-
DOSAGE = "Dosage"
350-
MEDICATION = "Medication"
351-
FORM = "Form"
352-
FREQUENCY = "Frequency"
353-
QUALIFIER = "Qualifier"
354-
RELATION = "Relation"
355-
ROUTE = "Route"
356-
TIME = "Time"
357-
EVENT = "Event"
358-
UNIT = "Unit"
359-
VALUE = "Value"
360340

361341
class DetectedLanguage(DictMixin):
362342
"""DetectedLanguage contains the predicted language found in text,
@@ -538,7 +518,7 @@ class HealthcareRelation(DictMixin):
538518
539519
:ivar relation_type: The type of relation, i.e. the relationship between "100mg" and
540520
"ibuprofen" in the document "The subject took 100 mg of ibuprofen" is "DosageOfMedication".
541-
:vartype relation_type: str or ~azure.ai.textanalytics.HealthcareEntityRelationType
521+
:vartype relation_type: str or ~azure.ai.textanalytics.HealthcareEntityRelation
542522
:ivar roles: The roles present in this relation. I.e., in the document
543523
"The subject took 100 mg of ibuprofen", the present roles are "Dosage" and "Medication".
544524
:vartype roles: list[~azure.ai.textanalytics.HealthcareRelationRole]
@@ -575,7 +555,7 @@ class HealthcareRelationRole(DictMixin):
575555
:ivar name: The role of the entity in the relationship. I.e., in the relation
576556
"The subject took 100 mg of ibuprofen", the dosage entity "100 mg" has role
577557
"Dosage".
578-
:vartype name: str or ~azure.ai.textanalytics.HealthcareEntityRelationRoleType
558+
:vartype name: str
579559
:ivar entity: The entity that is present in the relationship. For example, in
580560
"The subject took 100 mg of ibuprofen", this property holds the dosage entity
581561
of "100 mg".
@@ -1769,8 +1749,8 @@ class RecognizePiiEntitiesAction(DictMixin):
17691749
:keyword categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
17701750
the specific PII entity categories you want to filter out. For example, if you only want to filter out
17711751
U.S. social security numbers in a document, you can pass in
1772-
`[PiiEntityCategoryType.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
1773-
:paramtype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategoryType]
1752+
`[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
1753+
:paramtype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategory]
17741754
:keyword str string_index_type: Specifies the method used to interpret string offsets.
17751755
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
17761756
you can also pass in `Utf16CodePoint` or TextElement_v8`. For additional information
@@ -1789,8 +1769,8 @@ class RecognizePiiEntitiesAction(DictMixin):
17891769
:ivar categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
17901770
the specific PII entity categories you want to filter out. For example, if you only want to filter out
17911771
U.S. social security numbers in a document, you can pass in
1792-
`[PiiEntityCategoryType.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
1793-
:vartype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategoryType]
1772+
`[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
1773+
:vartype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategory]
17941774
:ivar str string_index_type: Specifies the method used to interpret string offsets.
17951775
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
17961776
you can also pass in `Utf16CodePoint` or TextElement_v8`. For additional information

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,12 @@ def recognize_pii_entities( # type: ignore
324324
:keyword domain_filter: Filters the response entities to ones only included in the specified domain.
325325
I.e., if set to 'phi', will only return entities in the Protected Healthcare Information domain.
326326
See https://aka.ms/tanerpii for more information.
327-
:paramtype domain_filter: str or ~azure.ai.textanalytics.PiiEntityDomainType
327+
:paramtype domain_filter: str or ~azure.ai.textanalytics.PiiEntityDomain
328328
:keyword categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
329329
the specific PII entity categories you want to filter out. For example, if you only want to filter out
330330
U.S. social security numbers in a document, you can pass in
331-
`[PiiEntityCategoryType.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
332-
:paramtype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategoryType]
331+
`[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
332+
:paramtype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategory]
333333
:keyword str string_index_type: Specifies the method used to interpret string offsets.
334334
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
335335
you can also pass in `Utf16CodePoint` or `TextElement_v8`. For additional information
@@ -506,7 +506,7 @@ def begin_analyze_healthcare_entities( # type: ignore
506506
self,
507507
documents, # type: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]]
508508
**kwargs # type: Any
509-
): # type: (...) -> AnalyzeHealthcareEntitiesLROPoller[ItemPaged[AnalyzeHealthcareEntitiesResult]]
509+
): # type: (...) -> AnalyzeHealthcareEntitiesLROPoller[ItemPaged[Union[AnalyzeHealthcareEntitiesResult, DocumentError]]] # pylint: disable=line-too-long
510510
"""Analyze healthcare entities and identify relationships between these entities in a batch of documents.
511511
512512
Entities are associated with references that can be found in existing knowledge bases,
@@ -547,10 +547,12 @@ def begin_analyze_healthcare_entities( # type: ignore
547547
additional details, and Microsoft Responsible AI principles at
548548
https://www.microsoft.com/ai/responsible-ai.
549549
:return: An instance of an AnalyzeHealthcareEntitiesLROPoller. Call `result()` on the this
550-
object to return a pageable of :class:`~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult`.
550+
object to return a heterogeneous pageable of
551+
:class:`~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult` and
552+
:class:`~azure.ai.textanalytics.DocumentError`.
551553
:rtype:
552554
~azure.ai.textanalytics.AnalyzeHealthcareEntitiesLROPoller[~azure.core.paging.ItemPaged[
553-
~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult]]
555+
Union[~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult, ~azure.ai.textanalytics.DocumentError]]]
554556
:raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError:
555557
556558
.. admonition:: Example:
@@ -818,7 +820,7 @@ def begin_analyze_actions( # type: ignore
818820
documents, # type: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]]
819821
actions, # type: List[Union[RecognizeEntitiesAction, RecognizeLinkedEntitiesAction, RecognizePiiEntitiesAction, ExtractKeyPhrasesAction, AnalyzeSentimentAction]] # pylint: disable=line-too-long
820822
**kwargs # type: Any
821-
): # type: (...) -> AnalyzeActionsLROPoller[ItemPaged[List[Union[RecognizeEntitiesResult, RecognizeLinkedEntitiesResult, RecognizePiiEntitiesResult, ExtractKeyPhrasesResult, AnalyzeSentimentResult]]]] # pylint: disable=line-too-long
823+
): # type: (...) -> AnalyzeActionsLROPoller[ItemPaged[List[Union[RecognizeEntitiesResult, RecognizeLinkedEntitiesResult, RecognizePiiEntitiesResult, ExtractKeyPhrasesResult, AnalyzeSentimentResult, DocumentError]]]] # pylint: disable=line-too-long
822824
"""Start a long-running operation to perform a variety of text analysis actions over a batch of documents.
823825
824826
We recommend you use this function if you're looking to analyze larger documents, and / or
@@ -864,7 +866,7 @@ def begin_analyze_actions( # type: ignore
864866
~azure.ai.textanalytics.AnalyzeActionsLROPoller[~azure.core.paging.ItemPaged[
865867
list[
866868
RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult or
867-
ExtractKeyPhrasesResult or AnalyzeSentimentResult
869+
ExtractKeyPhrasesResult or AnalyzeSentimentResult or DocumentError
868870
]]]
869871
:raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError:
870872

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ async def recognize_pii_entities( # type: ignore
320320
:keyword domain_filter: Filters the response entities to ones only included in the specified domain.
321321
I.e., if set to 'phi', will only return entities in the Protected Healthcare Information domain.
322322
See https://aka.ms/tanerpii for more information.
323-
:paramtype domain_filter: str or ~azure.ai.textanalytics.PiiEntityDomainType
323+
:paramtype domain_filter: str or ~azure.ai.textanalytics.PiiEntityDomain
324324
:keyword categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
325325
the specific PII entity categories you want to filter out. For example, if you only want to filter out
326326
U.S. social security numbers in a document, you can pass in
327-
`[PiiEntityCategoryType.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
328-
:paramtype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategoryType]
327+
`[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
328+
:paramtype categories_filter: list[~azure.ai.textanalytics.PiiEntityCategory]
329329
:keyword str string_index_type: Specifies the method used to interpret string offsets.
330330
Can be one of 'UnicodeCodePoint' (default), 'Utf16CodePoint', or 'TextElement_v8'.
331331
For additional information see https://aka.ms/text-analytics-offsets
@@ -682,7 +682,7 @@ async def begin_analyze_healthcare_entities( # type: ignore
682682
self,
683683
documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
684684
**kwargs: Any,
685-
) -> AsyncAnalyzeHealthcareEntitiesLROPoller[AsyncItemPaged[AnalyzeHealthcareEntitiesResult]]:
685+
) -> AsyncAnalyzeHealthcareEntitiesLROPoller[AsyncItemPaged[Union[AnalyzeHealthcareEntitiesResult, DocumentError]]]:
686686
"""Analyze healthcare entities and identify relationships between these entities in a batch of documents.
687687
688688
Entities are associated with references that can be found in existing knowledge bases,
@@ -722,10 +722,12 @@ async def begin_analyze_healthcare_entities( # type: ignore
722722
additional details, and Microsoft Responsible AI principles at
723723
https://www.microsoft.com/ai/responsible-ai.
724724
:return: An instance of an AsyncAnalyzeHealthcareEntitiesLROPoller. Call `result()` on the poller
725-
object to return a pageable of :class:`~azure.ai.textanalytics.AnalyzeHealthcareResultItem`.
725+
object to return a heterogeneous pageable of
726+
:class:`~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult` and
727+
:class:`~azure.ai.textanalytics.DocumentError`.
726728
:rtype:
727729
~azure.ai.textanalytics.aio.AsyncAnalyzeHealthcareEntitiesLROPoller[~azure.core.paging.AsyncItemPaged[
728-
~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult]]
730+
Union[~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult, ~azure.ai.textanalytics.DocumentError]]]
729731
:raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError:
730732
731733
.. admonition:: Example:
@@ -802,7 +804,7 @@ async def begin_analyze_actions( # type: ignore
802804
documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
803805
actions: List[Union[RecognizeEntitiesAction, RecognizeLinkedEntitiesAction, RecognizePiiEntitiesAction, ExtractKeyPhrasesAction, AnalyzeSentimentAction]], # pylint: disable=line-too-long
804806
**kwargs: Any
805-
) -> AsyncAnalyzeActionsLROPoller[AsyncItemPaged[List[Union[RecognizeEntitiesResult, RecognizeLinkedEntitiesResult, RecognizePiiEntitiesResult, ExtractKeyPhrasesResult, AnalyzeSentimentResult]]]]: # pylint: disable=line-too-long
807+
) -> AsyncAnalyzeActionsLROPoller[AsyncItemPaged[List[Union[RecognizeEntitiesResult, RecognizeLinkedEntitiesResult, RecognizePiiEntitiesResult, ExtractKeyPhrasesResult, AnalyzeSentimentResult, DocumentError]]]]: # pylint: disable=line-too-long
806808
"""Start a long-running operation to perform a variety of text analysis actions over a batch of documents.
807809
808810
We recommend you use this function if you're looking to analyze larger documents, and / or
@@ -848,7 +850,7 @@ async def begin_analyze_actions( # type: ignore
848850
~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[
849851
list[
850852
RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult or
851-
ExtractKeyPhrasesResult or AnalyzeSentimentResult
853+
ExtractKeyPhrasesResult or AnalyzeSentimentResult or DocumentError
852854
]]]
853855
:raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError:
854856

sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def sample_analyze_healthcare_entities_async():
4141
# [START analyze_healthcare_entities_async]
4242
import os
4343
from azure.core.credentials import AzureKeyCredential
44-
from azure.ai.textanalytics import HealthcareEntityRelationType, HealthcareEntityRelationRoleType
44+
from azure.ai.textanalytics import HealthcareEntityRelation
4545
from azure.ai.textanalytics.aio import TextAnalyticsClient
4646

4747
endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"]
@@ -96,7 +96,7 @@ async def sample_analyze_healthcare_entities_async():
9696
dosage_of_medication_relations = [
9797
entity_relation
9898
for doc in docs
99-
for entity_relation in doc.entity_relations if entity_relation.relation_type == HealthcareEntityRelationType.DOSAGE_OF_MEDICATION
99+
for entity_relation in doc.entity_relations if entity_relation.relation_type == HealthcareEntityRelation.DOSAGE_OF_MEDICATION
100100
]
101101
# [END analyze_healthcare_entities_async]
102102

@@ -113,8 +113,8 @@ async def sample_analyze_healthcare_entities_async():
113113
for relation in dosage_of_medication_relations:
114114
# The DosageOfMedication relation should only contain the dosage and medication roles
115115

116-
dosage_role = next(filter(lambda x: x.name == HealthcareEntityRelationRoleType.DOSAGE, relation.roles))
117-
medication_role = next(filter(lambda x: x.name == HealthcareEntityRelationRoleType.MEDICATION, relation.roles))
116+
dosage_role = next(filter(lambda x: x.name == "Dosage", relation.roles))
117+
medication_role = next(filter(lambda x: x.name == "Medication", relation.roles))
118118

119119
try:
120120
dosage_value = int(re.findall(r"\d+", dosage_role.entity.text)[0]) # we find the numbers in the dosage

sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def sample_analyze_healthcare_entities():
3838
# [START analyze_healthcare_entities]
3939
import os
4040
from azure.core.credentials import AzureKeyCredential
41-
from azure.ai.textanalytics import TextAnalyticsClient, HealthcareEntityRelationType, HealthcareEntityRelationRoleType
41+
from azure.ai.textanalytics import TextAnalyticsClient, HealthcareEntityRelation
4242

4343
endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"]
4444
key = os.environ["AZURE_TEXT_ANALYTICS_KEY"]
@@ -92,7 +92,7 @@ def sample_analyze_healthcare_entities():
9292
dosage_of_medication_relations = [
9393
entity_relation
9494
for doc in docs
95-
for entity_relation in doc.entity_relations if entity_relation.relation_type == HealthcareEntityRelationType.DOSAGE_OF_MEDICATION
95+
for entity_relation in doc.entity_relations if entity_relation.relation_type == HealthcareEntityRelation.DOSAGE_OF_MEDICATION
9696
]
9797
# [END analyze_healthcare_entities]
9898

@@ -109,8 +109,8 @@ def sample_analyze_healthcare_entities():
109109
for relation in dosage_of_medication_relations:
110110
# The DosageOfMedication relation should only contain the dosage and medication roles
111111

112-
dosage_role = next(iter(filter(lambda x: x.name == HealthcareEntityRelationRoleType.DOSAGE, relation.roles)))
113-
medication_role = next(iter(filter(lambda x: x.name == HealthcareEntityRelationRoleType.MEDICATION, relation.roles)))
112+
dosage_role = next(iter(filter(lambda x: x.name == "Dosage", relation.roles)))
113+
medication_role = next(iter(filter(lambda x: x.name == "Medication", relation.roles)))
114114

115115
try:
116116
dosage_value = int(re.findall(r"\d+", dosage_role.entity.text)[0]) # we find the numbers in the dosage

0 commit comments

Comments
 (0)