Perform Subjectivity & Objectivity Analysis on Text in Go

Cloudmersive
1 min readMar 8, 2022

--

It’s the moment you’ve been waiting for: powerful NLP capabilities are easily available for your Golang project with a free Cloudmersive API key. Incorporate the ability to analyze text for Subjective or Objective language using ready-to-run code in Go further down the page, or check out the Cloudmersive API Console to find code in 13 other programming languages including Python, C#, Node.JS, Java, and more.

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/nlp-v2/analytics/subjectivity"
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))
}

To get the API key you’ll need, head to our website (www.cloudmersive.com) and create an account. Once you plug that in, include your input text, and await your API call results.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet