Perform Profanity and Obscene Language Analysis and Detection on Text in Go

Quick — earmuffs!

Unfortunately, when you let content with unsavory language slip through your nets, it can make you look just as bad as the original perpetrator, and it can be tough to put ‘earmuffs’ on the situation. Thankfully, you can take advantage of our powerful Natural Language Processing API to easily check for profane/obscene language in an input text string. When called, this API will return a “ProfanityScoreResult” with a value indicating the extent to which a piece of written content did, or did not, contain profane language. In this article we’ve included code examples in Go for seamless integration into your project.

If this is your first time using a Cloudmersive API, first head to our website (www.cloudmersive.com) to get your API key. You can make a free account with zero financial commitments and get 800 API calls per month, with access to all of our other APIs. Check out our Cloudmersive API Console to find our APIs with code samples ready-to-run in 13 common programming languages.

Copy and paste the below code examples, and include your API key & text string where indicated in the documentation:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/nlp-v2/analytics/profanity"
method := "POST"
payload := strings.NewReader("TextToAnalyze=%3Cstring%3E")client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

--

--

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
Cloudmersive

Cloudmersive

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