How to Spell Check a Sentence in Node.JS with NLP
1 min readApr 7, 2020
Spellchecking is truly a lifesaver, especially in this day and age when a huge amount of written content is tapped out on tiny phone screens. Setting up a spellcheck system is no easy task, which is why I’ve already done it for you. All you have to do is call it from an API. Here’s how to do it.
Install our client with this command for npm install:
npm install cloudmersive-nlp-api-client --save
Then call spellcheckCheckSentence:
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 = new CloudmersiveNlpApiClient.CheckSentenceRequest(); // CheckSentenceRequest | Input sentencevar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.spellcheckCheckSentence(value, callback);
Input your sentence to try, and voila, the API will return your results as a JSON file. So easy!