How to parse a String into a Penn Treebank Syntax Tree in Node.JS
1 min readApr 8, 2020
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.