How to Paraphrase or Rephrase English Text in Go

Cloudmersive
1 min readMar 29, 2021

--

information from a reference? I know I have, and it’s not a good time. Let technology save you from this frustration by running an API in Go that uses advanced Deep Learning AI and neural Natural Language Processing to generate several rephrasing candidates for specific sentences. Each rephrased option consumes 1–2 API calls per sentence.

To use this API, we simply need to input the rephrase request, including the text to translate and the target rephrasing:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/nlp-v2/rephrase/rephrase/eng/by-sentence"
method := "POST"
payload := strings.NewReader("TextToTranslate=%3Cstring%3E&TargetRephrasingCount=%3Cinteger%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))
}

In no time at all, we will have some fresh rephrasing options that we can plug into the applicable project. Visit the Cloudmersive website to retrieve your free API key and gain access to 800 monthly calls across our library of APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet