Findging synonyms with GroupDocs.Rewriter SDK
Leave feedback
Although you can directly call the GroupDocs.Rewriter Cloud REST API to send text 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.
usingGroupDocs.Rewriter.Cloud.Sdk.Api;usingGroupDocs.Rewriter.Cloud.Sdk.Client;usingGroupDocs.Rewriter.Cloud.Sdk.Client.Auth;usingGroupDocs.Rewriter.Cloud.Sdk.Model;usingConfiguration=GroupDocs.Rewriter.Cloud.Sdk.Client.Configuration;usingSystem.Diagnostics;usingSystem.IO;usingSystem.Collections.Generic;usingSystem.Net.Http;usingHttpStatusCode=System.Net.HttpStatusCode;namespaceGroupDocs.Rewriter.Cloud.Sdk{publicclassTextSynonymizer{publicTextSynonymizer(){Configurationconfig=newConfiguration();config.OAuthFlow=OAuthFlow.APPLICATION;config.OAuthClientId="YOU_CLIENT_ID";config.OAuthClientSecret="YOU_CLIENT_SECRET";config.BasePath="https://api.groupdocs.cloud/v2.0/rewriter";SynonymizeApiapi=newSynonymizeApi(conf);stringsrcText="YOUR_WORD";stringsourceLanguage="en";SynonymizeTextResponseresponse=newSynonymizeTextResponse();SynonymizeTextRequestrequest=newSynonymizeTextRequest(language:sourceLanguage,text:srcText,synonyms:SynonymizeTextRequest.SynonymsEnum.All);StatusResponseresponseId=awaitapi.SynonymizeTextPostAsync(request);try{if(responseId.Status.ToString()=="Accepted"){while(true){response=awaitapi.SynonymizeTextRequestIdGetAsync(responseId.Id);if(response.Status.ToString()=="OK"){foreach(stringsynonyminresponse.SynonymizerResults){Console.WriteLine($"Synonym for word {srcText}: {synonym}");}break;}elseThread.Sleep(2000);}}else{response=newSynonymizeTextResponse(){Status=responseId.Status,Message=responseId.Message};Console.WriteLine("Text error: "+textResponse.Message);}}catch(Exceptionex){Console.WriteLine("Text exception: "+ex.ToString());}}}}