Part-of-speech tag a string, filter to pronouns in Go

Working on an NLP project in Go? Try incorporating our NLP for POS tagging (and much more via the Cloudmersive API Console). Below, take advantage of ready-to-run code in Go to POS tag pronouns in an input text string. Calling this API will return each pronoun in the input sentence with a tag underneath it in JSON format.

If you’re new to using Cloudmersive APIs, first get an API key by creating an account on our website (www.cloudmersive.com). You can elect to create a free account with zero financial commitments & a limit of 800 API calls per month, or choose from other API subscription options.

Copy the below code, input your text & API key and you’re ready to tag pronouns:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/nlp-v2/pos/tag/pronouns"
method := "POST"
payload := strings.NewReader("InputText=%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

437 Followers

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