How Rephrase Sentences with Deep Learning AI in PHP
Rephrasing text has a lot of relevant business use-cases, such as improving SEO and optimizing readability for better customer engagement. Our Rephrase/Paraphrase NLP API will provide multiple rephrasing candidates (up to 10 at most) per input sentence while preserving the original semantic meaning, leaving you with plenty of possible new phrasing options to choose from.
You can easily take advantage of this API for free by copying from the ready-to-run code examples below and registering a free account on our website (this provides you with a free-tier API key with a limit of 800 API calls per month & no additional commitments).
To start, let’s first install the PHP client. We can do so with Composer by executing the following command from the command line:
composer require cloudmersive/cloudmersive_nlp_api_client
Next, to structure our API call, let’s copy in the below examples:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer');
$apiInstance = new Swagger\Client\Api\RephraseApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$input = new \Swagger\Client\Model\RephraseRequest(); // \Swagger\Client\Model\RephraseRequest | Input rephrase request
try {
$result = $apiInstance->rephraseTranslateDeuToEng($input);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling RephraseApi->rephraseTranslateDeuToEng: ', $e->getMessage(), PHP_EOL;
}
?>
We can use the following model to structure our input requests and customize the number of rephrasing candidates we’d ideally like to see:
{
"TextToTranslate": "string",
"TargetRephrasingCount": 0
}
That’s all the code you’ll need — now you can give it a try and see if you like the results. Enjoy!