Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,916 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
Hey
Rom
With the Text Analytics API in Azure Cognitive Services, you can analyze text and extract valuable insights effortlessly. Sample snipp below.
from azure.ai.textanalytics 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.