Part-of-Speech (POS) Tag a String in Python

2 min readJan 20, 2022


Using Cloudmersive’s NLP API v2, you can empower your applications with a wide variety of NLP capabilities. In this article we’ll cover an iteration of this API which allows for tagging Part-of-Speech (POS) in a string, and returning the result as a JSON object. It’s easy to use with ready-to-run code in over 13 different programming languages — today we’ll walk through how to get set up in Python.

The first step is to install the Python SDK using the following snippet:

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

Next, you can copy in the following code, which enables API key authorization (your API key can be acquired by visiting the Cloudmersive website & creating a free account):

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

Finally, you can complete the Python callback function with the last code snippet here:

# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.PosTaggerApi(cloudmersive_nlp_api_client.ApiClient(configuration))
request = cloudmersive_nlp_api_client.PosRequest() # PosRequest | Input string
# Part-of-speech tag a string
api_response = api_instance.pos_tagger_tag_sentence(request)
except ApiException as e:
print("Exception when calling PosTaggerApi->pos_tagger_tag_sentence: %s\n" % e)




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