Detecting paraphrases in files with GroupDocs.Rewriter SDK
Detecting paraphrases in files with GroupDocs.Rewriter SDK
Leave feedback
Although you can directly call the GroupDocs.Rewriter Cloud REST API to send file and fetch the result, there is a much easier way to implement required functionality in your applications. We provide software development kits (SDKs) for all popular programming languages. They wrap up all routine operations such as establishing connections, sending API requests, and parsing responses into a few simple methods. It makes interaction with GroupDocs.Rewriter Cloud services much easier, allowing you to focus on business logic rather than technical details.
packagecom.groupdocs;// Import classes:
importcom.groupdocs.model.*;importorg.openapitools.client.api.DetectApi;importorg.openapitools.client.api.FileApi;importjava.io.File;publicclassDemo{publicstaticvoidmain(String[]args){// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
StringbasePath="https://api.groupdocs.cloud/v2.0/rewriter";StringcliendId="YOUR_CLIENT_ID";StringclientSecret="YOUR_CLIENT_SECRET";ApiClientdefaultClient=newApiClient(basePath,cliendId,clientSecret,null);// Upload file
FileApifileApi=newFileApi(defaultClient);StringfileName="FILE_PATH";FilefileToUpload=newFile(fileName);Stringfile_url=null;try{Stringfile_url=fileApi.fileUploadPost("FILE_FORMAT",fileToUpload);}catch(ApiExceptione){System.err.println("Exception when calling FileApi#fileUploadPost");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}// Create instance of the DetectApi if the file was uploaded successfully
if(file_url!=null){DetectApiapiInstance=newDetectApi(defaultClient);DetectionFileRequestfileRequest=newDetectionFileRequest();fileRequest.setLanguage("en");fileRequest.setFormat(DetectionSupportedFormats.PDF);fileRequest.setSavingMode(FileSavingMode.FILES);fileRequest.setUrl(file_url);fileRequest.setOrigin("");try{StatusResponseresponse=apiInstance.detectDocumentPost(fileRequest);System.out.println(response);Stringresponse_id=response.getId();if(!response.getStatus().toString().equals("BadRequest")){while(true){DetectionFileResponsedetectionResponse=apiInstance.detectDocumentRequestIdGet(response_id);if(detectionResponse.getStatus().toString().equals("OK")){System.out.println(detectionResponse);break;}try{Thread.sleep(2000);}catch(InterruptedExceptione){e.printStackTrace();}}}}catch(ApiExceptione){System.err.println("Exception when calling DetectApi#detectDocumentPost");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}}