How to Paraphrase or Rephrase English Text in JavaScript

Cloudmersive
2 min readMar 23, 2021

--

Natural Language Processing has become a huge component of speech analysis over the past decade. Originally NLP tasks were performed by hand, but now machine learning can be used for a multitude of purposes such as language detection and translation, extracting sentences and entities from strings, and analyzing the sentiment, subjectivity, and objectivity of text. In this lesson we will provide instructions on how to use an API in JavaScript for another function of NLP — paraphrasing or rephrasing text. It is important to note that this process currently only works on English text.

Let’s get things started by installing the jQuery library:

bower install jquery

Now we are going to call the function, which I have laid out in the example code below — the only inputs you need to provide are the text to translate, target rephrasing count, and API key.

var settings = {
"url": "https://api.cloudmersive.com/nlp-v2/rephrase/rephrase/eng/by-sentence",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"TextToTranslate": "<string>",
"TargetRephrasingCount": "<integer>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});

The returned response will contain your rephrasing options for each input sentence string; for reference, the API consumes 1–2 calls per generated output, per sentence. If you don’t have an API key yet, you can register for a free account on the Cloudmersive website to obtain your personal API key and gain access to 800 calls/month.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

Responses (1)