azure-ai-textanalytics 5.3.0b1__py3-none-any.whl → 6.0.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of azure-ai-textanalytics might be problematic. Click here for more details.

Files changed (128) hide show
  1. azure/ai/textanalytics/__init__.py +26 -197
  2. azure/ai/textanalytics/_client.py +111 -0
  3. azure/ai/textanalytics/_configuration.py +73 -0
  4. azure/ai/textanalytics/{_generated/v2022_05_01/operations → _operations}/__init__.py +13 -8
  5. azure/ai/textanalytics/_operations/_operations.py +716 -0
  6. azure/ai/textanalytics/{_generated/v2022_05_01/models → _operations}/_patch.py +8 -6
  7. azure/ai/textanalytics/_patch.py +350 -0
  8. azure/ai/textanalytics/{_generated/aio → _utils}/__init__.py +1 -5
  9. azure/ai/textanalytics/_utils/model_base.py +1237 -0
  10. azure/ai/textanalytics/{_generated/_serialization.py → _utils/serialization.py} +640 -616
  11. azure/ai/textanalytics/{_generated/v2022_05_01/aio/_vendor.py → _utils/utils.py} +10 -12
  12. azure/ai/textanalytics/_version.py +8 -7
  13. azure/ai/textanalytics/aio/__init__.py +25 -14
  14. azure/ai/textanalytics/aio/_client.py +115 -0
  15. azure/ai/textanalytics/aio/_configuration.py +75 -0
  16. azure/ai/textanalytics/{_generated/v2022_10_01_preview/aio/operations → aio/_operations}/__init__.py +13 -8
  17. azure/ai/textanalytics/aio/_operations/_operations.py +623 -0
  18. azure/ai/textanalytics/{_generated/v2022_05_01 → aio/_operations}/_patch.py +8 -6
  19. azure/ai/textanalytics/aio/_patch.py +344 -0
  20. azure/ai/textanalytics/models/__init__.py +402 -0
  21. azure/ai/textanalytics/models/_enums.py +1979 -0
  22. azure/ai/textanalytics/models/_models.py +6641 -0
  23. azure/ai/textanalytics/{_generated/v2022_05_01/aio → models}/_patch.py +8 -6
  24. azure/ai/textanalytics/py.typed +1 -0
  25. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/METADATA +755 -319
  26. azure_ai_textanalytics-6.0.0b1.dist-info/RECORD +29 -0
  27. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/WHEEL +1 -1
  28. azure/ai/textanalytics/_base_client.py +0 -111
  29. azure/ai/textanalytics/_check.py +0 -22
  30. azure/ai/textanalytics/_dict_mixin.py +0 -54
  31. azure/ai/textanalytics/_generated/__init__.py +0 -16
  32. azure/ai/textanalytics/_generated/_configuration.py +0 -70
  33. azure/ai/textanalytics/_generated/_operations_mixin.py +0 -795
  34. azure/ai/textanalytics/_generated/_text_analytics_client.py +0 -126
  35. azure/ai/textanalytics/_generated/_version.py +0 -8
  36. azure/ai/textanalytics/_generated/aio/_configuration.py +0 -66
  37. azure/ai/textanalytics/_generated/aio/_operations_mixin.py +0 -776
  38. azure/ai/textanalytics/_generated/aio/_text_analytics_client.py +0 -124
  39. azure/ai/textanalytics/_generated/models.py +0 -8
  40. azure/ai/textanalytics/_generated/v2022_05_01/__init__.py +0 -20
  41. azure/ai/textanalytics/_generated/v2022_05_01/_configuration.py +0 -72
  42. azure/ai/textanalytics/_generated/v2022_05_01/_text_analytics_client.py +0 -100
  43. azure/ai/textanalytics/_generated/v2022_05_01/_vendor.py +0 -45
  44. azure/ai/textanalytics/_generated/v2022_05_01/aio/__init__.py +0 -20
  45. azure/ai/textanalytics/_generated/v2022_05_01/aio/_configuration.py +0 -71
  46. azure/ai/textanalytics/_generated/v2022_05_01/aio/_text_analytics_client.py +0 -97
  47. azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/__init__.py +0 -18
  48. azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_patch.py +0 -121
  49. azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_text_analytics_client_operations.py +0 -603
  50. azure/ai/textanalytics/_generated/v2022_05_01/models/__init__.py +0 -281
  51. azure/ai/textanalytics/_generated/v2022_05_01/models/_models_py3.py +0 -5722
  52. azure/ai/textanalytics/_generated/v2022_05_01/models/_text_analytics_client_enums.py +0 -439
  53. azure/ai/textanalytics/_generated/v2022_05_01/operations/_patch.py +0 -120
  54. azure/ai/textanalytics/_generated/v2022_05_01/operations/_text_analytics_client_operations.py +0 -744
  55. azure/ai/textanalytics/_generated/v2022_10_01_preview/__init__.py +0 -20
  56. azure/ai/textanalytics/_generated/v2022_10_01_preview/_configuration.py +0 -72
  57. azure/ai/textanalytics/_generated/v2022_10_01_preview/_patch.py +0 -19
  58. azure/ai/textanalytics/_generated/v2022_10_01_preview/_text_analytics_client.py +0 -100
  59. azure/ai/textanalytics/_generated/v2022_10_01_preview/_vendor.py +0 -45
  60. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/__init__.py +0 -20
  61. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_configuration.py +0 -71
  62. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_patch.py +0 -19
  63. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_text_analytics_client.py +0 -97
  64. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_vendor.py +0 -27
  65. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_patch.py +0 -121
  66. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_text_analytics_client_operations.py +0 -603
  67. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/__init__.py +0 -407
  68. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_models_py3.py +0 -8462
  69. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_patch.py +0 -72
  70. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_text_analytics_client_enums.py +0 -730
  71. azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/__init__.py +0 -18
  72. azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_patch.py +0 -120
  73. azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_text_analytics_client_operations.py +0 -744
  74. azure/ai/textanalytics/_generated/v3_0/__init__.py +0 -20
  75. azure/ai/textanalytics/_generated/v3_0/_configuration.py +0 -66
  76. azure/ai/textanalytics/_generated/v3_0/_patch.py +0 -31
  77. azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py +0 -96
  78. azure/ai/textanalytics/_generated/v3_0/_vendor.py +0 -33
  79. azure/ai/textanalytics/_generated/v3_0/aio/__init__.py +0 -20
  80. azure/ai/textanalytics/_generated/v3_0/aio/_configuration.py +0 -65
  81. azure/ai/textanalytics/_generated/v3_0/aio/_patch.py +0 -31
  82. azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py +0 -93
  83. azure/ai/textanalytics/_generated/v3_0/aio/_vendor.py +0 -27
  84. azure/ai/textanalytics/_generated/v3_0/aio/operations/__init__.py +0 -18
  85. azure/ai/textanalytics/_generated/v3_0/aio/operations/_patch.py +0 -19
  86. azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py +0 -428
  87. azure/ai/textanalytics/_generated/v3_0/models/__init__.py +0 -81
  88. azure/ai/textanalytics/_generated/v3_0/models/_models_py3.py +0 -1467
  89. azure/ai/textanalytics/_generated/v3_0/models/_patch.py +0 -19
  90. azure/ai/textanalytics/_generated/v3_0/models/_text_analytics_client_enums.py +0 -58
  91. azure/ai/textanalytics/_generated/v3_0/operations/__init__.py +0 -18
  92. azure/ai/textanalytics/_generated/v3_0/operations/_patch.py +0 -19
  93. azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py +0 -604
  94. azure/ai/textanalytics/_generated/v3_1/__init__.py +0 -20
  95. azure/ai/textanalytics/_generated/v3_1/_configuration.py +0 -66
  96. azure/ai/textanalytics/_generated/v3_1/_patch.py +0 -31
  97. azure/ai/textanalytics/_generated/v3_1/_text_analytics_client.py +0 -98
  98. azure/ai/textanalytics/_generated/v3_1/_vendor.py +0 -45
  99. azure/ai/textanalytics/_generated/v3_1/aio/__init__.py +0 -20
  100. azure/ai/textanalytics/_generated/v3_1/aio/_configuration.py +0 -65
  101. azure/ai/textanalytics/_generated/v3_1/aio/_patch.py +0 -31
  102. azure/ai/textanalytics/_generated/v3_1/aio/_text_analytics_client.py +0 -95
  103. azure/ai/textanalytics/_generated/v3_1/aio/_vendor.py +0 -27
  104. azure/ai/textanalytics/_generated/v3_1/aio/operations/__init__.py +0 -18
  105. azure/ai/textanalytics/_generated/v3_1/aio/operations/_patch.py +0 -19
  106. azure/ai/textanalytics/_generated/v3_1/aio/operations/_text_analytics_client_operations.py +0 -1291
  107. azure/ai/textanalytics/_generated/v3_1/models/__init__.py +0 -205
  108. azure/ai/textanalytics/_generated/v3_1/models/_models_py3.py +0 -3976
  109. azure/ai/textanalytics/_generated/v3_1/models/_patch.py +0 -19
  110. azure/ai/textanalytics/_generated/v3_1/models/_text_analytics_client_enums.py +0 -367
  111. azure/ai/textanalytics/_generated/v3_1/operations/__init__.py +0 -18
  112. azure/ai/textanalytics/_generated/v3_1/operations/_patch.py +0 -19
  113. azure/ai/textanalytics/_generated/v3_1/operations/_text_analytics_client_operations.py +0 -1709
  114. azure/ai/textanalytics/_lro.py +0 -552
  115. azure/ai/textanalytics/_models.py +0 -3142
  116. azure/ai/textanalytics/_policies.py +0 -66
  117. azure/ai/textanalytics/_request_handlers.py +0 -104
  118. azure/ai/textanalytics/_response_handlers.py +0 -580
  119. azure/ai/textanalytics/_text_analytics_client.py +0 -1802
  120. azure/ai/textanalytics/_user_agent.py +0 -8
  121. azure/ai/textanalytics/_validate.py +0 -113
  122. azure/ai/textanalytics/aio/_base_client_async.py +0 -95
  123. azure/ai/textanalytics/aio/_lro_async.py +0 -501
  124. azure/ai/textanalytics/aio/_response_handlers_async.py +0 -94
  125. azure/ai/textanalytics/aio/_text_analytics_client_async.py +0 -1800
  126. azure_ai_textanalytics-5.3.0b1.dist-info/RECORD +0 -115
  127. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info/licenses}/LICENSE +0 -0
  128. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/top_level.txt +0 -0
