<jupyter_start><jupyter_text>Azure Text Analytics API (v3.0-preview.1) Reference: https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v3-0-Preview-1/operations/Sentiment<jupyter_code>import requests
subscription_key = 'YOUR_SUBSCRIPTION_KEY'
endpoint = 'YOUR_ENDPOINT_URL'
request_url = f'{endpoint}/text/analytics/v3.0-preview.1/sentiment'
headers = {
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': subscription_key
}
body = {
  "documents": [
    {
      "language": "en",
      "id": "1",
      "text": "Hello world. This is some input text that I love."
    },
    {
      "language": "en",
      "id": "2",
      "text": "It's incredibly sunny outside! I'm so happy."
    },
    {
      "language": "en",
      "id": "3",
      "text": "Pike place market is my favorite Seattle attraction."
    }
  ]
}
response = requests.post(request_url, json=body, headers=headers)
response.status_code
response.json()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15532994923857868, 'fraction_numerical': 0.012182741116751269, 'mean_word_length': 3.650943396226415, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '121649', 'license': 'MIT', 'n_tokens_mistral': 349, 'n_tokens_neox': 340, 'n_words': 67, 'path': 'evaluate-text-with-azure-cognitive-language-services/sentiment-analysis.ipynb', 'repo_name': 'zkan/azure-ai-engineer-associate-workshop', 'size': '985'}