How to Part-Of-Speech Tag a Text String and Filter the Verbs in Python with NLP

Verb filtering through POS tagging is about to become as easy as pie, just you wait.

First step: install the client we will be using:

pip install git+

Secondly, paste in this chunk of example code here:

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.PosTaggerApi(cloudmersive_nlp_api_client.ApiClient(configuration))request = cloudmersive_nlp_api_client.PosRequest() # PosRequest | Input stringtry:# Part-of-speech tag a string, filter to verbsapi_response = api_instance.pos_tagger_tag_verbs(request)pprint(api_response)except ApiException as e:print("Exception when calling PosTaggerApi->pos_tagger_tag_verbs: %s\n" % e)

Alright, that’s it for the setup. Now you need only enter your string as part of the PosRequest object and let the API take care of it for you. If you have other POS tagging needs, or have a desired for a wide range of other NLP-related functions, this same library is full of them. Give it a look and find out how much more time you can save.

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