Rephrase, Paraphrase English Text Sentence-by-Sentence using Deep Learning AI in Python

Paraphrasing is a fairly regular task in the professional world. For example, media/content related businesses may need to curtail or rephrase repetitive posts & newsletters so that they aren’t flagged as spam on blog sites. Paraphrasing can be a pain to do manually, but it doesn’t have to be that way — using the Rephrase/Paraphrase iteration of the Cloudmersive NLP API v2, you can have a body of text automatically rephrased or paraphrased with Deep Learning and Neural NLP. This iteration will create between 1–10 rephrasing candidates per input sentence, all while striving to preserve the original semantic meaning. Let’s see how you can connect to this API in Python.

To start off, you’ll need to install the Python SDK by running the below command:

pip install cloudmersive-nlp-api-clientfrom __future__ import print_function
import time
import cloudmersive_nlp_api_client
from cloudmersive_nlp_api_client.rest import ApiException
from pprint import pprint

After that, you can copy in the portion of code which will capture & authorize your API key (obtained on the Cloudmersive website by creating a free account):

# Configure API key authorization: Apikey
configuration = cloudmersive_nlp_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'

And for the last step, you can copy in the rest of the callback function:

# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.RephraseApi(cloudmersive_nlp_api_client.ApiClient(configuration))
input = cloudmersive_nlp_api_client.RephraseRequest() # RephraseRequest | Input rephrase request
try:
# Rephrase, paraphrase English text sentence-by-sentence using Deep Learning AI
api_response = api_instance.rephrase_english_rephrase_sentence_by_sentence(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling RephraseApi->rephrase_english_rephrase_sentence_by_sentence: %s\n" % e)

--

--

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

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