Doubt- Text Analytics API

Rom 20 Reputation points

Hi all How can I use text analytics api it to extract key information like sentiment and entities from a given piece of text any samples plz, im a begginer, thanks

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,270 questions
0 comments No comments
{count} votes

Accepted answer
  1. Azar 13,705 Reputation points

    With the Text Analytics API in Azure Cognitive Services, you can analyze text and extract valuable insights effortlessly. Sample snipp below.

    from import TextAnalyticsClient
    from azure.core.credentials import AzureKeyCredential
    # Your Text Analytics API credentials
    key = "YourApiKey"
    endpoint = "YourEndpoint"
    # Create a Text Analytics client
    text_analytics_client = TextAnalyticsClient(endpoint, AzureKeyCredential(key))
    # Sample text for analysis
    document = "I love Azure Cognitive Services! The sentiment analysis is incredible."
    # Analyze sentiment
    sentiment_analysis = text_analytics_client.analyze_sentiment([document])[0]
    print(f"Sentiment: {sentiment_analysis.sentiment}")
    # Extract entities
    entity_recognition = text_analytics_client.recognize_entities([document])[0]
    entities = [entity.text for entity in entity_recognition.entities]
    print(f"Entities: {entities}")

    Just replace "YourApiKey" and "YourEndpoint" and hope this helps you If this helps kindly accept the answer thanks muc.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful