azure.cognitiveservices.language.textanalytics package

Module contents

class azure.cognitiveservices.language.textanalytics.TextAnalyticsClient(endpoint, credentials)[source]

Bases: msrest.service_client.SDKClient

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

Variables:

config (TextAnalyticsClientConfiguration) – Configuration for client.

Parameters:
detect_language(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)[source]

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.

Parameters:
  • show_stats (bool) – (optional) if set to true, response will contain input and document level statistics.
  • documents (list[LanguageInput]) –
  • custom_headers (dict) – headers that will be added to the request
  • raw (bool) – returns the direct response alongside the deserialized response
  • operation_configOperation configuration overrides.
Returns:

LanguageBatchResult or ClientRawResponse if raw=true

Return type:

LanguageBatchResult or ClientRawResponse

Raises:

ErrorResponseException

entities(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)[source]

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 <a href=”https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages”>Supported languages in Text Analytics API</a> for the list of enabled languages.

Parameters:
  • show_stats (bool) – (optional) if set to true, response will contain input and document level statistics.
  • documents (list[MultiLanguageInput]) –
  • custom_headers (dict) – headers that will be added to the request
  • raw (bool) – returns the direct response alongside the deserialized response
  • operation_configOperation configuration overrides.
Returns:

EntitiesBatchResult or ClientRawResponse if raw=true

Return type:

EntitiesBatchResult or ClientRawResponse

Raises:

ErrorResponseException

key_phrases(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)[source]

The API returns a list of strings denoting the key talking points in the input text.

See the <a href=”https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages”>Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction.

Parameters:
  • show_stats (bool) – (optional) if set to true, response will contain input and document level statistics.
  • documents (list[MultiLanguageInput]) –
  • custom_headers (dict) – headers that will be added to the request
  • raw (bool) – returns the direct response alongside the deserialized response
  • operation_configOperation configuration overrides.
Returns:

KeyPhraseBatchResult or ClientRawResponse if raw=true

Return type:

KeyPhraseBatchResult or ClientRawResponse

Raises:

ErrorResponseException

sentiment(show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config)[source]

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 <a href=”https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages”>Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis.

Parameters:
  • show_stats (bool) – (optional) if set to true, response will contain input and document level statistics.
  • documents (list[MultiLanguageInput]) –
  • custom_headers (dict) – headers that will be added to the request
  • raw (bool) – returns the direct response alongside the deserialized response
  • operation_configOperation configuration overrides.
Returns:

object or ClientRawResponse if raw=true

Return type:

object or ClientRawResponse

Raises:

HttpOperationError