How to Perform Sentiment Analysis on Text in Node.JS

Properly synthesizing customer or client feedback is integral to promoting natural growth for your organization. To achieve this, client comment analysis will allow you to not only receive responses but track trends in their contents. While parsing through hundreds, if not thousands, of comments on a full layout of products and services may be impossible by analog means, the following API will not only analyze the input text automatically, but also classify the sentiment implied in the string as positive, negative, or neutral feedback. This can also be useful when creating an app that shows ratings for your products to your consumers, such as a five-star system.

Image for post
Image for post

To run this API, we first need to install the SDK by running this command:

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

Or, you can add the following snippet to your package.json:

"dependencies": {
"cloudmersive-nlp-api-client": "^2.0.9"

Once you have completed install for the SDK, you can call the function:

var CloudmersiveNlpApiClient = require('cloudmersive-nlp-api-client');
var defaultClient = CloudmersiveNlpApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveNlpApiClient.AnalyticsApi();var input = new CloudmersiveNlpApiClient.SentimentAnalysisRequest(); // SentimentAnalysisRequest | Input sentiment analysis requestvar callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.analyticsSentiment(input, callback);

Now you can automatically retrieve and categorize text feedback to help improve your user experience. You can retrieve your free API Key from Cloudmersive. This will give you access to 800 monthly calls across our library of 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