How to find Spelling Corrections/Suggestions for a Word in Node.JS with NLP

Cloudmersive
1 min readApr 8, 2020

If you are trying to set up a spell checker, I am about to save you a ton of time and hair-pulling. Instead of grinding your way through coding out a spelling suggestion system, we are going to whip out an API that already performs this exact function. Total setup time? Less than five minutes.

First, use this reference for our package.json to install our API client.

"dependencies": {
"cloudmersive-nlp-api-client": "^1.1.2"
}

Now call our function:

var CloudmersiveNlpApiClient = require('cloudmersive-nlp-api-client');var defaultClient = CloudmersiveNlpApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveNlpApiClient.SpellCheckApi();var value = "value_example"; // String | Input wordvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.spellCheckCorrect(value, callback);

Then simply input your misspelled word and the API will return a set of suggestions. How easy was that!

--

--

Cloudmersive

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