How to Perform Profanity and Obscene Language Analysis and Detection on Text with JavaScript

Hey — no cursing on my website!

Are you getting tired of asking people to keep it clean? We hear you. When you include our Profanity and Obscene Language Detection API in your app, you won’t have to. This API analyzes (English) natural language text inputs and provides a score indicating the degree to which the text in question is profane or obscene. That score will range from 0.0 to 1.0, with lower numbers indicating little profanity was detected, and higher numbers indicating a lot of profanity was detected.

To structure your API call in JavaScript, follow instructions to include ready-to-run code snippets below.

Let’s install the jQuery library first:

bower install jquery

Then let’s include the code for our API call:

var settings = {
"url": "https://api.cloudmersive.com/nlp-v2/analytics/profanity",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"TextToAnalyze": "<string>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});

You’ll need to include your Cloudmersive API key (attainable by creating a free account on our website — Home — Cloudmersive APIs) and configure your text input where indicated in the documentation. Once you do that, you’re all good to go.

--

--

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