How to parse a String into a Penn Treebank Syntax Tree in Node.JS

Today is all about lightning-fast setup of Penn Treebank syntax tree parsing from within Node.JS. You might be skeptical about just how fast until I reveal my secret weapon: an API that’s already custom built to perform the task. Let’s look at how to use it.

First, npm install will import our client and let us begin calling API functions.

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

With that out of the way, call parseParseString:

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

And it’s as easy as that! You can also use this API for its other functions, such as filtering word types and identifying text language.

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