Perform Hate Speech Analysis and Detection on Text in C#

Cloudmersive
1 min readFeb 23, 2022

--

Stop hate speech in its tracks with the Cloudmersive Natural Langauge Processing (NLP) API. With the /nlp-v2/analytics/hate-speech iteration, you can analyze input text using advanced Hate Speech Analysis to determine if the input content contains hate speech language. Easily connect in C# using the documented code snippets below.

First, run the .NET SDK installation command:

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

After that, all you need to do is copy & paste the C# callback function below, and 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 AnalyticsHateSpeechExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
var apiInstance = new AnalyticsApi();
var input = new HateSpeechAnalysisRequest(); // HateSpeechAnalysisRequest | Input hate speech analysis request
try
{
// Perform Hate Speech Analysis and Detection on Text
HateSpeechAnalysisResponse result = apiInstance.AnalyticsHateSpeech(input);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AnalyticsApi.AnalyticsHateSpeech: " + e.Message );
}
}
}
}

For instant analysis in a controlled environment, try using the Cloudmersive NLP Connector in Power Automate or Azure Logic Apps as well.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet