Part-of-Speech Tag a String, Filter to Adverbs in Python

Cloudmersive
2 min readJan 21, 2022

Using the Part-of-Speech (POS) tagger iterations of the Cloudmersive NLP API v2, you can break down any body of text into its various parts-of-speech in the blink of an eye. In this article we’ll cover how you can use an iteration of this API in Python to tag adverbs and return a JSON result. It’s simple and easy to do following the below steps using ready-to-run code.

Starting off you need to install the Python SDK by running the below command:

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

After that you can copy & paste the below snippet to authorize your API key (obtained by creating a free account on the Cloudmersive website):

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

Finally, you can create the API class instance & call the API with the rest of the function below:

# 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
try:
# Part-of-speech tag a string, filter to adverbs
api_response = api_instance.pos_tagger_tag_adverbs(request)
pprint(api_response)
except ApiException as e:
print("Exception when calling PosTaggerApi->pos_tagger_tag_adverbs: %s\n" % e)

--

--

Cloudmersive

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