How to perform Named Entity Recognition NER in Node.JS with NLP

Today we will be using NLP (natural language processing) to extract a list of named entities from a string of text. Before you brace for the coding onslaught that you’re expecting, let me just say this: There is a much easier way to get this done. I’m going to show it to you right now.

Install our client with this command for npm install:

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

Now we can call extractEntitiesStringPost, like this:

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.ExtractEntitiesStringApi();var value = "value_example"; // String | Input stringvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.extractEntitiesStringPost(value, callback);

Done with our setup! Now any string that you provide will be sent to our API, which will run the NLP routines required, then return your list of named entities as well as their entity type. It’s as simple as that. Let’s test it out on this sentence: “Jack and Jill went up the hill.” Here is what the API returned:

{
"Successful": true,
"Entities": [
{
"EntityType": "PERSON",
"EntityText": "Jack"
},
{
"EntityType": "PERSON",
"EntityText": "Jill"
}
]
}
Image for post
Image for post

Written by

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