Perform sentiment analysis with Azure AI Language

Perform sentiment analysis with Azure AI Language

What is Azure AI Language?

According to the official Microsoft documentation Azure AI Language is a cloud-based service that provides Natural Language Processing (NLP) features for understanding and analyzing text.

The Language service unifies the following previously available Azure AI services: Text Analytics, QnA Maker, and LUIS.

We can also use Language service containers to deploy API features on-premises. These containers enable us to bring the service closer to our data for compliance, security, or other operational reasons.


Creating an Azure AI Language resource

The first thing we need to do is to create the Azure AI Language resource we will use in the example.

Go to the Azure portal and search for 'Language'. Then, from the Language service click on 'Create language'.

From the feature choices, use the default features and continue to create your resource.

Next, fill in the details similar to the below image and be sure to use the free pricing tier.

Finally, check if the resource was successfully created.


Creating the application

Now we will build a simple console application that will help us perform sentiment analysis.

I will show only code snippets in this article, but the full code can be found on my GitHub repository.

Before we get started, let's install the following NuGet package:

What we initially do is create a text analytics client and a list of documents we want to perform sentiment analysis for.

Don't forget the language endpoint and language service key needed for creating the credential.

The next step is to call AnalyzeSentimentBatch and provide the list of documents we created previously.

Additionally, we can set AnalyzeSentimentOptions to include Opinion Mining. I leave it to you to play with this a little more 😊.

Finally, let's print the results to the console and see what we get as a response.

Let's take a better look at the response:

We can observe that, for both documents, we get the sentiment of the whole document, and additionally the sentiment of each sentence from the analyzed document.

It also provides us with the positive, negative and neutral scores.

Thanks for sticking to the end of another article from 'Iliev Talks Tech'.


Next steps:

To view or add a comment, sign in

Others also viewed

Explore topics