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 requesttry
{
// 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.