@@ -1,3142 +0,0 @@
1
- # pylint: disable=too-many-lines
2
- # ------------------------------------
3
- # Copyright (c) Microsoft Corporation.
4
- # Licensed under the MIT License.
5
- # ------------------------------------
6
- import re
7
- from enum import Enum
8
- from typing_extensions import Literal
9
- from azure.core import CaseInsensitiveEnumMeta
10
- from ._generated.models import (
11
- LanguageInput,
12
- MultiLanguageInput,
13
- )
14
- from ._generated.v3_0 import models as _v3_0_models
15
- from ._generated.v3_1 import models as _v3_1_models
16
- from ._generated.v2022_10_01_preview import models as _v2022_10_01_preview_models
17
- from ._check import is_language_api, string_index_type_compatibility
18
- from ._dict_mixin import DictMixin
19
-
20
-
21
- def _get_indices(relation):
22
- return [int(s) for s in re.findall(r"\d+", relation)]
23
-
24
-
25
- class TextAnalysisKind(str, Enum, metaclass=CaseInsensitiveEnumMeta):
26
- """Enumeration of supported Text Analysis kinds.
27
-
28
- .. versionadded:: 2022-05-01
29
- The *TextAnalysisKind* enum.
30
- """
31
-
32
- SENTIMENT_ANALYSIS = "SentimentAnalysis"
33
- ENTITY_RECOGNITION = "EntityRecognition"
34
- PII_ENTITY_RECOGNITION = "PiiEntityRecognition"
35
- KEY_PHRASE_EXTRACTION = "KeyPhraseExtraction"
36
- ENTITY_LINKING = "EntityLinking"
37
- HEALTHCARE = "Healthcare"
38
- CUSTOM_ENTITY_RECOGNITION = "CustomEntityRecognition"
39
- CUSTOM_DOCUMENT_CLASSIFICATION = "CustomDocumentClassification"
40
- LANGUAGE_DETECTION = "LanguageDetection"
41
- EXTRACTIVE_SUMMARIZATION = "ExtractiveSummarization"
42
- ABSTRACTIVE_SUMMARIZATION = "AbstractiveSummarization"
43
- DYNAMIC_CLASSIFICATION = "DynamicClassification"
44
-
45
-
46
- class EntityAssociation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
47
- """Describes if the entity is the subject of the text or if it describes someone else."""
48
-
49
- SUBJECT = "subject"
50
- OTHER = "other"
51
-
52
-
53
- class EntityCertainty(str, Enum, metaclass=CaseInsensitiveEnumMeta):
54
- """Describes the entities certainty and polarity."""
55
-
56
- POSITIVE = "positive"
57
- POSITIVE_POSSIBLE = "positivePossible"
58
- NEUTRAL_POSSIBLE = "neutralPossible"
59
- NEGATIVE_POSSIBLE = "negativePossible"
60
- NEGATIVE = "negative"
61
-
62
-
63
- class EntityConditionality(str, Enum, metaclass=CaseInsensitiveEnumMeta):
64
- """Describes any conditionality on the entity."""
65
-
66
- HYPOTHETICAL = "hypothetical"
67
- CONDITIONAL = "conditional"
68
-
69
-
70
- class HealthcareEntityRelation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
71
- """Type of relation. Examples include: 'DosageOfMedication' or 'FrequencyOfMedication', etc."""
72
-
73
- ABBREVIATION = "Abbreviation"
74
- DIRECTION_OF_BODY_STRUCTURE = "DirectionOfBodyStructure"
75
- DIRECTION_OF_CONDITION = "DirectionOfCondition"
76
- DIRECTION_OF_EXAMINATION = "DirectionOfExamination"
77
- DIRECTION_OF_TREATMENT = "DirectionOfTreatment"
78
- DOSAGE_OF_MEDICATION = "DosageOfMedication"
79
- FORM_OF_MEDICATION = "FormOfMedication"
80
- FREQUENCY_OF_MEDICATION = "FrequencyOfMedication"
81
- FREQUENCY_OF_TREATMENT = "FrequencyOfTreatment"
82
- QUALIFIER_OF_CONDITION = "QualifierOfCondition"
83
- RELATION_OF_EXAMINATION = "RelationOfExamination"
84
- ROUTE_OF_MEDICATION = "RouteOfMedication"
85
- TIME_OF_CONDITION = "TimeOfCondition"
86
- TIME_OF_EVENT = "TimeOfEvent"
87
- TIME_OF_EXAMINATION = "TimeOfExamination"
88
- TIME_OF_MEDICATION = "TimeOfMedication"
89
- TIME_OF_TREATMENT = "TimeOfTreatment"
90
- UNIT_OF_CONDITION = "UnitOfCondition"
91
- UNIT_OF_EXAMINATION = "UnitOfExamination"
92
- VALUE_OF_CONDITION = "ValueOfCondition"
93
- VALUE_OF_EXAMINATION = "ValueOfExamination"
94
-
95
-
96
- class PiiEntityCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta):
97
- """Categories of Personally Identifiable Information (PII)."""
98
-
99
- ABA_ROUTING_NUMBER = "ABARoutingNumber"
100
- AR_NATIONAL_IDENTITY_NUMBER = "ARNationalIdentityNumber"
101
- AU_BANK_ACCOUNT_NUMBER = "AUBankAccountNumber"
102
- AU_DRIVERS_LICENSE_NUMBER = "AUDriversLicenseNumber"
103
- AU_MEDICAL_ACCOUNT_NUMBER = "AUMedicalAccountNumber"
104
- AU_PASSPORT_NUMBER = "AUPassportNumber"
105
- AU_TAX_FILE_NUMBER = "AUTaxFileNumber"
106
- AU_BUSINESS_NUMBER = "AUBusinessNumber"
107
- AU_COMPANY_NUMBER = "AUCompanyNumber"
108
- AT_IDENTITY_CARD = "ATIdentityCard"
109
- AT_TAX_IDENTIFICATION_NUMBER = "ATTaxIdentificationNumber"
110
- AT_VALUE_ADDED_TAX_NUMBER = "ATValueAddedTaxNumber"
111
- AZURE_DOCUMENT_DB_AUTH_KEY = "AzureDocumentDBAuthKey"
112
- AZURE_IAAS_DATABASE_CONNECTION_AND_SQL_STRING = (
113
- "AzureIAASDatabaseConnectionAndSQLString"
114
- )
115
- AZURE_IO_T_CONNECTION_STRING = "AzureIoTConnectionString"
116
- AZURE_PUBLISH_SETTING_PASSWORD = "AzurePublishSettingPassword"
117
- AZURE_REDIS_CACHE_STRING = "AzureRedisCacheString"
118
- AZURE_SAS = "AzureSAS"
119
- AZURE_SERVICE_BUS_STRING = "AzureServiceBusString"
120
- AZURE_STORAGE_ACCOUNT_KEY = "AzureStorageAccountKey"
121
- AZURE_STORAGE_ACCOUNT_GENERIC = "AzureStorageAccountGeneric"
122
- BE_NATIONAL_NUMBER = "BENationalNumber"
123
- BE_NATIONAL_NUMBER_V2 = "BENationalNumberV2"
124
- BE_VALUE_ADDED_TAX_NUMBER = "BEValueAddedTaxNumber"
125
- BRCPF_NUMBER = "BRCPFNumber"
126
- BR_LEGAL_ENTITY_NUMBER = "BRLegalEntityNumber"
127
- BR_NATIONAL_IDRG = "BRNationalIDRG"
128
- BG_UNIFORM_CIVIL_NUMBER = "BGUniformCivilNumber"
129
- CA_BANK_ACCOUNT_NUMBER = "CABankAccountNumber"
130
- CA_DRIVERS_LICENSE_NUMBER = "CADriversLicenseNumber"
131
- CA_HEALTH_SERVICE_NUMBER = "CAHealthServiceNumber"
132
- CA_PASSPORT_NUMBER = "CAPassportNumber"
133
- CA_PERSONAL_HEALTH_IDENTIFICATION = "CAPersonalHealthIdentification"
134
- CA_SOCIAL_INSURANCE_NUMBER = "CASocialInsuranceNumber"
135
- CL_IDENTITY_CARD_NUMBER = "CLIdentityCardNumber"
136
- CN_RESIDENT_IDENTITY_CARD_NUMBER = "CNResidentIdentityCardNumber"
137
- CREDIT_CARD_NUMBER = "CreditCardNumber"
138
- HR_IDENTITY_CARD_NUMBER = "HRIdentityCardNumber"
139
- HR_NATIONAL_ID_NUMBER = "HRNationalIDNumber"
140
- HR_PERSONAL_IDENTIFICATION_NUMBER = "HRPersonalIdentificationNumber"
141
- HR_PERSONAL_IDENTIFICATION_OIB_NUMBER_V2 = "HRPersonalIdentificationOIBNumberV2"
142
- CY_IDENTITY_CARD = "CYIdentityCard"
143
- CY_TAX_IDENTIFICATION_NUMBER = "CYTaxIdentificationNumber"
144
- CZ_PERSONAL_IDENTITY_NUMBER = "CZPersonalIdentityNumber"
145
- CZ_PERSONAL_IDENTITY_V2 = "CZPersonalIdentityV2"
146
- DK_PERSONAL_IDENTIFICATION_NUMBER = "DKPersonalIdentificationNumber"
147
- DK_PERSONAL_IDENTIFICATION_V2 = "DKPersonalIdentificationV2"
148
- DRUG_ENFORCEMENT_AGENCY_NUMBER = "DrugEnforcementAgencyNumber"
149
- EE_PERSONAL_IDENTIFICATION_CODE = "EEPersonalIdentificationCode"
150
- EU_DEBIT_CARD_NUMBER = "EUDebitCardNumber"
151
- EU_DRIVERS_LICENSE_NUMBER = "EUDriversLicenseNumber"
152
- EUGPS_COORDINATES = "EUGPSCoordinates"
153
- EU_NATIONAL_IDENTIFICATION_NUMBER = "EUNationalIdentificationNumber"
154
- EU_PASSPORT_NUMBER = "EUPassportNumber"
155
- EU_SOCIAL_SECURITY_NUMBER = "EUSocialSecurityNumber"
156
- EU_TAX_IDENTIFICATION_NUMBER = "EUTaxIdentificationNumber"
157
- FI_EUROPEAN_HEALTH_NUMBER = "FIEuropeanHealthNumber"
158
- FI_NATIONAL_ID = "FINationalID"
159
- FI_NATIONAL_IDV2 = "FINationalIDV2"
160
- FI_PASSPORT_NUMBER = "FIPassportNumber"
161
- FR_DRIVERS_LICENSE_NUMBER = "FRDriversLicenseNumber"
162
- FR_HEALTH_INSURANCE_NUMBER = "FRHealthInsuranceNumber"
163
- FR_NATIONAL_ID = "FRNationalID"
164
- FR_PASSPORT_NUMBER = "FRPassportNumber"
165
- FR_SOCIAL_SECURITY_NUMBER = "FRSocialSecurityNumber"
166
- FR_TAX_IDENTIFICATION_NUMBER = "FRTaxIdentificationNumber"
167
- FR_VALUE_ADDED_TAX_NUMBER = "FRValueAddedTaxNumber"
168
- DE_DRIVERS_LICENSE_NUMBER = "DEDriversLicenseNumber"
169
- DE_PASSPORT_NUMBER = "DEPassportNumber"
170
- DE_IDENTITY_CARD_NUMBER = "DEIdentityCardNumber"
171
- DE_TAX_IDENTIFICATION_NUMBER = "DETaxIdentificationNumber"
172
- DE_VALUE_ADDED_NUMBER = "DEValueAddedNumber"
173
- GR_NATIONAL_ID_CARD = "GRNationalIDCard"
174
- GR_NATIONAL_IDV2 = "GRNationalIDV2"
175
- GR_TAX_IDENTIFICATION_NUMBER = "GRTaxIdentificationNumber"
176
- HK_IDENTITY_CARD_NUMBER = "HKIdentityCardNumber"
177
- HU_VALUE_ADDED_NUMBER = "HUValueAddedNumber"
178
- HU_PERSONAL_IDENTIFICATION_NUMBER = "HUPersonalIdentificationNumber"
179
- HU_TAX_IDENTIFICATION_NUMBER = "HUTaxIdentificationNumber"
180
- IN_PERMANENT_ACCOUNT = "INPermanentAccount"
181
- IN_UNIQUE_IDENTIFICATION_NUMBER = "INUniqueIdentificationNumber"
182
- ID_IDENTITY_CARD_NUMBER = "IDIdentityCardNumber"
183
- INTERNATIONAL_BANKING_ACCOUNT_NUMBER = "InternationalBankingAccountNumber"
184
- IE_PERSONAL_PUBLIC_SERVICE_NUMBER = "IEPersonalPublicServiceNumber"
185
- IE_PERSONAL_PUBLIC_SERVICE_NUMBER_V2 = "IEPersonalPublicServiceNumberV2"
186
- IL_BANK_ACCOUNT_NUMBER = "ILBankAccountNumber"
187
- IL_NATIONAL_ID = "ILNationalID"
188
- IT_DRIVERS_LICENSE_NUMBER = "ITDriversLicenseNumber"
189
- IT_FISCAL_CODE = "ITFiscalCode"
190
- IT_VALUE_ADDED_TAX_NUMBER = "ITValueAddedTaxNumber"
191
- JP_BANK_ACCOUNT_NUMBER = "JPBankAccountNumber"
192
- JP_DRIVERS_LICENSE_NUMBER = "JPDriversLicenseNumber"
193
- JP_PASSPORT_NUMBER = "JPPassportNumber"
194
- JP_RESIDENT_REGISTRATION_NUMBER = "JPResidentRegistrationNumber"
195
- JP_SOCIAL_INSURANCE_NUMBER = "JPSocialInsuranceNumber"
196
- JP_MY_NUMBER_CORPORATE = "JPMyNumberCorporate"
197
- JP_MY_NUMBER_PERSONAL = "JPMyNumberPersonal"
198
- JP_RESIDENCE_CARD_NUMBER = "JPResidenceCardNumber"
199
- LV_PERSONAL_CODE = "LVPersonalCode"
200
- LT_PERSONAL_CODE = "LTPersonalCode"
201
- LU_NATIONAL_IDENTIFICATION_NUMBER_NATURAL = "LUNationalIdentificationNumberNatural"
202
- LU_NATIONAL_IDENTIFICATION_NUMBER_NON_NATURAL = (
203
- "LUNationalIdentificationNumberNonNatural"
204
- )
205
- MY_IDENTITY_CARD_NUMBER = "MYIdentityCardNumber"
206
- MT_IDENTITY_CARD_NUMBER = "MTIdentityCardNumber"
207
- MT_TAX_ID_NUMBER = "MTTaxIDNumber"
208
- NL_CITIZENS_SERVICE_NUMBER = "NLCitizensServiceNumber"
209
- NL_CITIZENS_SERVICE_NUMBER_V2 = "NLCitizensServiceNumberV2"
210
- NL_TAX_IDENTIFICATION_NUMBER = "NLTaxIdentificationNumber"
211
- NL_VALUE_ADDED_TAX_NUMBER = "NLValueAddedTaxNumber"
212
- NZ_BANK_ACCOUNT_NUMBER = "NZBankAccountNumber"
213
- NZ_DRIVERS_LICENSE_NUMBER = "NZDriversLicenseNumber"
214
- NZ_INLAND_REVENUE_NUMBER = "NZInlandRevenueNumber"
215
- NZ_MINISTRY_OF_HEALTH_NUMBER = "NZMinistryOfHealthNumber"
216
- NZ_SOCIAL_WELFARE_NUMBER = "NZSocialWelfareNumber"
217
- NO_IDENTITY_NUMBER = "NOIdentityNumber"
218
- PH_UNIFIED_MULTI_PURPOSE_ID_NUMBER = "PHUnifiedMultiPurposeIDNumber"
219
- PL_IDENTITY_CARD = "PLIdentityCard"
220
- PL_NATIONAL_ID = "PLNationalID"
221
- PL_NATIONAL_IDV2 = "PLNationalIDV2"
222
- PL_PASSPORT_NUMBER = "PLPassportNumber"
223
- PL_TAX_IDENTIFICATION_NUMBER = "PLTaxIdentificationNumber"
224
- PLREGON_NUMBER = "PLREGONNumber"
225
- PT_CITIZEN_CARD_NUMBER = "PTCitizenCardNumber"
226
- PT_CITIZEN_CARD_NUMBER_V2 = "PTCitizenCardNumberV2"
227
- PT_TAX_IDENTIFICATION_NUMBER = "PTTaxIdentificationNumber"
228
- RO_PERSONAL_NUMERICAL_CODE = "ROPersonalNumericalCode"
229
- RU_PASSPORT_NUMBER_DOMESTIC = "RUPassportNumberDomestic"
230
- RU_PASSPORT_NUMBER_INTERNATIONAL = "RUPassportNumberInternational"
231
- SA_NATIONAL_ID = "SANationalID"
232
- SG_NATIONAL_REGISTRATION_IDENTITY_CARD_NUMBER = (
233
- "SGNationalRegistrationIdentityCardNumber"
234
- )
235
- SK_PERSONAL_NUMBER = "SKPersonalNumber"
236
- SI_TAX_IDENTIFICATION_NUMBER = "SITaxIdentificationNumber"
237
- SI_UNIQUE_MASTER_CITIZEN_NUMBER = "SIUniqueMasterCitizenNumber"
238
- ZA_IDENTIFICATION_NUMBER = "ZAIdentificationNumber"
239
- KR_RESIDENT_REGISTRATION_NUMBER = "KRResidentRegistrationNumber"
240
- ESDNI = "ESDNI"
241
- ES_SOCIAL_SECURITY_NUMBER = "ESSocialSecurityNumber"
242
- ES_TAX_IDENTIFICATION_NUMBER = "ESTaxIdentificationNumber"
243
- SQL_SERVER_CONNECTION_STRING = "SQLServerConnectionString"
244
- SE_NATIONAL_ID = "SENationalID"
245
- SE_NATIONAL_IDV2 = "SENationalIDV2"
246
- SE_PASSPORT_NUMBER = "SEPassportNumber"
247
- SE_TAX_IDENTIFICATION_NUMBER = "SETaxIdentificationNumber"
248
- SWIFT_CODE = "SWIFTCode"
249
- CH_SOCIAL_SECURITY_NUMBER = "CHSocialSecurityNumber"
250
- TW_NATIONAL_ID = "TWNationalID"
251
- TW_PASSPORT_NUMBER = "TWPassportNumber"
252
- TW_RESIDENT_CERTIFICATE = "TWResidentCertificate"
253
- TH_POPULATION_IDENTIFICATION_CODE = "THPopulationIdentificationCode"
254
- TR_NATIONAL_IDENTIFICATION_NUMBER = "TRNationalIdentificationNumber"
255
- UK_DRIVERS_LICENSE_NUMBER = "UKDriversLicenseNumber"
256
- UK_ELECTORAL_ROLL_NUMBER = "UKElectoralRollNumber"
257
- UK_NATIONAL_HEALTH_NUMBER = "UKNationalHealthNumber"
258
- UK_NATIONAL_INSURANCE_NUMBER = "UKNationalInsuranceNumber"
259
- UK_UNIQUE_TAXPAYER_NUMBER = "UKUniqueTaxpayerNumber"
260
- USUK_PASSPORT_NUMBER = "USUKPassportNumber"
261
- US_BANK_ACCOUNT_NUMBER = "USBankAccountNumber"
262
- US_DRIVERS_LICENSE_NUMBER = "USDriversLicenseNumber"
263
- US_INDIVIDUAL_TAXPAYER_IDENTIFICATION = "USIndividualTaxpayerIdentification"
264
- US_SOCIAL_SECURITY_NUMBER = "USSocialSecurityNumber"
265
- UA_PASSPORT_NUMBER_DOMESTIC = "UAPassportNumberDomestic"
266
- UA_PASSPORT_NUMBER_INTERNATIONAL = "UAPassportNumberInternational"
267
- ORGANIZATION = "Organization"
268
- EMAIL = "Email"
269
- URL = "URL"
270
- AGE = "Age"
271
- PHONE_NUMBER = "PhoneNumber"
272
- IP_ADDRESS = "IPAddress"
273
- DATE = "Date"
274
- PERSON = "Person"
275
- ADDRESS = "Address"
276
- ALL = "All"
277
- DEFAULT = "Default"
278
-
279
-
280
- class HealthcareEntityCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta):
281
- """Healthcare Entity Category."""
282
-
283
- BODY_STRUCTURE = "BodyStructure"
284
- AGE = "Age"
285
- GENDER = "Gender"
286
- EXAMINATION_NAME = "ExaminationName"
287
- DATE = "Date"
288
- DIRECTION = "Direction"
289
- FREQUENCY = "Frequency"
290
- MEASUREMENT_VALUE = "MeasurementValue"
291
- MEASUREMENT_UNIT = "MeasurementUnit"
292
- RELATIONAL_OPERATOR = "RelationalOperator"
293
- TIME = "Time"
294
- GENE_OR_PROTEIN = "GeneOrProtein"
295
- VARIANT = "Variant"
296
- ADMINISTRATIVE_EVENT = "AdministrativeEvent"
297
- CARE_ENVIRONMENT = "CareEnvironment"
298
- HEALTHCARE_PROFESSION = "HealthcareProfession"
299
- DIAGNOSIS = "Diagnosis"
300
- SYMPTOM_OR_SIGN = "SymptomOrSign"
301
- CONDITION_QUALIFIER = "ConditionQualifier"
302
- MEDICATION_CLASS = "MedicationClass"
303
- MEDICATION_NAME = "MedicationName"
304
- DOSAGE = "Dosage"
305
- MEDICATION_FORM = "MedicationForm"
306
- MEDICATION_ROUTE = "MedicationRoute"
307
- FAMILY_RELATION = "FamilyRelation"
308
- TREATMENT_NAME = "TreatmentName"
309
-
310
-
311
- class PiiEntityDomain(str, Enum, metaclass=CaseInsensitiveEnumMeta):
312
- """The different domains of PII entities that users can filter by"""
313
-
314
- PROTECTED_HEALTH_INFORMATION = (
315
- "phi" # See https://aka.ms/tanerpii for more information.
316
- )
317
-
318
-
319
- class DetectedLanguage(DictMixin):
320
- """DetectedLanguage contains the predicted language found in text,
321
- its confidence score, and its ISO 639-1 representation.
322
-
323
- :ivar name: Long name of a detected language (e.g. English,
324
- French).
325
- :vartype name: str
326
- :ivar iso6391_name: A two letter representation of the detected
327
- language according to the ISO 639-1 standard (e.g. en, fr).
328
- :vartype iso6391_name: str
329
- :ivar confidence_score: A confidence score between 0 and 1. Scores close
330
- to 1 indicate 100% certainty that the identified language is true.
331
- :vartype confidence_score: float
332
- :ivar Optional[str] script: Identifies the script of the input document. Possible values: "Latin".
333
-
334
- .. versionadded:: 2022-10-01-preview
335
- The *script* property.
336
- """
337
-
338
- def __init__(self, **kwargs):
339
- self.name = kwargs.get("name", None)
340
- self.iso6391_name = kwargs.get("iso6391_name", None)
341
- self.confidence_score = kwargs.get("confidence_score", None)
342
- self.script = kwargs.get("script", None)
343
-
344
- @classmethod
345
- def _from_generated(cls, language):
346
- script = language.script if hasattr(language, "script") else None
347
- return cls(
348
- name=language.name,
349
- iso6391_name=language.iso6391_name,
350
- confidence_score=language.confidence_score,
351
- script=script
352
- )
353
-
354
- def __repr__(self):
355
- return "DetectedLanguage(name={}, iso6391_name={}, confidence_score={}, script={})".format(
356
- self.name, self.iso6391_name, self.confidence_score, self.script
357
- )[:1024]
358
-
359
-
360
- class RecognizeEntitiesResult(DictMixin):
361
- """RecognizeEntitiesResult is a result object which contains
362
- the recognized entities from a particular document.
363
-
364
- :ivar id: Unique, non-empty document identifier that matches the
365
- document id that was passed in with the request. If not specified
366
- in the request, an id is assigned for the document.
367
- :vartype id: str
368
- :ivar entities: Recognized entities in the document.
369
- :vartype entities:
370
- list[~azure.ai.textanalytics.CategorizedEntity]
371
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
372
- if there are warnings, but they may not be fully accurate.
373
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
374
- :ivar statistics: If `show_stats=True` was specified in the request this
375
- field will contain information about the document payload.
376
- :vartype statistics:
377
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
378
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
379
- field will contain the DetectedLanguage for the document.
380
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
381
- :ivar bool is_error: Boolean check for error item when iterating over list of
382
- results. Always False for an instance of a RecognizeEntitiesResult.
383
- :ivar str kind: The text analysis kind - "EntityRecognition".
384
-
385
- .. versionadded:: 2022-10-01-preview
386
- The *detected_language* property.
387
- """
388
-
389
- def __init__(self, **kwargs):
390
- self.id = kwargs.get("id", None)
391
- self.entities = kwargs.get("entities", None)
392
- self.warnings = kwargs.get("warnings", [])
393
- self.statistics = kwargs.get("statistics", None)
394
- self.detected_language = kwargs.get("detected_language", None)
395
- self.is_error: Literal[False] = False
396
- self.kind: Literal["EntityRecognition"] = "EntityRecognition"
397
-
398
- def __repr__(self):
399
- return "RecognizeEntitiesResult(id={}, entities={}, warnings={}, statistics={}, " \
400
- "detected_language={}, is_error={})".format(
401
- self.id,
402
- repr(self.entities),
403
- repr(self.warnings),
404
- repr(self.statistics),
405
- repr(self.detected_language),
406
- self.is_error,
407
- )[
408
- :1024
409
- ]
410
-
411
-
412
- class RecognizePiiEntitiesResult(DictMixin):
413
- """RecognizePiiEntitiesResult is a result object which contains
414
- the recognized Personally Identifiable Information (PII) entities
415
- from a particular document.
416
-
417
- :ivar str id: Unique, non-empty document identifier that matches the
418
- document id that was passed in with the request. If not specified
419
- in the request, an id is assigned for the document.
420
- :ivar entities: Recognized PII entities in the document.
421
- :vartype entities:
422
- list[~azure.ai.textanalytics.PiiEntity]
423
- :ivar str redacted_text: Returns the text of the input document with all of the PII information
424
- redacted out.
425
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
426
- if there are warnings, but they may not be fully accurate.
427
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
428
- :ivar statistics: If `show_stats=True` was specified in the request this
429
- field will contain information about the document payload.
430
- :vartype statistics:
431
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
432
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
433
- field will contain the DetectedLanguage for the document.
434
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
435
- :ivar bool is_error: Boolean check for error item when iterating over list of
436
- results. Always False for an instance of a RecognizePiiEntitiesResult.
437
- :ivar str kind: The text analysis kind - "PiiEntityRecognition".
438
-
439
- .. versionadded:: 2022-10-01-preview
440
- The *detected_language* property.
441
- """
442
-
443
- def __init__(self, **kwargs):
444
- self.id = kwargs.get("id", None)
445
- self.entities = kwargs.get("entities", None)
446
- self.redacted_text = kwargs.get("redacted_text", None)
447
- self.warnings = kwargs.get("warnings", [])
448
- self.statistics = kwargs.get("statistics", None)
449
- self.detected_language = kwargs.get('detected_language', None)
450
- self.is_error: Literal[False] = False
451
- self.kind: Literal["PiiEntityRecognition"] = "PiiEntityRecognition"
452
-
453
- def __repr__(self):
454
- return (
455
- "RecognizePiiEntitiesResult(id={}, entities={}, redacted_text={}, warnings={}, "
456
- "statistics={}, detected_language={}, is_error={})".format(
457
- self.id,
458
- repr(self.entities),
459
- self.redacted_text,
460
- repr(self.warnings),
461
- repr(self.statistics),
462
- repr(self.detected_language),
463
- self.is_error,
464
- )[:1024]
465
- )
466
-
467
-
468
- class AnalyzeHealthcareEntitiesResult(DictMixin):
469
- """
470
- AnalyzeHealthcareEntitiesResult contains the Healthcare entities from a
471
- particular document.
472
-
473
- :ivar str id: Unique, non-empty document identifier that matches the
474
- document id that was passed in with the request. If not specified
475
- in the request, an id is assigned for the document.
476
- :ivar entities: Identified Healthcare entities in the document, i.e. in
477
- the document "The subject took ibuprofen", "ibuprofen" is an identified entity
478
- from the document.
479
- :vartype entities:
480
- list[~azure.ai.textanalytics.HealthcareEntity]
481
- :ivar entity_relations: Identified Healthcare relations between entities. For example, in the
482
- document "The subject took 100mg of ibuprofen", we would identify the relationship
483
- between the dosage of 100mg and the medication ibuprofen.
484
- :vartype entity_relations: list[~azure.ai.textanalytics.HealthcareRelation]
485
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
486
- if there are warnings, but they may not be fully accurate.
487
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
488
- :ivar statistics: If show_stats=true was specified in the request this
489
- field will contain information about the document payload.
490
- :vartype statistics:
491
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
492
- :ivar fhir_bundle: If `fhir_version` is passed, this will contain a
493
- FHIR compatible object for consumption in other Healthcare tools. For additional
494
- information see https://www.hl7.org/fhir/overview.html.
495
- :vartype fhir_bundle: Optional[dict[str, any]]
496
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
497
- field will contain the detected language for the document.
498
- :vartype detected_language: Optional[str]
499
- :ivar bool is_error: Boolean check for error item when iterating over list of
500
- results. Always False for an instance of a AnalyzeHealthcareEntitiesResult.
501
- :ivar str kind: The text analysis kind - "Healthcare".
502
-
503
- .. versionadded:: 2022-10-01-preview
504
- The *fhir_bundle* and *detected_language* properties.
505
- """
506
-
507
- def __init__(self, **kwargs):
508
- self.id = kwargs.get("id", None)
509
- self.entities = kwargs.get("entities", None)
510
- self.entity_relations = kwargs.get("entity_relations", None)
511
- self.warnings = kwargs.get("warnings", [])
512
- self.statistics = kwargs.get("statistics", None)
513
- self.fhir_bundle = kwargs.get("fhir_bundle", None)
514
- self.detected_language = kwargs.get('detected_language', None)
515
- self.is_error: Literal[False] = False
516
- self.kind: Literal["Healthcare"] = "Healthcare"
517
-
518
- @classmethod
519
- def _from_generated(cls, healthcare_result):
520
- entities = [
521
- HealthcareEntity._from_generated(e) # pylint: disable=protected-access
522
- for e in healthcare_result.entities
523
- ]
524
- relations = [
525
- HealthcareRelation._from_generated( # pylint: disable=protected-access
526
- r, entities
527
- )
528
- for r in healthcare_result.relations
529
- ]
530
- fhir_bundle = healthcare_result.fhir_bundle if hasattr(healthcare_result, "fhir_bundle") else None
531
- detected_language = healthcare_result.detected_language \
532
- if hasattr(healthcare_result, "detected_language") else None
533
- return cls(
534
- id=healthcare_result.id,
535
- entities=entities,
536
- entity_relations=relations,
537
- warnings=[
538
- TextAnalyticsWarning._from_generated( # pylint: disable=protected-access
539
- w
540
- )
541
- for w in healthcare_result.warnings
542
- ],
543
- statistics=TextDocumentStatistics._from_generated( # pylint: disable=protected-access
544
- healthcare_result.statistics
545
- ),
546
- fhir_bundle=fhir_bundle,
547
- detected_language=detected_language # https://github.com/Azure/azure-sdk-for-python/issues/27171
548
- # detected_language=DetectedLanguage._from_generated( # pylint: disable=protected-access
549
- # healthcare_result.detected_language
550
- # ) if hasattr(healthcare_result, "detected_language") and healthcare_result.detected_language else None
551
- )
552
-
553
- def __repr__(self):
554
- return (
555
- "AnalyzeHealthcareEntitiesResult(id={}, entities={}, entity_relations={}, warnings={}, "
556
- "statistics={}, fhir_bundle={}, detected_language={}, is_error={})".format(
557
- self.id,
558
- repr(self.entities),
559
- repr(self.entity_relations),
560
- repr(self.warnings),
561
- repr(self.statistics),
562
- self.fhir_bundle,
563
- self.detected_language,
564
- self.is_error,
565
- )[:1024]
566
- )
567
-
568
-
569
- class HealthcareRelation(DictMixin):
570
- """HealthcareRelation is a result object which represents a relation detected in a document.
571
-
572
- Every HealthcareRelation is an entity graph of a certain relation type,
573
- where all entities are connected and have specific roles within the relation context.
574
-
575
- :ivar relation_type: The type of relation, i.e. the relationship between "100mg" and
576
- "ibuprofen" in the document "The subject took 100 mg of ibuprofen" is "DosageOfMedication".
577
- Possible values found in :class:`~azure.ai.textanalytics.HealthcareEntityRelation`
578
- :vartype relation_type: str
579
- :ivar roles: The roles present in this relation. I.e., in the document
580
- "The subject took 100 mg of ibuprofen", the present roles are "Dosage" and "Medication".
581
- :vartype roles: list[~azure.ai.textanalytics.HealthcareRelationRole]
582
- :ivar confidence_score: Confidence score between 0 and 1 of the extracted relation.
583
- :vartype confidence_score: Optional[float]
584
-
585
- .. versionadded:: 2022-10-01-preview
586
- The *confidence_score* property.
587
- """
588
-
589
- def __init__(self, **kwargs):
590
- self.relation_type = kwargs.get("relation_type")
591
- self.roles = kwargs.get("roles")
592
- self.confidence_score = kwargs.get("confidence_score")
593
-
594
- @classmethod
595
- def _from_generated(cls, healthcare_relation_result, entities):
596
- roles = [
597
- HealthcareRelationRole._from_generated( # pylint: disable=protected-access
598
- r, entities
599
- )
600
- for r in healthcare_relation_result.entities
601
- ]
602
- confidence_score = healthcare_relation_result.confidence_score \
603
- if hasattr(healthcare_relation_result, "confidence_score") else None
604
- return cls(
605
- relation_type=healthcare_relation_result.relation_type,
606
- roles=roles,
607
- confidence_score=confidence_score,
608
- )
609
-
610
- def __repr__(self):
611
- return "HealthcareRelation(relation_type={}, roles={}, confidence_score={})".format(
612
- self.relation_type,
613
- repr(self.roles),
614
- self.confidence_score,
615
- )[:1024]
616
-
617
-
618
- class HealthcareRelationRole(DictMixin):
619
- """A model representing a role in a relation.
620
-
621
- For example, in "The subject took 100 mg of ibuprofen",
622
- "100 mg" is a dosage entity fulfilling the role "Dosage"
623
- in the extracted relation "DosageOfMedication".
624
-
625
- :ivar name: The role of the entity in the relationship. I.e., in the relation
626
- "The subject took 100 mg of ibuprofen", the dosage entity "100 mg" has role
627
- "Dosage".
628
- :vartype name: str
629
- :ivar entity: The entity that is present in the relationship. For example, in
630
- "The subject took 100 mg of ibuprofen", this property holds the dosage entity
631
- of "100 mg".
632
- :vartype entity: ~azure.ai.textanalytics.HealthcareEntity
633
- """
634
-
635
- def __init__(self, **kwargs):
636
- self.name = kwargs.get("name")
637
- self.entity = kwargs.get("entity")
638
-
639
- @staticmethod
640
- def _get_entity(healthcare_role_result, entities):
641
- numbers = _get_indices(healthcare_role_result.ref)
642
- entity_index = numbers[
643
- 1
644
- ] # first number parsed from index is document #, second is entity index
645
- return entities[entity_index]
646
-
647
- @classmethod
648
- def _from_generated(cls, healthcare_role_result, entities):
649
- return cls(
650
- name=healthcare_role_result.role,
651
- entity=HealthcareRelationRole._get_entity(healthcare_role_result, entities),
652
- )
653
-
654
- def __repr__(self):
655
- return "HealthcareRelationRole(name={}, entity={})".format(
656
- self.name, repr(self.entity)
657
- )
658
-
659
-
660
- class DetectLanguageResult(DictMixin):
661
- """DetectLanguageResult is a result object which contains
662
- the detected language of a particular document.
663
-
664
- :ivar id: Unique, non-empty document identifier that matches the
665
- document id that was passed in with the request. If not specified
666
- in the request, an id is assigned for the document.
667
- :vartype id: str
668
- :ivar primary_language: The primary language detected in the document.
669
- :vartype primary_language: ~azure.ai.textanalytics.DetectedLanguage
670
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
671
- if there are warnings, but they may not be fully accurate.
672
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
673
- :ivar statistics: If `show_stats=True` was specified in the request this
674
- field will contain information about the document payload.
675
- :vartype statistics:
676
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
677
- :ivar bool is_error: Boolean check for error item when iterating over list of
678
- results. Always False for an instance of a DetectLanguageResult.
679
- :ivar str kind: The text analysis kind - "LanguageDetection".
680
- """
681
-
682
- def __init__(self, **kwargs):
683
- self.id = kwargs.get("id", None)
684
- self.primary_language = kwargs.get("primary_language", None)
685
- self.warnings = kwargs.get("warnings", [])
686
- self.statistics = kwargs.get("statistics", None)
687
- self.is_error: Literal[False] = False
688
- self.kind: Literal["LanguageDetection"] = "LanguageDetection"
689
-
690
- def __repr__(self):
691
- return (
692
- "DetectLanguageResult(id={}, primary_language={}, warnings={}, statistics={}, "
693
- "is_error={})".format(
694
- self.id,
695
- repr(self.primary_language),
696
- repr(self.warnings),
697
- repr(self.statistics),
698
- self.is_error,
699
- )[:1024]
700
- )
701
-
702
-
703
- class CategorizedEntity(DictMixin):
704
- """CategorizedEntity contains information about a particular
705
- entity found in text.
706
-
707
- :ivar text: Entity text as appears in the request.
708
- :vartype text: str
709
- :ivar category: Entity category, such as Person/Location/Org/SSN etc
710
- :vartype category: str
711
- :ivar subcategory: Entity subcategory, such as Age/Year/TimeRange etc
712
- :vartype subcategory: Optional[str]
713
- :ivar int length: The entity text length. This value depends on the value of the
714
- `string_index_type` parameter set in the original request, which is UnicodeCodePoints
715
- by default.
716
- :ivar int offset: The entity text offset from the start of the document.
717
- The value depends on the value of the `string_index_type` parameter
718
- set in the original request, which is UnicodeCodePoints by default.
719
- :ivar confidence_score: Confidence score between 0 and 1 of the extracted
720
- entity.
721
- :vartype confidence_score: float
722
- :ivar resolutions: The collection of entity resolution objects. More information can be found here:
723
- https://aka.ms/azsdk/language/ner-resolutions
724
- :vartype resolutions: Optional[list[AgeResolution or AreaResolution or BooleanResolution or
725
- CurrencyResolution or DateTimeResolution or InformationResolution or LengthResolution or
726
- NumberResolution or NumericRangeResolution or OrdinalResolution or SpeedResolution or
727
- TemperatureResolution or TemporalSpanResolution or VolumeResolution or WeightResolution]]
728
-
729
- .. versionadded:: v3.1
730
- The *offset* and *length* properties.
731
- .. versionadded:: 2022-10-01-preview
732
- The *resolutions* property.
733
- """
734
-
735
- def __init__(self, **kwargs):
736
- self.text = kwargs.get("text", None)
737
- self.category = kwargs.get("category", None)
738
- self.subcategory = kwargs.get("subcategory", None)
739
- self.length = kwargs.get("length", None)
740
- self.offset = kwargs.get("offset", None)
741
- self.confidence_score = kwargs.get("confidence_score", None)
742
- self.resolutions = kwargs.get("resolutions", None)
743
-
744
- @classmethod
745
- def _from_generated(cls, entity):
746
- offset = entity.offset
747
- length = entity.length
748
- if isinstance(entity, _v3_0_models.Entity):
749
- # we do not return offset for v3.0 since
750
- # the correct encoding was not introduced for v3.0
751
- offset = None
752
- length = None
753
- return cls(
754
- text=entity.text,
755
- category=entity.category,
756
- subcategory=entity.subcategory,
757
- length=length,
758
- offset=offset,
759
- confidence_score=entity.confidence_score,
760
- resolutions=entity.resolutions if hasattr(entity, "resolutions") else None
761
- )
762
-
763
- def __repr__(self):
764
- return (
765
- "CategorizedEntity(text={}, category={}, subcategory={}, "
766
- "length={}, offset={}, confidence_score={}, resolutions={})".format(
767
- self.text,
768
- self.category,
769
- self.subcategory,
770
- self.length,
771
- self.offset,
772
- self.confidence_score,
773
- repr(self.resolutions)
774
- )[:1024]
775
- )
776
-
777
-
778
- class PiiEntity(DictMixin):
779
- """PiiEntity contains information about a Personally Identifiable
780
- Information (PII) entity found in text.
781
-
782
- :ivar str text: Entity text as appears in the request.
783
- :ivar str category: Entity category, such as Financial Account
784
- Identification/Social Security Number/Phone Number, etc.
785
- :ivar str subcategory: Entity subcategory, such as Credit Card/EU
786
- Phone number/ABA Routing Numbers, etc.
787
- :ivar int length: The PII entity text length. This value depends on the value
788
- of the `string_index_type` parameter specified in the original request, which
789
- is UnicodeCodePoints by default.
790
- :ivar int offset: The PII entity text offset from the start of the document.
791
- This value depends on the value of the `string_index_type` parameter specified
792
- in the original request, which is UnicodeCodePoints by default.
793
- :ivar float confidence_score: Confidence score between 0 and 1 of the extracted
794
- entity.
795
- """
796
-
797
- def __init__(self, **kwargs):
798
- self.text = kwargs.get("text", None)
799
- self.category = kwargs.get("category", None)
800
- self.subcategory = kwargs.get("subcategory", None)
801
- self.length = kwargs.get("length", None)
802
- self.offset = kwargs.get("offset", None)
803
- self.confidence_score = kwargs.get("confidence_score", None)
804
-
805
- @classmethod
806
- def _from_generated(cls, entity):
807
- return cls(
808
- text=entity.text,
809
- category=entity.category,
810
- subcategory=entity.subcategory,
811
- length=entity.length,
812
- offset=entity.offset,
813
- confidence_score=entity.confidence_score,
814
- )
815
-
816
- def __repr__(self):
817
- return (
818
- "PiiEntity(text={}, category={}, subcategory={}, length={}, "
819
- "offset={}, confidence_score={})".format(
820
- self.text,
821
- self.category,
822
- self.subcategory,
823
- self.length,
824
- self.offset,
825
- self.confidence_score,
826
- )[:1024]
827
- )
828
-
829
-
830
- class HealthcareEntity(DictMixin):
831
- """HealthcareEntity contains information about a Healthcare entity found in text.
832
-
833
- :ivar str text: Entity text as appears in the document.
834
- :ivar Optional[str] normalized_text: Normalized version of the raw `text` we extract
835
- from the document. Not all `text` will have a normalized version.
836
- :ivar str category: Entity category, see the :class:`~azure.ai.textanalytics.HealthcareEntityCategory`
837
- type for possible healthcare entity categories.
838
- :ivar Optional[str] subcategory: Entity subcategory.
839
- :ivar assertion: Contains various assertions about this entity. For example, if
840
- an entity is a diagnosis, is this diagnosis 'conditional' on a symptom?
841
- Are the doctors 'certain' about this diagnosis? Is this diagnosis 'associated'
842
- with another diagnosis?
843
- :vartype assertion: Optional[~azure.ai.textanalytics.HealthcareEntityAssertion]
844
- :ivar int length: The entity text length. This value depends on the value
845
- of the `string_index_type` parameter specified in the original request, which is
846
- UnicodeCodePoints by default.
847
- :ivar int offset: The entity text offset from the start of the document.
848
- This value depends on the value of the `string_index_type` parameter specified
849
- in the original request, which is UnicodeCodePoints by default.
850
- :ivar float confidence_score: Confidence score between 0 and 1 of the extracted
851
- entity.
852
- :ivar data_sources: A collection of entity references in known data sources.
853
- :vartype data_sources: Optional[list[~azure.ai.textanalytics.HealthcareEntityDataSource]]
854
- """
855
-
856
- def __init__(self, **kwargs):
857
- self.text = kwargs.get("text", None)
858
- self.normalized_text = kwargs.get("normalized_text", None)
859
- self.category = kwargs.get("category", None)
860
- self.subcategory = kwargs.get("subcategory", None)
861
- self.assertion = kwargs.get("assertion", None)
862
- self.length = kwargs.get("length", None)
863
- self.offset = kwargs.get("offset", None)
864
- self.confidence_score = kwargs.get("confidence_score", None)
865
- self.data_sources = kwargs.get("data_sources", [])
866
-
867
- @classmethod
868
- def _from_generated(cls, healthcare_entity):
869
- assertion = None
870
- try:
871
- if healthcare_entity.assertion:
872
- assertion = HealthcareEntityAssertion._from_generated( # pylint: disable=protected-access
873
- healthcare_entity.assertion
874
- )
875
- except AttributeError:
876
- assertion = None
877
-
878
- return cls(
879
- text=healthcare_entity.text,
880
- normalized_text=healthcare_entity.name,
881
- category=healthcare_entity.category,
882
- subcategory=healthcare_entity.subcategory,
883
- assertion=assertion,
884
- length=healthcare_entity.length,
885
- offset=healthcare_entity.offset,
886
- confidence_score=healthcare_entity.confidence_score,
887
- data_sources=[
888
- HealthcareEntityDataSource(entity_id=l.id, name=l.data_source)
889
- for l in healthcare_entity.links
890
- ]
891
- if healthcare_entity.links
892
- else None,
893
- )
894
-
895
- def __hash__(self):
896
- return hash(repr(self))
897
-
898
- def __repr__(self):
899
- return (
900
- "HealthcareEntity(text={}, normalized_text={}, category={}, subcategory={}, assertion={}, length={}, "
901
- "offset={}, confidence_score={}, data_sources={})".format(
902
- self.text,
903
- self.normalized_text,
904
- self.category,
905
- self.subcategory,
906
- repr(self.assertion),
907
- self.length,
908
- self.offset,
909
- self.confidence_score,
910
- repr(self.data_sources),
911
- )[:1024]
912
- )
913
-
914
-
915
- class HealthcareEntityAssertion(DictMixin):
916
- """Contains various assertions about a `HealthcareEntity`.
917
-
918
- For example, if an entity is a diagnosis, is this diagnosis 'conditional' on a symptom?
919
- Are the doctors 'certain' about this diagnosis? Is this diagnosis 'associated'
920
- with another diagnosis?
921
-
922
- :ivar Optional[str] conditionality: Describes whether the healthcare entity it's on is conditional
923
- on another entity. For example, "If the patient has a fever, he has pneumonia", the diagnosis of pneumonia
924
- is 'conditional' on whether the patient has a fever. Possible values are "hypothetical" and
925
- "conditional".
926
- :ivar Optional[str] certainty: Describes how certain the healthcare entity it's on is. For example,
927
- in "The patient may have a fever", the fever entity is not 100% certain, but is instead
928
- "positivePossible". Possible values are "positive", "positivePossible", "neutralPossible",
929
- "negativePossible", and "negative".
930
- :ivar Optional[str] association: Describes whether the healthcare entity it's on is the subject of the document, or
931
- if this entity describes someone else in the document. For example, in "The subject's mother has
932
- a fever", the "fever" entity is not associated with the subject themselves, but with the subject's
933
- mother. Possible values are "subject" and "other".
934
- """
935
-
936
- def __init__(self, **kwargs):
937
- self.conditionality = kwargs.get("conditionality", None)
938
- self.certainty = kwargs.get("certainty", None)
939
- self.association = kwargs.get("association", None)
940
-
941
- @classmethod
942
- def _from_generated(cls, healthcare_assertion):
943
- return cls(
944
- conditionality=healthcare_assertion.conditionality,
945
- certainty=healthcare_assertion.certainty,
946
- association=healthcare_assertion.association,
947
- )
948
-
949
- def __repr__(self):
950
- return "HealthcareEntityAssertion(conditionality={}, certainty={}, association={})".format(
951
- self.conditionality, self.certainty, self.association
952
- )
953
-
954
-
955
- class HealthcareEntityDataSource(DictMixin):
956
- """
957
- HealthcareEntityDataSource contains information representing an entity reference in a known data source.
958
-
959
- :ivar str entity_id: ID of the entity in the given source catalog.
960
- :ivar str name: The name of the entity catalog from where the entity was identified, such as UMLS, CHV, MSH, etc.
961
- """
962
-
963
- def __init__(self, **kwargs):
964
- self.entity_id = kwargs.get("entity_id", None)
965
- self.name = kwargs.get("name", None)
966
-
967
- def __repr__(self):
968
- return "HealthcareEntityDataSource(entity_id={}, name={})".format(
969
- self.entity_id, self.name
970
- )[:1024]
971
-
972
-
973
- class TextAnalyticsError(DictMixin):
974
- """TextAnalyticsError contains the error code, message, and
975
- other details that explain why the batch or individual document
976
- failed to be processed by the service.
977
-
978
- :ivar code: Error code. Possible values include:
979
- 'invalidRequest', 'invalidArgument', 'internalServerError',
980
- 'serviceUnavailable', 'invalidParameterValue', 'invalidRequestBodyFormat',
981
- 'emptyRequest', 'missingInputRecords', 'invalidDocument', 'modelVersionIncorrect',
982
- 'invalidDocumentBatch', 'unsupportedLanguageCode', 'invalidCountryHint'
983
- :vartype code: str
984
- :ivar message: Error message.
985
- :vartype message: str
986
- :ivar target: Error target.
987
- :vartype target: Optional[str]
988
- """
989
-
990
- def __init__(self, **kwargs):
991
- self.code = kwargs.get("code", None)
992
- self.message = kwargs.get("message", None)
993
- self.target = kwargs.get("target", None)
994
-
995
- @classmethod
996
- def _from_generated(cls, err):
997
- if err.innererror:
998
- return cls(
999
- code=err.innererror.code,
1000
- message=err.innererror.message,
1001
- target=err.innererror.target,
1002
- )
1003
- return cls(code=err.code, message=err.message, target=err.target)
1004
-
1005
- def __repr__(self):
1006
- return "TextAnalyticsError(code={}, message={}, target={})".format(
1007
- self.code, self.message, self.target
1008
- )[:1024]
1009
-
1010
-
1011
- class TextAnalyticsWarning(DictMixin):
1012
- """TextAnalyticsWarning contains the warning code and message that explains why
1013
- the response has a warning.
1014
-
1015
- :ivar code: Warning code. Possible values include: 'LongWordsInDocument',
1016
- 'DocumentTruncated'.
1017
- :vartype code: str
1018
- :ivar message: Warning message.
1019
- :vartype message: str
1020
- """
1021
-
1022
- def __init__(self, **kwargs):
1023
- self.code = kwargs.get("code", None)
1024
- self.message = kwargs.get("message", None)
1025
-
1026
- @classmethod
1027
- def _from_generated(cls, warning):
1028
- return cls(
1029
- code=warning.code,
1030
- message=warning.message,
1031
- )
1032
-
1033
- def __repr__(self):
1034
- return "TextAnalyticsWarning(code={}, message={})".format(
1035
- self.code, self.message
1036
- )[:1024]
1037
-
1038
-
1039
- class ExtractKeyPhrasesResult(DictMixin):
1040
- """ExtractKeyPhrasesResult is a result object which contains
1041
- the key phrases found in a particular document.
1042
-
1043
- :ivar id: Unique, non-empty document identifier that matches the
1044
- document id that was passed in with the request. If not specified
1045
- in the request, an id is assigned for the document.
1046
- :vartype id: str
1047
- :ivar key_phrases: A list of representative words or phrases.
1048
- The number of key phrases returned is proportional to the number of words
1049
- in the input document.
1050
- :vartype key_phrases: list[str]
1051
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
1052
- if there are warnings, but they may not be fully accurate.
1053
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
1054
- :ivar statistics: If `show_stats=True` was specified in the request this
1055
- field will contain information about the document payload.
1056
- :vartype statistics:
1057
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
1058
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
1059
- field will contain the DetectedLanguage for the document.
1060
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
1061
- :ivar bool is_error: Boolean check for error item when iterating over list of
1062
- results. Always False for an instance of a ExtractKeyPhrasesResult.
1063
- :ivar str kind: The text analysis kind - "KeyPhraseExtraction".
1064
-
1065
- .. versionadded:: 2022-10-01-preview
1066
- The *detected_language* property.
1067
- """
1068
-
1069
- def __init__(self, **kwargs):
1070
- self.id = kwargs.get("id", None)
1071
- self.key_phrases = kwargs.get("key_phrases", None)
1072
- self.warnings = kwargs.get("warnings", [])
1073
- self.statistics = kwargs.get("statistics", None)
1074
- self.detected_language = kwargs.get('detected_language', None)
1075
- self.is_error: Literal[False] = False
1076
- self.kind: Literal["KeyPhraseExtraction"] = "KeyPhraseExtraction"
1077
-
1078
- def __repr__(self):
1079
- return "ExtractKeyPhrasesResult(id={}, key_phrases={}, warnings={}, statistics={}, " \
1080
- "detected_language={}, is_error={})".format(
1081
- self.id,
1082
- self.key_phrases,
1083
- repr(self.warnings),
1084
- repr(self.statistics),
1085
- repr(self.detected_language),
1086
- self.is_error,
1087
- )[
1088
- :1024
1089
- ]
1090
-
1091
-
1092
- class RecognizeLinkedEntitiesResult(DictMixin):
1093
- """RecognizeLinkedEntitiesResult is a result object which contains
1094
- links to a well-known knowledge base, like for example, Wikipedia or Bing.
1095
-
1096
- :ivar id: Unique, non-empty document identifier that matches the
1097
- document id that was passed in with the request. If not specified
1098
- in the request, an id is assigned for the document.
1099
- :vartype id: str
1100
- :ivar entities: Recognized well-known entities in the document.
1101
- :vartype entities:
1102
- list[~azure.ai.textanalytics.LinkedEntity]
1103
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
1104
- if there are warnings, but they may not be fully accurate.
1105
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
1106
- :ivar statistics: If `show_stats=True` was specified in the request this
1107
- field will contain information about the document payload.
1108
- :vartype statistics:
1109
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
1110
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
1111
- field will contain the DetectedLanguage for the document.
1112
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
1113
- :ivar bool is_error: Boolean check for error item when iterating over list of
1114
- results. Always False for an instance of a RecognizeLinkedEntitiesResult.
1115
- :ivar str kind: The text analysis kind - "EntityLinking".
1116
-
1117
- .. versionadded:: 2022-10-01-preview
1118
- The *detected_language* property.
1119
- """
1120
-
1121
- def __init__(self, **kwargs):
1122
- self.id = kwargs.get("id", None)
1123
- self.entities = kwargs.get("entities", None)
1124
- self.warnings = kwargs.get("warnings", [])
1125
- self.statistics = kwargs.get("statistics", None)
1126
- self.detected_language = kwargs.get('detected_language', None)
1127
- self.is_error: Literal[False] = False
1128
- self.kind: Literal["EntityLinking"] = "EntityLinking"
1129
-
1130
- def __repr__(self):
1131
- return "RecognizeLinkedEntitiesResult(id={}, entities={}, warnings={}, statistics={}, " \
1132
- "detected_language={}, is_error={})".format(
1133
- self.id,
1134
- repr(self.entities),
1135
- repr(self.warnings),
1136
- repr(self.statistics),
1137
- repr(self.detected_language),
1138
- self.is_error,
1139
- )[
1140
- :1024
1141
- ]
1142
-
1143
-
1144
- class AnalyzeSentimentResult(DictMixin):
1145
- """AnalyzeSentimentResult is a result object which contains
1146
- the overall predicted sentiment and confidence scores for your document
1147
- and a per-sentence sentiment prediction with scores.
1148
-
1149
- :ivar id: Unique, non-empty document identifier that matches the
1150
- document id that was passed in with the request. If not specified
1151
- in the request, an id is assigned for the document.
1152
- :vartype id: str
1153
- :ivar sentiment: Predicted sentiment for document (Negative,
1154
- Neutral, Positive, or Mixed). Possible values include: 'positive',
1155
- 'neutral', 'negative', 'mixed'
1156
- :vartype sentiment: str
1157
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
1158
- if there are warnings, but they may not be fully accurate.
1159
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
1160
- :ivar statistics: If `show_stats=True` was specified in the request this
1161
- field will contain information about the document payload.
1162
- :vartype statistics:
1163
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
1164
- :ivar confidence_scores: Document level sentiment confidence
1165
- scores between 0 and 1 for each sentiment label.
1166
- :vartype confidence_scores:
1167
- ~azure.ai.textanalytics.SentimentConfidenceScores
1168
- :ivar sentences: Sentence level sentiment analysis.
1169
- :vartype sentences:
1170
- list[~azure.ai.textanalytics.SentenceSentiment]
1171
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
1172
- field will contain the DetectedLanguage for the document.
1173
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
1174
- :ivar bool is_error: Boolean check for error item when iterating over list of
1175
- results. Always False for an instance of a AnalyzeSentimentResult.
1176
- :ivar str kind: The text analysis kind - "SentimentAnalysis".
1177
-
1178
- .. versionadded:: 2022-10-01-preview
1179
- The *detected_language* property.
1180
- """
1181
-
1182
- def __init__(self, **kwargs):
1183
- self.id = kwargs.get("id", None)
1184
- self.sentiment = kwargs.get("sentiment", None)
1185
- self.warnings = kwargs.get("warnings", [])
1186
- self.statistics = kwargs.get("statistics", None)
1187
- self.confidence_scores = kwargs.get("confidence_scores", None)
1188
- self.sentences = kwargs.get("sentences", None)
1189
- self.detected_language = kwargs.get("detected_language", None)
1190
- self.is_error: Literal[False] = False
1191
- self.kind: Literal["SentimentAnalysis"] = "SentimentAnalysis"
1192
-
1193
- def __repr__(self):
1194
- return (
1195
- "AnalyzeSentimentResult(id={}, sentiment={}, warnings={}, statistics={}, confidence_scores={}, "
1196
- "sentences={}, detected_language={}, is_error={})".format(
1197
- self.id,
1198
- self.sentiment,
1199
- repr(self.warnings),
1200
- repr(self.statistics),
1201
- repr(self.confidence_scores),
1202
- repr(self.sentences),
1203
- repr(self.detected_language),
1204
- self.is_error,
1205
- )[:1024]
1206
- )
1207
-
1208
-
1209
- class TextDocumentStatistics(DictMixin):
1210
- """TextDocumentStatistics contains information about
1211
- the document payload.
1212
-
1213
- :ivar character_count: Number of text elements recognized in
1214
- the document.
1215
- :vartype character_count: int
1216
- :ivar transaction_count: Number of transactions for the document.
1217
- :vartype transaction_count: int
1218
- """
1219
-
1220
- def __init__(self, **kwargs):
1221
- self.character_count = kwargs.get("character_count", None)
1222
- self.transaction_count = kwargs.get("transaction_count", None)
1223
-
1224
- @classmethod
1225
- def _from_generated(cls, stats):
1226
- if stats is None:
1227
- return None
1228
- return cls(
1229
- character_count=stats.characters_count,
1230
- transaction_count=stats.transactions_count,
1231
- )
1232
-
1233
- def __repr__(self):
1234
- return (
1235
- "TextDocumentStatistics(character_count={}, transaction_count={})".format(
1236
- self.character_count, self.transaction_count
1237
- )[:1024]
1238
- )
1239
-
1240
-
1241
- class DocumentError(DictMixin):
1242
- """DocumentError is an error object which represents an error on
1243
- the individual document.
1244
-
1245
- :ivar id: Unique, non-empty document identifier that matches the
1246
- document id that was passed in with the request. If not specified
1247
- in the request, an id is assigned for the document.
1248
- :vartype id: str
1249
- :ivar error: The document error.
1250
- :vartype error: ~azure.ai.textanalytics.TextAnalyticsError
1251
- :ivar bool is_error: Boolean check for error item when iterating over list of
1252
- results. Always True for an instance of a DocumentError.
1253
- :ivar str kind: Error kind - "DocumentError".
1254
- """
1255
-
1256
- def __init__(self, **kwargs):
1257
- self.id = kwargs.get("id", None)
1258
- self.error = kwargs.get("error", None)
1259
- self.is_error: Literal[True] = True
1260
- self.kind: Literal["DocumentError"] = "DocumentError"
1261
-
1262
- def __getattr__(self, attr):
1263
- result_set = set()
1264
- result_set.update(
1265
- RecognizeEntitiesResult().keys()
1266
- + RecognizePiiEntitiesResult().keys()
1267
- + DetectLanguageResult().keys()
1268
- + RecognizeLinkedEntitiesResult().keys()
1269
- + AnalyzeSentimentResult().keys()
1270
- + ExtractKeyPhrasesResult().keys()
1271
- + AnalyzeHealthcareEntitiesResult().keys()
1272
- + RecognizeCustomEntitiesResult().keys()
1273
- + ClassifyDocumentResult().keys()
1274
- + ExtractSummaryResult().keys()
1275
- + AbstractSummaryResult().keys()
1276
- + DynamicClassificationResult().keys()
1277
- )
1278
- result_attrs = result_set.difference(DocumentError().keys())
1279
- if attr in result_attrs:
1280
- raise AttributeError(
1281
- "'DocumentError' object has no attribute '{}'. The service was unable to process this document:\n"
1282
- "Document Id: {}\nError: {} - {}\n".format(
1283
- attr, self.id, self.error.code, self.error.message
1284
- )
1285
- )
1286
- raise AttributeError(
1287
- f"'DocumentError' object has no attribute '{attr}'"
1288
- )
1289
-
1290
- @classmethod
1291
- def _from_generated(cls, doc_err):
1292
- return cls(
1293
- id=doc_err.id,
1294
- error=TextAnalyticsError._from_generated( # pylint: disable=protected-access
1295
- doc_err.error
1296
- ),
1297
- is_error=True,
1298
- )
1299
-
1300
- def __repr__(self):
1301
- return "DocumentError(id={}, error={}, is_error={})".format(
1302
- self.id, repr(self.error), self.is_error
1303
- )[:1024]
1304
-
1305
-
1306
- class DetectLanguageInput(LanguageInput):
1307
- """The input document to be analyzed for detecting language.
1308
-
1309
- :keyword str id: Required. Unique, non-empty document identifier.
1310
- :keyword str text: Required. The input text to process.
1311
- :keyword Optional[str] country_hint: A country hint to help better detect
1312
- the language of the text. Accepts two letter country codes
1313
- specified by ISO 3166-1 alpha-2. Defaults to "US". Pass
1314
- in the string "none" to not use a country_hint.
1315
- :ivar id: Required. Unique, non-empty document identifier.
1316
- :vartype id: str
1317
- :ivar text: Required. The input text to process.
1318
- :vartype text: str
1319
- :ivar country_hint: A country hint to help better detect
1320
- the language of the text. Accepts two letter country codes
1321
- specified by ISO 3166-1 alpha-2. Defaults to "US". Pass
1322
- in the string "none" to not use a country_hint.
1323
- :vartype country_hint: Optional[str]
1324
- """
1325
-
1326
- def __init__(self, **kwargs):
1327
- super().__init__(**kwargs)
1328
- self.id = kwargs.get("id", None)
1329
- self.text = kwargs.get("text", None)
1330
- self.country_hint = kwargs.get("country_hint", None)
1331
-
1332
- def __repr__(self):
1333
- return "DetectLanguageInput(id={}, text={}, country_hint={})".format(
1334
- self.id, self.text, self.country_hint
1335
- )[:1024]
1336
-
1337
-
1338
- class LinkedEntity(DictMixin):
1339
- """LinkedEntity contains a link to the well-known recognized
1340
- entity in text. The link comes from a data source like Wikipedia
1341
- or Bing. It additionally includes all of the matches of this
1342
- entity found in the document.
1343
-
1344
- :ivar name: Entity Linking formal name.
1345
- :vartype name: str
1346
- :ivar matches: List of instances this entity appears in the text.
1347
- :vartype matches:
1348
- list[~azure.ai.textanalytics.LinkedEntityMatch]
1349
- :ivar language: Language used in the data source.
1350
- :vartype language: str
1351
- :ivar data_source_entity_id: Unique identifier of the recognized entity from the data
1352
- source.
1353
- :vartype data_source_entity_id: Optional[str]
1354
- :ivar url: URL to the entity's page from the data source.
1355
- :vartype url: str
1356
- :ivar data_source: Data source used to extract entity linking,
1357
- such as Wiki/Bing etc.
1358
- :vartype data_source: str
1359
- :ivar Optional[str] bing_entity_search_api_id: Bing Entity Search unique identifier of the recognized entity.
1360
- Use in conjunction with the Bing Entity Search SDK to fetch additional relevant information.
1361
-
1362
- .. versionadded:: v3.1
1363
- The *bing_entity_search_api_id* property.
1364
- """
1365
-
1366
- def __init__(self, **kwargs):
1367
- self.name = kwargs.get("name", None)
1368
- self.matches = kwargs.get("matches", None)
1369
- self.language = kwargs.get("language", None)
1370
- self.data_source_entity_id = kwargs.get("data_source_entity_id", None)
1371
- self.url = kwargs.get("url", None)
1372
- self.data_source = kwargs.get("data_source", None)
1373
- self.bing_entity_search_api_id = kwargs.get("bing_entity_search_api_id", None)
1374
-
1375
- @classmethod
1376
- def _from_generated(cls, entity):
1377
- bing_entity_search_api_id = (
1378
- entity.bing_id if hasattr(entity, "bing_id") else None
1379
- )
1380
- return cls(
1381
- name=entity.name,
1382
- matches=[
1383
- LinkedEntityMatch._from_generated(e) # pylint: disable=protected-access
1384
- for e in entity.matches
1385
- ],
1386
- language=entity.language,
1387
- data_source_entity_id=entity.id,
1388
- url=entity.url,
1389
- data_source=entity.data_source,
1390
- bing_entity_search_api_id=bing_entity_search_api_id,
1391
- )
1392
-
1393
- def __repr__(self):
1394
- return (
1395
- "LinkedEntity(name={}, matches={}, language={}, data_source_entity_id={}, url={}, "
1396
- "data_source={}, bing_entity_search_api_id={})".format(
1397
- self.name,
1398
- repr(self.matches),
1399
- self.language,
1400
- self.data_source_entity_id,
1401
- self.url,
1402
- self.data_source,
1403
- self.bing_entity_search_api_id,
1404
- )[:1024]
1405
- )
1406
-
1407
-
1408
- class LinkedEntityMatch(DictMixin):
1409
- """A match for the linked entity found in text. Provides
1410
- the confidence score of the prediction and where the entity
1411
- was found in the text.
1412
-
1413
- :ivar confidence_score: If a well-known item is recognized, a
1414
- decimal number denoting the confidence level between 0 and 1 will be
1415
- returned.
1416
- :vartype confidence_score: float
1417
- :ivar text: Entity text as appears in the request.
1418
- :ivar int length: The linked entity match text length. This value depends on the value of the
1419
- `string_index_type` parameter set in the original request, which is UnicodeCodePoints by default.
1420
- :ivar int offset: The linked entity match text offset from the start of the document.
1421
- The value depends on the value of the `string_index_type` parameter
1422
- set in the original request, which is UnicodeCodePoints by default.
1423
- :vartype text: str
1424
-
1425
- .. versionadded:: v3.1
1426
- The *offset* and *length* properties.
1427
- """
1428
-
1429
- def __init__(self, **kwargs):
1430
- self.confidence_score = kwargs.get("confidence_score", None)
1431
- self.text = kwargs.get("text", None)
1432
- self.length = kwargs.get("length", None)
1433
- self.offset = kwargs.get("offset", None)
1434
-
1435
- @classmethod
1436
- def _from_generated(cls, match):
1437
- offset = match.offset
1438
- length = match.length
1439
- if isinstance(match, _v3_0_models.Match):
1440
- # we do not return offset for v3.0 since
1441
- # the correct encoding was not introduced for v3.0
1442
- offset = None
1443
- length = None
1444
- return cls(
1445
- confidence_score=match.confidence_score,
1446
- text=match.text,
1447
- length=length,
1448
- offset=offset,
1449
- )
1450
-
1451
- def __repr__(self):
1452
- return "LinkedEntityMatch(confidence_score={}, text={}, length={}, offset={})".format(
1453
- self.confidence_score, self.text, self.length, self.offset
1454
- )[
1455
- :1024
1456
- ]
1457
-
1458
-
1459
- class TextDocumentInput(DictMixin, MultiLanguageInput):
1460
- """The input document to be analyzed by the service.
1461
-
1462
- :keyword str id: Required. Unique, non-empty document identifier.
1463
- :keyword str text: Required. The input text to process.
1464
- :keyword str language: This is the 2 letter ISO 639-1 representation
1465
- of a language. For example, use "en" for English; "es" for Spanish etc.
1466
- For automatic language detection, use "auto" (Only supported by long-running
1467
- operation APIs with API version 2022-10-01-preview or newer). If
1468
- not set, uses "en" for English as default.
1469
- :ivar id: Required. Unique, non-empty document identifier.
1470
- :vartype id: str
1471
- :ivar text: Required. The input text to process.
1472
- :vartype text: str
1473
- :ivar language: This is the 2 letter ISO 639-1 representation
1474
- of a language. For example, use "en" for English; "es" for Spanish etc.
1475
- For automatic language detection, use "auto" (Only supported by long-running
1476
- operation APIs with API version 2022-10-01-preview or newer). If
1477
- not set, uses "en" for English as default.
1478
- :vartype language: Optional[str]
1479
-
1480
- .. versionadded:: 2022-10-01-preview
1481
- The 'auto' option for language.
1482
- """
1483
-
1484
- def __init__(self, **kwargs):
1485
- super().__init__(**kwargs)
1486
- self.id = kwargs.get("id", None)
1487
- self.text = kwargs.get("text", None)
1488
- self.language = kwargs.get("language", None)
1489
-
1490
- def __repr__(self):
1491
- return "TextDocumentInput(id={}, text={}, language={})".format(
1492
- self.id, self.text, self.language
1493
- )[:1024]
1494
-
1495
-
1496
- class TextDocumentBatchStatistics(DictMixin):
1497
- """TextDocumentBatchStatistics contains information about the
1498
- request payload. Note: This object is not returned
1499
- in the response and needs to be retrieved by a response hook.
1500
-
1501
- :ivar document_count: Number of documents submitted in the request.
1502
- :vartype document_count: int
1503
- :ivar valid_document_count: Number of valid documents. This
1504
- excludes empty, over-size limit or non-supported languages documents.
1505
- :vartype valid_document_count: int
1506
- :ivar erroneous_document_count: Number of invalid documents.
1507
- This includes empty, over-size limit or non-supported languages documents.
1508
- :vartype erroneous_document_count: int
1509
- :ivar transaction_count: Number of transactions for the request.
1510
- :vartype transaction_count: int
1511
- """
1512
-
1513
- def __init__(self, **kwargs):
1514
- self.document_count = kwargs.get("document_count", None)
1515
- self.valid_document_count = kwargs.get("valid_document_count", None)
1516
- self.erroneous_document_count = kwargs.get("erroneous_document_count", None)
1517
- self.transaction_count = kwargs.get("transaction_count", None)
1518
-
1519
- @classmethod
1520
- def _from_generated(cls, statistics):
1521
- if statistics is None:
1522
- return None
1523
- return cls(
1524
- document_count=statistics["documentsCount"],
1525
- valid_document_count=statistics["validDocumentsCount"],
1526
- erroneous_document_count=statistics["erroneousDocumentsCount"],
1527
- transaction_count=statistics["transactionsCount"],
1528
- )
1529
-
1530
- def __repr__(self):
1531
- return (
1532
- "TextDocumentBatchStatistics(document_count={}, valid_document_count={}, erroneous_document_count={}, "
1533
- "transaction_count={})".format(
1534
- self.document_count,
1535
- self.valid_document_count,
1536
- self.erroneous_document_count,
1537
- self.transaction_count,
1538
- )[:1024]
1539
- )
1540
-
1541
-
1542
- class SentenceSentiment(DictMixin):
1543
- """SentenceSentiment contains the predicted sentiment and
1544
- confidence scores for each individual sentence in the document.
1545
-
1546
- :ivar text: The sentence text.
1547
- :vartype text: str
1548
- :ivar sentiment: The predicted Sentiment for the sentence.
1549
- Possible values include: 'positive', 'neutral', 'negative'
1550
- :vartype sentiment: str
1551
- :ivar confidence_scores: The sentiment confidence score between 0
1552
- and 1 for the sentence for all labels.
1553
- :vartype confidence_scores:
1554
- ~azure.ai.textanalytics.SentimentConfidenceScores
1555
- :ivar int length: The sentence text length. This value depends on the value of the
1556
- `string_index_type` parameter set in the original request, which is UnicodeCodePoints
1557
- by default.
1558
- :ivar int offset: The sentence text offset from the start of the document.
1559
- The value depends on the value of the `string_index_type` parameter
1560
- set in the original request, which is UnicodeCodePoints by default.
1561
- :ivar mined_opinions: The list of opinions mined from this sentence.
1562
- For example in the sentence "The food is good, but the service is bad", we would
1563
- mine the two opinions "food is good" and "service is bad". Only returned
1564
- if `show_opinion_mining` is set to True in the call to `analyze_sentiment` and
1565
- api version is v3.1 and up.
1566
- :vartype mined_opinions:
1567
- Optional[list[~azure.ai.textanalytics.MinedOpinion]]
1568
-
1569
- .. versionadded:: v3.1
1570
- The *offset*, *length*, and *mined_opinions* properties.
1571
- """
1572
-
1573
- def __init__(self, **kwargs):
1574
- self.text = kwargs.get("text", None)
1575
- self.sentiment = kwargs.get("sentiment", None)
1576
- self.confidence_scores = kwargs.get("confidence_scores", None)
1577
- self.length = kwargs.get("length", None)
1578
- self.offset = kwargs.get("offset", None)
1579
- self.mined_opinions = kwargs.get("mined_opinions", None)
1580
-
1581
- @classmethod
1582
- def _from_generated(cls, sentence, results, sentiment):
1583
- offset = sentence.offset
1584
- length = sentence.length
1585
- if isinstance(sentence, _v3_0_models.SentenceSentiment):
1586
- # we do not return offset for v3.0 since
1587
- # the correct encoding was not introduced for v3.0
1588
- offset = None
1589
- length = None
1590
- if hasattr(sentence, "targets"):
1591
- mined_opinions = (
1592
- [
1593
- MinedOpinion._from_generated( # pylint: disable=protected-access
1594
- target, results, sentiment
1595
- )
1596
- for target in sentence.targets
1597
- ]
1598
- if sentence.targets
1599
- else []
1600
- )
1601
- else:
1602
- mined_opinions = None
1603
- return cls(
1604
- text=sentence.text,
1605
- sentiment=sentence.sentiment,
1606
- confidence_scores=SentimentConfidenceScores._from_generated( # pylint: disable=protected-access
1607
- sentence.confidence_scores
1608
- ),
1609
- length=length,
1610
- offset=offset,
1611
- mined_opinions=mined_opinions,
1612
- )
1613
-
1614
- def __repr__(self):
1615
- return (
1616
- "SentenceSentiment(text={}, sentiment={}, confidence_scores={}, "
1617
- "length={}, offset={}, mined_opinions={})".format(
1618
- self.text,
1619
- self.sentiment,
1620
- repr(self.confidence_scores),
1621
- self.length,
1622
- self.offset,
1623
- repr(self.mined_opinions),
1624
- )[:1024]
1625
- )
1626
-
1627
-
1628
- class MinedOpinion(DictMixin):
1629
- """A mined opinion object represents an opinion we've extracted from a sentence.
1630
- It consists of both a target that these opinions are about, and the assessments
1631
- representing the opinion.
1632
-
1633
- :ivar target: The target of an opinion about a product/service.
1634
- :vartype target: Optional[~azure.ai.textanalytics.TargetSentiment]
1635
- :ivar assessments: The assessments representing the opinion of the target.
1636
- :vartype assessments: Optional[list[~azure.ai.textanalytics.AssessmentSentiment]]
1637
- """
1638
-
1639
- def __init__(self, **kwargs):
1640
- self.target = kwargs.get("target", None)
1641
- self.assessments = kwargs.get("assessments", None)
1642
-
1643
- @staticmethod
1644
- def _get_assessments(
1645
- relations, results, sentiment
1646
- ): # pylint: disable=unused-argument
1647
- if not relations:
1648
- return []
1649
- assessment_relations = [
1650
- r.ref for r in relations if r.relation_type == "assessment"
1651
- ]
1652
- assessments = []
1653
- for assessment_relation in assessment_relations:
1654
- numbers = _get_indices(assessment_relation)
1655
- sentence_index = numbers[1]
1656
- assessment_index = numbers[2]
1657
- assessments.append(
1658
- sentiment.sentences[sentence_index].assessments[assessment_index]
1659
- )
1660
- return assessments
1661
-
1662
- @classmethod
1663
- def _from_generated(cls, target, results, sentiment):
1664
- return cls(
1665
- target=TargetSentiment._from_generated( # pylint: disable=protected-access
1666
- target
1667
- ),
1668
- assessments=[
1669
- AssessmentSentiment._from_generated( # pylint: disable=protected-access
1670
- assessment
1671
- )
1672
- for assessment in cls._get_assessments(
1673
- target.relations, results, sentiment
1674
- )
1675
- ],
1676
- )
1677
-
1678
- def __repr__(self):
1679
- return "MinedOpinion(target={}, assessments={})".format(
1680
- repr(self.target), repr(self.assessments)
1681
- )[:1024]
1682
-
1683
-
1684
- class TargetSentiment(DictMixin):
1685
- """TargetSentiment contains the predicted sentiment,
1686
- confidence scores and other information about a key component of a product/service.
1687
- For example in "The food at Hotel Foo is good", "food" is an key component of
1688
- "Hotel Foo".
1689
-
1690
- :ivar str text: The text value of the target.
1691
- :ivar str sentiment: The predicted Sentiment for the target. Possible values
1692
- include 'positive', 'mixed', and 'negative'.
1693
- :ivar confidence_scores: The sentiment confidence score between 0
1694
- and 1 for the target for 'positive' and 'negative' labels. It's score
1695
- for 'neutral' will always be 0
1696
- :vartype confidence_scores:
1697
- ~azure.ai.textanalytics.SentimentConfidenceScores
1698
- :ivar int length: The target text length. This value depends on the value of the
1699
- `string_index_type` parameter set in the original request, which is UnicodeCodePoints
1700
- by default.
1701
- :ivar int offset: The target text offset from the start of the document.
1702
- The value depends on the value of the `string_index_type` parameter
1703
- set in the original request, which is UnicodeCodePoints by default.
1704
- """
1705
-
1706
- def __init__(self, **kwargs):
1707
- self.text = kwargs.get("text", None)
1708
- self.sentiment = kwargs.get("sentiment", None)
1709
- self.confidence_scores = kwargs.get("confidence_scores", None)
1710
- self.length = kwargs.get("length", None)
1711
- self.offset = kwargs.get("offset", None)
1712
-
1713
- @classmethod
1714
- def _from_generated(cls, target):
1715
- return cls(
1716
- text=target.text,
1717
- sentiment=target.sentiment,
1718
- confidence_scores=SentimentConfidenceScores._from_generated( # pylint: disable=protected-access
1719
- target.confidence_scores
1720
- ),
1721
- length=target.length,
1722
- offset=target.offset,
1723
- )
1724
-
1725
- def __repr__(self):
1726
- return (
1727
- "TargetSentiment(text={}, sentiment={}, confidence_scores={}, "
1728
- "length={}, offset={})".format(
1729
- self.text,
1730
- self.sentiment,
1731
- repr(self.confidence_scores),
1732
- self.length,
1733
- self.offset,
1734
- )[:1024]
1735
- )
1736
-
1737
-
1738
- class AssessmentSentiment(DictMixin):
1739
- """AssessmentSentiment contains the predicted sentiment,
1740
- confidence scores and other information about an assessment given about
1741
- a particular target. For example, in the sentence "The food is good", the assessment
1742
- of the target 'food' is 'good'.
1743
-
1744
- :ivar str text: The assessment text.
1745
- :ivar str sentiment: The predicted Sentiment for the assessment. Possible values
1746
- include 'positive', 'mixed', and 'negative'.
1747
- :ivar confidence_scores: The sentiment confidence score between 0
1748
- and 1 for the assessment for 'positive' and 'negative' labels. It's score
1749
- for 'neutral' will always be 0
1750
- :vartype confidence_scores:
1751
- ~azure.ai.textanalytics.SentimentConfidenceScores
1752
- :ivar int length: The assessment text length. This value depends on the value of the
1753
- `string_index_type` parameter set in the original request, which is UnicodeCodePoints
1754
- by default.
1755
- :ivar int offset: The assessment text offset from the start of the document.
1756
- The value depends on the value of the `string_index_type` parameter
1757
- set in the original request, which is UnicodeCodePoints by default.
1758
- :ivar bool is_negated: Whether the value of the assessment is negated. For example, in
1759
- "The food is not good", the assessment "good" is negated.
1760
- """
1761
-
1762
- def __init__(self, **kwargs):
1763
- self.text = kwargs.get("text", None)
1764
- self.sentiment = kwargs.get("sentiment", None)
1765
- self.confidence_scores = kwargs.get("confidence_scores", None)
1766
- self.length = kwargs.get("length", None)
1767
- self.offset = kwargs.get("offset", None)
1768
- self.is_negated = kwargs.get("is_negated", None)
1769
-
1770
- @classmethod
1771
- def _from_generated(cls, assessment):
1772
- return cls(
1773
- text=assessment.text,
1774
- sentiment=assessment.sentiment,
1775
- confidence_scores=SentimentConfidenceScores._from_generated( # pylint: disable=protected-access
1776
- assessment.confidence_scores
1777
- ),
1778
- length=assessment.length,
1779
- offset=assessment.offset,
1780
- is_negated=assessment.is_negated,
1781
- )
1782
-
1783
- def __repr__(self):
1784
- return (
1785
- "AssessmentSentiment(text={}, sentiment={}, confidence_scores={}, length={}, offset={}, "
1786
- "is_negated={})".format(
1787
- self.text,
1788
- self.sentiment,
1789
- repr(self.confidence_scores),
1790
- self.length,
1791
- self.offset,
1792
- self.is_negated,
1793
- )[:1024]
1794
- )
1795
-
1796
-
1797
- class SentimentConfidenceScores(DictMixin):
1798
- """The confidence scores (Softmax scores) between 0 and 1.
1799
- Higher values indicate higher confidence.
1800
-
1801
- :ivar positive: Positive score.
1802
- :vartype positive: float
1803
- :ivar neutral: Neutral score.
1804
- :vartype neutral: float
1805
- :ivar negative: Negative score.
1806
- :vartype negative: float
1807
- """
1808
-
1809
- def __init__(self, **kwargs):
1810
- self.positive = kwargs.get("positive", 0.0)
1811
- self.neutral = kwargs.get("neutral", 0.0)
1812
- self.negative = kwargs.get("negative", 0.0)
1813
-
1814
- @classmethod
1815
- def _from_generated(cls, score):
1816
- return cls(
1817
- positive=score.positive,
1818
- neutral=score.neutral if hasattr(score, "neutral") else 0.0,
1819
- negative=score.negative,
1820
- )
1821
-
1822
- def __repr__(self):
1823
- return "SentimentConfidenceScores(positive={}, neutral={}, negative={})".format(
1824
- self.positive, self.neutral, self.negative
1825
- )[:1024]
1826
-
1827
-
1828
- class _AnalyzeActionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1829
- """The type of action that was applied to the documents"""
1830
-
1831
- RECOGNIZE_ENTITIES = "recognize_entities" #: Entities Recognition action.
1832
- RECOGNIZE_PII_ENTITIES = (
1833
- "recognize_pii_entities" #: PII Entities Recognition action.
1834
- )
1835
- EXTRACT_KEY_PHRASES = "extract_key_phrases" #: Key Phrase Extraction action.
1836
- RECOGNIZE_LINKED_ENTITIES = (
1837
- "recognize_linked_entities" #: Linked Entities Recognition action.
1838
- )
1839
- ANALYZE_SENTIMENT = "analyze_sentiment" #: Sentiment Analysis action.
1840
- RECOGNIZE_CUSTOM_ENTITIES = "recognize_custom_entities"
1841
- SINGLE_LABEL_CLASSIFY = "single_label_classify"
1842
- MULTI_LABEL_CLASSIFY = "multi_label_classify"
1843
- ANALYZE_HEALTHCARE_ENTITIES = "analyze_healthcare_entities"
1844
- EXTRACT_SUMMARY = "extract_summary"
1845
- ABSTRACT_SUMMARY = "abstract_summary"
1846
-
1847
-
1848
- class ActionPointerKind(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1849
- """v3.1 only"""
1850
- RECOGNIZE_ENTITIES = "entityRecognitionTasks"
1851
- RECOGNIZE_PII_ENTITIES = "piiEntityRecognitionTasks"
1852
- EXTRACT_KEY_PHRASES = "keyPhraseExtractionTasks"
1853
- RECOGNIZE_LINKED_ENTITIES = "entityLinkingTasks"
1854
- ANALYZE_SENTIMENT = "sentimentAnalysisTasks"
1855
-
1856
-
1857
- class RecognizeEntitiesAction(DictMixin):
1858
- """RecognizeEntitiesAction encapsulates the parameters for starting a long-running Entities Recognition operation.
1859
-
1860
- If you just want to recognize entities in a list of documents, and not perform multiple
1861
- long running actions on the input of documents, call method `recognize_entities` instead
1862
- of interfacing with this model.
1863
-
1864
- :keyword Optional[str] model_version: The model version to use for the analysis.
1865
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
1866
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
1867
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
1868
- see https://aka.ms/text-analytics-offsets
1869
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
1870
- logged on the service side for troubleshooting. By default, the Language service logs your
1871
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1872
- the service's natural language processing functions. Setting this parameter to true,
1873
- disables input logging and may limit our ability to remediate issues that occur. Please see
1874
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1875
- additional details, and Microsoft Responsible AI principles at
1876
- https://www.microsoft.com/ai/responsible-ai.
1877
- :ivar Optional[str] model_version: The model version to use for the analysis.
1878
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
1879
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
1880
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
1881
- see https://aka.ms/text-analytics-offsets
1882
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
1883
- logged on the service side for troubleshooting. By default, the Language service logs your
1884
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1885
- the service's natural language processing functions. Setting this parameter to true,
1886
- disables input logging and may limit our ability to remediate issues that occur. Please see
1887
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1888
- additional details, and Microsoft Responsible AI principles at
1889
- https://www.microsoft.com/ai/responsible-ai.
1890
- """
1891
-
1892
- def __init__(self, **kwargs):
1893
- self.model_version = kwargs.get("model_version", None)
1894
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
1895
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
1896
-
1897
- def __repr__(self, **kwargs):
1898
- return "RecognizeEntitiesAction(model_version={}, string_index_type={}, disable_service_logs={})".format(
1899
- self.model_version, self.string_index_type, self.disable_service_logs
1900
- )[
1901
- :1024
1902
- ]
1903
-
1904
- def _to_generated(self, api_version, task_id):
1905
- if is_language_api(api_version):
1906
- return _v2022_10_01_preview_models.EntitiesLROTask(
1907
- task_name=task_id,
1908
- parameters=_v2022_10_01_preview_models.EntitiesTaskParameters(
1909
- model_version=self.model_version,
1910
- string_index_type=string_index_type_compatibility(self.string_index_type),
1911
- logging_opt_out=self.disable_service_logs,
1912
- )
1913
- )
1914
-
1915
- return _v3_1_models.EntitiesTask(
1916
- parameters=_v3_1_models.EntitiesTaskParameters(
1917
- model_version=self.model_version,
1918
- string_index_type=self.string_index_type,
1919
- logging_opt_out=self.disable_service_logs,
1920
- ),
1921
- task_name=task_id
1922
- )
1923
-
1924
-
1925
- class AnalyzeSentimentAction(DictMixin):
1926
- """AnalyzeSentimentAction encapsulates the parameters for starting a long-running
1927
- Sentiment Analysis operation.
1928
-
1929
- If you just want to analyze sentiment in a list of documents, and not perform multiple
1930
- long running actions on the input of documents, call method `analyze_sentiment` instead
1931
- of interfacing with this model.
1932
-
1933
- :keyword Optional[str] model_version: The model version to use for the analysis.
1934
- :keyword Optional[bool] show_opinion_mining: Whether to mine the opinions of a sentence and conduct more
1935
- granular analysis around the aspects of a product or service (also known as
1936
- aspect-based sentiment analysis). If set to true, the returned
1937
- :class:`~azure.ai.textanalytics.SentenceSentiment` objects
1938
- will have property `mined_opinions` containing the result of this analysis.
1939
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
1940
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
1941
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
1942
- see https://aka.ms/text-analytics-offsets
1943
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
1944
- logged on the service side for troubleshooting. By default, the Language service logs your
1945
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1946
- the service's natural language processing functions. Setting this parameter to true,
1947
- disables input logging and may limit our ability to remediate issues that occur. Please see
1948
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1949
- additional details, and Microsoft Responsible AI principles at
1950
- https://www.microsoft.com/ai/responsible-ai.
1951
- :ivar Optional[str] model_version: The model version to use for the analysis.
1952
- :ivar Optional[bool] show_opinion_mining: Whether to mine the opinions of a sentence and conduct more
1953
- granular analysis around the aspects of a product or service (also known as
1954
- aspect-based sentiment analysis). If set to true, the returned
1955
- :class:`~azure.ai.textanalytics.SentenceSentiment` objects
1956
- will have property `mined_opinions` containing the result of this analysis.
1957
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
1958
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
1959
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
1960
- see https://aka.ms/text-analytics-offsets
1961
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
1962
- logged on the service side for troubleshooting. By default, the Language service logs your
1963
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1964
- the service's natural language processing functions. Setting this parameter to true,
1965
- disables input logging and may limit our ability to remediate issues that occur. Please see
1966
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1967
- additional details, and Microsoft Responsible AI principles at
1968
- https://www.microsoft.com/ai/responsible-ai.
1969
- """
1970
-
1971
- def __init__(self, **kwargs):
1972
- self.model_version = kwargs.get("model_version", None)
1973
- self.show_opinion_mining = kwargs.get("show_opinion_mining", None)
1974
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
1975
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
1976
-
1977
- def __repr__(self, **kwargs):
1978
- return (
1979
- "AnalyzeSentimentAction(model_version={}, show_opinion_mining={}, string_index_type={}, "
1980
- "disable_service_logs={}".format(
1981
- self.model_version,
1982
- self.show_opinion_mining,
1983
- self.string_index_type,
1984
- self.disable_service_logs,
1985
- )[:1024]
1986
- )
1987
-
1988
- def _to_generated(self, api_version, task_id):
1989
- if is_language_api(api_version):
1990
- return _v2022_10_01_preview_models.SentimentAnalysisLROTask(
1991
- task_name=task_id,
1992
- parameters=_v2022_10_01_preview_models.SentimentAnalysisTaskParameters(
1993
- model_version=self.model_version,
1994
- opinion_mining=self.show_opinion_mining,
1995
- string_index_type=string_index_type_compatibility(self.string_index_type),
1996
- logging_opt_out=self.disable_service_logs,
1997
- )
1998
- )
1999
- return _v3_1_models.SentimentAnalysisTask(
2000
- parameters=_v3_1_models.SentimentAnalysisTaskParameters(
2001
- model_version=self.model_version,
2002
- opinion_mining=self.show_opinion_mining,
2003
- string_index_type=self.string_index_type,
2004
- logging_opt_out=self.disable_service_logs,
2005
- ),
2006
- task_name=task_id
2007
- )
2008
-
2009
-
2010
- class RecognizePiiEntitiesAction(DictMixin):
2011
- """RecognizePiiEntitiesAction encapsulates the parameters for starting a long-running PII
2012
- Entities Recognition operation.
2013
-
2014
- If you just want to recognize pii entities in a list of documents, and not perform multiple
2015
- long running actions on the input of documents, call method `recognize_pii_entities` instead
2016
- of interfacing with this model.
2017
-
2018
- :keyword Optional[str] model_version: The model version to use for the analysis.
2019
- :keyword Optional[str] domain_filter: An optional string to set the PII domain to include only a
2020
- subset of the PII entity categories. Possible values include 'phi' or None.
2021
- :keyword categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
2022
- the specific PII entity categories you want to filter out. For example, if you only want to filter out
2023
- U.S. social security numbers in a document, you can pass in
2024
- `[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
2025
- :paramtype categories_filter: Optional[list[str or ~azure.ai.textanalytics.PiiEntityCategory]]
2026
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2027
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2028
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2029
- see https://aka.ms/text-analytics-offsets
2030
- :keyword Optional[bool] disable_service_logs: Defaults to true, meaning that the Language service will not log your
2031
- input text on the service side for troubleshooting. If set to False, the Language service logs your
2032
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2033
- the service's natural language processing functions. Please see
2034
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2035
- additional details, and Microsoft Responsible AI principles at
2036
- https://www.microsoft.com/ai/responsible-ai.
2037
- :ivar Optional[str] model_version: The model version to use for the analysis.
2038
- :ivar Optional[str] domain_filter: An optional string to set the PII domain to include only a
2039
- subset of the PII entity categories. Possible values include 'phi' or None.
2040
- :ivar categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
2041
- the specific PII entity categories you want to filter out. For example, if you only want to filter out
2042
- U.S. social security numbers in a document, you can pass in
2043
- `[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
2044
- :vartype categories_filter: Optional[list[str or ~azure.ai.textanalytics.PiiEntityCategory]]
2045
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2046
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2047
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2048
- see https://aka.ms/text-analytics-offsets
2049
- :ivar Optional[bool] disable_service_logs: Defaults to true, meaning that the Language service will not log your
2050
- input text on the service side for troubleshooting. If set to False, the Language service logs your
2051
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2052
- the service's natural language processing functions. Please see
2053
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2054
- additional details, and Microsoft Responsible AI principles at
2055
- https://www.microsoft.com/ai/responsible-ai.
2056
- """
2057
-
2058
- def __init__(self, **kwargs):
2059
- self.model_version = kwargs.get("model_version", None)
2060
- self.domain_filter = kwargs.get("domain_filter", None)
2061
- self.categories_filter = kwargs.get("categories_filter", None)
2062
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
2063
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
2064
-
2065
- def __repr__(self, **kwargs):
2066
- return (
2067
- "RecognizePiiEntitiesAction(model_version={}, domain_filter={}, categories_filter={}, "
2068
- "string_index_type={}, disable_service_logs={}".format(
2069
- self.model_version,
2070
- self.domain_filter,
2071
- self.categories_filter,
2072
- self.string_index_type,
2073
- self.disable_service_logs,
2074
- )[:1024]
2075
- )
2076
-
2077
- def _to_generated(self, api_version, task_id):
2078
- if is_language_api(api_version):
2079
- return _v2022_10_01_preview_models.PiiLROTask(
2080
- task_name=task_id,
2081
- parameters=_v2022_10_01_preview_models.PiiTaskParameters(
2082
- model_version=self.model_version,
2083
- domain=self.domain_filter,
2084
- pii_categories=self.categories_filter,
2085
- string_index_type=string_index_type_compatibility(self.string_index_type),
2086
- logging_opt_out=self.disable_service_logs,
2087
- )
2088
- )
2089
-
2090
- return _v3_1_models.PiiTask(
2091
- parameters=_v3_1_models.PiiTaskParameters(
2092
- model_version=self.model_version,
2093
- domain=self.domain_filter,
2094
- pii_categories=self.categories_filter,
2095
- string_index_type=self.string_index_type,
2096
- logging_opt_out=self.disable_service_logs,
2097
- ),
2098
- task_name=task_id
2099
- )
2100
-
2101
-
2102
- class ExtractKeyPhrasesAction(DictMixin):
2103
- """ExtractKeyPhrasesAction encapsulates the parameters for starting a long-running key phrase
2104
- extraction operation
2105
-
2106
- If you just want to extract key phrases from a list of documents, and not perform multiple
2107
- long running actions on the input of documents, call method `extract_key_phrases` instead
2108
- of interfacing with this model.
2109
-
2110
- :keyword Optional[str] model_version: The model version to use for the analysis.
2111
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2112
- logged on the service side for troubleshooting. By default, the Language service logs your
2113
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2114
- the service's natural language processing functions. Setting this parameter to true,
2115
- disables input logging and may limit our ability to remediate issues that occur. Please see
2116
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2117
- additional details, and Microsoft Responsible AI principles at
2118
- https://www.microsoft.com/ai/responsible-ai.
2119
- :ivar Optional[str] model_version: The model version to use for the analysis.
2120
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2121
- logged on the service side for troubleshooting. By default, the Language service logs your
2122
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2123
- the service's natural language processing functions. Setting this parameter to true,
2124
- disables input logging and may limit our ability to remediate issues that occur. Please see
2125
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2126
- additional details, and Microsoft Responsible AI principles at
2127
- https://www.microsoft.com/ai/responsible-ai.
2128
- """
2129
-
2130
- def __init__(self, **kwargs):
2131
- self.model_version = kwargs.get("model_version", None)
2132
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
2133
-
2134
- def __repr__(self, **kwargs):
2135
- return (
2136
- "ExtractKeyPhrasesAction(model_version={}, disable_service_logs={})".format(
2137
- self.model_version, self.disable_service_logs
2138
- )[:1024]
2139
- )
2140
-
2141
- def _to_generated(self, api_version, task_id):
2142
- if is_language_api(api_version):
2143
- return _v2022_10_01_preview_models.KeyPhraseLROTask(
2144
- task_name=task_id,
2145
- parameters=_v2022_10_01_preview_models.KeyPhraseTaskParameters(
2146
- model_version=self.model_version,
2147
- logging_opt_out=self.disable_service_logs,
2148
- )
2149
- )
2150
-
2151
- return _v3_1_models.KeyPhrasesTask(
2152
- parameters=_v3_1_models.KeyPhrasesTaskParameters(
2153
- model_version=self.model_version,
2154
- logging_opt_out=self.disable_service_logs,
2155
- ),
2156
- task_name=task_id
2157
- )
2158
-
2159
-
2160
- class RecognizeLinkedEntitiesAction(DictMixin):
2161
- """RecognizeLinkedEntitiesAction encapsulates the parameters for starting a long-running Linked Entities
2162
- Recognition operation.
2163
-
2164
- If you just want to recognize linked entities in a list of documents, and not perform multiple
2165
- long running actions on the input of documents, call method `recognize_linked_entities` instead
2166
- of interfacing with this model.
2167
-
2168
- :keyword Optional[str] model_version: The model version to use for the analysis.
2169
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2170
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2171
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2172
- see https://aka.ms/text-analytics-offsets
2173
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2174
- logged on the service side for troubleshooting. By default, the Language service logs your
2175
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2176
- the service's natural language processing functions. Setting this parameter to true,
2177
- disables input logging and may limit our ability to remediate issues that occur. Please see
2178
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2179
- additional details, and Microsoft Responsible AI principles at
2180
- https://www.microsoft.com/ai/responsible-ai.
2181
- :ivar Optional[str] model_version: The model version to use for the analysis.
2182
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2183
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2184
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2185
- see https://aka.ms/text-analytics-offsets
2186
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2187
- logged on the service side for troubleshooting. By default, the Language service logs your
2188
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2189
- the service's natural language processing functions. Setting this parameter to true,
2190
- disables input logging and may limit our ability to remediate issues that occur. Please see
2191
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2192
- additional details, and Microsoft Responsible AI principles at
2193
- https://www.microsoft.com/ai/responsible-ai.
2194
- """
2195
-
2196
- def __init__(self, **kwargs):
2197
- self.model_version = kwargs.get("model_version", None)
2198
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
2199
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
2200
-
2201
- def __repr__(self, **kwargs):
2202
- return (
2203
- "RecognizeLinkedEntitiesAction(model_version={}, string_index_type={}), "
2204
- "disable_service_logs={}".format(
2205
- self.model_version, self.string_index_type, self.disable_service_logs
2206
- )[:1024]
2207
- )
2208
-
2209
- def _to_generated(self, api_version, task_id):
2210
- if is_language_api(api_version):
2211
- return _v2022_10_01_preview_models.EntityLinkingLROTask(
2212
- task_name=task_id,
2213
- parameters=_v2022_10_01_preview_models.EntityLinkingTaskParameters(
2214
- model_version=self.model_version,
2215
- string_index_type=string_index_type_compatibility(self.string_index_type),
2216
- logging_opt_out=self.disable_service_logs,
2217
- )
2218
- )
2219
-
2220
- return _v3_1_models.EntityLinkingTask(
2221
- parameters=_v3_1_models.EntityLinkingTaskParameters(
2222
- model_version=self.model_version,
2223
- string_index_type=self.string_index_type,
2224
- logging_opt_out=self.disable_service_logs,
2225
- ),
2226
- task_name=task_id
2227
- )
2228
-
2229
-
2230
- class RecognizeCustomEntitiesAction(DictMixin):
2231
- """RecognizeCustomEntitiesAction encapsulates the parameters for starting a long-running custom entity
2232
- recognition operation. For information on regional support of custom features and how to train a model to
2233
- recognize custom entities, see https://aka.ms/azsdk/textanalytics/customentityrecognition
2234
-
2235
- :param str project_name: Required. This field indicates the project name for the model.
2236
- :param str deployment_name: This field indicates the deployment name for the model.
2237
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2238
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2239
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2240
- see https://aka.ms/text-analytics-offsets
2241
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2242
- logged on the service side for troubleshooting. By default, the Language service logs your
2243
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2244
- the service's natural language processing functions. Setting this parameter to true,
2245
- disables input logging and may limit our ability to remediate issues that occur. Please see
2246
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2247
- additional details, and Microsoft Responsible AI principles at
2248
- https://www.microsoft.com/ai/responsible-ai.
2249
- :ivar str project_name: This field indicates the project name for the model.
2250
- :ivar str deployment_name: This field indicates the deployment name for the model.
2251
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2252
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2253
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2254
- see https://aka.ms/text-analytics-offsets
2255
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2256
- logged on the service side for troubleshooting. By default, the Language service logs your
2257
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2258
- the service's natural language processing functions. Setting this parameter to true,
2259
- disables input logging and may limit our ability to remediate issues that occur. Please see
2260
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2261
- additional details, and Microsoft Responsible AI principles at
2262
- https://www.microsoft.com/ai/responsible-ai.
2263
-
2264
- .. versionadded:: 2022-05-01
2265
- The *RecognizeCustomEntitiesAction* model.
2266
- """
2267
-
2268
- def __init__(
2269
- self,
2270
- project_name: str,
2271
- deployment_name: str,
2272
- **kwargs
2273
- ) -> None:
2274
- self.project_name = project_name
2275
- self.deployment_name = deployment_name
2276
- self.disable_service_logs = kwargs.get('disable_service_logs', None)
2277
- self.string_index_type = kwargs.get('string_index_type', "UnicodeCodePoint")
2278
-
2279
- def __repr__(self):
2280
- return "RecognizeCustomEntitiesAction(project_name={}, deployment_name={}, disable_service_logs={}, " \
2281
- "string_index_type={})".format(
2282
- self.project_name,
2283
- self.deployment_name,
2284
- self.disable_service_logs,
2285
- self.string_index_type,
2286
- )[:1024]
2287
-
2288
- def _to_generated(self, api_version, task_id): # pylint: disable=unused-argument
2289
- return _v2022_10_01_preview_models.CustomEntitiesLROTask(
2290
- task_name=task_id,
2291
- parameters=_v2022_10_01_preview_models.CustomEntitiesTaskParameters(
2292
- project_name=self.project_name,
2293
- deployment_name=self.deployment_name,
2294
- string_index_type=string_index_type_compatibility(self.string_index_type),
2295
- logging_opt_out=self.disable_service_logs,
2296
- )
2297
- )
2298
-
2299
-
2300
- class RecognizeCustomEntitiesResult(DictMixin):
2301
- """RecognizeCustomEntitiesResult is a result object which contains
2302
- the custom recognized entities from a particular document.
2303
-
2304
- :ivar str id: Unique, non-empty document identifier that matches the
2305
- document id that was passed in with the request. If not specified
2306
- in the request, an id is assigned for the document.
2307
- :ivar entities: Recognized custom entities in the document.
2308
- :vartype entities:
2309
- list[~azure.ai.textanalytics.CategorizedEntity]
2310
- :ivar warnings: Warnings encountered while processing document.
2311
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
2312
- :ivar statistics: If `show_stats=True` was specified in the request this
2313
- field will contain information about the document payload.
2314
- :vartype statistics: Optional[~azure.ai.textanalytics.TextDocumentStatistics]
2315
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
2316
- field will contain the DetectedLanguage for the document.
2317
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
2318
- :ivar bool is_error: Boolean check for error item when iterating over list of
2319
- results. Always False for an instance of a RecognizeCustomEntitiesResult.
2320
- :ivar str kind: The text analysis kind - "CustomEntityRecognition".
2321
-
2322
- .. versionadded:: 2022-10-01-preview
2323
- The *detected_language* property.
2324
- """
2325
-
2326
- def __init__(self, **kwargs):
2327
- self.id = kwargs.get("id", None)
2328
- self.entities = kwargs.get("entities", None)
2329
- self.warnings = kwargs.get("warnings", [])
2330
- self.statistics = kwargs.get("statistics", None)
2331
- self.detected_language = kwargs.get("detected_language", None)
2332
- self.is_error: Literal[False] = False
2333
- self.kind: Literal["CustomEntityRecognition"] = "CustomEntityRecognition"
2334
-
2335
- def __repr__(self):
2336
- return "RecognizeCustomEntitiesResult(id={}, entities={}, warnings={}, statistics={}, " \
2337
- "detected_language={}, is_error={})".format(
2338
- self.id,
2339
- repr(self.entities),
2340
- repr(self.warnings),
2341
- repr(self.statistics),
2342
- repr(self.detected_language),
2343
- self.is_error,
2344
- )[
2345
- :1024
2346
- ]
2347
-
2348
- @classmethod
2349
- def _from_generated(cls, result):
2350
- return cls(
2351
- id=result.id,
2352
- entities=[
2353
- CategorizedEntity._from_generated(e) # pylint: disable=protected-access
2354
- for e in result.entities
2355
- ],
2356
- warnings=[
2357
- TextAnalyticsWarning._from_generated( # pylint: disable=protected-access
2358
- w
2359
- )
2360
- for w in result.warnings
2361
- ],
2362
- statistics=TextDocumentStatistics._from_generated( # pylint: disable=protected-access
2363
- result.statistics
2364
- ),
2365
- detected_language=DetectedLanguage._from_generated( # pylint: disable=protected-access
2366
- result.detected_language
2367
- ) if hasattr(result, "detected_language") and result.detected_language else None
2368
- )
2369
-
2370
-
2371
- class MultiLabelClassifyAction(DictMixin):
2372
- """MultiLabelClassifyAction encapsulates the parameters for starting a long-running custom multi label
2373
- classification operation. For information on regional support of custom features and how to train a model to
2374
- classify your documents, see https://aka.ms/azsdk/textanalytics/customfunctionalities
2375
-
2376
- :param str project_name: Required. This field indicates the project name for the model.
2377
- :param str deployment_name: Required. This field indicates the deployment name for the model.
2378
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2379
- logged on the service side for troubleshooting. By default, the Language service logs your
2380
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2381
- the service's natural language processing functions. Setting this parameter to true,
2382
- disables input logging and may limit our ability to remediate issues that occur. Please see
2383
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2384
- additional details, and Microsoft Responsible AI principles at
2385
- https://www.microsoft.com/ai/responsible-ai.
2386
- :ivar str project_name: This field indicates the project name for the model.
2387
- :ivar str deployment_name: This field indicates the deployment name for the model.
2388
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2389
- logged on the service side for troubleshooting. By default, the Language service logs your
2390
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2391
- the service's natural language processing functions. Setting this parameter to true,
2392
- disables input logging and may limit our ability to remediate issues that occur. Please see
2393
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2394
- additional details, and Microsoft Responsible AI principles at
2395
- https://www.microsoft.com/ai/responsible-ai.
2396
-
2397
- .. versionadded:: 2022-05-01
2398
- The *MultiLabelClassifyAction* model.
2399
- """
2400
-
2401
- def __init__(
2402
- self,
2403
- project_name: str,
2404
- deployment_name: str,
2405
- **kwargs
2406
- ) -> None:
2407
- self.project_name = project_name
2408
- self.deployment_name = deployment_name
2409
- self.disable_service_logs = kwargs.get('disable_service_logs', None)
2410
-
2411
- def __repr__(self):
2412
- return "MultiLabelClassifyAction(project_name={}, deployment_name={}, " \
2413
- "disable_service_logs={})".format(
2414
- self.project_name,
2415
- self.deployment_name,
2416
- self.disable_service_logs,
2417
- )[:1024]
2418
-
2419
- def _to_generated(self, api_version, task_id): # pylint: disable=unused-argument
2420
- return _v2022_10_01_preview_models.CustomMultiLabelClassificationLROTask(
2421
- task_name=task_id,
2422
- parameters=_v2022_10_01_preview_models.CustomMultiLabelClassificationTaskParameters(
2423
- project_name=self.project_name,
2424
- deployment_name=self.deployment_name,
2425
- logging_opt_out=self.disable_service_logs,
2426
- )
2427
- )
2428
-
2429
-
2430
- class ClassifyDocumentResult(DictMixin):
2431
- """ClassifyDocumentResult is a result object which contains
2432
- the classifications for a particular document.
2433
-
2434
- :ivar str id: Unique, non-empty document identifier.
2435
- :ivar classifications: Recognized classification results in the document.
2436
- :vartype classifications: list[~azure.ai.textanalytics.ClassificationCategory]
2437
- :ivar warnings: Warnings encountered while processing document.
2438
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
2439
- :ivar statistics: If `show_stats=True` was specified in the request this
2440
- field will contain information about the document payload.
2441
- :vartype statistics: Optional[~azure.ai.textanalytics.TextDocumentStatistics]
2442
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
2443
- field will contain the DetectedLanguage for the document.
2444
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
2445
- :ivar bool is_error: Boolean check for error item when iterating over list of
2446
- results. Always False for an instance of a ClassifyDocumentResult.
2447
- :ivar str kind: The text analysis kind - "CustomDocumentClassification".
2448
-
2449
- .. versionadded:: 2022-10-01-preview
2450
- The *detected_language* property.
2451
- """
2452
-
2453
- def __init__(
2454
- self,
2455
- **kwargs
2456
- ):
2457
- self.id = kwargs.get('id', None)
2458
- self.classifications = kwargs.get('classifications', None)
2459
- self.warnings = kwargs.get('warnings', [])
2460
- self.statistics = kwargs.get('statistics', None)
2461
- self.detected_language = kwargs.get('detected_language', None)
2462
- self.is_error: Literal[False] = False
2463
- self.kind: Literal["CustomDocumentClassification"] = "CustomDocumentClassification"
2464
-
2465
- def __repr__(self):
2466
- return "ClassifyDocumentResult(id={}, classifications={}, warnings={}, statistics={}, detected_language={} " \
2467
- "is_error={})".format(
2468
- self.id,
2469
- repr(self.classifications),
2470
- repr(self.warnings),
2471
- repr(self.statistics),
2472
- repr(self.detected_language),
2473
- self.is_error,
2474
- )[
2475
- :1024
2476
- ]
2477
-
2478
- @classmethod
2479
- def _from_generated(cls, result):
2480
- return cls(
2481
- id=result.id,
2482
- classifications=[
2483
- ClassificationCategory._from_generated(e) # pylint: disable=protected-access
2484
- for e in result.class_property
2485
- ],
2486
- warnings=[
2487
- TextAnalyticsWarning._from_generated( # pylint: disable=protected-access
2488
- w
2489
- )
2490
- for w in result.warnings
2491
- ],
2492
- statistics=TextDocumentStatistics._from_generated( # pylint: disable=protected-access
2493
- result.statistics
2494
- ),
2495
- detected_language=DetectedLanguage._from_generated( # pylint: disable=protected-access
2496
- result.detected_language
2497
- ) if hasattr(result, "detected_language") and result.detected_language else None
2498
- )
2499
-
2500
-
2501
- class SingleLabelClassifyAction(DictMixin):
2502
- """SingleLabelClassifyAction encapsulates the parameters for starting a long-running custom single label
2503
- classification operation. For information on regional support of custom features and how to train a model to
2504
- classify your documents, see https://aka.ms/azsdk/textanalytics/customfunctionalities
2505
-
2506
- :param str project_name: Required. This field indicates the project name for the model.
2507
- :param str deployment_name: Required. This field indicates the deployment name for the model.
2508
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2509
- logged on the service side for troubleshooting. By default, the Language service logs your
2510
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2511
- the service's natural language processing functions. Setting this parameter to true,
2512
- disables input logging and may limit our ability to remediate issues that occur. Please see
2513
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2514
- additional details, and Microsoft Responsible AI principles at
2515
- https://www.microsoft.com/ai/responsible-ai.
2516
- :ivar str project_name: This field indicates the project name for the model.
2517
- :ivar str deployment_name: This field indicates the deployment name for the model.
2518
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2519
- logged on the service side for troubleshooting. By default, the Language service logs your
2520
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2521
- the service's natural language processing functions. Setting this parameter to true,
2522
- disables input logging and may limit our ability to remediate issues that occur. Please see
2523
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2524
- additional details, and Microsoft Responsible AI principles at
2525
- https://www.microsoft.com/ai/responsible-ai.
2526
-
2527
- .. versionadded:: 2022-05-01
2528
- The *SingleLabelClassifyAction* model.
2529
- """
2530
-
2531
- def __init__(
2532
- self,
2533
- project_name: str,
2534
- deployment_name: str,
2535
- **kwargs
2536
- ) -> None:
2537
- self.project_name = project_name
2538
- self.deployment_name = deployment_name
2539
- self.disable_service_logs = kwargs.get('disable_service_logs', None)
2540
-
2541
- def __repr__(self):
2542
- return "SingleLabelClassifyAction(project_name={}, deployment_name={}, " \
2543
- "disable_service_logs={})".format(
2544
- self.project_name,
2545
- self.deployment_name,
2546
- self.disable_service_logs,
2547
- )[:1024]
2548
-
2549
- def _to_generated(self, api_version, task_id): # pylint: disable=unused-argument
2550
- return _v2022_10_01_preview_models.CustomSingleLabelClassificationLROTask(
2551
- task_name=task_id,
2552
- parameters=_v2022_10_01_preview_models.CustomSingleLabelClassificationTaskParameters(
2553
- project_name=self.project_name,
2554
- deployment_name=self.deployment_name,
2555
- logging_opt_out=self.disable_service_logs,
2556
- )
2557
- )
2558
-
2559
-
2560
- class ClassificationCategory(DictMixin):
2561
- """ClassificationCategory represents a classification of the input document.
2562
-
2563
- :ivar str category: Classification category for the document.
2564
- :ivar float confidence_score: Confidence score between 0 and 1 of the recognized classification.
2565
- """
2566
-
2567
- def __init__(
2568
- self,
2569
- **kwargs
2570
- ):
2571
- self.category = kwargs.get('category', None)
2572
- self.confidence_score = kwargs.get('confidence_score', None)
2573
-
2574
- def __repr__(self):
2575
- return "ClassificationCategory(category={}, confidence_score={})".format(
2576
- self.category,
2577
- self.confidence_score,
2578
- )[:1024]
2579
-
2580
- @classmethod
2581
- def _from_generated(cls, result):
2582
- # FIXME: https://github.com/Azure/azure-sdk-for-python/issues/27089
2583
- if isinstance(result, dict):
2584
- return cls(
2585
- category=result["category"],
2586
- confidence_score=result["confidenceScore"]
2587
- )
2588
- return cls(
2589
- category=result.category,
2590
- confidence_score=result.confidence_score
2591
- )
2592
-
2593
-
2594
- class AnalyzeHealthcareEntitiesAction(DictMixin):
2595
- """AnalyzeHealthcareEntitiesAction encapsulates the parameters for starting a long-running
2596
- healthcare entities analysis operation.
2597
-
2598
- If you just want to analyze healthcare entities in a list of documents, and not perform multiple
2599
- long running actions on the input of documents, call method `begin_analyze_healthcare_entities` instead
2600
- of interfacing with this model.
2601
-
2602
- :keyword Optional[str] model_version: The model version to use for the analysis.
2603
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2604
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2605
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2606
- see https://aka.ms/text-analytics-offsets
2607
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2608
- logged on the service side for troubleshooting. By default, the Language service logs your
2609
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2610
- the service's natural language processing functions. Setting this parameter to true,
2611
- disables input logging and may limit our ability to remediate issues that occur. Please see
2612
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2613
- additional details, and Microsoft Responsible AI principles at
2614
- https://www.microsoft.com/ai/responsible-ai.
2615
- :keyword Optional[str] fhir_version: The FHIR Spec version that the result will use to format the fhir_bundle
2616
- on the result object. For additional information see https://www.hl7.org/fhir/overview.html.
2617
- The only acceptable values to pass in are None and "4.0.1". The default value is None.
2618
- :keyword document_type: Document type that can be provided as input for Fhir Documents. Expect to
2619
- have fhir_version provided when used. Behavior of using None enum is the same as not using the
2620
- document_type parameter. Known values are: "None", "ClinicalTrial", "DischargeSummary",
2621
- "ProgressNote", "HistoryAndPhysical", "Consult", "Imaging", "Pathology", and "ProcedureNote".
2622
- :paramtype document_type: Optional[str or ~azure.ai.textanalytics.HealthcareDocumentType]
2623
- :ivar Optional[str] model_version: The model version to use for the analysis.
2624
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2625
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2626
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2627
- see https://aka.ms/text-analytics-offsets
2628
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2629
- logged on the service side for troubleshooting. By default, the Language service logs your
2630
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2631
- the service's natural language processing functions. Setting this parameter to true,
2632
- disables input logging and may limit our ability to remediate issues that occur. Please see
2633
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2634
- additional details, and Microsoft Responsible AI principles at
2635
- https://www.microsoft.com/ai/responsible-ai.
2636
- :ivar Optional[str] fhir_version: The FHIR Spec version that the result will use to format the fhir_bundle
2637
- on the result object. For additional information see https://www.hl7.org/fhir/overview.html.
2638
- The only acceptable values to pass in are None and "4.0.1". The default value is None.
2639
- :ivar document_type: Document type that can be provided as input for Fhir Documents. Expect to
2640
- have fhir_version provided when used. Behavior of using None enum is the same as not using the
2641
- document_type parameter. Known values are: "None", "ClinicalTrial", "DischargeSummary",
2642
- "ProgressNote", "HistoryAndPhysical", "Consult", "Imaging", "Pathology", and "ProcedureNote".
2643
- :vartype document_type: Optional[str or ~azure.ai.textanalytics.HealthcareDocumentType]
2644
-
2645
- .. versionadded:: 2022-05-01
2646
- The *AnalyzeHealthcareEntitiesAction* model.
2647
- .. versionadded:: 2022-10-01-preview
2648
- The *fhir_version* and *document_type* keyword arguments.
2649
- """
2650
-
2651
- def __init__(self, **kwargs):
2652
- self.model_version = kwargs.get("model_version", None)
2653
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
2654
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
2655
- self.fhir_version = kwargs.get("fhir_version", None)
2656
- self.document_type = kwargs.get("document_type", None)
2657
-
2658
- def __repr__(self):
2659
- return (
2660
- "AnalyzeHealthcareEntitiesAction(model_version={}, string_index_type={}, disable_service_logs={}, "
2661
- "fhir_version={}, document_type={})".format(
2662
- self.model_version,
2663
- self.string_index_type,
2664
- self.disable_service_logs,
2665
- self.fhir_version,
2666
- self.document_type
2667
- )[:1024]
2668
- )
2669
-
2670
- def _to_generated(self, api_version, task_id): # pylint: disable=unused-argument
2671
- return _v2022_10_01_preview_models.HealthcareLROTask(
2672
- task_name=task_id,
2673
- parameters=_v2022_10_01_preview_models.HealthcareTaskParameters(
2674
- model_version=self.model_version,
2675
- string_index_type=string_index_type_compatibility(self.string_index_type),
2676
- logging_opt_out=self.disable_service_logs,
2677
- fhir_version=self.fhir_version,
2678
- document_type=self.document_type,
2679
- )
2680
- )
2681
-
2682
-
2683
- class ExtractSummaryAction(DictMixin):
2684
- """ExtractSummaryAction encapsulates the parameters for starting a long-running Extractive Text
2685
- Summarization operation. For a conceptual discussion of extractive summarization, see the service documentation:
2686
- https://learn.microsoft.com/azure/cognitive-services/language-service/summarization/overview
2687
-
2688
- :keyword Optional[str] model_version: The model version to use for the analysis.
2689
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2690
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2691
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2692
- see https://aka.ms/text-analytics-offsets
2693
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2694
- logged on the service side for troubleshooting. By default, the Language service logs your
2695
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2696
- the service's natural language processing functions. Setting this parameter to true,
2697
- disables input logging and may limit our ability to remediate issues that occur. Please see
2698
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2699
- additional details, and Microsoft Responsible AI principles at
2700
- https://www.microsoft.com/ai/responsible-ai.
2701
- :keyword Optional[int] max_sentence_count: Maximum number of sentences to return. Defaults to 3.
2702
- :keyword Optional[str] order_by: Possible values include: "Offset", "Rank". Default value: "Offset".
2703
- :ivar Optional[str] model_version: The model version to use for the analysis.
2704
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
2705
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
2706
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
2707
- see https://aka.ms/text-analytics-offsets
2708
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
2709
- logged on the service side for troubleshooting. By default, the Language service logs your
2710
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
2711
- the service's natural language processing functions. Setting this parameter to true,
2712
- disables input logging and may limit our ability to remediate issues that occur. Please see
2713
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
2714
- additional details, and Microsoft Responsible AI principles at
2715
- https://www.microsoft.com/ai/responsible-ai.
2716
- :ivar Optional[int] max_sentence_count: Number of sentences to return. Defaults to 3.
2717
- :ivar Optional[str] order_by: Possible values include: "Offset", "Rank". Default value: "Offset".
2718
-
2719
- .. versionadded:: 2022-10-01-preview
2720
- The *ExtractSummaryAction* model.
2721
- """
2722
-
2723
- def __init__(self, **kwargs):
2724
- self.model_version = kwargs.get("model_version", None)
2725
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
2726
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
2727
- self.max_sentence_count = kwargs.get("max_sentence_count", None)
2728
- self.order_by = kwargs.get("order_by", None)
2729
-
2730
- def __repr__(self):
2731
- return (
2732
- "ExtractSummaryAction(model_version={}, string_index_type={}, disable_service_logs={}, "
2733
- "max_sentence_count={}, order_by={})".format(
2734
- self.model_version,
2735
- self.string_index_type,
2736
- self.disable_service_logs,
2737
- self.max_sentence_count,
2738
- self.order_by,
2739
- )[:1024]
2740
- )
2741
-
2742
- def _to_generated(self, api_version, task_id): # pylint: disable=unused-argument
2743
- return _v2022_10_01_preview_models.ExtractiveSummarizationLROTask( # pylint: disable=no-member
2744
- task_name=task_id,
2745
- parameters=_v2022_10_01_preview_models.ExtractiveSummarizationTaskParameters( # pylint: disable=no-member
2746
- model_version=self.model_version,
2747
- string_index_type=string_index_type_compatibility(self.string_index_type),
2748
- logging_opt_out=self.disable_service_logs,
2749
- sentence_count=self.max_sentence_count,
2750
- sort_by=self.order_by,
2751
- )
2752
- )
2753
-
2754
-
2755
- class ExtractSummaryResult(DictMixin):
2756
- """ExtractSummaryResult is a result object which contains
2757
- the extractive text summarization from a particular document.
2758
-
2759
- :ivar str id: Unique, non-empty document identifier.
2760
- :ivar sentences: A ranked list of sentences representing the extracted summary.
2761
- :vartype sentences: list[~azure.ai.textanalytics.SummarySentence]
2762
- :ivar warnings: Warnings encountered while processing document.
2763
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
2764
- :ivar statistics: If `show_stats=True` was specified in the request this
2765
- field will contain information about the document payload.
2766
- :vartype statistics: Optional[~azure.ai.textanalytics.TextDocumentStatistics]
2767
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
2768
- field will contain the DetectedLanguage for the document.
2769
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
2770
- :ivar bool is_error: Boolean check for error item when iterating over list of
2771
- results. Always False for an instance of an ExtractSummaryResult.
2772
- :ivar str kind: The text analysis kind - "ExtractiveSummarization".
2773
-
2774
- .. versionadded:: 2022-10-01-preview
2775
- The *ExtractSummaryResult* model.
2776
- """
2777
-
2778
- def __init__(self, **kwargs):
2779
- self.id = kwargs.get("id", None)
2780
- self.sentences = kwargs.get("sentences", None)
2781
- self.warnings = kwargs.get("warnings", None)
2782
- self.statistics = kwargs.get("statistics", None)
2783
- self.detected_language = kwargs.get("detected_language", None)
2784
- self.is_error: Literal[False] = False
2785
- self.kind: Literal["ExtractiveSummarization"] = "ExtractiveSummarization"
2786
-
2787
- def __repr__(self):
2788
- return "ExtractSummaryResult(id={}, sentences={}, warnings={}, statistics={}, detected_language={}," \
2789
- " is_error={})".format(
2790
- self.id,
2791
- repr(self.sentences),
2792
- repr(self.warnings),
2793
- repr(self.statistics),
2794
- repr(self.detected_language),
2795
- self.is_error,
2796
- )[
2797
- :1024
2798
- ]
2799
-
2800
- @classmethod
2801
- def _from_generated(cls, summary):
2802
- return cls(
2803
- id=summary.id,
2804
- sentences=[
2805
- SummarySentence._from_generated( # pylint: disable=protected-access
2806
- sentence
2807
- )
2808
- for sentence in summary.sentences
2809
- ],
2810
- warnings=[
2811
- TextAnalyticsWarning._from_generated( # pylint: disable=protected-access
2812
- w
2813
- )
2814
- for w in summary.warnings
2815
- ],
2816
- statistics=TextDocumentStatistics._from_generated( # pylint: disable=protected-access
2817
- summary.statistics
2818
- ),
2819
- detected_language=DetectedLanguage._from_generated( # pylint: disable=protected-access
2820
- summary.detected_language
2821
- ) if hasattr(summary, "detected_language") and summary.detected_language else None
2822
- )
2823
-
2824
-
2825
- class SummarySentence(DictMixin):
2826
- """Represents a single sentence from the extractive text summarization.
2827
-
2828
- :ivar str text: The extracted sentence text.
2829
- :ivar float rank_score: A float value representing the relevance of the sentence within
2830
- the summary. Higher values indicate higher importance.
2831
- :ivar int offset: The sentence offset from the start of the document.
2832
- The value depends on the value of the `string_index_type` parameter
2833
- set in the original request, which is UnicodeCodePoint by default.
2834
- :ivar int length: The length of the sentence. This value depends on the value of the
2835
- `string_index_type` parameter set in the original request, which is UnicodeCodePoint
2836
- by default.
2837
-
2838
- .. versionadded:: 2022-10-01-preview
2839
- The *SummarySentence* model.
2840
- """
2841
-
2842
- def __init__(self, **kwargs):
2843
- self.text = kwargs.get("text", None)
2844
- self.rank_score = kwargs.get("rank_score", None)
2845
- self.offset = kwargs.get("offset", None)
2846
- self.length = kwargs.get("length", None)
2847
-
2848
- def __repr__(self):
2849
- return "SummarySentence(text={}, rank_score={}, offset={}, length={})".format(
2850
- self.text,
2851
- self.rank_score,
2852
- self.offset,
2853
- self.length,
2854
- )[:1024]
2855
-
2856
- @classmethod
2857
- def _from_generated(cls, sentence):
2858
- return cls(
2859
- text=sentence.text,
2860
- rank_score=sentence.rank_score,
2861
- offset=sentence.offset,
2862
- length=sentence.length,
2863
- )
2864
-
2865
-
2866
- class AbstractSummaryResult(DictMixin):
2867
- """AbstractSummaryResult is a result object which contains
2868
- the summary generated for a particular document.
2869
-
2870
- :ivar id: Unique, non-empty document identifier. Required.
2871
- :vartype id: str
2872
- :ivar detected_language: If 'language' is set to 'auto' for the document in the request this
2873
- field will contain the DetectedLanguage for the document.
2874
- :vartype detected_language: Optional[~azure.ai.textanalytics.DetectedLanguage]
2875
- :ivar warnings: Warnings encountered while processing document. Results will still be returned
2876
- if there are warnings, but they may not be fully accurate.
2877
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
2878
- :ivar statistics: If `show_stats=True` was specified in the request this
2879
- field will contain information about the document payload.
2880
- :vartype statistics:
2881
- Optional[~azure.ai.textanalytics.TextDocumentStatistics]
2882
- :ivar summaries: A list of abstractive summaries. Required.
2883
- :vartype summaries: list[~azure.ai.textanalytics.AbstractiveSummary]
2884
- :ivar bool is_error: Boolean check for error item when iterating over list of
2885
- results. Always False for an instance of a AbstractSummaryResult.
2886
- :ivar str kind: The text analysis kind - "AbstractiveSummarization".
2887
-
2888
- .. versionadded:: 2022-10-01-preview
2889
- The *AbstractSummaryResult* model.
2890
- """
2891
-
2892
- def __init__(self, **kwargs):
2893
- self.id = kwargs.get("id", None)
2894
- self.detected_language = kwargs.get("detected_language", None)
2895
- self.warnings = kwargs.get("warnings", None)
2896
- self.statistics = kwargs.get("statistics", None)
2897
- self.summaries = kwargs.get("summaries", None)
2898
- self.is_error: Literal[False] = False
2899
- self.kind: Literal["AbstractiveSummarization"] = "AbstractiveSummarization"
2900
-
2901
- def __repr__(self):
2902
- return "AbstractSummaryResult(id={}, detected_language={}, warnings={}, statistics={}, " \
2903
- "summaries={}, is_error={})".format(
2904
- self.id,
2905
- repr(self.detected_language),
2906
- repr(self.warnings),
2907
- repr(self.statistics),
2908
- repr(self.summaries),
2909
- self.is_error,
2910
- )[
2911
- :1024
2912
- ]
2913
-
2914
- @classmethod
2915
- def _from_generated(cls, result):
2916
- return cls(
2917
- id=result.id,
2918
- detected_language=DetectedLanguage._from_generated( # pylint: disable=protected-access
2919
- result.detected_language
2920
- ) if hasattr(result, "detected_language") and result.detected_language else None,
2921
- warnings=[
2922
- TextAnalyticsWarning._from_generated( # pylint: disable=protected-access
2923
- w
2924
- )
2925
- for w in result.warnings
2926
- ],
2927
- statistics=TextDocumentStatistics._from_generated( # pylint: disable=protected-access
2928
- result.statistics
2929
- ),
2930
- summaries=[
2931
- AbstractiveSummary._from_generated(summary) # pylint: disable=protected-access
2932
- for summary in result.summaries
2933
- ],
2934
- )
2935
-
2936
-
2937
- class AbstractiveSummary(DictMixin):
2938
- """An object representing a single summary with context for given document.
2939
-
2940
- :ivar text: The text of the summary. Required.
2941
- :vartype text: str
2942
- :ivar contexts: The context list of the summary.
2943
- :vartype contexts: Optional[list[~azure.ai.textanalytics.SummaryContext]]
2944
-
2945
- .. versionadded:: 2022-10-01-preview
2946
- The *AbstractiveSummary* model.
2947
- """
2948
-
2949
- def __init__(self, **kwargs):
2950
- self.text = kwargs.get("text", None)
2951
- self.contexts = kwargs.get("contexts", None)
2952
-
2953
- def __repr__(self):
2954
- return "AbstractiveSummary(text={}, contexts={})".format(
2955
- self.text,
2956
- repr(self.contexts),
2957
- )[
2958
- :1024
2959
- ]
2960
-
2961
- @classmethod
2962
- def _from_generated(cls, result):
2963
- return cls(
2964
- text=result.text,
2965
- contexts=[
2966
- SummaryContext._from_generated(context) # pylint: disable=protected-access
2967
- for context in result.contexts
2968
- ] if result.contexts else None
2969
- )
2970
-
2971
-
2972
- class SummaryContext(DictMixin):
2973
- """The context of the summary.
2974
-
2975
- :ivar offset: Start position for the context. Use of different 'stringIndexType' values can
2976
- affect the offset returned. Required.
2977
- :vartype offset: int
2978
- :ivar length: The length of the context. Use of different 'stringIndexType' values can affect
2979
- the length returned. Required.
2980
- :vartype length: int
2981
-
2982
- .. versionadded:: 2022-10-01-preview
2983
- The *SummaryContext* model.
2984
- """
2985
-
2986
- def __init__(self, **kwargs):
2987
- self.offset = kwargs.get("offset", None)
2988
- self.length = kwargs.get("length", None)
2989
-
2990
- def __repr__(self):
2991
- return "SummaryContext(offset={}, length={})".format(
2992
- self.offset,
2993
- self.length,
2994
- )[
2995
- :1024
2996
- ]
2997
-
2998
- @classmethod
2999
- def _from_generated(cls, summary):
3000
- return cls(
3001
- offset=summary.offset,
3002
- length=summary.length
3003
- )
3004
-
3005
-
3006
- class AbstractSummaryAction(DictMixin):
3007
- """AbstractSummaryAction encapsulates the parameters for starting a long-running
3008
- abstractive summarization operation. For a conceptual discussion of extractive summarization,
3009
- see the service documentation:
3010
- https://learn.microsoft.com/azure/cognitive-services/language-service/summarization/overview
3011
-
3012
- Abstractive summarization generates a summary for the input documents. Abstractive summarization
3013
- is different from extractive summarization in that extractive summarization is the strategy of
3014
- concatenating extracted sentences from the input document into a summary, while abstractive
3015
- summarization involves paraphrasing the document using novel sentences.
3016
-
3017
- .. note:: The abstractive summarization feature is part of a gated preview. Request access here:
3018
- https://aka.ms/applyforgatedsummarizationfeatures
3019
-
3020
- :keyword Optional[int] sentence_count: It controls the approximate number of sentences in the output summaries.
3021
- :keyword Optional[str] model_version: The model version to use for the analysis.
3022
- :keyword Optional[str] string_index_type: Specifies the method used to interpret string offsets.
3023
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
3024
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
3025
- see https://aka.ms/text-analytics-offsets
3026
- :keyword Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
3027
- logged on the service side for troubleshooting. By default, the Language service logs your
3028
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
3029
- the service's natural language processing functions. Setting this parameter to true,
3030
- disables input logging and may limit our ability to remediate issues that occur. Please see
3031
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
3032
- additional details, and Microsoft Responsible AI principles at
3033
- https://www.microsoft.com/ai/responsible-ai.
3034
- :ivar Optional[int] sentence_count: It controls the approximate number of sentences in the output summaries.
3035
- :ivar Optional[str] model_version: The model version to use for the analysis.
3036
- :ivar Optional[str] string_index_type: Specifies the method used to interpret string offsets.
3037
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
3038
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
3039
- see https://aka.ms/text-analytics-offsets
3040
- :ivar Optional[bool] disable_service_logs: If set to true, you opt-out of having your text input
3041
- logged on the service side for troubleshooting. By default, the Language service logs your
3042
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
3043
- the service's natural language processing functions. Setting this parameter to true,
3044
- disables input logging and may limit our ability to remediate issues that occur. Please see
3045
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
3046
- additional details, and Microsoft Responsible AI principles at
3047
- https://www.microsoft.com/ai/responsible-ai.
3048
-
3049
- .. versionadded:: 2022-10-01-preview
3050
- The *AbstractSummaryAction* model.
3051
- """
3052
-
3053
- def __init__(self, **kwargs):
3054
- self.sentence_count = kwargs.get("sentence_count", None)
3055
- self.model_version = kwargs.get("model_version", None)
3056
- self.string_index_type = kwargs.get("string_index_type", "UnicodeCodePoint")
3057
- self.disable_service_logs = kwargs.get("disable_service_logs", None)
3058
-
3059
- def __repr__(self):
3060
- return "AbstractSummaryAction(model_version={}, string_index_type={}, disable_service_logs={}, " \
3061
- "sentence_count={})".format(
3062
- self.model_version,
3063
- self.string_index_type,
3064
- self.disable_service_logs,
3065
- self.sentence_count,
3066
- )[
3067
- :1024
3068
- ]
3069
-
3070
- def _to_generated(self, api_version, task_id): # pylint: disable=unused-argument
3071
- return _v2022_10_01_preview_models.AbstractiveSummarizationLROTask(
3072
- task_name=task_id,
3073
- parameters=_v2022_10_01_preview_models.AbstractiveSummarizationTaskParameters(
3074
- model_version=self.model_version,
3075
- string_index_type=string_index_type_compatibility(self.string_index_type),
3076
- logging_opt_out=self.disable_service_logs,
3077
- sentence_count=self.sentence_count,
3078
- )
3079
- )
3080
-
3081
-
3082
- class DynamicClassificationResult(DictMixin):
3083
- """DynamicClassificationResult is a result object which contains
3084
- the classifications for a particular document.
3085
-
3086
- :ivar str id: Unique, non-empty document identifier.
3087
- :ivar classifications: Recognized classification results in the document.
3088
- :vartype classifications: list[~azure.ai.textanalytics.ClassificationCategory]
3089
- :ivar warnings: Warnings encountered while processing document.
3090
- :vartype warnings: list[~azure.ai.textanalytics.TextAnalyticsWarning]
3091
- :ivar statistics: If `show_stats=True` was specified in the request this
3092
- field will contain information about the document payload.
3093
- :vartype statistics: Optional[~azure.ai.textanalytics.TextDocumentStatistics]
3094
- :ivar bool is_error: Boolean check for error item when iterating over list of
3095
- results. Always False for an instance of a DynamicClassificationResult.
3096
- :ivar str kind: The text analysis kind - "DynamicClassification".
3097
-
3098
- .. versionadded:: 2022-10-01-preview
3099
- The *DynamicClassificationResult* model.
3100
- """
3101
-
3102
- def __init__(
3103
- self,
3104
- **kwargs
3105
- ):
3106
- self.id = kwargs.get('id', None)
3107
- self.classifications = kwargs.get('classifications', None)
3108
- self.warnings = kwargs.get('warnings', [])
3109
- self.statistics = kwargs.get('statistics', None)
3110
- self.is_error: Literal[False] = False
3111
- self.kind: Literal["DynamicClassification"] = "DynamicClassification"
3112
-
3113
- def __repr__(self):
3114
- return "DynamicClassificationResult(id={}, classifications={}, warnings={}, statistics={}, " \
3115
- "is_error={})".format(
3116
- self.id,
3117
- repr(self.classifications),
3118
- repr(self.warnings),
3119
- repr(self.statistics),
3120
- self.is_error,
3121
- )[
3122
- :1024
3123
- ]
3124
-
3125
- @classmethod
3126
- def _from_generated(cls, result):
3127
- return cls(
3128
- id=result.id,
3129
- classifications=[
3130
- ClassificationCategory._from_generated(c) # pylint: disable=protected-access
3131
- for c in result.classifications
3132
- ],
3133
- warnings=[
3134
- TextAnalyticsWarning._from_generated( # pylint: disable=protected-access
3135
- w
3136
- )
3137
- for w in result.warnings
3138
- ],
3139
- statistics=TextDocumentStatistics._from_generated( # pylint: disable=protected-access
3140
- result.statistics
3141
- ),
3142
- )