How to find all Pronouns in a String in Python with NLP

For today’s tutorial, we are going to cover pronoun filtering in Python. Normally this would require some pretty hefty NLP programming time to get off the ground, but not today. No, today we are busting out an API that is already fully equipped to pluck you from the jaws of tedium and perform the task for you. Let’s look at how the setup works.

Install the client as your first step:

pip install git+

Now we are going to instantiate our API, followed by calling our function using this instance, and providing it with a key and string to work with.

from __future__ import print_functionimport timeimport cloudmersive_nlp_api_clientfrom import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_nlp_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_nlp_api_client.WordsApi(cloudmersive_nlp_api_client.ApiClient(configuration))input = 'input_example' # str | Input stringtry:# Returns all pronounts in stringapi_response = api_instance.words_pronouns(input)pprint(api_response)except ApiException as e:print("Exception when calling WordsApi->words_pronouns: %s\n" % e)

And would you believe it, that’s all there is to it.

Image for post

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