3
3
# Copyright (c) Microsoft Corporation.
4
4
# Licensed under the MIT License.
5
5
# ------------------------------------
6
-
6
+ import copy
7
7
from typing import ( # pylint: disable=unused-import
8
8
Union ,
9
9
Optional ,
@@ -157,6 +157,14 @@ def detect_language( # type: ignore
157
157
See here for more info: https://aka.ms/text-analytics-model-versioning
158
158
:keyword bool show_stats: If set to true, response will contain document
159
159
level statistics in the `statistics` field of the document-level response.
160
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
161
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
162
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
163
+ the Text Analytics natural language processing functions. Setting this parameter to true,
164
+ disables input logging and may limit our ability to remediate issues that occur. Please see
165
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
166
+ additional details, and Microsoft Responsible AI principles at
167
+ https://www.microsoft.com/ai/responsible-ai.
160
168
:return: The combined list of :class:`~azure.ai.textanalytics.DetectLanguageResult` and
161
169
:class:`~azure.ai.textanalytics.DocumentError` in the order the original documents were
162
170
passed in.
@@ -178,6 +186,9 @@ def detect_language( # type: ignore
178
186
docs = _validate_input (documents , "country_hint" , country_hint )
179
187
model_version = kwargs .pop ("model_version" , None )
180
188
show_stats = kwargs .pop ("show_stats" , False )
189
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
190
+ if disable_service_logs is not None :
191
+ kwargs ['logging_opt_out' ] = disable_service_logs
181
192
try :
182
193
return self ._client .languages (
183
194
documents = docs ,
@@ -228,6 +239,14 @@ def recognize_entities( # type: ignore
228
239
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
229
240
you can also pass in `Utf16CodePoint` or TextElement_v8`. For additional information
230
241
see https://aka.ms/text-analytics-offsets
242
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
243
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
244
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
245
+ the Text Analytics natural language processing functions. Setting this parameter to true,
246
+ disables input logging and may limit our ability to remediate issues that occur. Please see
247
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
248
+ additional details, and Microsoft Responsible AI principles at
249
+ https://www.microsoft.com/ai/responsible-ai.
231
250
:return: The combined list of :class:`~azure.ai.textanalytics.RecognizeEntitiesResult` and
232
251
:class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
233
252
were passed in.
@@ -256,6 +275,9 @@ def recognize_entities( # type: ignore
256
275
)
257
276
if string_index_type :
258
277
kwargs .update ({"string_index_type" : string_index_type })
278
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
279
+ if disable_service_logs is not None :
280
+ kwargs ['logging_opt_out' ] = disable_service_logs
259
281
260
282
try :
261
283
return self ._client .entities_recognition_general (
@@ -316,6 +338,14 @@ def recognize_pii_entities( # type: ignore
316
338
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
317
339
you can also pass in `Utf16CodePoint` or `TextElement_v8`. For additional information
318
340
see https://aka.ms/text-analytics-offsets
341
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
342
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
343
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
344
+ the Text Analytics natural language processing functions. Setting this parameter to true,
345
+ disables input logging and may limit our ability to remediate issues that occur. Please see
346
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
347
+ additional details, and Microsoft Responsible AI principles at
348
+ https://www.microsoft.com/ai/responsible-ai.
319
349
:return: The combined list of :class:`~azure.ai.textanalytics.RecognizePiiEntitiesResult`
320
350
and :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
321
351
were passed in.
@@ -347,6 +377,9 @@ def recognize_pii_entities( # type: ignore
347
377
)
348
378
if string_index_type :
349
379
kwargs .update ({"string_index_type" : string_index_type })
380
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
381
+ if disable_service_logs is not None :
382
+ kwargs ['logging_opt_out' ] = disable_service_logs
350
383
351
384
try :
352
385
return self ._client .entities_recognition_pii (
@@ -407,6 +440,14 @@ def recognize_linked_entities( # type: ignore
407
440
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
408
441
you can also pass in `Utf16CodePoint` or `TextElement_v8`. For additional information
409
442
see https://aka.ms/text-analytics-offsets
443
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
444
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
445
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
446
+ the Text Analytics natural language processing functions. Setting this parameter to true,
447
+ disables input logging and may limit our ability to remediate issues that occur. Please see
448
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
449
+ additional details, and Microsoft Responsible AI principles at
450
+ https://www.microsoft.com/ai/responsible-ai.
410
451
:return: The combined list of :class:`~azure.ai.textanalytics.RecognizeLinkedEntitiesResult`
411
452
and :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
412
453
were passed in.
@@ -428,6 +469,9 @@ def recognize_linked_entities( # type: ignore
428
469
docs = _validate_input (documents , "language" , language )
429
470
model_version = kwargs .pop ("model_version" , None )
430
471
show_stats = kwargs .pop ("show_stats" , False )
472
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
473
+ if disable_service_logs is not None :
474
+ kwargs ['logging_opt_out' ] = disable_service_logs
431
475
432
476
string_index_type = _check_string_index_type_arg (
433
477
kwargs .pop ("string_index_type" , None ),
@@ -503,6 +547,14 @@ def begin_analyze_healthcare_entities( # type: ignore
503
547
:keyword int polling_interval: Waiting time between two polls for LRO operations
504
548
if no Retry-After header is present. Defaults to 5 seconds.
505
549
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
550
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
551
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
552
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
553
+ the Text Analytics natural language processing functions. Setting this parameter to true,
554
+ disables input logging and may limit our ability to remediate issues that occur. Please see
555
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
556
+ additional details, and Microsoft Responsible AI principles at
557
+ https://www.microsoft.com/ai/responsible-ai.
506
558
:return: An instance of an AnalyzeHealthcareEntitiesLROPoller. Call `result()` on the this
507
559
object to return a pageable of :class:`~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResultItem`.
508
560
:rtype:
@@ -529,22 +581,30 @@ def begin_analyze_healthcare_entities( # type: ignore
529
581
string_index_type = kwargs .pop ("string_index_type" , self ._string_index_type_default )
530
582
531
583
doc_id_order = [doc .get ("id" ) for doc in docs ]
584
+ my_cls = kwargs .pop (
585
+ "cls" , partial (self ._healthcare_result_callback , doc_id_order , show_stats = show_stats )
586
+ )
587
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
588
+ polling_kwargs = kwargs
589
+ operation_kwargs = copy .copy (kwargs )
590
+ if disable_service_logs is not None :
591
+ operation_kwargs ['logging_opt_out' ] = disable_service_logs
532
592
533
593
try :
534
594
return self ._client .begin_health (
535
595
docs ,
536
596
model_version = model_version ,
537
597
string_index_type = string_index_type ,
538
- cls = kwargs . pop ( "cls" , partial ( self . _healthcare_result_callback , doc_id_order , show_stats = show_stats )) ,
598
+ cls = my_cls ,
539
599
polling = AnalyzeHealthcareEntitiesLROPollingMethod (
540
600
text_analytics_client = self ._client ,
541
601
timeout = polling_interval ,
542
602
lro_algorithms = [
543
603
TextAnalyticsOperationResourcePolling (show_stats = show_stats )
544
604
],
545
- ** kwargs ),
605
+ ** polling_kwargs ),
546
606
continuation_token = continuation_token ,
547
- ** kwargs
607
+ ** operation_kwargs
548
608
)
549
609
550
610
except ValueError as error :
@@ -595,6 +655,14 @@ def extract_key_phrases( # type: ignore
595
655
See here for more info: https://aka.ms/text-analytics-model-versioning
596
656
:keyword bool show_stats: If set to true, response will contain document
597
657
level statistics in the `statistics` field of the document-level response.
658
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
659
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
660
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
661
+ the Text Analytics natural language processing functions. Setting this parameter to true,
662
+ disables input logging and may limit our ability to remediate issues that occur. Please see
663
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
664
+ additional details, and Microsoft Responsible AI principles at
665
+ https://www.microsoft.com/ai/responsible-ai.
598
666
:return: The combined list of :class:`~azure.ai.textanalytics.ExtractKeyPhrasesResult` and
599
667
:class:`~azure.ai.textanalytics.DocumentError` in the order the original documents were
600
668
passed in.
@@ -616,6 +684,10 @@ def extract_key_phrases( # type: ignore
616
684
docs = _validate_input (documents , "language" , language )
617
685
model_version = kwargs .pop ("model_version" , None )
618
686
show_stats = kwargs .pop ("show_stats" , False )
687
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
688
+ if disable_service_logs is not None :
689
+ kwargs ['logging_opt_out' ] = disable_service_logs
690
+
619
691
try :
620
692
return self ._client .key_phrases (
621
693
documents = docs ,
@@ -672,6 +744,14 @@ def analyze_sentiment( # type: ignore
672
744
`UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
673
745
you can also pass in `Utf16CodePoint` or `TextElement_v8`. For additional information
674
746
see https://aka.ms/text-analytics-offsets
747
+ :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
748
+ logged on the service side for troubleshooting. By default, Text Analytics logs your
749
+ input text for 48 hours, solely to allow for troubleshooting issues in providing you with
750
+ the Text Analytics natural language processing functions. Setting this parameter to true,
751
+ disables input logging and may limit our ability to remediate issues that occur. Please see
752
+ Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
753
+ additional details, and Microsoft Responsible AI principles at
754
+ https://www.microsoft.com/ai/responsible-ai.
675
755
.. versionadded:: v3.1-preview
676
756
The *show_opinion_mining* parameter.
677
757
The *string_index_type* parameter.
@@ -697,6 +777,9 @@ def analyze_sentiment( # type: ignore
697
777
model_version = kwargs .pop ("model_version" , None )
698
778
show_stats = kwargs .pop ("show_stats" , False )
699
779
show_opinion_mining = kwargs .pop ("show_opinion_mining" , None )
780
+ disable_service_logs = kwargs .pop ("disable_service_logs" , None )
781
+ if disable_service_logs is not None :
782
+ kwargs ['logging_opt_out' ] = disable_service_logs
700
783
701
784
string_index_type = _check_string_index_type_arg (
702
785
kwargs .pop ("string_index_type" , None ),
0 commit comments