Open In App

Microsoft Azure – Opinion Mining with Azure Cognitive Services

Last Updated : 15 May, 2023
Like Article

In this article, we will learn how to do opinion mining with Azure Cognitive Services. We can use the opinion mining feature of the Text Analytics API to analyze multiple sentiments in a sentence. To follow along, we will need Visual Studio, although you can also use Visual Studio Code.

Opinion mining, also known as sentiment analysis, is the process of using natural language processing (NLP) techniques to extract and analyze opinions and sentiments expressed in textual data, such as customer reviews, social media posts, and survey responses.

Azure Cognitive Services is a cloud-based platform that provides a range of NLP and machine learning capabilities, including sentiment analysis. With Azure Cognitive Services, you can easily perform opinion mining on large volumes of textual data and gain insights into customer sentiment and feedback.


Follow the below steps to perform opinion mim=ning with Azure Cognitive Services:

Step 1: To start, we need to create a Cognitive Service in Azure. Here we will search for text analytics. There we will click, create.

Step 2: Let’s select a resource group and now fill in a name. Finally, select a pricing tier. That’s it. Let’s create it.

Step 3: We are going to create an application that can talk with this Cognitive Service. To do that, we need information from the keys and endpoint blade. Specifically, we need the access key and the endpoint.

Step 4: Now, we are in Visual Studio and we have already created a console application. The first thing we did was add a NuGet package. Let’s take a look at the one we need to talk to the Text Analytics API.

Step 5: Let’s navigate to program.cs. Here we have inserted a use to use the NuGet package. Here, we create a text analytics client with the credentials and endpoints that we have copied from the Azure portal, with that client we call the SentimentAnalysisWithOpinionMining example method.

Step 6: First, this sentence is put in a list which we will use. The sentence contains both positive and negative sentiments. Let’s see if the service picks that up. Next, we call AnalyzeSentimentBatch with that list and also pass along the perimeter IncludeOpinionMining, which asks the server for deeper analysis. 

Step 7: Finally, we take the results from the call and loop over them. This writes the results on the screen which consist out of overall sentiment analysis and the results for the deeper analysis. Then, let’s see what happens when we run it. It first provides an overall score of 84 percent positive. In the further analysis, we see that it detected aspects like food, service, and concierge, which it rates based on words that describe them positively or negatively. For instance, for food, it detected unacceptable, which is 99 percent negative. So that’s correct. For the concierge, it detected nice, which is positive.

The opinion mining feature of the Azure Cognitive Service Text Analytics API can analyze multiple sentiments within a sentence. 


  1. Accuracy and scalability: Azure Cognitive Services uses advanced machine learning algorithms to accurately identify sentiments in text data, and it can easily scale to analyze large volumes of data in real-time.
  2. Multilingual support: Azure Cognitive Services supports sentiment analysis in multiple languages, including English, Spanish, French, German, Italian, Chinese, and more.
  3. Customization options: Azure Cognitive Services provides the ability to customize sentiment analysis models to match your specific domain and industry, allowing you to achieve higher accuracy and relevance for your use case.
  4. Integration with other Azure services: Azure Cognitive Services can be easily integrated with other Azure services, such as Azure Synapse Analytics, Azure Data Factory, and Azure Stream Analytics, to enable real-time sentiment analysis on your data streams.
  5. Easy to use: Azure Cognitive Services provides a simple API interface that can be easily integrated with your existing applications or workflows.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads