Parse String to Syntax Tree (Penn Treebank) in Python

The Penn Treebank is a massive dataset of annotated & human-corrected words maintained by the University of Pennsylvania, designed to make the process of breaking down and tagging natural language sentences easy & accessible. It’s useful to have a sentence broken down in this way, especially if you’re incorporating other elements of NLP into your application. The /nlp-v2/parse/tree iteration of the Cloudmersive NLP API v2 will empower your application to quickly perform this task. Let’s walk through how to use this in Python.

You can copy in this first snippet to install the Python SDK:

pip install cloudmersive-nlp-api-clientfrom __future__ import print_function
import time
import cloudmersive_nlp_api_client
from import ApiException
from pprint import pprint

After that, you’ll need to authorize your API key in the below snippet:

# Configure API key authorization: Apikey
configuration = cloudmersive_nlp_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'

Finally, you can add in the rest of the callback function below:

# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.ParseApi(cloudmersive_nlp_api_client.ApiClient(configuration))
input = cloudmersive_nlp_api_client.ParseRequest() # ParseRequest | Input string
# Parse string to syntax tree
api_response = api_instance.parse_parse_string(input)
except ApiException as e:
print("Exception when calling ParseApi->parse_parse_string: %s\n" % e)




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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to apply Authentication to any Web Service in 15 Minutes using Keycloak and Keycloak Proxy

A Python & 2 Java devs walk into a bar…

Building a serverless website with S3

Docker Registry Service Account Validation.

A Guide to Initialisation - Swift 4

Fintech App Development: 7 Challenges Need to Face While Develop Fintech Apps

Smart Monitoring of Connected Assets Using Azure IoT

Architecture — Smart monitoring of Connected Assets

How I fixed the macbook pro 16 fan noise overheating problem

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


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

More from Medium

Perform Profanity and Obscene Language Analysis and Detection on Text in Python

Deploy model with FastAPI and Heroku

How to deploy an application using Heroku?

How to make text in images on the harddrive searchable

output of the script