TextAnalysisClient Class
Async client for Text Analysis APIs.
Create a TextAnalysisClient.
Constructor
TextAnalysisClient(endpoint: str, credential: AzureKeyCredential | AsyncTokenCredential, *, api_version: str | None = None, **kwargs: Any)
Parameters
| Name | Description |
|---|---|
|
endpoint
Required
|
Supported Cognitive Services endpoint. |
|
credential
Required
|
AzureKeyCredential or
<xref:azure.core.credentials.AsyncTokenCredential>
Key or token credential. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
api_version
|
The API version to use for this operation. Default value is
Default value: None
|
Methods
| analyze_text |
Request text analysis over a collection of documents. |
| begin_analyze_text_job |
Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a long-running operation. |
| begin_cancel_job |
Cancel a long-running Text Analysis job. Cancel a long-running Text Analysis job. |
| close | |
| get_job_status |
Get analysis status and results. Get the status of an analysis job. A job can consist of one or more tasks. After all tasks succeed, the job transitions to the succeeded state and results are available for each task. |
| send_request |
Runs the network request through the client's chained policies.
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
analyze_text
Request text analysis over a collection of documents.
async analyze_text(body: AnalyzeTextInput | MutableMapping[str, Any] | IO[bytes], *, show_stats: bool | None = None, **kwargs: Any) -> AnalyzeTextResult
Parameters
| Name | Description |
|---|---|
|
body
Required
|
The input documents to analyze. Is one of the following types: AnalyzeTextInput, JSON, IO[bytes] Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
show_stats
|
(Optional) if set to true, response will contain request and document level statistics. Default value is None. Default value: None
|
Returns
| Type | Description |
|---|---|
|
AnalyzeTextResult. The AnalyzeTextResult is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
begin_analyze_text_job
Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a long-running operation.
async begin_analyze_text_job(*, text_input: _models.MultiLanguageTextInput, actions: list[_models.AnalyzeTextOperationAction], content_type: str = 'application/json', display_name: str | None = None, default_language: str | None = None, cancel_after: float | None = None, **kwargs: Any) -> AnalyzeTextAsyncLROPoller[AsyncItemPaged['TextActions']]
Parameters
| Name | Description |
|---|---|
|
body
|
Is either a JSON type or a IO[bytes] type. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
text_input
|
Contains the input to be analyzed. Required. Default value: <object object at 0x0000028A2665FF60>
|
|
actions
|
List of tasks to be performed as part of the LRO. Required. Default value: <object object at 0x0000028A2665FF60>
|
|
display_name
|
Name for the task. Default value is Default value: None
|
|
default_language
|
Default language to use for records requesting automatic language
detection. Default value is Default value: None
|
|
cancel_after
|
Optional duration in seconds after which the job will be canceled if not
completed. Default value is Default value: None
|
Returns
| Type | Description |
|---|---|
|
A poller whose |
Exceptions
| Type | Description |
|---|---|
begin_cancel_job
Cancel a long-running Text Analysis job.
Cancel a long-running Text Analysis job.
async begin_cancel_job(job_id: str, **kwargs: Any) -> AsyncLROPoller[None]
Parameters
| Name | Description |
|---|---|
|
job_id
Required
|
The job ID to cancel. Required. |
Returns
| Type | Description |
|---|---|
|
An instance of AsyncLROPoller that returns None |
Exceptions
| Type | Description |
|---|---|
close
async close() -> None
get_job_status
Get analysis status and results.
Get the status of an analysis job. A job can consist of one or more tasks. After all tasks succeed, the job transitions to the succeeded state and results are available for each task.
async get_job_status(job_id: str, *, show_stats: bool | None = None, top: int | None = None, skip: int | None = None, **kwargs: Any) -> AnalyzeTextOperationState
Parameters
| Name | Description |
|---|---|
|
job_id
Required
|
job ID. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
show_stats
|
(Optional) if set to true, response will contain request and document level statistics. Default value is None. Default value: None
|
|
top
|
The maximum number of resources to return from the collection. Default value is None. Default value: None
|
|
skip
|
An offset into the collection of the first resource to be returned. Default value is None. Default value: None
|
Returns
| Type | Description |
|---|---|
|
AnalyzeTextOperationState. The AnalyzeTextOperationState is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
send_request
Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> Awaitable[AsyncHttpResponse]
Parameters
| Name | Description |
|---|---|
|
request
Required
|
The network request you want to make. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
stream
|
Whether the response payload will be streamed. Defaults to False. Default value: False
|
Returns
| Type | Description |
|---|---|
|
The response of your network call. Does not do error handling on your response. |