Perform Subjectivity and Objectivity Analysis on Text in C#

Cloudmersive
2 min readFeb 28, 2022
Example Value Response Model from the Cloudmersive API Console

With well-documented code examples from the Cloudmersive API Console, you can easily incorporate useful NLP capabilities into your project. Follow steps below to take advantage of our Subjectivity & Objectivity Analysis API in C#, which will provide you with a subjectivity score result between 0 and 1 (higher numbers indicate more subjective, and lower numbers indicate more objective).

If you’re using .NET, use this command to install your SDK & copy the next snippet to begin the API call:

Install-Package Cloudmersive.APIClient.NET.NLP -Version 4.1.0using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.NLP.Api;
using Cloudmersive.APIClient.NET.NLP.Client;
using Cloudmersive.APIClient.NET.NLP.Model;

For .NET Core, use this instead:

Install-Package Cloudmersive.APIClient.NETCore.NLP -Version 2.1.3using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NETCore.NLP.Api;
using Cloudmersive.APIClient.NETCore.NLP.Client;
using Cloudmersive.APIClient.NETCore.NLP.Model;

After that, it’s smooth sailing. Copy the below code to call the API, and input your Cloudmersive API key where indicated. If you don’t have a key yet, you can make a free account on the Cloudmersive website (with zero financial commitments) to get one.

namespace Example
{
public class AnalyticsSubjectivityExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
var apiInstance = new AnalyticsApi();
var input = new SubjectivityAnalysisRequest(); // SubjectivityAnalysisRequest | Input subjectivity analysis request
try
{
// Perform Subjectivity and Objectivity Analysis on Text
SubjectivityAnalysisResponse result = apiInstance.AnalyticsSubjectivity(input);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AnalyticsApi.AnalyticsSubjectivity: " + e.Message );
}
}
}
}

--

--

Cloudmersive

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