How to Spell Check a Sentence in Node.JS with NLP

In this age of thumb typing on phone screens, spell checking is more important than ever. To create this type of system from scratch is quite an undertaking, however. With that said, we won’t be doing this the old-fashioned way. Today, we will be busting out a handy API that’s already designed for spell checking with NLP.

Let’s install our client to start with, through use of this command:

npm install cloudmersive-nlp-api-client --save

After installation has finished, we can proceed with implementing the spellCheckCheckSentenceString 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 sentence wordvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.spellCheckCheckSentenceString(value, callback);

Done! Now, wasn’t that easy? Just enter in your sentence and your spell check data will be returned. The NLP client itself contains a lot of other related functions which are definitely worth looking into if you are working with language focused tasks.

Image for post

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

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