How to get Nouns from a Sentence in Node.JS

Cloudmersive
1 min readApr 8, 2020

--

Today’s lesson is very simple. Our goal is to retrieve all nouns from a target sentence or string. Instead of using a word library or NLP to accomplish this the hard way, we will be taking a massive shortcut. An API is going to get us the same results in a fraction of the time. Let’s get started.

Install our NLP client with this reference for our package.json file:

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

Now call the wordsNouns 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.WordsApi();var input = "input_example"; // String | Input stringvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.wordsNouns(input, callback);

All done. Yes, you read correctly, that’s all there is to it. For more useful functionality like this, check out what else our NLP API can do!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet