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

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!

Image for post
Image for post

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