Perform Profanity and Obscene Language Analysis and Detection on Text in C#
Bad language stops here. Take advantage of powerful NLP capabilities with the /nlp-v2/analytics/profanity iteration of the NLP API, and make it possible to flag and quarantine text-filled files with high profanity scores. Connecting is simple and easy in C#; just check out the ready-to-run code available below, sourced directly from the Cloudmersive API console.
Before you begin, copy in the below command to install the .NET SDK:
Install-Package Cloudmersive.APIClient.NET.NLP -Version 4.1.0
After that, simply copy in the code below to call the API in your C# environment. Your API key needs to be included within the Configuration.Default.AddApiKey(“Apikey”, “YOUR_API_KEY”) snippet — if you don’t currently have a key, visit the Cloudmersive website and make a free account to easily attain one.
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 AnalyticsProfanityExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");var apiInstance = new AnalyticsApi();
var input = new ProfanityAnalysisRequest(); // ProfanityAnalysisRequest | Input profanity analysis requesttry
{
// Perform Profanity and Obscene Language Analysis and Detection on Text
ProfanityAnalysisResponse result = apiInstance.AnalyticsProfanity(input);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AnalyticsApi.AnalyticsProfanity: " + e.Message );
}
}
}
}