69
69
MultiCategoryClassifyResult ,
70
70
)
71
71
72
- ActionInputTypes = List [
73
- Union [
74
- RecognizeEntitiesAction ,
75
- RecognizeLinkedEntitiesAction ,
76
- RecognizePiiEntitiesAction ,
77
- ExtractKeyPhrasesAction ,
78
- AnalyzeSentimentAction ,
79
- ExtractSummaryAction ,
80
- RecognizeCustomEntitiesAction ,
81
- SingleCategoryClassifyAction ,
82
- MultiCategoryClassifyAction ,
83
- ]
84
- ]
85
-
86
- ActionResultTypes = List [
87
- Union [
88
- RecognizeEntitiesResult ,
89
- RecognizeLinkedEntitiesResult ,
90
- RecognizePiiEntitiesResult ,
91
- ExtractKeyPhrasesResult ,
92
- AnalyzeSentimentResult ,
93
- ExtractSummaryResult ,
94
- RecognizeCustomEntitiesResult ,
95
- SingleCategoryClassifyResult ,
96
- MultiCategoryClassifyResult ,
97
- DocumentError ,
98
- ]
99
- ]
100
-
101
72
if TYPE_CHECKING :
102
73
from azure .core .credentials import TokenCredential
103
74
@@ -106,20 +77,19 @@ class TextAnalyticsClient(TextAnalyticsClientBase):
106
77
"""The Text Analytics API is a suite of text analytics web services built with best-in-class
107
78
Microsoft machine learning algorithms. The API can be used to analyze unstructured text for
108
79
tasks such as sentiment analysis, key phrase extraction, entities recognition,
109
- and language detection. No training data is needed to use this API - just bring your text data.
80
+ and language detection, and more . No training data is needed to use this API - just bring your text data.
110
81
This API uses advanced natural language processing techniques to deliver best in class predictions.
111
82
112
83
Further documentation can be found in
113
- https://docs.microsoft.com/azure/cognitive-services/text-analytics /overview
84
+ https://docs.microsoft.com/azure/cognitive-services/language-service /overview
114
85
115
86
:param str endpoint: Supported Cognitive Services or Text Analytics resource
116
- endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft. com).
87
+ endpoints (protocol and hostname, for example: ' https://<resource-name>.cognitiveservices.azure. com' ).
117
88
:param credential: Credentials needed for the client to connect to Azure.
118
89
This can be the an instance of AzureKeyCredential if using a
119
90
cognitive services/text analytics API key or a token credential
120
91
from :mod:`azure.identity`.
121
- :type credential: :class:`~azure.core.credentials.AzureKeyCredential` or
122
- :class:`~azure.core.credentials.TokenCredential`
92
+ :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential
123
93
:keyword str default_country_hint: Sets the default country_hint to use for all operations.
124
94
Defaults to "US". If you don't want to use a country hint, pass the string "none".
125
95
:keyword str default_language: Sets the default language to use for all operations.
@@ -173,17 +143,15 @@ def detect_language(
173
143
one. Scores close to one indicate 100% certainty that the identified
174
144
language is true. See https://aka.ms/talangs for the list of enabled languages.
175
145
176
- See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
177
- for document length limits, maximum batch size, and supported text encoding.
146
+ See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
178
147
179
148
:param documents: The set of documents to process as part of this batch.
180
149
If you wish to specify the ID and country_hint on a per-item basis you must
181
150
use as input a list[:class:`~azure.ai.textanalytics.DetectLanguageInput`] or a list of
182
151
dict representations of :class:`~azure.ai.textanalytics.DetectLanguageInput`, like
183
152
`{"id": "1", "country_hint": "us", "text": "hello world"}`.
184
153
:type documents:
185
- list[str] or list[~azure.ai.textanalytics.DetectLanguageInput] or
186
- list[dict[str, str]]
154
+ list[str] or list[~azure.ai.textanalytics.DetectLanguageInput] or list[dict[str, str]]
187
155
:keyword str country_hint: Country of origin hint for the entire batch. Accepts two
188
156
letter country codes specified by ISO 3166-1 alpha-2. Per-document
189
157
country hints will take precedence over whole batch hints. Defaults to
@@ -255,17 +223,15 @@ def recognize_entities(
255
223
organizations, date/time, quantities, percentages, currencies, and more.
256
224
For the list of supported entity types, check: https://aka.ms/taner
257
225
258
- See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
259
- for document length limits, maximum batch size, and supported text encoding.
226
+ See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
260
227
261
228
:param documents: The set of documents to process as part of this batch.
262
229
If you wish to specify the ID and language on a per-item basis you must
263
230
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list
264
231
of dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`,
265
232
like `{"id": "1", "language": "en", "text": "hello world"}`.
266
233
:type documents:
267
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
268
- list[dict[str, str]]
234
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
269
235
:keyword str language: The 2 letter ISO 639-1 representation of language for the
270
236
entire batch. For example, use "en" for English; "es" for Spanish etc.
271
237
If not set, uses "en" for English as default. Per-document language will
@@ -346,17 +312,15 @@ def recognize_pii_entities(
346
312
"Bank Account", etc) in the document. For the list of supported entity types,
347
313
check https://aka.ms/tanerpii
348
314
349
- See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
350
- for document length limits, maximum batch size, and supported text encoding.
315
+ See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
351
316
352
317
:param documents: The set of documents to process as part of this batch.
353
318
If you wish to specify the ID and language on a per-item basis you must
354
319
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
355
320
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
356
321
`{"id": "1", "language": "en", "text": "hello world"}`.
357
322
:type documents:
358
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
359
- list[dict[str, str]]
323
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
360
324
:keyword str language: The 2 letter ISO 639-1 representation of language for the
361
325
entire batch. For example, use "en" for English; "es" for Spanish etc.
362
326
If not set, uses "en" for English as default. Per-document language will
@@ -460,17 +424,15 @@ def recognize_linked_entities(
460
424
Roman god of war). Recognized entities are associated with URLs to a well-known
461
425
knowledge base, like Wikipedia.
462
426
463
- See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
464
- for document length limits, maximum batch size, and supported text encoding.
427
+ See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
465
428
466
429
:param documents: The set of documents to process as part of this batch.
467
430
If you wish to specify the ID and language on a per-item basis you must
468
431
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
469
432
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
470
433
`{"id": "1", "language": "en", "text": "hello world"}`.
471
434
:type documents:
472
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
473
- list[dict[str, str]]
435
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
474
436
:keyword str language: The 2 letter ISO 639-1 representation of language for the
475
437
entire batch. For example, use "en" for English; "es" for Spanish etc.
476
438
If not set, uses "en" for English as default. Per-document language will
@@ -575,8 +537,7 @@ def begin_analyze_healthcare_entities(
575
537
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
576
538
`{"id": "1", "language": "en", "text": "hello world"}`.
577
539
:type documents:
578
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
579
- list[dict[str, str]]
540
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
580
541
:keyword str model_version: This value indicates which model will
581
542
be used for scoring, e.g. "latest", "2019-10-01". If a model-version
582
543
is not specified, the API will default to the latest, non-preview version.
@@ -711,17 +672,15 @@ def extract_key_phrases(
711
672
were wonderful staff", the API returns the main talking points: "food"
712
673
and "wonderful staff"
713
674
714
- See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
715
- for document length limits, maximum batch size, and supported text encoding.
675
+ See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
716
676
717
677
:param documents: The set of documents to process as part of this batch.
718
678
If you wish to specify the ID and language on a per-item basis you must
719
679
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
720
680
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
721
681
`{"id": "1", "language": "en", "text": "hello world"}`.
722
682
:type documents:
723
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
724
- list[dict[str, str]]
683
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
725
684
:keyword str language: The 2 letter ISO 639-1 representation of language for the
726
685
entire batch. For example, use "en" for English; "es" for Spanish etc.
727
686
If not set, uses "en" for English as default. Per-document language will
@@ -791,17 +750,15 @@ def analyze_sentiment(
791
750
each sentiment class (Positive, Negative, and Neutral) for the document
792
751
and each sentence within it.
793
752
794
- See https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
795
- for document length limits, maximum batch size, and supported text encoding.
753
+ See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
796
754
797
755
:param documents: The set of documents to process as part of this batch.
798
756
If you wish to specify the ID and language on a per-item basis you must
799
757
use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
800
758
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
801
759
`{"id": "1", "language": "en", "text": "hello world"}`.
802
760
:type documents:
803
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
804
- list[dict[str, str]]
761
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
805
762
:keyword bool show_opinion_mining: Whether to mine the opinions of a sentence and conduct more
806
763
granular analysis around the aspects of a product or service (also known as
807
764
aspect-based sentiment analysis). If set to true, the returned
@@ -908,10 +865,37 @@ def _analyze_result_callback(
908
865
def begin_analyze_actions (
909
866
self ,
910
867
documents : Union [List [str ], List [TextDocumentInput ], List [Dict [str , str ]]],
911
- actions : ActionInputTypes ,
868
+ actions : List [
869
+ Union [
870
+ RecognizeEntitiesAction ,
871
+ RecognizeLinkedEntitiesAction ,
872
+ RecognizePiiEntitiesAction ,
873
+ ExtractKeyPhrasesAction ,
874
+ AnalyzeSentimentAction ,
875
+ ExtractSummaryAction ,
876
+ RecognizeCustomEntitiesAction ,
877
+ SingleCategoryClassifyAction ,
878
+ MultiCategoryClassifyAction ,
879
+ ]
880
+ ],
912
881
** kwargs : Any ,
913
882
) -> AnalyzeActionsLROPoller [
914
- ItemPaged [ActionResultTypes ]
883
+ ItemPaged [
884
+ List [
885
+ Union [
886
+ RecognizeEntitiesResult ,
887
+ RecognizeLinkedEntitiesResult ,
888
+ RecognizePiiEntitiesResult ,
889
+ ExtractKeyPhrasesResult ,
890
+ AnalyzeSentimentResult ,
891
+ ExtractSummaryResult ,
892
+ RecognizeCustomEntitiesResult ,
893
+ SingleCategoryClassifyResult ,
894
+ MultiCategoryClassifyResult ,
895
+ DocumentError ,
896
+ ]
897
+ ]
898
+ ]
915
899
]:
916
900
"""Start a long-running operation to perform a variety of text analysis actions over a batch of documents.
917
901
@@ -928,8 +912,7 @@ def begin_analyze_actions(
928
912
dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
929
913
`{"id": "1", "language": "en", "text": "hello world"}`.
930
914
:type documents:
931
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or
932
- list[dict[str, str]]
915
+ list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
933
916
:param actions: A heterogeneous list of actions to perform on the input documents.
934
917
Each action object encapsulates the parameters used for the particular action type.
935
918
The action results will be in the same order of the input actions.
@@ -963,7 +946,7 @@ def begin_analyze_actions(
963
946
:class:`~azure.ai.textanalytics.AnalyzeSentimentResult` of "world".
964
947
:rtype:
965
948
~azure.ai.textanalytics.AnalyzeActionsLROPoller[~azure.core.paging.ItemPaged[
966
- list[RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult,
949
+ list[RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult or
967
950
ExtractKeyPhrasesResult or AnalyzeSentimentResult or ExtractSummaryAction or RecognizeCustomEntitiesResult
968
951
or SingleCategoryClassifyResult or MultiCategoryClassifyResult or DocumentError]]]
969
952
:raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError:
0 commit comments