Share via


TextAnalysisClient Class

Create a TextAnalysisClient. :param endpoint: Supported Cognitive Services endpoint. :type endpoint: str :param credential: Key or token credential. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential :keyword api_version: The API version to use for this operation. Default value is "2025-05-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str`

Constructor

TextAnalysisClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, *, api_version: str | None = None, **kwargs: Any)

Parameters

Name Description
endpoint
Required
credential
Required

Keyword-Only Parameters

Name Description
api_version
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.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

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.

analyze_text(body: AnalyzeTextInput | MutableMapping[str, Any] | IO[bytes], *, show_stats: bool | None = None, **kwargs: Any) -> AnalyzeTextResult

Parameters

Name Description
body
Required
AnalyzeTextInput or <xref:JSON> or IO[bytes]

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.

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) -> AnalyzeTextLROPoller[ItemPaged['TextActions']]

Parameters

Name Description
body
<xref:JSON> or IO[bytes]

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 0x0000028A23FF7E10>
actions

List of tasks to be performed as part of the LRO. Required.

Default value: <object object at 0x0000028A23FF7E10>
display_name
str

Name for the task. Default value is None.

Default value: None
default_language
str

Default language to use for records requesting automatic language detection. Default value is None.

Default value: None
cancel_after

Optional duration in seconds after which the job will be canceled if not completed. Default value is None.

Default value: None

Returns

Type Description

A poller whose result() yields ItemPaged[TextActions] and exposes metadata via .details.

Exceptions

Type Description

begin_cancel_job

Cancel a long-running Text Analysis job.

Cancel a long-running Text Analysis job.

begin_cancel_job(job_id: str, **kwargs: Any) -> LROPoller[None]

Parameters

Name Description
job_id
Required
str

The job ID to cancel. Required.

Returns

Type Description

An instance of LROPoller that returns None

Exceptions

Type Description

close

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.

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
str

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
int

The maximum number of resources to return from the collection. Default value is None.

Default value: None
skip
int

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 = client.send_request(request)
<HttpResponse: 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) -> HttpResponse

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.