|
60 | 60 | AnalyzeHealthcareEntitiesResult,
|
61 | 61 | RecognizeCustomEntitiesAction,
|
62 | 62 | RecognizeCustomEntitiesResult,
|
63 |
| - SingleCategoryClassifyAction, |
| 63 | + SingleLabelClassifyAction, |
64 | 64 | MultiCategoryClassifyAction,
|
65 | 65 | ClassifyDocumentResult,
|
66 | 66 | AnalyzeHealthcareEntitiesAction,
|
@@ -1057,7 +1057,7 @@ def begin_analyze_actions(
|
1057 | 1057 | ExtractKeyPhrasesAction,
|
1058 | 1058 | AnalyzeSentimentAction,
|
1059 | 1059 | RecognizeCustomEntitiesAction,
|
1060 |
| - SingleCategoryClassifyAction, |
| 1060 | + SingleLabelClassifyAction, |
1061 | 1061 | MultiCategoryClassifyAction,
|
1062 | 1062 | AnalyzeHealthcareEntitiesAction,
|
1063 | 1063 | ]
|
@@ -1102,7 +1102,7 @@ def begin_analyze_actions(
|
1102 | 1102 | :type actions:
|
1103 | 1103 | list[RecognizeEntitiesAction or RecognizePiiEntitiesAction or ExtractKeyPhrasesAction or
|
1104 | 1104 | RecognizeLinkedEntitiesAction or AnalyzeSentimentAction or
|
1105 |
| - RecognizeCustomEntitiesAction or SingleCategoryClassifyAction or |
| 1105 | + RecognizeCustomEntitiesAction or SingleLabelClassifyAction or |
1106 | 1106 | MultiCategoryClassifyAction or AnalyzeHealthcareEntitiesAction]
|
1107 | 1107 | :keyword str display_name: An optional display name to set for the requested analysis.
|
1108 | 1108 | :keyword str language: The 2 letter ISO 639-1 representation of language for the
|
@@ -1138,7 +1138,7 @@ def begin_analyze_actions(
|
1138 | 1138 | .. versionadded:: v3.1
|
1139 | 1139 | The *begin_analyze_actions* client method.
|
1140 | 1140 | .. versionadded:: 2022-04-01-preview
|
1141 |
| - The *RecognizeCustomEntitiesAction*, *SingleCategoryClassifyAction*, |
| 1141 | + The *RecognizeCustomEntitiesAction*, *SingleLabelClassifyAction*, |
1142 | 1142 | *MultiCategoryClassifyAction*, and *AnalyzeHealthcareEntitiesAction* input options and the
|
1143 | 1143 | corresponding *RecognizeCustomEntitiesResult*, *ClassifyDocumentResult*,
|
1144 | 1144 | and *AnalyzeHealthcareEntitiesResult* result objects
|
@@ -1404,3 +1404,115 @@ def begin_recognize_custom_entities(
|
1404 | 1404 |
|
1405 | 1405 | except HttpResponseError as error:
|
1406 | 1406 | return process_http_response_error(error)
|
| 1407 | + |
| 1408 | + @distributed_trace |
| 1409 | + @validate_multiapi_args( |
| 1410 | + version_method_added="2022-05-01" |
| 1411 | + ) |
| 1412 | + def begin_single_label_classify( |
| 1413 | + self, |
| 1414 | + documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], |
| 1415 | + project_name, |
| 1416 | + deployment_name, |
| 1417 | + **kwargs: Any, |
| 1418 | + ) -> TextAnalyticsLROPoller[ItemPaged[Union[ClassifyDocumentResult, DocumentError]]]: |
| 1419 | + """Start a long-running custom single label classification operation. |
| 1420 | +
|
| 1421 | + For information on regional support of custom features and how to train a model to |
| 1422 | + classify your documents, see https://aka.ms/azsdk/textanalytics/customfunctionalities |
| 1423 | +
|
| 1424 | + :param documents: The set of documents to process as part of this batch. |
| 1425 | + If you wish to specify the ID and language on a per-item basis you must |
| 1426 | + use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of |
| 1427 | + dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like |
| 1428 | + `{"id": "1", "language": "en", "text": "hello world"}`. |
| 1429 | + :type documents: |
| 1430 | + list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]] |
| 1431 | + :param str project_name: Required. This field indicates the project name for the model. |
| 1432 | + :param str deployment_name: This field indicates the deployment name for the model. |
| 1433 | + :keyword str language: The 2 letter ISO 639-1 representation of language for the |
| 1434 | + entire batch. For example, use "en" for English; "es" for Spanish etc. |
| 1435 | + If not set, uses "en" for English as default. Per-document language will |
| 1436 | + take precedence over whole batch language. See https://aka.ms/talangs for |
| 1437 | + supported languages in Language API. |
| 1438 | + :keyword bool show_stats: If set to true, response will contain document level statistics. |
| 1439 | + :keyword bool disable_service_logs: If set to true, you opt-out of having your text input |
| 1440 | + logged on the service side for troubleshooting. By default, the Language service logs your |
| 1441 | + input text for 48 hours, solely to allow for troubleshooting issues in providing you with |
| 1442 | + the service's natural language processing functions. Setting this parameter to true, |
| 1443 | + disables input logging and may limit our ability to remediate issues that occur. Please see |
| 1444 | + Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for |
| 1445 | + additional details, and Microsoft Responsible AI principles at |
| 1446 | + https://www.microsoft.com/ai/responsible-ai. |
| 1447 | + :keyword int polling_interval: Waiting time between two polls for LRO operations |
| 1448 | + if no Retry-After header is present. Defaults to 5 seconds. |
| 1449 | + :keyword str continuation_token: |
| 1450 | + Call `continuation_token()` on the poller object to save the long-running operation (LRO) |
| 1451 | + state into an opaque token. Pass the value as the `continuation_token` keyword argument |
| 1452 | + to restart the LRO from a saved state. |
| 1453 | + :keyword str display_name: An optional display name to set for the requested analysis. |
| 1454 | + :return: An instance of an TextAnalyticsLROPoller. Call `result()` on the this |
| 1455 | + object to return a heterogeneous pageable of |
| 1456 | + :class:`~azure.ai.textanalytics.ClassifyDocumentResult` and |
| 1457 | + :class:`~azure.ai.textanalytics.DocumentError`. |
| 1458 | + :rtype: |
| 1459 | + ~azure.ai.textanalytics.TextAnalyticsLROPoller[~azure.core.paging.ItemPaged[ |
| 1460 | + ~azure.ai.textanalytics.ClassifyDocumentResult or ~azure.ai.textanalytics.DocumentError]] |
| 1461 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 1462 | +
|
| 1463 | + .. versionadded:: 2022-05-01 |
| 1464 | + The *begin_single_label_classify* client method. |
| 1465 | +
|
| 1466 | + .. admonition:: Example: |
| 1467 | +
|
| 1468 | + .. literalinclude:: ../samples/sample_single_label_classify.py |
| 1469 | + :start-after: [START single_label_classify] |
| 1470 | + :end-before: [END single_label_classify] |
| 1471 | + :language: python |
| 1472 | + :dedent: 4 |
| 1473 | + :caption: Perform single label classification on a batch of documents. |
| 1474 | + """ |
| 1475 | + |
| 1476 | + continuation_token = kwargs.pop("continuation_token", None) |
| 1477 | + disable_service_logs = kwargs.pop("disable_service_logs", None) |
| 1478 | + polling_interval = kwargs.pop("polling_interval", 5) |
| 1479 | + |
| 1480 | + if continuation_token: |
| 1481 | + return cast( |
| 1482 | + TextAnalyticsLROPoller[ItemPaged[Union[ClassifyDocumentResult, DocumentError]]], |
| 1483 | + _get_result_from_continuation_token( |
| 1484 | + self._client._client, # pylint: disable=protected-access |
| 1485 | + continuation_token, |
| 1486 | + TextAnalyticsLROPoller, |
| 1487 | + AnalyzeActionsLROPollingMethod( |
| 1488 | + timeout=polling_interval, |
| 1489 | + **kwargs |
| 1490 | + ), |
| 1491 | + self._analyze_result_callback, |
| 1492 | + bespoke=True |
| 1493 | + ) |
| 1494 | + ) |
| 1495 | + |
| 1496 | + try: |
| 1497 | + return cast( |
| 1498 | + TextAnalyticsLROPoller[ |
| 1499 | + ItemPaged[Union[ClassifyDocumentResult, DocumentError]] |
| 1500 | + ], |
| 1501 | + self.begin_analyze_actions( |
| 1502 | + documents, |
| 1503 | + actions=[ |
| 1504 | + SingleLabelClassifyAction( |
| 1505 | + project_name=project_name, |
| 1506 | + deployment_name=deployment_name, |
| 1507 | + disable_service_logs=disable_service_logs |
| 1508 | + ) |
| 1509 | + ], |
| 1510 | + polling_interval=polling_interval, |
| 1511 | + poller_cls=TextAnalyticsLROPoller, |
| 1512 | + bespoke=True, |
| 1513 | + **kwargs |
| 1514 | + ) |
| 1515 | + ) |
| 1516 | + |
| 1517 | + except HttpResponseError as error: |
| 1518 | + return process_http_response_error(error) |
0 commit comments