Perform Sentiment Analysis & Classification on Text in C#

Cloudmersive’s Natural Language Processing API enables you to find meaning in text. Incorporate dozens of NLP capabilities into your application with a single API key from your Cloudmersive Account. Find out if a text input is positive, negative, or neutral with the /nlp-v2/analytics/sentiment iteration of the NLP API, available with ready-to-run code connections in 13 programming languages. Let’s look at how to connect in C#.

Your first step is to install the .NET SDK:

Install-Package Cloudmersive.APIClient.NET.NLP -Version 4.1.0

After that, include the callback function below. Make sure to include your Cloudmersive API key where indicated:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.NLP.Api;
using Cloudmersive.APIClient.NET.NLP.Client;
using Cloudmersive.APIClient.NET.NLP.Model;
namespace Example
{
public class AnalyticsSentimentExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
var apiInstance = new AnalyticsApi();
var input = new SentimentAnalysisRequest(); // SentimentAnalysisRequest | Input sentiment analysis request
try
{
// Perform Sentiment Analysis and Classification on Text
SentimentAnalysisResponse result = apiInstance.AnalyticsSentiment(input);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AnalyticsApi.AnalyticsSentiment: " + e.Message );
}
}
}
}

To get an API key, simply navigate to the Cloudmersive website and create a free account (with zero commitments). You’ll receive an API key and have access to any of the API’s on the Cloudmersive console, with 800 API calls per month.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.