How to Part-Of-Speech Tag a Text String and Filter the Verbs in Node.JS with NLP

Cloudmersive
2 min readApr 9, 2020

--

Natural Language Processing (NLP) is truly miraculous in its potential uses. Today, we are going to be focusing on one simple application of NLP, but one that is no less useful for its simplicity. We will be tagging words in a string and creating a list of verbs. If you are worried about how long this might take, don’t be. I’m only going to need about 5 minutes of your time.

To begin, use npm install to setup the Cloudmersive NLP client with this command:

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

Now call our posTaggerTagVerbs function with these lines of code:

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.PosTaggerApi();var request = new CloudmersiveNlpApiClient.PosRequest(); // PosRequest | Input stringvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.posTaggerTagVerbs(request, callback);

Done! Let’s give it a quick test run. I used: “I like ice cream.” Here’s my return:

{
"TaggedSentences": [
{
"Words": [
{
"Word": "like",
"Tag": "VBP"
}
]
}
]
}

--

--

Cloudmersive

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