| page_type | languages | products | urlFragment | ||||
|---|---|---|---|---|---|---|---|
sample |
|
|
textanalytics-samples |
These code samples show common scenario operations with the Azure Text Analytics client library.
You can authenticate your client with a Language API key or through Azure Active Directory with a token credential from azure-identity:
- See sample_authentication.py and sample_authentication_async.py for how to authenticate in the above cases.
These sample programs show common scenarios for the Text Analytics client's offerings.
- Python 3.7 or later is required to use this package
- You must have an Azure subscription and an Azure Language account to run these samples.
- Install the Azure Text Analytics client library for Python with pip:
pip install azure-ai-textanalyticsFor more information about how the versioning story of the SDK corresponds to the versioning story of the service's API, see here.
- If authenticating with Azure Active Directory, make sure you have azure-identity installed:
pip install azure-identity
- Clone the repo or download the sample file
- Open the sample file in Visual Studio Code or your IDE of choice.
- Open a terminal window and
cdto the directory that the samples are saved in. - Set the environment variables specified in the sample file you wish to run.
- Follow the usage described in the file, e.g.
python sample_detect_language.py
Check out the API reference documentation to learn more about what you can do with the Azure Text Analytics client library.
| Advanced Sample File Name | Description |
|---|---|
| sample_analyze_sentiment_with_opinion_mining.py and sample_analyze_sentiment_with_opinion_mining_async.py | Analyze sentiment in documents with granular analysis into individual opinions present in a sentence. Only available with API version v3.1 and up. |
| sample_get_detailed_diagnostics_information.py and sample_get_detailed_diagnostics_information_async.py | Get the request batch statistics, model version, and raw response in JSON format through a callback |
| sample_analyze_healthcare_entities_with_cancellation.py and sample_analyze_healthcare_entities_with_cancellation_async.py | Cancel an analyze healthcare entities operation after it's started. |