How to Part-of-Speech Tag a String & Filter to Verbs in Go
1 min readMar 9, 2022
Find the verbs in a text string and identify them in JSON format easily using the Part-of-Speech (POS) tagging iteration of our NLP API. If you’re working in Golang and eager to make use of this API in your project, take advantage of ready-to-run code from our API console (Cloudmersive API Console) included below.
package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)func main() {url := "https://api.cloudmersive.com/nlp-v2/pos/tag/verbs"
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))
}
First time using a Cloudmersive API? You’ll need an API key — head to our website (www.cloudmersive.com) and make an account to receive one. You’ll have the option to make a free account with zero financial commitments and a limit of 800 API calls per month.