TextAnalyticsClient Class
The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. No training data is needed to use this API; just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview
- Inheritance
-
msrest.service_client.SDKClientTextAnalyticsClient
Constructor
TextAnalyticsClient(endpoint, credentials)
Parameters
Name | Description |
---|---|
endpoint
Required
|
Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). |
credentials
Required
|
Subscription credentials which uniquely identify client subscription. |
Variables
Name | Description |
---|---|
config
|
Configuration for client. |
Methods
close |
Close the client if keep_alive is True. |
detect_language |
The API returns the detected language and a numeric score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. |
entities |
The API returns a list of recognized entities in a given document. To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the Supported languages in Text Analytics API for the list of enabled languages. |
key_phrases |
The API returns a list of strings denoting the key talking points in the input text. See the Text Analytics Documentation for details about the languages that are supported by key phrase extraction. |
sentiment |
The API returns a numeric score between 0 and 1. Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the Text Analytics Documentation for details about the languages that are supported by sentiment analysis. |
close
Close the client if keep_alive is True.
close() -> None
detect_language
The API returns the detected language and a numeric score between 0 and 1.
Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported.
detect_language(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
show_stats
|
(optional) if set to true, response will contain input and document level statistics. default value: None
|
documents
|
default value: None
|
custom_headers
|
headers that will be added to the request default value: None
|
raw
|
returns the direct response alongside the deserialized response default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
LanguageBatchResult or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
entities
The API returns a list of recognized entities in a given document.
To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the Supported languages in Text Analytics API for the list of enabled languages.
entities(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
show_stats
|
(optional) if set to true, response will contain input and document level statistics. default value: None
|
documents
|
default value: None
|
custom_headers
|
headers that will be added to the request default value: None
|
raw
|
returns the direct response alongside the deserialized response default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
EntitiesBatchResult or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
key_phrases
The API returns a list of strings denoting the key talking points in the input text.
See the Text Analytics Documentation for details about the languages that are supported by key phrase extraction.
key_phrases(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
show_stats
|
(optional) if set to true, response will contain input and document level statistics. default value: None
|
documents
|
default value: None
|
custom_headers
|
headers that will be added to the request default value: None
|
raw
|
returns the direct response alongside the deserialized response default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
KeyPhraseBatchResult or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
sentiment
The API returns a numeric score between 0 and 1.
Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the Text Analytics Documentation for details about the languages that are supported by sentiment analysis.
sentiment(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
show_stats
|
(optional) if set to true, response will contain input and document level statistics. default value: None
|
documents
|
default value: None
|
custom_headers
|
headers that will be added to the request default value: None
|
raw
|
returns the direct response alongside the deserialized response default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
object or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
Azure SDK for Python
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for