How to perform Profanity and Obscene Language Analysis and Detection on Text using Java

Let’s keep it clean, shall we? Our profanity & obscene language analysis API uses natural language processing to determine the degree to which your input text is profane or obscene. It will quantify the result with a profanity score included in the API response (lower values indicate less profanity, whereas higher values indicate more profanity).

Take advantage of the ready-to-run code snippets in Java included below to easily use this API in your application.

First, begin installing the Java SDK with Maven by adding the below reference to the pom.xml repository:


Complete installation by adding a reference to the dependency in pom.xml:


Next, add the import classes and call the NLP function:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.AnalyticsApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
AnalyticsApi apiInstance = new AnalyticsApi();
ProfanityAnalysisRequest input = new ProfanityAnalysisRequest(); // ProfanityAnalysisRequest | Input profanity analysis request
try {
ProfanityAnalysisResponse result = apiInstance.analyticsProfanity(input);
} catch (ApiException e) {
System.err.println("Exception when calling AnalyticsApi#analyticsProfanity");



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



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